[jdom-interest] Re: Bug patch for DOMBuilder ( JDOM )

Jason Hunter jhunter at collab.net
Wed Mar 14 14:46:58 PST 2001

Laurent ROMEO wrote:
> > > I've worked on JDOM, and I've discovered a bug with DOMBuilder class. I
> > > was using it with the DOM obtained from JTidy with  HTML documents.
> > >
> > > The problem is that the JTidy DOM interface proves to be a level 1 one.
> > > Your code need a DOM level 2 one, so the bug.
> > >
> > > In fact, there is not so much things to change to made it compliant.
> > > I've written a patch that is joined with this mail. For building it,
> > > I've just downloaded the last source from the JDOM cvs.
> > >
> > > I've also found a NullPointerException, so I think your code was not so
> > > much finished. Anyway, I'll keep working on it.

The NPE occurs because the DOM implementation is buggy.  Per 
http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html the
"childNodes" attribute must always returns a NodeList, possibly empty
but never null: "A NodeList that contains all children of this node. If
there are no children, this is a NodeList containing no nodes."

Makes me wonder if there's more non-compliance in JTidy.  It does seem
to have lost developer momentum, see http://www3.sympatico.ca/ac.quick/.

On this topic, there are a few philosophical questions here we need to

1) Should DOMBuilder support building from a DOM Level 1 document? 
Right now DOMBuilder assumes DOM2 support.  The alternative is to check
the DOMImplementation feature "XML" for the DOM level and follow a
different code path to read from a DOM1 document than a DOM2 document. 
Is this worthwhile?  I suspect there's more work needed to make this
solid than that LR wrote in.

2) Should DOMOutputter support creation of a DOM Level 1 document? 
Right now DOMOutputter builds a DOM2 document.  We could theoretically
do the same "XML" version check and if the parser supports only DOM1 we
could build for DOM1.  Is that worthwhile?

Remember, in the tradition of open source if you vote it should be done
that means you'd be willing to do the coding work yourself or actively
support the effort.  :-)


More information about the jdom-interest mailing list