// need to parse the DTD's/schemas, put them
// in a grammar pool, possibly instantiate an
// appropriate configuration, and we're on our way.
SymbolTable sym = new SymbolTable(BIG_PRIME);
XMLGrammarPreparser preparser = new XMLGrammarPreparser(sym);
XMLGrammarPoolImpl grammarPool = new XMLGrammarPoolImpl();
boolean isDTD = false;
if(externalDTDs != null) {
preparser.registerPreparser(XMLGrammarDescription.XML_DTD, null);
isDTD = true;
} else if(schemas != null) {
preparser.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null);
isDTD = false;
} else {
System.err.println("No schema or DTD specified!");
System.exit(1);
}
preparser.setProperty(GRAMMAR_POOL, grammarPool);
preparser.setFeature(NAMESPACES_FEATURE_ID, true);
preparser.setFeature(VALIDATION_FEATURE_ID, true);
// note we can set schema features just in case...
preparser.setFeature(SCHEMA_VALIDATION_FEATURE_ID, true);
preparser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, schemaFullChecking);
preparser.setFeature(HONOUR_ALL_SCHEMA_LOCATIONS_ID, honourAllSchemaLocations);
// parse the grammar...
try {
if(isDTD) {
for (i = 0; i < externalDTDs.size(); i++) {
Grammar g = preparser.preparseGrammar(XMLGrammarDescription.XML_DTD, stringToXIS((String)externalDTDs.elementAt(i)));
// we don't really care about g; grammarPool will take care of everything.
}
} else { // must be schemas!
for (i = 0; i < schemas.size(); i++) {
Grammar g = preparser.preparseGrammar(XMLGrammarDescription.XML_SCHEMA, stringToXIS((String)schemas.elementAt(i)));
// we don't really care about g; grammarPool will take care of everything.
}
}
} catch (Exception e) {
e.printStackTrace();