[jdom-interest] moving namespaces up

Vladimir Grishchenko VGrishchenko at serena.com
Fri Jun 15 16:28:42 PDT 2001


Here is a dumb question but I need this functionality for my project.
I looked briefly at JDOM api and couldn't find a way to do the following:

Say, I have an XML doc stored as:

   <A:child1 xmlns:A="FOO:"/>
   <B:child2 xmlns:B="BAR:"/>

I read it in via SAXBuilder and I want it to be outputted as:

<root xmlns:A="FOO:" xmlns:B="BAR:">

Basically I need all namespace declarations to be moved up, possibly
changing prefix names if there's any prefix name collisions. 

What else I can do aside from subclassing Element or Document and writing my

own method to do that?

This question comes from the need to integrate the product I'm working on
with some other tool which is not able to recognize that child1 actually is 
in namespace FOO: and child2 is in namespace BAR: unless namespaces are
somewhere up in the tree.

Thanks and regards,

This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. Any unauthorized review, use, disclosure or distribution
is prohibited. If you are not the intended recipient, please contact
the sender by reply e-mail and destroy all copies of the original

More information about the jdom-interest mailing list