Looking at the Java org.w3c.dom.Document, we should also provide the ability to import the whole node tree or just the node.
Also we should probably leave the cloneNode as it allows developers to replicate the node or node tree. There is now way specify this if we just reply on clone(). Bob (Buffone) -----Original Message----- From: James Margaris [mailto:[EMAIL PROTECTED] Sent: Monday, September 11, 2006 8:03 PM To: [email protected] Subject: ownerDocument confusion I am having a bit of trouble figuring out how the DOM spec says owner document should be treated, and how we can reconcile that with what we need. We certainly have some issues around our ownerDocument and _ownerDocument. (Yes we have both) I think this is because there are two concepts at work here: 1: What document did this element originate from? 2: Is this element currently part of that document? (Has a path up to the document) For example if you create an element from a doc but then never do something with it the ownerDocument should point to that document, but the element is not actually a part of it. We use "ownerDocument" and "_ownerDocument" to track these ideas in a confusing fashion. In addition the "ownerDocument" field is not kept up to date by cloning and we don't have an "importNode()" implementation. This is a big issue because the xpath id() function relies on ownerDocument. My proposal: 1: ownerDocument will track what it is supposed to track according to spec - the document the node was created from. 2: importNode() will be introduced and will correctly update ownerDocument on the imported nodes. 3: We will disallow moving elements between documents without the use of importNode() 4: We will hide/remove/rename our implementation of cloneNode(), since it is used to copy between documents but does not track ownerDocument. 5: We will introduce separate methods/variables to keep track of whether or not the current node has a path to the document root. We need this concept for our document level attribute/structure listeners, among other reasons. Once an element is removed from a document it should not fire document level structure/attribute changes, but technically the "ownerDocument" has not changed. Sound reasonable? James Margaris
