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

Rodney S. Foley rsfoley at harddollar.com
Wed Aug 29 08:59:36 PDT 2001

But, a "" namespace is illegal per w3c DOM.
I have created XML with other tools and they do not do this.  When you
assign xmlns="http://www.someplace.com" all it's children are part of that
namespace unless you explicitly say other wise.  So when I set the root
element to xmlns="http://www.someplace.com" all it children are in that
namespace, so for JDOM to add to the first level children an illegal
namespace of "" this file is now invalid when I try to convert a JDOM
document to a w3c DOM Document an exception is thrown stating that "" is
illegal for a namespace.  

I should NOT have to assign a namespace to every element.  I am creating XML
files that must be validated against a Schema and the schema works as I
stated, that all children are in the same namespace as the parent unless
explicitly changed.

-----Original Message-----
From: philip.nelson at omniresources.com
[mailto:philip.nelson at omniresources.com]
Sent: Wednesday, August 29, 2001 8:37 AM
To: rsfoley at harddollar.com; jdom-interest at jdom.org
Subject: RE: [jdom-interest] xmlns="" in children elements of root

> I tried this with the beta 7 binaries, and also downloaded the source
> yesterday (8-28-01) afternoon and have the same problem.
> When I give my root element (using XMLOutputter) a namespace of just
> "xmlns=http://www.someplace.com" I do not explicitly assign a 
> namespace to
> any of the children elements at any level, but the first 
> level children of
> the root are assigned a namespace of 'xmlns=""' which I can 
> not figure out
> why and can not get ride of it.  This should not be happening 
> and makes it
> invalid against the schema.  

You *must* assign the namespace to each element you create.  A child element
does not automagically get the parents namespace which means it is in the ""
namespace.  This is by design and was *HEAVILY* discussed here.

More information about the jdom-interest mailing list