[jdom-interest] JDOMResult silently absorbs document fragments
(was: Re: [jdom-interest] Question about JDOMResult and usage with XMLReader)
laurent.bihanic at atosorigin.com
Mon Aug 19 06:26:00 PDT 2002
Elliotte Rusty Harold wrote:
>> No, JDOMResult only accepts well-formed documents and do throw an
>> exception when it detects multiple root elements.
> But it shouldn't be doing that! An XSLT transformation can produce a
> document fragment. JDOM's representation of a document fragment is a
> java.util.List containing various Text, Element, Comment, and
> ProcessingInstruction objects. JDOMResult should be based on such a List
> rather than on a Document. The design of JDOMResult is simply not
> consistent with XSLT or TrAX.
You already said this sometime ago and I replied with 2 questions yet unanswered:
1. DOMResult can indeed return a DocumentFrangment but I do not agree with you
for SAXResult: It is configured with a ContentHandler and the javadoc for
ContentHandler states: "Receive notification of the logical content of *a*
So it seems SAXResults should not accept document fragments (and JDOMResult
extends SAXResult). What is the SAX event flow fired by an XSLT processor when
reporting a document fragment? For example, are start/endDocument fired in
case of document fragments?
2. How would JDOMResult decide what the result actually is: If the
transformation returns a list of nodes, no problem; but if a single element is
returned, should it return a Document or an Element? Is there something in the
XSLT spec to help distinguish between these 2 cases?
More information about the jdom-interest