Mr. Sneekes,
No your interpretation about [#document: null] and dom.toString() is not exactly correct.
The implementation of toString is as follows:
public String toString() { return "["+getNodeName()+": "+getNodeValue()+"]"; }
According to the DOM1 specification the following are the name and value for a DOM Document:
name = #document value = null
Therefore this is not a bug.
Going back to your original request this is what I had in mind:
Node nodeClonedFromAnotherDocument;
nodeClonedFromAnotherDocument = parsedDom.importNode(theRealElement, true); // This copies theRealElement from another document into parsedDOM
parsedDom.replaceChild( nodeClonedFromAnotherDocument, theElement);// replace theElement with nodeClonedFromAnotherDocument
You can pass your document to the dom.DOMWriter printer method to traverse the dom and print out your document this would show your "theElement" node replaced by the nodeClonedFromAnotherDocument.
Thanks,
Jeffrey Rodriguez XML Development IBM Cupertino
From: "Peet Sneekes" <[EMAIL PROTECTED]> Reply-To: "Peet Sneekes" <[EMAIL PROTECTED]> To: "Jeffrey Rodriguez" <[EMAIL PROTECTED]> CC: "Xerces Mailgroup" <[EMAIL PROTECTED]> Subject: Re: replaceChild Date: Wed, 15 Mar 2000 17:45:20 +0100
Hi Jeffrey,
I thought this would work, but both (parent) Documents seems to be [#document: null] if I do Document dom.toString(). And if I look in the Xerces 1.0.2 code this check is made before replaceChild() can be done. Is this a bug of the Xerces DomParser?
What to do?
Cheers,
Peet
New code: parsedDom.importNode(theRealElement, true); parsedDom.replaceChild(theElement, theElement);
----- Original Message ----- From: "Jeffrey Rodriguez" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, March 15, 2000 12:47 PM Subject: Re: replaceChild
> Mr. Sneekes, I think that the way to do this is by using
> the org.w3c.dom.Document public importNode method.
>
> Node importNode(Node importedNode,
> boolean deep)
> throws DOMException;
>
> Thanks,
> Jeffrey Rodriguez
> XML4J Development
> IBM Cupertino
>
>
>
>
> >From: "Peet Sneekes" <[EMAIL PROTECTED]>
> >Reply-To: "Peet Sneekes" <[EMAIL PROTECTED]>
> >To: "Xerces Mailgroup" <[EMAIL PROTECTED]>
> >Subject: replaceChild
> >Date: Wed, 15 Mar 2000 12:31:07 +0100
> >
> >Hi,
> >
> >I want to replace an Element of a Document with another Element from
> >another
> >Document.
> >So I first clone the new Element and than I do replaceChild() (see sample
> >code).
> >
> >Still it gives the "DOM005 Wrong document" error.
> >
> >Any suggestions? Thanks!
> >
> >Peet Sneekes,
> >Mediamatic IP,
> >Amsterdam
> ><< sampleCode.java >>
>
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com
>
______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com