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

  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!--    Category:     Variables
  3.     Sample from Zvon XSLT tutorial (www.zvon.org)  
  4.     Description:    Parameters for a template can be passed with xsl:with-param element. 
  5.        If the template contains a xsl:param element with the same name as name attribute 
  6.        of xsl:with-param, this value is used. -->
  7. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  8.     <xsl:template match="/">
  9.         <TABLE>
  10.             <xsl:for-each select="//number">
  11.                 <TR>
  12.                     <TH>
  13.                         <xsl:choose>
  14.                             <xsl:when test="text() mod 2">
  15.                                 <xsl:apply-templates select=".">
  16.                                     <xsl:with-param name="type">odd</xsl:with-param>
  17.                                 </xsl:apply-templates>
  18.                             </xsl:when>
  19.                             <xsl:otherwise>
  20.                                 <xsl:apply-templates select="."/>
  21.                             </xsl:otherwise>
  22.                         </xsl:choose>
  23.                     </TH>
  24.                 </TR>
  25.             </xsl:for-each>
  26.         </TABLE>
  27.     </xsl:template>
  28.     <xsl:template match="number">
  29.         <xsl:param name="type">even</xsl:param>
  30.         <xsl:value-of select="."/>
  31.         <xsl:text> (</xsl:text>
  32.         <xsl:value-of select="$type"/>
  33.         <xsl:text>)</xsl:text>
  34.     </xsl:template>
  35. </xsl:stylesheet>
  36.