[jdom-interest] No namespaces for attributes without prefix

Galluzzo, Eric EGalluzzo at synchrony.net
Wed Sep 13 07:50:56 PDT 2000


> -----Original Message-----
> From: Elliotte Rusty Harold [mailto:elharo at metalab.unc.edu]
> Sent: Wednesday, September 13, 2000 8:39 AM
> To: Galluzzo, Eric; 'jdom-interest at jdom.org'
> Subject: Re: [jdom-interest] No namespaces for attributes 
> without prefix
> 
> 
> At 6:08 PM -0400 9/12/00, Galluzzo, Eric wrote:
> >When SAXBuilder (latest, from CVS) builds a document, it 
> appears that the
> >attributes are created in the wrong namespace.  For example, in the
> >following (very small) document:
> >
> ><foo:bar xmlns:foo="http://www.foo.com/" glurp="howdy"/>
> >
> >the "glurp" attribute would be considered part of the 
> default namespace,
> >whereas it should actually be part of the foo namespace.  
> The "foo:" prefix
> >is implied by the element itself being in the "foo" namespace.
> >
> 
> This is correct behavior. The glurp attribute is NOT in the 
> http://www.foo.com/ namespace. Unrpefixed attributes are always in no 
> namespace, not the default namespace, not the namespace of the 
> element they belong to. This is the behavior specified and required 
> by the Namespaces in XML specification.

Hmmm...I don't know about that.  I just re-read through the proposal, and
actually it didn't say anything about what namespace, if any, un-prefixed
attributes are in.  In Appendix A (which is non-normative), it says that
there's a per-element-type partition into which all un-prefixed attributes
fall.  So it looks like (in the above example) the attribute would be in the
"element bar within namespace http://www.foo.com/" namespace.  This is sort
of borne out by the <ExpAName .../> stuff in section A.3.  (By the way, when
I said "default namespace" in the original mail, I really meant "empty
namespace" -- sorry about that!)

In any case, it's a rather fuzzy area.  I guess I'm happy with them being
considered part of the empty namespace, if that's the consensus.

> JDOM is simply inheriting 
> this correct behavior from the underlying parser, which is what tells 
> JDOM which namespace each attribute is (or is not) in.

Actually, the parser is doing nothing more than giving you the qualified
name of the attribute (i.e. exactly what's in the XML file).  SAXBuilder
does the work of figuring out the prefix and doing its own namespace
processing.

    - Eric



More information about the jdom-interest mailing list