use of nl.nn.adapterframework.xml.ClassLoaderXmlEntityResolver 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