public static void testDocument(
     InputStream inputStream,
     InputStream refStream,
     OutputStream outputStream,
     String templateResourceName,
     String baseUri,
     boolean compare)
     throws IOException {
   Element templateElement = getTemplate(templateResourceName, baseUri);
   Text2XMLTemplateConverter tc = new Text2XMLTemplateConverter(templateElement);
   String text = IOUtils.toString(inputStream);
   Element testXml = parseText(tc, text);
   CMLUtil.debug(testXml, outputStream, 1);
   if (compare) {
     Element refXml = CMLUtil.parseQuietlyToDocument(refStream).getRootElement();
     JumboTestUtils.assertEqualsCanonically("test template", refXml, testXml, true);
   }
 }
 public static void runCommentExamples(Element template) {
   Text2XMLTemplateConverter tc = new Text2XMLTemplateConverter(template);
   Nodes exampleInputComments = template.query("comment[@class='" + EXAMPLE_INPUT + "' and @id]");
   if (exampleInputComments.size() == 0) {
     throw new RuntimeException("No examples found");
   }
   for (int j = 0; j < exampleInputComments.size(); j++) {
     Element exampleInput = (Element) exampleInputComments.get(j);
     String id = exampleInput.getAttributeValue(ID);
     if (id == null) {
       throw new RuntimeException("outputElement must have id: ");
     }
     Element outputElement = getOutputElement(template, id);
     if (outputElement == null) {
       throw new RuntimeException("Cannot create OutputElement: " + id);
     }
     String exampleContent = exampleInput.getValue();
     Element outputXML = parseText(tc, exampleContent);
     JumboTestUtils.assertEqualsCanonically("template", outputElement, outputXML, true);
   }
 }