private final File src;
public ISchema schema;
public void runTest() throws Exception {
// load grammar
ISchema source = firstValidator.parseSchema(src);
if (source == null)
fail("failed to parse the original grammar"); // unexpected result
// then convert it to the target grammar,
// and parse it by the target grammar reader parser.
GrammarWriter writer = getWriter();
// serialize it into the XML representation
ByteArrayOutputStream baos = new ByteArrayOutputStream();
writer.setDocumentHandler(new XMLSerializer(baos, new OutputFormat("xml", null, true)));
writer.write(source.asGrammar());
// then parse it again
schema = secondValidator.parseSchema(new ByteArrayInputStream(baos.toByteArray()));
if (schema == null)
fail("conversion failed"); // unexpected result