[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Generating serial no.s for XML tags

Subject: Re: Generating serial no.s for XML tags
From: "Marcus Andersson" <marcan@xxxxxxx>
Date: Mon, 28 Apr 2003 13:04:54 +0200
dotag download video
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) &gt; 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) &gt; 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.