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
interface, which perhaps needs to be clarified a bit.  I was led to read
definition closely while examining the relevance of the DOM data model to
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
attribute as part of the Node interface (even though for a whole document
is redundant with the childNodes attributes of the parent nodes).  However,
note that the definition of cloneNode sets the parentNode attribute to null
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
- is this intended?  Probably not - it looks as though it would help to
out additionally that all the child and sibling attributes of the parent
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)
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
- is that correct? 
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 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:05 UTC