You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by John Gentilin <jo...@eyecatching.com> on 2000/10/30 05:46:10 UTC
Help, usage of Document::ImportNode
I am trying to use the importNode function on the Document object to
overlay one document on top of another one, effectively a merge. It all
seems to run find, except that the imported document is not apparent
when I serialize the destination document. I included my example code.
The importNode works without an exception and its return value behaves
as I would expect it. (I get different results when changing the value
of deep).
I even tried to import Doc2 into a new Document, same problem.
Am I missing something here ??
What is the intended use of this method ??
TIA
John G
Document Doc1 = parseDoc( file1 );
Document Doc2 = parseDoc( file2 );
System.out.println("Start of Document 1");
serializeDocument(Doc1);
System.out.println("Start of Document 2");
serializeDocument(Doc2);
// Test Code
// Doc1 = getNewDocument():
Element root1 = Doc1.getDocumentElement();
Element root2 = Doc2.getDocumentElement();
// Works without error
Node rNode = Doc1.importNode(root2, true);
System.out.println("Start of Output");
// Only has the original content of Doc1, not the result of the
merge
serializeDocument(Doc1);
System.out.println("Start of importNode Return Value");
// contains what I would expect, if on import deep == false then
only the top
// level node, if its true then the whole contents of Doc2
serializeDocument(rNode);