[jdom-interest] xmlns="" in children elements of root

Jason Hunter jhunter at collab.net
Wed Aug 29 10:38:35 PDT 2001


Laurent Bihanic wrote:
> 
> philip.nelson at omniresources.com wrote:
> 
> > Really, it's easier than you think.  Create the parent element with a
> > namespace and then use the overloaded constructors for the children that
> > take namespace objects, and pass the parents namespace.
> 
> Yet, I agree with Rodney that if you define a default Namespace one can expect
> the constructor with no Namespace argument to use the default Namespace.

There is no such thing as a default Namespace for a document.  The same
document could have 20 things called "default namespaces".  So when you
call

new Element("foo");

Just which namespace would you have that element be in?  You can't know
at construction!  

You could have it depend on where you later place the element, but as
XML experts will tell you, an element's namespace is intrinsic to that
element and should not change depending on location, and elements should
not have to be namespace-less if they aren't in a document.

Think of "default namespace" as "no-prefix namespace" and it makes easy
sense.

-jh-



More information about the jdom-interest mailing list