SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
XMLReader reader = factory.newSAXParser().getXMLReader();
// create an instance of verifier,
TypeDetector verifier = new TypeDetector(grammar, new ErrorHandlerImpl() );
// configure a pipeline so that the verifier will receive SAX events first.
reader.setContentHandler(verifier);
// then set your application handler to verifier.