[jdom-interest] addNamespaceDeclaration()

philip.nelson at omniresources.com philip.nelson at omniresources.com
Tue Apr 17 11:42:57 PDT 2001

> I would like to add the xsi namespace to the top element of 
> my JDOM document
> so that I can use xsi:xxx attributes in subelements.  I did 
> the following:
>   Namespace XSI_NAMESPACE = Namespace.getNamespace("xsi", 
> "http://www.w3.org/2000/10/XMLSchema-instance");
>   // Set a namespace for xsi:type attributes on the top Element
>   Element top = (Element)resultDoc.getRootElement();
>   top.addNamespaceDeclaration(XSI_NAMESPACE);
> What happens is JDOM will output an 
> xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
> on every element that has an xsi:xxx attribute and not on the 
> top element
> (presumably because there is no xsi:xxx attribute there).  

This is clearly NOT the intended result!  Before I/we confirm this bug, are
you using the latest cvs version of JDOM?

More information about the jdom-interest mailing list