Radical Suggestion (was Re: Antwort: RE: [jdom-interest] Namespace help)

Dennis Sosnoski dms at sosnoski.com
Thu Jul 25 10:43:11 PDT 2002

Namespace handling is an especially messy issue for developers, judging 
from the number of times this misunderstanding occurs with all the 
document models. The problem is that XML defines each element as having 
a definite namespace (even if it's the "no namespace" namespace), but 
from a programmer's point of view it's more natural to see things in 
terms of namespace inheritance through the tree structure - an element 
either has an explicit namespace denoted by a prefix or default 
namespace definition, or is in the default namespace defined by an ancestor.

If JDOM's goal is ease of use it seems like matching the programmer's 
POV rather than the XML POV would be the right way to go. What this 
would probably mean is that elements created without a specified 
namespace would just inherit the default namespace determined by where 
they were linked into the tree. The namespace could still be set 
explicitly if desired, and it'd be easy enough to extract and set the 
namespace when removing an element (and children) from a tree, again if 

I think this has been discussed before. The fact that it keeps popping 
up as a source of confusion for users says that the current scheme 
(which is the same as DOM, dom4j, and all the other document models) 
doesn't work well for programmers.

  - Dennis

Li Xu wrote:

>Bob and Ken
>Thank you!!! You answered my vague question clearly here.
>I thought when I assign a namespace using setNamespace() in an element, all its existing children will "by default" get it if they don't have a NS yet. Ken hit my nail in the head that I was using the string representation logic to assume the inheritance among the actual java objects.
>Cheers all!
>To control your jdom-interest membership:

More information about the jdom-interest mailing list