[jdom-interest] Possible bug in SAXHandler when "namespaces" feature is off

Dmitri Plotnikov dmitri at apache.org
Mon Jan 19 07:38:46 PST 2004


> >Doctor,
> >
> >This issue came up when I was adding support for "external namespace
> >registration" to JXPath.  There was a discussion on
commons-dev at apache.org
> >regarding the need to register namespaces externally.
> Can you provide a reference to this discussion? What is this feature
> and why is it necessary?
To be honest with you, I am not sure what the use case is myself. All I see
that there are at least two users interested, and one of them actually
hacked JXPath to introduce that feature - must've been important to him.


Now that I think about this, I am leaning toward changing the implementation
so that instead of disabling namespaces altoghether, it would pre-register
the external ones with the parser, which I believe is possible with both DOM
and JDOM.

> >True, it does not comply with XML Namespaces, because "my" is not
> >mapped to a namespace URI in the same file. But I need to parse this
> >So, I turn off the "namespaces" feature.  Works like a charm with DOM.
> >should JDOM be less flexible?
> Because JDOM hits a nice 80/20 point rather than the confusing mess
> of trying to do everything you find in DOM.
Still, if a one-line change makes it 85/15, why not make that change? I am
not sure it just that one line though.  I bet that's your concern - but have
you actually tried?

> >Or is there a better way?
> Probably, but I'd need to understand your use-case first.
> >Here's another argument. JDOM has great flexibility in regards to
> >SAX driver: you can provide your own if you want to. Since SAXDriver is
> >supposed to have namespaces=true, JDOM should really be prepared to
> >the situation.
> What is SAXDriver? I have not heard of this class, and I don't think
> it's anything JDOM uses.
What the JDOM source code calls SAX driver, others call SAX parser. Perhaps
you overlooked that term in the source file org.jdom.input.SAXBuilder.

> >Finally, even if JDOM is not designed to work with SAX drivers that do
> >support namespaces, why doesn't it report that explicitly by throwing a
> >relevant exception? Why doesn't it check that the driver in fact supports
> >the feature?  A simple call to getFeature(), checking the result and
> >throwing an exception would do.
> Again, JDOM doesn't (I think) use any class called "SAXDriver" so
> there's really nothing to be done here. If you mean XMLReader (I'm
> not sure you do) there is no major implementation of XMLReader that
> does not support namespaces, and any such implementation would be
> non-conformant with the SAX spec. But I'm not sure if that answers
> your question or not. The references to "SAXDriver" are throwing me.
Sorry - I should have mentioned where the term comes from. I just assumed
familiarity with the JDOM source code.

Let me reiterated my point, which is that even though all modern SAX parsers
SUPPORT namespaces, that support can be DISABLED for whatever reason, and
JDOM should be smart enough to either deal with it or explicitly report that
it cannot deal with it.  Instead, it throws an obscure exception in the
middle of the construction of the tree.

By the way, I have another question: is there a bug reporting database for
JDOM? I could not find a link on the Jdom.org website.

Thanks again,

- Dmitri

More information about the jdom-interest mailing list