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

tail recursion and NaN

Subject: tail recursion and NaN
From: "Susan Campbell" <SCampbell@xxxxxxxxxxxxxx>
Date: Mon, 3 May 2004 12:15:47 -0400
susan campbell
Greetings,
I was using a simple recursion I found on this list and I testing for values that were NaN.  Everything was fine. But I began working with larger files and found that simple recursion would not handle the larger files.  I found an article about tail recursion and switched to that.  The files now get processed, but I do not know where to put the test for empty nodes.

Thank you for any help you can give me.
Susan Campbell


<!--this passes the price and gets the value for output-->
<xsl:variable name="sum">
        <xsl:call-template name="total-value">
              <xsl:with-param name="price"
                		select="//z30-price"/>
        </xsl:call-template>
</xsl:variable>



<!--This is the template with recursion to add the prices, needs test for NaN-->
<xsl:template name="total-value">
   <xsl:param name="price"/>
   <xsl:param name="result" select="0"/>
	   <xsl:choose>
	     <xsl:when test="$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:otherwise><xsl:value-of select="$result"/></xsl:otherwise>
             </xsl:choose>

</xsl:template>



<xsl:template name="section-01">
	<xsl:call-template name="table-open"/>
    	<xsl:call-template name="display-gen">
		<!--Here's where the total is used-->
		 <xsl:with-param name="width" select="'70'"/>
		 <xsl:with-param name="label" select="'Prices total:'"/>
		 <xsl:with-param name="value" select="format-number(sum($sum),'$###,###.##')"/>
	</xsl:call-template>
	 <xsl:call-template name="display-gen">
		<!--Here's where the count is used-->
		<xsl:with-param name="width" select="'70'"/>
		<xsl:with-param name="label" select="'No. of items:'"/>
		<xsl:with-param name="value" select="format-number(count(//z30-doc-number), '###,###,###')"/>
	 </xsl:call-template>
          <xsl:call-template name="table-close"/>
</xsl:template>

  </xsl:template>
</xsl:stylesheet>

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.