Re: [xsl] How Can I Reference previous XML in Subsequent Iterations?

Subject: Re: [xsl] How Can I Reference previous XML in Subsequent Iterations?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 18 Apr 2007 17:02:03 +0100
something like this:

<xsl:stylesheet version="1.0"
  xmlns:s="urn:schemas-microsoft-com:office:spreadsheet"
  xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  
<xsl:output method="html"/>
<xsl:key name="s" match="s:Style" use="@ss:ID"/>
<xsl:template match="s:Workbook">
  <xsl:apply-templates select="s:Worksheet"/>
</xsl:template>
<xsl:template match="s:Worksheet">
  <table>
  <xsl:apply-templates select="s:Row"/>
  </table>
</xsl:template>
<xsl:template match="s:Row">
  <tr>
  <xsl:apply-templates select="s:Cell"/>
  </tr>
</xsl:template>
<xsl:template match="s:Cell">
  <td>
  <xsl:apply-templates select="key('s',@ss:StyleID)|s:Data"/>
  </td>
</xsl:template>
<xsl:template match="s:Data[starts-with(.,'http://')]">
  <a href="{.}"><xsl:value-of select="."/></a>
</xsl:template>
<xsl:template match="s:Style">
  <xsl:attribute name="style">
    <xsl:apply-templates select="*"/>
  </xsl:attribute>
</xsl:template>
<xsl:template match="s:Alignment[@ss:Vertical]">vertical-align: <xsl:value-of select="translate(@ss:Vertical,'TBM','tbm')"/>; </xsl:template>
<xsl:template match="s:Font">
  <xsl:apply-templates select="@ss:*"/>
</xsl:template>
<xsl:template match="@ss:FontName">font-family: <xsl:value-of select="."/>; </xsl:template>
<xsl:template match="@ss:Color">color: <xsl:value-of select="."/>; </xsl:template>
</xsl:stylesheet>



$ saxon wb.xml wb.xsl
<table xmlns:s="urn:schemas-microsoft-com:office:spreadsheet" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
   <tr>
      <td style="vertical-align: bottom; font-family: Verdana; ">Some  
         String
      </td>
      <td style="vertical-align: bottom; font-family: Verdana; ">Some  
         String 2
      </td>
      <td style="font-family: Verdana; color: #0000D4; Single"><a href="http://example.com";>http://example.com</a></td>
   </tr>
</table>


David

Current Thread