Search in sources :

Example 1 with ShadowedSymbolTable

use of org.apache.xerces.util.ShadowedSymbolTable in project iaf by ibissource.

the class MyErrorHandler method createValidatingParser.

public XMLReader createValidatingParser(IPipeLineSession session, ValidationContext context) throws XmlValidatorException, ConfigurationException, PipeRunException {
    SymbolTable symbolTable = ((XercesValidationContext) context).getSymbolTable();
    XMLGrammarPool grammarPool = ((XercesValidationContext) context).getGrammarPool();
    XMLReader parser = new SAXParser(new ShadowedSymbolTable(symbolTable), grammarPool);
    try {
        parser.setFeature(NAMESPACES_FEATURE_ID, true);
        parser.setFeature(VALIDATION_FEATURE_ID, true);
        // parser.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); // this feature is not recognized
        // parser.setFeature(EXTERNAL_GENERAL_ENTITIES_FEATURE_ID, false); // this one appears to be not working
        // parser.setFeature(EXTERNAL_PARAMETER_ENTITIES_FEATURE_ID, false);
        // parser.setFeature(DISSALLOW_DOCTYPE_DECL_FEATURE_ID, true);
        parser.setFeature(SCHEMA_VALIDATION_FEATURE_ID, true);
        parser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, isFullSchemaChecking());
        parser.setErrorHandler(context.getErrorHandler());
        org.apache.xerces.util.SecurityManager mgr = new org.apache.xerces.util.SecurityManager();
        mgr.setEntityExpansionLimit(entityExpansionLimit);
        parser.setProperty(SECURITY_MANAGER_PROPERTY_ID, mgr);
    } catch (SAXNotRecognizedException e) {
        throw new XmlValidatorException(logPrefix + "parser does not recognize necessary feature", e);
    } catch (SAXNotSupportedException e) {
        throw new XmlValidatorException(logPrefix + "parser does not support necessary feature", e);
    }
    return parser;
}
Also used : XMLGrammarPool(org.apache.xerces.xni.grammars.XMLGrammarPool) SymbolTable(org.apache.xerces.util.SymbolTable) ShadowedSymbolTable(org.apache.xerces.util.ShadowedSymbolTable) SAXNotRecognizedException(org.xml.sax.SAXNotRecognizedException) SAXNotSupportedException(org.xml.sax.SAXNotSupportedException) SAXParser(org.apache.xerces.parsers.SAXParser) ShadowedSymbolTable(org.apache.xerces.util.ShadowedSymbolTable) XMLReader(org.xml.sax.XMLReader)

Aggregations

SAXParser (org.apache.xerces.parsers.SAXParser)1 ShadowedSymbolTable (org.apache.xerces.util.ShadowedSymbolTable)1 SymbolTable (org.apache.xerces.util.SymbolTable)1 XMLGrammarPool (org.apache.xerces.xni.grammars.XMLGrammarPool)1 SAXNotRecognizedException (org.xml.sax.SAXNotRecognizedException)1 SAXNotSupportedException (org.xml.sax.SAXNotSupportedException)1 XMLReader (org.xml.sax.XMLReader)1