[jdom-interest] bug in Element.getCopy ?

Jochen Strunk strunk at signal7.de
Thu Mar 1 09:40:41 PST 2001


that's not what I meant. I wanted to change the default namespace of an 
element. The only
way I found to do so is via the getCopy Method:

Element a = 

I'd expect the result to be:

<a xmlns="http://www.x.org">

because I created b with no namespace.

But the result is:

<a xmlns="http://www.x.org">
    <b xmlns=""></b>

because b has an empty namespace.

I think applying a default namespace to an element should also apply that 
namespace to every child element with no namespace.
This does not work because in that case jdom seems to not properly separate 
between the empty namespace and no namespace.

Any suggestions on this ??

The patch I posted does not really solve this problem, it simply sets the 
given namespace on all child elements which is certainly incorrect 
behaviour in most cases.


At 23:39 27.02.2001 -0800, you wrote:
>Jochen Strunk wrote:
> >
> > Hi,
> >
> > i think there is a bug in Element.getCopy. It doesn' t deep copy the
> > namespace, which makes it difficult to change the default namespace of an
> > element. The patch below solves the problem for me.
>If you call getCopy(String) it makes a copy of the element using the
>given name in no namespace.  My guess is you're seeing that behavior but
>expect it to copy the namespace over too?

(-) Jochen Strunk
(-) SIGNAL 7 Gesellschaft für Informationstechnologie mbH
(-) Brüder-Knauß-Str. 79 - 64285 Darmstadt,
(-) Tel: 06151 665402, Fax: 06151 665373
(-) strunk at signal7.de, www.signal7.de

More information about the jdom-interest mailing list