[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Problem with cloneNode


clonenode
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.