[jdom-interest] Namespace patch

bob bob at accurev.com
Tue Aug 29 12:00:51 PDT 2000

> The big question is whether anyone cares where the namespace prefixes 
> are declared as long as they're declared; i.e. would it matter if a 
> namespace declaration moved from a child node to a parent node?

Yes.  Immensely.  JDOM has no idea how the namespace will be used,
and by shifting it around, you could be changing the semantics of
the document.

Also, remember you can 'unset' namespace prefixes, by using a
URI of "".  Likewise, I think a prefix can be overriden by inner
Elements, so foo: might mean one thing to an element, and foo:
could be completely different to a parent/ancestor.

> Simply holding on to all namespace declarations is not hard. Making 
> sure they stay in one place is hard given the current architecture. 

> It might also require changes to how client programmers work with 
> JDOM. Right now you can add any element as a child of any other 
> element, and any attribute to any element and the namespaces will 
> sort themselves out. I'm not sure if we can maintain that simplicity 
> if we allow people to directly add namespace declarations.  Maybe we 
> can. I need to think about it some more.

Yah, it seems that Namespaces are currently keyed by URI alone.
I think prefix/uri is what we really need to key.

Regarding the addAttribute()/addNamespaceDeclaration() dichotomy...

getAttributes() does not (and shouldn't!) return namespace declarations.
So, it seems that addAttribute() shouldn't add namespace declarations
either.  (If you addAttribute() with 'xml*' namespace, maybe toss an

Hence the added pair of addNamespaceDeclaration() and 
getNamespaceDeclaration() on Element in my patch.

Just ponderin'


More information about the jdom-interest mailing list