| Subject: Re: [xsl] Generating serial no.s for XML tags From: "Marcus Andersson" <marcan@xxxxxxx> Date: Mon, 28 Apr 2003 13:04:54 +0200 | 
A slightly modified version of the "doTag" template from the stylesheet I posted earlier is the one below. It's a bit shorter, a bit clearer and also performs a check at the beginning to assure that there really is a node to process.
/Marcus
<xsl:template name="doTag">
  <xsl:param name="nodes"/>
  <xsl:param name="currentValue"/>
  <xsl:if test="count($nodes) > 0">
    <xsl:value-of select="$currentValue + 1"/>
    <xsl:if test="$nodes[1]/total">
        <xsl:value-of select="$currentValue + 2"/>
    </xsl:if>
    <xsl:variable name="modifier">
      <xsl:choose>
        <xsl:when test="$nodes[1]/total">2</xsl:when>
        <xsl:otherwise>1</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:if test="count($nodes) > 1">
      <xsl:call-template name="doTag">
        <xsl:with-param name="nodes" select="$nodes[position() != 1]"/>
        <xsl:with-param name="currentValue" select="$currentValue + $modifier"/>
      </xsl:call-template>
    </xsl:if>    
  </xsl:if>
</xsl:template>
 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
| Current Thread | 
|---|
| 
 | 
| <- Previous | Index | Next -> | 
|---|---|---|
| Re: [xsl] Generating serial no.s fo, Marcus Andersson | Thread | [xsl] Vertical display, Sundar Shanmugasunda | 
| Re: [xsl] Get specific elements, Oleg Tkachenko | Date | RE: [xsl] Generating serial no.s fo, Jarno . Elovirta | 
| Month |