public static void validate (@Nonnull final Schema aSchema,
                               @Nonnull final Source aXML,
                               @Nonnull final ErrorList aErrorList,
                               @Nullable final Locale aLocale)
  {
    ValueEnforcer.notNull (aSchema, "Schema");
    ValueEnforcer.notNull (aXML, "XML");
    ValueEnforcer.notNull (aErrorList, "ErrorList");

    // Build the validator
    final Validator aValidator = aSchema.newValidator ();
    if (aLocale != null)
      EXMLParserProperty.GENERAL_LOCALE.applyTo (aValidator, aLocale);
    aValidator.setErrorHandler (new WrappedCollectingSAXErrorHandler (aErrorList));
    try
    {
      aValidator.validate (aXML, null);
    }
    catch (final Exception ex)
    {
      // Most likely the input XML document is invalid
      throw new IllegalArgumentException ("Failed to validate the XML " + aXML + " against " + aSchema, ex);
    }
  }
public static void validate ( @ Nonnull final Schema aSchema , @ Nonnull final Source aXML , @ Nonnull final ErrorList aErrorList , @ Nullable final Locale aLocale ) { ValueEnforcer . notNull ( aSchema , "Schema" ) ; ValueEnforcer . notNull ( aXML , "XML" ) ; ValueEnforcer . notNull ( aErrorList , "ErrorList" ) ; final Validator aValidator = aSchema . newValidator ( ) ; if ( aLocale != null ) EXMLParserProperty . GENERAL_LOCALE . applyTo ( aValidator , aLocale ) ; aValidator . setErrorHandler ( new WrappedCollectingSAXErrorHandler ( aErrorList ) ) ; try { aValidator . validate ( aXML , null ) ; } catch ( final Exception ex ) { throw new IllegalArgumentException ( "Failed to validate the XML " + aXML + " against " + aSchema , ex ) ; } }
Validate the passed XML against the passed XSD and put all errors in the
passed error list.

@param aSchema
The source XSD. May not be <code>null</code>.
@param aXML
The XML to be validated. May not be <code>null</code>.
@param aErrorList
The error list to be filled. May not be <code>null</code>.
@param aLocale
The locale to use for error messages. May be <code>null</code> to
use the system default locale.
@throws IllegalArgumentException
If XSD validation failed with an exception
@since 9.0.1