[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] DOM Node.cloneNode()
In the most recent DOM spec the method Node.cloneNode(boolean deep) does not really specify how the Node should be cloned (e.g. a shallow copy or a deep copy). It has a boolean "deep" argument that would imply a true deep copy, but still this is not totally clear as a true deep copy would be a copy by value instead of the implicit copy by reference. In other words, if I have a Node named "A" with two children named "B" and "C", would you do something like this in Java for A: public Node cloneNode(boolean deep) { Node newNode = new NodeImpl(); // Do attribute copies here if (deep) { newNode.appendChild(B); newNode.appendChild(C); } return newNode; } or else would you do something like: public Node cloneNode(boolean deep) { Node newNode = new NodeImpl(); // Do attribute copies here if (deep) { newNode.appendChild(B.cloneNode(deep)); newNode.appendChild(C.cloneNode(deep)); } return newNode; } Similiarly, what happens with the Attributes of a Node is also not too clear to me. Are attributes copied by value or by reference as well? What happens to the parent attribute? Should it be copied as well or should it just have the implicit DocumentFragment reference as its parent? What happens to the references to the siblings of a node? Any help on these issues would be greatly appreciated... Thanx in advance, Tyler xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@i... Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ To (un)subscribe, mailto:majordomo@i... the following message; (un)subscribe xml-dev To subscribe to the digests, mailto:majordomo@i... the following message; subscribe xml-dev-digest List coordinator, Henry Rzepa (mailto:rzepa@i...)
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|