[jdom-interest] [Patch] Bug regarding attributes local name using JDOMResult

Elliotte Harold elharo at metalab.unc.edu
Mon Nov 21 12:53:13 PST 2005


Mattias Jiderhamn wrote:

> The only case when the current code would produce the expected output 
> while the patched code would not, is if attQName contains both prefix 
> and name while attLocalName is the empty string. I figured that if such 
> a parser exists, it is erroneous and it shouldn't be JDOMs 
> responsibility to handle this. But maybe I'm wrong here?

Where and when SAX parsers report nulls and empty strings for the qName 
and localName arguments is shockingly non-deterministic. Most parsers do 
what you expect, but they're a few weird ones out there that are still 
spec-conformant. XOM goes to some effort to make sure that all these 
arguments are properly set. The only way to guarantee this is to set the 
namespace and namespace-prefixes properties both to true, if I recall:

             parser.setFeature(
               "http://xml.org/sax/features/namespace-prefixes", true);

I'm not sure whether JDOM's SAXBuilder class does that or not.

-- 
Elliotte Rusty Harold  elharo at metalab.unc.edu
XML in a Nutshell 3rd Edition Just Published!
http://www.cafeconleche.org/books/xian3/
http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim


More information about the jdom-interest mailing list