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

RE: tail recursion and NaN

Subject: RE: tail recursion and NaN
From: "Susan Campbell" <SCampbell@xxxxxxxxxxxxxx>
Date: Fri, 7 May 2004 08:59:19 -0400
susan campbell
Thanks for the help.  I later learned I also had to test for a dollar sign as well as empty cells.  This is what I'm using.  It works, but there may be a more compact/elegant way to do it.
sc

<xsl:template name="total-value">
   <xsl:param name="price"/>
 	 <xsl:param name="result" select="0"/>
 	 <xsl:param name="nodollarsign" select="translate($price,'$','')"/>
	   <xsl:choose>
		<xsl:when test="$price and number($price) = number($price)">			
			 <xsl:call-template name="total-value">
  			<xsl:with-param name="price" select="$price[position() &gt; 1]"/>
  			<xsl:with-param name="result" select="$result + $price"/>
  			</xsl:call-template>
  		</xsl:when>
		<xsl:when test="$nodollarsign">			
			<xsl:call-template name="total-value">
  			<xsl:with-param name="price" select="$price[position() &gt; 1]"/>
  			<xsl:with-param name="result" select="$result + $nodollarsign"/>
  		            </xsl:call-template>
  	           </xsl:when>				
  		<xsl:when test="$price and number($price) != number($price)">			
			<xsl:call-template name="total-value">
  			<xsl:with-param name="price" select="$price[position() &gt; 1]"/>
  			<xsl:with-param name="result" select="$result"/>
  			</xsl:call-template>
  		</xsl:when>
		<xsl:otherwise><xsl:value-of select="$result"/></xsl:otherwise>
	 </xsl:choose>
</xsl:template>

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.