AW: DOM005 Wrong Document Error during transformation 2003-01-30 - By Stefan.Kaesberg@(protected)
Hi, the 2 Documents are just linked to a third (new) one. You still have 2 Documents. Use importNode to "copy" the 2 Documents into the new one:
just appending the elements is not enough, try to use:
Node n1 = doc1.getDocumentElement(); document.importNode(n1,true); rootNode.appendChild(n1);
Node n2 = doc2.getDocumentElement(); document.importNode(n2,true); rootNode.appendChild(n2);
Hope that helps, Stefan
>Hi All,
>In my project, I am merging 2 W3C Documents and getting a single W3C Dcoument and then doing >transformation on the merged document. Sometimes I am getting javax.xml.transform.TransformerException: >org.w3c.dom.DOMException: DOM005 Wrong document > >The code is shown below. >//merging documents >public Document merge(String mergeName, Document doc1, Document doc2) >{ >Document document = new org.apache.xerces.dom.DocumentImpl(); >Element rootNode = document.createElement(mergeName); >rootNode.appendChild(doc1.getDocumentElement()); >rootNode.appendChild(doc2.getDocumentElement()); >document.appendChild(rootNode); >return document; >}
|
|