|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] tail recursion and NaN
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() > 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>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








