Michael Glavassevich wrote:

Hi Ron,

You cannot append a node from one document to a node owned by another document. Try using Document.importNode() [1].
Yep, this worked for me. Thank you.

Ron Addie
University of Southern Queensland.

[1] http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Core-Document-importNode

Ron Addie <[EMAIL PROTECTED]> wrote on 06/21/2005 02:56:28 AM:

I am having trouble appending a document fragment from one
document to a different document. In the following code, I
am trying to append all the children of document r to document
s. It fails with

WRONG_DOCUMENT_ERR: A node is used in a different document than the one that created it.

Here is the code:

Range rdf = ((DocumentImpl)r).createRange();
rdf.setStartBefore(r.getLastChild());
rdf.setEndAfter(r.getLastChild());
DocumentFragment df= rdf.extractContents(); // doesn't this allow the document fragment s.getFirstChild().appendChild(df); // to be appended to a different document?


Your assistance would be greatly appreciated.

Incidentally, I can disable the error by modifying the code in CoreDocumentImpl.java, but
I would prefer to use the library in the manner which was intended.

Ron Addie.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]
E-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to