Search in sources :

Example 1 with XMLSchemaFactory

use of nl.nn.adapterframework.validation.xerces_2_11.XMLSchemaFactory in project iaf by ibissource.

the class MyErrorHandler method getValidatorHandler.

public ValidatorHandler getValidatorHandler(IPipeLineSession session, ValidationContext context) throws ConfigurationException, PipeRunException {
    ValidatorHandler validatorHandler = null;
    try {
        XMLSchemaFactory schemaFactory = new XMLSchemaFactory();
        javax.xml.validation.Schema schemaObject = schemaFactory.newSchema(((XercesValidationContext) context).getGrammarPool());
        validatorHandler = schemaObject.newValidatorHandler();
    } catch (SAXException e) {
        throw new ConfigurationException(logPrefix + "Cannot create schema", e);
    }
    try {
        // validatorHandler.setFeature(NAMESPACES_FEATURE_ID, true);
        validatorHandler.setFeature(VALIDATION_FEATURE_ID, true);
        validatorHandler.setFeature(SCHEMA_VALIDATION_FEATURE_ID, true);
        validatorHandler.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, isFullSchemaChecking());
        validatorHandler.setErrorHandler(context.getErrorHandler());
    } catch (SAXNotRecognizedException e) {
        throw new ConfigurationException(logPrefix + "ValidatorHandler does not recognize necessary feature", e);
    } catch (SAXNotSupportedException e) {
        throw new ConfigurationException(logPrefix + "ValidatorHandler does not support necessary feature", e);
    }
    return validatorHandler;
}
Also used : SAXNotSupportedException(org.xml.sax.SAXNotSupportedException) ValidatorHandler(javax.xml.validation.ValidatorHandler) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) XMLSchemaFactory(nl.nn.adapterframework.validation.xerces_2_11.XMLSchemaFactory) SAXNotRecognizedException(org.xml.sax.SAXNotRecognizedException) SAXException(org.xml.sax.SAXException)

Aggregations

ValidatorHandler (javax.xml.validation.ValidatorHandler)1 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)1 XMLSchemaFactory (nl.nn.adapterframework.validation.xerces_2_11.XMLSchemaFactory)1 SAXException (org.xml.sax.SAXException)1 SAXNotRecognizedException (org.xml.sax.SAXNotRecognizedException)1 SAXNotSupportedException (org.xml.sax.SAXNotSupportedException)1