ContentHandler winner;
// sniff the XML and decide the reader to use.
if( localName.equals("module") ) {
// assume RELAX Core.
if( strictCheck ) {
Schema s = RELAXCoreReader.getRELAXCoreSchema4Schema();
reader[0] = new RELAXCoreReader(
getController(),
new SAXParserFactoryImpl(getSAXParserFactory(),s),
getPool() );
winner = setupPipeline(s);
} else {
winner = reader[0] = new RELAXCoreReader(
getController(),getSAXParserFactory(),getPool());
}
} else
if( localName.equals("schema") ) {
// assume W3C XML Schema
if( strictCheck ) {
Schema s = XMLSchemaReader.getXmlSchemaForXmlSchema();
reader[0] = new XMLSchemaReader(
getController(),
new SAXParserFactoryImpl(getSAXParserFactory(),s),
getPool() );
winner = setupPipeline(s);
} else {
winner = reader[0] = new XMLSchemaReader(
getController(),getSAXParserFactory(),getPool());
}
} else
if( RELAXNSReader.RELAXNamespaceNamespace.equals(namespaceURI) )
// assume RELAX Namespace
winner = reader[0] = new RELAXNSReader(
getController(), getSAXParserFactory(), getPool() );
else
if( TREXGrammarReader.TREXNamespace.equals(namespaceURI)
|| namespaceURI.equals("") )
// assume TREX
winner = reader[0] = new TREXGrammarReader(
getController(), getSAXParserFactory(), getPool() );
else {
// otherwise assume RELAX NG
if( strictCheck ) {
Schema s = RELAXNGCompReader.getRELAXNGSchema4Schema();
reader[0] = new RELAXNGCompReader(
getController(),
new SAXParserFactoryImpl(getSAXParserFactory(),s),
getPool() );
winner = setupPipeline(s);