[jdom-interest] Second element xmlns=""

Per Norrman per.norrman at austers.se
Fri Sep 17 07:57:14 PDT 2004


Myron Uecker wrote:
> I created a brand new XML document, added a root element with two 
> namespaces, xmlns="..." and xmlns:xsi="...".  I then added several more 
> elements and sub-elements.  On the second element, I get xmlns="" .  Why 
> is this?  Can it be shut off?  Here's an example:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <SubmitRequest xmlns="http://myns" 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <ResourcePlan xmlns="" resource="..." day="2004-08-06">
>   <ResourcePlanHourly hour="01">
> ...

You created the <ResourcePlan> elemnt in NO namespace, that's why. You
probably wanted it in "http://myns" namespace.

When dealing with namespaces, always use the namespace aware
constructors and access methods.

/pmn


More information about the jdom-interest mailing list