// the error handler passed to CheckingSchemaBuilder will receive additional
// errors found during the RELAX NG restrictions check.
// typically you'd want to pass in the same error handler,
// as there's really no distinction between those two kinds of errors.
SchemaBuilder sb = new CheckingSchemaBuilder(new DSchemaBuilderImpl(), eh);
try {
// run the parser
DGrammarPattern grammar = (DGrammarPattern) p.parse(sb);
OutputStream out = new FileOutputStream(args[1]);
XMLOutputFactory factory = XMLOutputFactory.newInstance();