Subject: [xsl] Merge two XML files From: "Kim Tran" <tav1210@xxxxxxxxxxx> Date: Tue, 29 Apr 2003 18:01:48 -0700 |
<Document> <row> <column name="FirstName">Smith</column> <column name="LastName">John</column> <column name="Address">7777 First </column> </row> <row> <column name="FirstName">Smith2</column> <column name="LastName">John2</column> <column name="Address">7777 Second </column> </row> ... </Document>
XML2.xml <Document> <row> <column name="FirstName">Smith</column> <column name="LastName">John</column> <column name="Age">36</column> </row> <row> <column name="FirstName">Smith2</column> <column name="LastName">John2</column> <column name="Age">40</column> </row> ... </Document>
The result XML should be: <Document> <row> <column name="FirstName">Smith</column> <column name="LastName">John</column> <column name="Address">7777 First </column> <column name="Age">36</column> </row> <row> <column name="FirstName">Smith2</column> <column name="LastName">John2</column> <column name="Address">7777 Second </column> <column name="Age">40</column> </row> ... </Document>
<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xalan="http://xml.apache.org/xalan">
<xsl:template match="/"> <!--document element--> <Document> <xsl:for-each select="Document/row"> <xsl:copy-of select="."/> <xsl:variable name="name" select="column[@name='FirstName']"/> <xsl:for-each select="document($source)/Document/row"> <xsl:apply-templates select="key('row', $name)"/> </xsl:for-each> --> </xsl:for-each> </Document> </xsl:template>
<xsl:template match="row"> <xsl:copy-of select="."/> </xsl:template>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] find previous node at the, Jarno . Elovirta | Thread | Re: [xsl] Merge two XML files, Rob Rohan |
[xsl] find previous node at the sam, Mark Ivs | Date | Re: [xsl] Merge two XML files, Rob Rohan |
Month |