Running a simple XSL transformation which succeeds or fails depending on the type of javax.xml.transform.Source used as input to the transformation. The basic scenario (with abbreviated code) follows:
Processor proc = new Processor(false);
XsltCompiler comp = proc.newXsltCompiler();
XsltExecutable exec = comp.compile(new StreamSource(new File("some/path/bug.xsl")));
XsltTransformer xsl = exec.load();
xsl.setSource( / this is where the problem is... see below /);
StringWriter writer = new StringWriter();
Serializer out = new Serializer();
out.setOutputWriter(writer);
xsl.setDestination(out);
// compare writer.toString() to expected output
Calling setSource() works when passing in a StreamSource or a DOMSource created with a org.w3c.Document, but it fails when a DOMSource created with the document's DocumentElement is passed in. The failure stacktrace is:
java.lang.ClassCastException: net.sf.saxon.tinytree.TinyElementImpl
at net.sf.saxon.Configuration.buildDocument(Configuration.java:2977)
at net.sf.saxon.s9api.DocumentBuilder.build(DocumentBuilder.java:287)
at net.sf.saxon.s9api.XsltTransformer.setSource(XsltTransformer.java:108)
at SaxonBug.main(SaxonBug.java:76)
You clearly didn't notice the highlighted text on the "Submit New" screen asking you not to submit bugs in this way - that's because I think it's helpful for the bug register to contain solved bugs rather than suspected bugs, making it easier to search. But never mind, 'tis done. But there are actually several distinct issues here.
The immediate problem is that Configuration.buildDocument crashes if given an AugmentedSource that wraps a DOMSource that wraps a DOM Node other than an element node. I've put a patch for this one in Subversion.
The more subtle problem is that in this Configuration.buildDocument copies the DOM tree rather than wrapping it. In fact the XsltTransformer documentation is pretty vague about what to expect here, so this isn't absolutely wrong, but I think people would expect it to be wrapped by default. Certainly, that's what the JAXP transform() interface does. I'll treat this as a separate issue.
Apologies, but I considered your response in this thread, https://sourceforge.net/forum/forum.php?thread_id=2158274&forum_id=94027, an acknowledgment of the issue. Also, this is a showstopper for us and I'd not seen any response on that thread in a month. No offense intended...
Will there be a versioned release with these fixes?
Mr. Kay,
When will the fix for this bug be available? It's a showstopper in our application.
Thanks!
Fixed in 9.1.0.3