OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   DOM Node.cloneNode()

[ Lists Home | Date Index | Thread Index ]
  • From: Tyler Baker <tyler@infinet.com>
  • To: xml-dev@ic.ac.uk
  • Date: Tue, 18 Aug 1998 12:06:34 -0400

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@ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo@ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@ic.ac.uk)





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS