use of org.apache.xerces.util.SymbolTable 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;
}
use of org.apache.xerces.util.SymbolTable in project iaf by ibissource.
the class MyErrorHandler method createValidatingParser.
public XMLReader createValidatingParser(PipeLineSession 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;
}
use of org.apache.xerces.util.SymbolTable in project iaf by ibissource.
the class MyErrorHandler method preparse.
private synchronized PreparseResult preparse(String schemasId, List<Schema> schemas) throws ConfigurationException {
SymbolTable symbolTable = getSymbolTable();
XMLGrammarPool grammarPool = new XMLGrammarPoolImpl();
Set<String> namespaceSet = new HashSet<String>();
XMLGrammarPreparser preparser = new XMLGrammarPreparser(symbolTable);
preparser.setEntityResolver(new ClassLoaderXmlEntityResolver(this));
preparser.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null);
preparser.setProperty(GRAMMAR_POOL, grammarPool);
preparser.setFeature(NAMESPACES_FEATURE_ID, true);
preparser.setFeature(VALIDATION_FEATURE_ID, true);
preparser.setFeature(SCHEMA_VALIDATION_FEATURE_ID, true);
preparser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, isFullSchemaChecking());
try {
preparser.setProperty(XML_SCHEMA_VERSION_PROPERTY, isXmlSchema1_0() ? Constants.W3C_XML_SCHEMA10EX_NS_URI : Constants.W3C_XML_SCHEMA11_NS_URI);
} catch (NoSuchFieldError e) {
String msg = "Cannot set property [" + XML_SCHEMA_VERSION_PROPERTY + "], requested xmlSchemaVersion [" + getXmlSchemaVersion() + "] xercesVersion [" + org.apache.xerces.impl.Version.getVersion() + "]";
if (isXmlSchema1_0()) {
log.warn(msg + ", assuming XML-Schema version 1.0 will be supported", e);
} else {
throw new ConfigurationException(msg, e);
}
}
MyErrorHandler errorHandler = new MyErrorHandler(this);
errorHandler.warn = warn;
preparser.setErrorHandler(errorHandler);
for (Schema schema : schemas) {
Grammar grammar = preparse(preparser, schemasId, schema);
registerNamespaces(grammar, namespaceSet);
}
grammarPool.lockPool();
PreparseResult preparseResult = new PreparseResult();
preparseResult.setSchemasId(schemasId);
preparseResult.setSymbolTable(symbolTable);
preparseResult.setGrammarPool(grammarPool);
preparseResult.setNamespaceSet(namespaceSet);
return preparseResult;
}
Aggregations