xsl-list
[Top] [All Lists]

Re: [xsl] Recursively Merging 2 XML files with XSLT

2006-11-23 05:16:21


If your two files are ad1.xml and ad2.xml, and they really have the same
structure, then something like this:


<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:variable name="a" select="document('ad1.xml')//data"/>
<xsl:variable name="b" select="document('ad2.xml')//data"/>

<xsl:template match="/">
  <html>
    <head>
    </head>
    <body>
      <table>
        <xsl:for-each select="$a">
          <xsl:variable name="p" select="position()"/>
          <tr>
            <td><xsl:value-of select="@val"/></td>
            <td><xsl:value-of select="$b[$p]/@val"/></td>
          </tr>
        </xsl:for-each>
      </table>
    </body>
  </html>
</xsl:template>

</xsl:stylesheet>



$ saxon ad.xsl ad.xsl
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   </head>
   <body>
      <table>
         <tr>
            <td>xx</td>
            <td>xx</td>
         </tr>
         <tr>
            <td>yy</td>
            <td>yy2</td>
         </tr>
         <tr>
            <td>ss</td>
            <td>ss</td>
         </tr>
         <tr>
            <td>gg</td>
            <td>gg2</td>
         </tr>
      </table>
   </body>
</html>

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>