[jdom-interest] Protected methods to make private

Jason Hunter jhunter at servlets.com
Tue Jun 17 13:09:23 PDT 2003


That's a beautiful solution, and I just checked it in.

-jh-

Laurent Bihanic wrote:
>> SAXHandler:
>>   atRoot
>>
>> I see JDOMResult.FragmentHandler uses this.  That's an odd property to 
>> expose.  Could this be done another way?  Laurent?
> 
> 
> Sure, this could be removed if SAXHandler provided a protected 
> pushElement() method.
> As JDOMResult may receive a node list and not a document, it needs to 
> add a dummy root element to the being-built document before the parse 
> begins. To do that, I simply pasted some code from startElement.
> 
> For example, in SAXHandler:
> 
> protected void pushElement(Element element) {
>     if (atRoot) {
>         document.setRootElement(element);
>         atRoot = false;
>     } else {
>         getCurrentElement().addContent(element);
>     }
>     currentElement = element;
> }
> 
> Then JDOMResult.FragmentHandler constructor could be changed to:
>     public FragmentHandler(JDOMFactory factory) {
>       super(factory);
> 
>       // Add a dummy root element to the being-built document as XSL
>       // transformation can output node lists instead of well-formed
>       // documents.
>       this.pushElement(dummyRoot);
>     }
> 
> Laurent
> 
> 




More information about the jdom-interest mailing list