Subject: RE: Merging two documents From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Mon, 13 Sep 1999 20:19:22 -0700 |
...I would be really interested in how this is implemented with examples!
On Behalf Of Terris Sent: Monday, September 13, 1999 6:24 PM To: xsl-list@xxxxxxxxxxxxxxxx Subject: Merging two documents
Can I use XSLT to do this?
I want to add part of an XML document to another XML document.
T:\ftemp>type doc1.xml <?xml version="1.0"?> <!DOCTYPE BookSet [ <!ATTLIST Book id ID #IMPLIED> ]> <BookSet> <Book id="1"><Name>The wizard of OZ</Name></Book> <Book id="2"><Name>Java Servlet Programming</Name></Book> <Book id="3"><Name>John Coltrane Rage</Name></Book> </BookSet>
T:\ftemp>type doc2.xml <BookList> <Book id="1"/> <Book id="2"/> </BookList>
T:\ftemp>type list.xsl <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">
<xsl:template match="/BookList"> <!--document element--> <BookList> <xsl:for-each select="Book"> <Book id="{@id}"> <xsl:variable name="id" select="string(@id)"/> <!--note you cannot use document($source)/id($id)--> <xsl:for-each select="document($source)"> <xsl:copy-of select="id($id)/*"/> </xsl:for-each> </Book> </xsl:for-each> </BookList> </xsl:template>
T:\ftemp>type result.xml <BookList> <Book id="1"> <Name>The wizard of OZ</Name> </Book> <Book id="2"> <Name>Java Servlet Programming</Name> </Book> </BookList>
-- G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995) Website: XSL/XML/DSSSL/SGML services, training, libraries, products. Practical Transformation Using XSLT and XPath ISBN 1-894049-01-2 Next instructor-led training: 1999-09-24, 1999-11-08, 1999-12-05/06, 1999-12-07, 2000-02-27/28, 2000-05-11/12
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: Merging two documents, Earl Bingham | Thread | Where is XT? (was: Re: Merging two, Terris |
RE: applying template in different , michael fischer | Date | Re: Help with modes in XSL, Miloslav Nic |
Month |