You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by Michael Kraus <mi...@informatik.uni-muenchen.de> on 2000/09/20 11:06:50 UTC
DOM Problems
Hello,
I'm experiencing a problem with the DOM (I'm using the Xerces-J DOM
implementation). I'm writing a kind of XML editor where the user is able
to select and copy nodes from one document tree and paste is into
another. But when I try to add the copied nodes to the new document
tree, I receive the following exception:
org.apache.xerces.dom.DOMExceptionImpl: DOM005 Wrong document
I use some code like this:
targetDocument.appendChild(sourceDocumentNode.cloneNode(true));
How can I copy nodes from one document to another? Is there any solution
within the DOM or within Xerces?
Michael
Re: DOM Problems
Posted by Joe Sabu <Jo...@dothill.com>.
look at Document.importNode(Node importedNode, boolean deep) API
----- Original Message -----
From: "Michael Kraus" <mi...@informatik.uni-muenchen.de>
To: <ge...@xml.apache.org>
Sent: Wednesday, September 20, 2000 5:06 AM
Subject: DOM Problems
Hello,
I'm experiencing a problem with the DOM (I'm using the Xerces-J DOM
implementation). I'm writing a kind of XML editor where the user is able
to select and copy nodes from one document tree and paste is into
another. But when I try to add the copied nodes to the new document
tree, I receive the following exception:
org.apache.xerces.dom.DOMExceptionImpl: DOM005 Wrong document
I use some code like this:
targetDocument.appendChild(sourceDocumentNode.cloneNode(true));
How can I copy nodes from one document to another? Is there any solution
within the DOM or within Xerces?
Michael
---------------------------------------------------------------------
In case of troubles, e-mail: webmaster@xml.apache.org
To unsubscribe, e-mail: general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org
Re: DOM Problems
Posted by Charles Douthart <ch...@trifolium.com>.
Michael,
You must first import the node into the destination document. See the
docs for org.w3c.dom.Document
Node importedNode = targetDocument.importNode(sourceDocumentNode,true);
targetDocument.appendChild(importedNode);
-charles douthart-
Michael Kraus wrote:
>
> Hello,
>
> I'm experiencing a problem with the DOM (I'm using the Xerces-J DOM
> implementation). I'm writing a kind of XML editor where the user is able
> to select and copy nodes from one document tree and paste is into
> another. But when I try to add the copied nodes to the new document
> tree, I receive the following exception:
>
> org.apache.xerces.dom.DOMExceptionImpl: DOM005 Wrong document
>
> I use some code like this:
>
> targetDocument.appendChild(sourceDocumentNode.cloneNode(true));
>
> How can I copy nodes from one document to another? Is there any solution
> within the DOM or within Xerces?
>
> Michael
>
> ---------------------------------------------------------------------
> In case of troubles, e-mail: webmaster@xml.apache.org
> To unsubscribe, e-mail: general-unsubscribe@xml.apache.org
> For additional commands, e-mail: general-help@xml.apache.org
--
----------------------------------------
Charles Douthart
Trifolium, Inc
(919)854-4920 x264
charles.douthart@trifolium.com