On further investigation this bug appears to be related to the reuse of
the Canonicalizer object. Changing the processTests method to create a
new Canonicalizer before canonicalizing each document as follows fixes
the problem.
private static void processTests(DocumentBuilder domBuilder,
Elements tests)
throws URISyntaxException, SAXException, IOException,
TransformerException,
Exception {
for (int j = 0; j < tests.size(); j++) {
nu.xom.Element test = tests.get(j);
String namespace = test.getAttributeValue("NAMESPACE");
if ("no".equals(namespace)) continue;
String type = test.getAttributeValue("TYPE");
if ("not-wf".equals(type)) continue;
String uri = test.getAttributeValue("URI");
String base = test.getBaseURI();
URI baseURI= new URI(base);
URI testURI = baseURI.resolve(uri);
Document testdoc = domBuilder.parse(testURI.toString());
Canonicalizer canonicalizer =
Canonicalizer.getInstance(Canonicalizer.ALGO_ID_C14N_EXCL_WITH_COMMENTS);
byte[] result = canonicalizer.canonicalizeSubtree(testdoc);
String outputFilename = testURI.toString().substring(5) +
".exc";
OutputStream out = new FileOutputStream(outputFilename);
out.write(result);
out.flush();
out.close();
System.out.println(outputFilename);
}
}
}
--
Elliotte Rusty Harold [EMAIL PROTECTED]
XML in a Nutshell 3rd Edition Just Published!
http://www.cafeconleche.org/books/xian3/
http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim