home *** CD-ROM | disk | FTP | other *** search
/ MacFormat UK 160 - Disc 2 / MF_UK_160_2.iso / pc / DiscContent / Trials / oxygen / samples / debugger / Variables / sample3.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2005-07-21  |  1.3 KB  |  30 lines

  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!--    Category:     Variables
  3.     Sample from Zvon XSLT tutorial (www.zvon.org)  
  4.     Description:    A stylesheet can contain several variables of the same name. -->
  5. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  6.     <xsl:variable name="text">Chapter</xsl:variable>
  7.     <xsl:template match="/">
  8.         <TABLE>
  9.             <xsl:for-each select="//chapter">
  10.                 <TR>
  11.                     <TD>
  12.                         <xsl:variable name="text">
  13.                             <xsl:choose>
  14.                                 <xsl:when test="position() = 1">First chapter</xsl:when>
  15.                                 <xsl:when test="position()=last()">Last chapter</xsl:when>
  16.                                 <xsl:otherwise>
  17.                                     <xsl:value-of select="$text"/>
  18.                                 </xsl:otherwise>
  19.                             </xsl:choose>
  20.                         </xsl:variable>
  21.                         <xsl:value-of select="$text"/>
  22.                         <xsl:text> : </xsl:text>
  23.                         <xsl:value-of select="."/>
  24.                     </TD>
  25.                 </TR>
  26.             </xsl:for-each>
  27.         </TABLE>
  28.     </xsl:template>
  29. </xsl:stylesheet>
  30.