You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Sean Zhang <Se...@ins.gte.com> on 2002/04/09 23:11:08 UTC

I'm having some problem with cloneNode(true)

I'm having problem assigning attribute values to child nodes of the newly
cloned node.  I'm using Xerces J v1.4.1

Following is what I did

1.	I'm using cloneNode(true) to deep copy a node.  This is successful.

For example, below is the original node
<level1 attr1="1">
	<level2 attr2="2.1"/>
<level2 attr2="2.2"/>
</level1>

below is the newly cloned node
<level1 attr1="1">
	<level2 attr2="2.1"/>
<level2 attr2="2.2"/>
</level1>

Then I start to assign values to the attributes of the newly cloned node.  I
plan to assign value for the new node as below
<level1 attr1="3">
	<level2 attr2="4.1"/>
<level2 attr2="4.2"/>
</level1>

finally, I will append the newly cloned node to the parent of the original
node 

below is what I should have after appending the newly cloned node
<level1 attr1="1">
	<level2 attr2="2.1"/>
<level2 attr2="2.2"/>
</level1>
<level1 attr1="3">
	<level2 attr2="4.1"/>
<level2 attr2="4.2"/>
</level1>

But I received follow
<level1 attr1="1">
	<level2 attr2="4.1"/>
<level2 attr2="4.2"/>
</level1>
<level1 attr1="3">
	<level2 attr2="2.1"/>
<level2 attr2="2.2"/>
</level1>

Seems to me that attribute values for level1 node is correctly assigned and
new values for child nodes for level1 are not assigned to the newly cloned
node but assigned to the original node.

Is this the correct behavior?  How can I assign the values to the newly
cloned node without affecting the original node?

Thanks,

Sean


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: I'm having some problem with cloneNode(true)

Posted by DingHui <dh...@bisp.com>.
I don't think it's the correct behavior.
Maybe it's a bug of Xerces-J 1.4.1, so , try using the newest version of Xerces-J.
----- Original Message ----- 
From: "Sean Zhang" <Se...@ins.gte.com>
To: <xe...@xml.apache.org>
Sent: Wednesday, April 10, 2002 5:11 AM
Subject: I'm having some problem with cloneNode(true)


> I'm having problem assigning attribute values to child nodes of the newly
> cloned node.  I'm using Xerces J v1.4.1
> 
> Following is what I did
> 
> 1. I'm using cloneNode(true) to deep copy a node.  This is successful.
> 
> For example, below is the original node
> <level1 attr1="1">
> <level2 attr2="2.1"/>
> <level2 attr2="2.2"/>
> </level1>
> 
> below is the newly cloned node
> <level1 attr1="1">
> <level2 attr2="2.1"/>
> <level2 attr2="2.2"/>
> </level1>
> 
> Then I start to assign values to the attributes of the newly cloned node.  I
> plan to assign value for the new node as below
> <level1 attr1="3">
> <level2 attr2="4.1"/>
> <level2 attr2="4.2"/>
> </level1>
> 
> finally, I will append the newly cloned node to the parent of the original
> node 
> 
> below is what I should have after appending the newly cloned node
> <level1 attr1="1">
> <level2 attr2="2.1"/>
> <level2 attr2="2.2"/>
> </level1>
> <level1 attr1="3">
> <level2 attr2="4.1"/>
> <level2 attr2="4.2"/>
> </level1>
> 
> But I received follow
> <level1 attr1="1">
> <level2 attr2="4.1"/>
> <level2 attr2="4.2"/>
> </level1>
> <level1 attr1="3">
> <level2 attr2="2.1"/>
> <level2 attr2="2.2"/>
> </level1>
> 
> Seems to me that attribute values for level1 node is correctly assigned and
> new values for child nodes for level1 are not assigned to the newly cloned
> node but assigned to the original node.
> 
> Is this the correct behavior?  How can I assign the values to the newly
> cloned node without affecting the original node?
> 
> Thanks,
> 
> Sean
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>