Re: Cut/Paste from one document to another

Espen Frimann Koren wrote:

> Yes, that is right. A document will only accept node that are created using ist
> createX operations. This means that you have to clone the node you will cut
> and paste, like this pseudo code:
> 
> newNode = newDocument.createNode(...);
> newNode.setAttribute(oldNode.getAttribute());
> ...
> newDocument.appendChild(newNode);
> 
> As you can see this is conseptual code, but the point is that first you create
> a new node similar to the old one, but connected to the new document (although
> not part of the tree after the
> createNode statement). Then you copy all attributes that are copyable, that is
> attributes that you can set on the new node, and then you add the new node to
> your document (makes it part of the tree)

Thanks for that answer. I have to say that this is really a bad surprise.
XML well-formed documents provide an easy way of fragment manipulation and
encapsulation into other XML w-f documents but DOM1 does not allow that :-(
In that case, DOM1 cannot be easily used out of the browser world, manipulating
one document only at a time.

> PS! Does someone know whether this has changed in DOM 2.0? I think I have
> seen something in the new interfaces in the spec that has this effect

I hope you are right !!!!

</Daniel>

Received on Tuesday, 24 August 1999 05:26:57 UTC