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