[jdom-interest] Question about JDOMResult and usage with XMLReader
laurent.bihanic at atosorigin.com
Tue Jul 30 07:48:00 PDT 2002
Elliotte Rusty Harold wrote:
> Hmmm, looking at the API docs I think this is a flaw in JDOM, not TrAX
> DOMResult and SAXResult do not assume they get a full document back from
> the transform. JDOMResult does. This is a mistaken assumption.
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*
document". Thus, SAXResults should not accept document fragments and
JDOMResult extends SAXResult.
> The List would contain the result of the transformation, which might be
> a single Document object or might be several element and text objects,
> or something else. I'm not sure what internal changes might be required
> here to support this. Possibly, JDOMResult would need to use a different
> ContentHandler; not SAXHandler. SAXHandler is designed for parsing an
> input document which is known to be well-formed. That is not the case here.
That could be done by subclassing SAXHandler and having a pre-allocated dummy
root element. The main problem would then be to decide what the result
actually is: If the transformation returns a list of node, no problem; but if
a single element iss returned, should we 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