[jdom-interest] Possible bug in SAXHandler when "namespaces" feature is off
dmitri at apache.org
Sun Jan 18 20:40:17 PST 2004
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. I decided to add
support to this "feature" to JXPath and discovered that it was a no-brainer
with DOM and impossible with JDOM. See, in order for external namespaces to
make any sense, I first need to be able to read a file that has unmapped
Let's say I want to parse this file:
True, it does not comply with XML Namespaces, because "my" is not explicitly
mapped to a namespace URI in the same file. But I need to parse this anyway.
So, I turn off the "namespaces" feature. Works like a charm with DOM. Why
should JDOM be less flexible? Or is there a better way?
Here's another argument. JDOM has great flexibility in regards to underlying
SAX driver: you can provide your own if you want to. Since SAXDriver is not
supposed to have namespaces=true, JDOM should really be prepared to handle
Finally, even if JDOM is not designed to work with SAX drivers that do not
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.
----- Original Message -----
From: "Elliotte Rusty Harold" <elharo at metalab.unc.edu>
To: "Dmitri Plotnikov" <dmitri at apache.org>
Sent: Saturday, January 17, 2004 8:53 PM
Subject: Re: [jdom-interest] Possible bug in SAXHandler when "namespaces"
feature is off
> >I've noticed that if I turn off the "namespaces" feature, JDOM fails with
> >the following exception:
> Patient: Doctor, it hurts when I turn off the "namespaces" feature.
> Doctor: Don't turn off the namespaces feature.
> Seriously, JDOM is designed to be namespace aware, and will not
> handle namespace aware and will not handle namespace malformed
> documents. Use the defaults and everything should be fine. Just
> because your documents don't use namespaces, doesn't mean you have to
> turn off the namespaces feature. You would only turn this off if your
> documents used colons in ways prohibited by Namespaces in XML, in
> which case you cannot use JDOM.
> Elliotte Rusty Harold
> elharo at metalab.unc.edu
> Effective XML (Addison-Wesley, 2003)
More information about the jdom-interest