Bug 18654 - How to clone a Node and assign a new name
Summary: How to clone a Node and assign a new name
Status: NEW
Alias: None
Product: Xerces-J
Classification: Unclassified
Component: Samples (show other bugs)
Version: unspecified
Hardware: PC All
: P3 enhancement
Target Milestone: ---
Assignee: Xerces-J Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-04-03 12:36 UTC by Juergen Donnerstag
Modified: 2005-03-20 17:06 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Juergen Donnerstag 2003-04-03 12:36:49 UTC
Sorry, for the probably simple question. I'm not an expert on DOM.

I need to clone a Node (including all its childs) and assign a new name to this 
copy. I found the method to clone the Node and to get the name, but there seems 
to be no way to change/set the name. The only way, I found, to create a new 
Node/Element and to assign a name to it, is by Document.createElement(). 
Could someone please guide me in the right direction in how to effectively 
clone a Node and all it's childs and to assign a new to the copy?

thanks
Juergen
Comment 1 Joe Kesselman 2003-04-03 14:27:05 UTC
In DOM Level 1 and  2, nodes may not be renamed. Create a new node with the 
appropriate name, and copy the other content to it.

DOM Level 3 (currently under development, may or may not yet be prototyped in 
Xalan) adds the method renameNode... but you should read the description of that 
method carefully, as not all DOMs can support renaming an existing node object 
and the method may have to create a new one.

Given the workaround, and given the new DOM method in the pipe, I think this 
request is pretty well covered...