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 St...@r2isante.fr on 2000/10/30 08:40:32 UTC
Réf. : Help, usage of Document::ImportNode
John, importing node in a document doesn't specify where they will be
positionned.
I think that you have to add this line just after importing your node
// Works without error
Node rNode = Doc1.importNode(root2, true);
-------> doc1.appendChild(rNode);
John Gentilin <jo...@eyecatching.com>@ca-ns1.eyecatching.com le
30/10/2000 05:46:10
Veuillez répondre à xerces-j-dev@xml.apache.org
Envoyé par : gentijo@ca-ns1.eyecatching.com
Pour : Xerces <xe...@xml.apache.org>
cc :
Objet : 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);
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org