Re: [xsl] Generating XML fragment to DOM node using XSL

Subject: Re: [xsl] Generating XML fragment to DOM node using XSL
From: Stan Devitt <jsdevitt@xxxxxxxxxxxxxx>
Date: Tue, 16 Dec 2003 18:50:29 -0500

Precisely. As a specific example, the following code fragment would append the
second document as the last node of the root element of the first document. (The step that is easy to miss here is the importNode.)
...
Element root = doc1.getDocumentElement(); Element root2 = doc2.getDocumentElement();
Element copy2 = (Element) doc1.importNode( root2 , true );
root.appendChild(copy2);


While it is also easy to apply an XSLT transform  directly to doc1
to transform doc1 into a new "Document" you would still need some
way of having XSLT's document( ) (or similar function)
refer to the already parsed document,  doc2.  So far the only suggestion for
how to do this has been to serialize and save doc2.

Stan Devitt


cknell@xxxxxxxxxx wrote:


[...]
It seems to me that what you are really after is DOM programming. You want to get a set of nodes from one document and append them to some element in a second document. For DOM programming, you may want to look at:
http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/java-binding.html
and
http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html





XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread