[jdom-interest] Protected methods to make private

Laurent Bihanic laurent.bihanic at atosorigin.com
Tue Jul 1 09:37:40 PDT 2003


Bradley S. Huffman wrote:
> I don't think the following is any uglier than "if (atRoot) ..." that's 
> currently in comment(), startElement(), processingInstruction(). And SAXHandler
> now becomes reuseable, and JDOMResult becomes simpler :)

Quite neat!

There are some problems, though.

Relying on endDocument to switch between result list and document won't work 
with XSLT processors.
First, some XSLT processors (e.g. Oracle's) never invoke start/endDocument.
Second, when the processor invokes endDocument (e.g. Xalan, Saxon, jd.xslt), 
the content of the result list may not be suitable to create a well-formed 
document as it may contain several elements.
A little bit more logic is needed to handle these cases. Maybe totally 
ignoring endDocument as in JDOMResult.FragmentHandler and moving all the 
Document construction logic in getDocument is the way to go

Reusing SAXHandler instances is another problem when startDocument is not 
called. To solve this problem JDOMResult.DocumentBuilder implements a method 
ensureInitialization that every ContentHandler callback method calls but I 
think this is too complicated to maintain.
Maybe I should remove FragmentHandler reuse in JDOMResult.

Laurent




More information about the jdom-interest mailing list