W3C home > Mailing lists > Public > www-dom@w3.org > October to December 1998

Definition of cloneNode method

From: David Beech <DBEECH@us.oracle.com>
Date: Tue, 29 Dec 1998 17:54:24 -0500 (EST)
Message-Id: <199812292254.OAA18154@mailsun2.us.oracle.com>
To: www-dom@w3.org
Greetings, DOM experts 
 
I have a suggestion about the definition in DOM CORE of cloneNode in the
Node 
interface, which perhaps needs to be clarified a bit.  I was led to read
this 
definition closely while examining the relevance of the DOM data model to
XML 
query possibilities (my usual list is w3c-ql@w3.org).   
 
Specifically I was comparing queries that return references to nodes with 
those that return copies of nodes.  A crucial aspect is whether a copy would 
still know the parent of the original, and the DOM model includes a
parentNode 
attribute as part of the Node interface (even though for a whole document
this 
is redundant with the childNodes attributes of the parent nodes).  However,
I 
note that the definition of cloneNode sets the parentNode attribute to null
in 
the result. 
 
My suggestion is about the recursive definition of deep cloning.  Strict 
recursive application of the definition that creates a result without a 
parentNode would produce subnodes that had lost their hierarchical
connection 
- is this intended?  Probably not - it looks as though it would help to
spell 
out additionally that all the child and sibling attributes of the parent
need 
to be changed to refer to the clones, and the parentNode attributes in the 
children need to be set to the node for which they were recursively created.
 
[Typo: "recursively clone the subtrees" in the plural?]  Is order always 
preserved between siblings in deep cloning? 
 
Incidentally, another welcome aid to readers of this section would be to 
remove the ambiguity of "attributes" as between the IDL attributes of a node 
and the XML attributes of an element. 
 
Just to check my understanding of shallow cloneNode - this will copy the 
chosen node, including its childNodes attribute, which (in IDL as in Java) 
consists of references to other objects, i.e. to the original child nodes.  
Hence by following the parentNode reference in the child, and then the 
parentNode reference again, one can arrive at the original parent (if any)
of 
the cloned node, even though parentNode is null in the clone. 
 
Net result - if a query returns a clone of a node (following the DOM model), 
it is not possible to navigate upwards to the original parent, except 
indirectly in the case of a clone that is shallow and has at least one
subnode 
- is that correct? 
 
 
Thanks, 
 
  David  
  
========================================================================  
David Beech			Oracle Corporation, 500, Oracle Parkway,    
Consulting MTS			M/S 2op12, Redwood Shores, CA 94065   
Server Technology		Phone: (650)506-6420, fax: (650)506-7582 
======================================================================== 
 
DISCLAIMER:  Any statements made in this message are at best my own  
opinions, and are not necessarily endorsed by Oracle Corporation.
Received on Wednesday, 30 December 1998 03:43:07 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:46 GMT