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

Re: Copying from one DOM to another

From: Joseph Kesselman <Joseph_Kesselman@lotus.com>
Date: Fri, 17 Nov 2000 17:09:37 -0500
Cc: www-dom@w3.org
Message-ID: <OF07184C11.3C03F103-ON8525699A.00796A03@pok.ibm.com>

>1) I don't understand why a document has to own all nodes it can

Brief answer: Because that's what the spec says.

Longer answer: Because implementing a DOM often involves nonpublic
interfaces (in order to achieve the desired behavior), and those won't work
across implementations. And because Documents may be subclassed
differently, in some DOMs, which can further impede interchangability of

>2) If I get a reference to DOM document, what should I do to be certain
>that the changes I do, don't reflects in the original data structure?
>Should I use importNode (to a memory-only document) or cloneNode?

I'm not sure what question you're asking. If you don't want to affect the
original DOM tree, don't alter the nodes which belong to that tree -- copy
them first. Whether that should be done via cloneNode or by importing into
a new Document is up to you, and depends on what you intend to do with the
copied nodes.

Joe Kesselman  / IBM Research
Received on Saturday, 18 November 2000 11:49:02 UTC

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