 |
 |
 |
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>
|
 | 

|  |
These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.
|  |
| |
 |
 |
 |