if( args.length != 1 ) {
System.out.println( "Error: Usage java TraverseSchema yourFile.xsd" );
System.exit(0);
}
DOMParser parser = new DOMParser() {
public void ignorableWhitespace(char ch[], int start, int length) {}
public void ignorableWhitespace(int dataIdx) {}
};
parser.setEntityResolver( new Resolver() );
parser.setErrorHandler( new ErrorHandler() );
try {
parser.setFeature("http://xml.org/sax/features/validation", false);
parser.setFeature("http://apache.org/xml/features/dom/defer-node-expansion", false);
}catch( org.xml.sax.SAXNotRecognizedException e ) {
e.printStackTrace();
}catch( org.xml.sax.SAXNotSupportedException e ) {
e.printStackTrace();
}
try {
parser.parse( args[0]);
}catch( IOException e ) {
e.printStackTrace();
}catch( SAXException e ) {
e.printStackTrace();
}
Document document = parser.getDocument(); //Our Grammar
OutputFormat format = new OutputFormat( document );
java.io.StringWriter outWriter = new java.io.StringWriter();
XMLSerializer serial = new XMLSerializer( outWriter,format);
TraverseSchema tst = null;
try {
Element root = document.getDocumentElement();// This is what we pass to TraverserSchema
//serial.serialize( root );
//System.out.println(outWriter.toString());
tst = new TraverseSchema( root, new StringPool(), new SchemaGrammar(), (GrammarResolver) new GrammarResolverImpl() );
}
catch (Exception e) {
e.printStackTrace(System.err);
}
parser.getDocument();
}