Subject: [xsl] tail recursion and NaN From: "Susan Campbell" <SCampbell@xxxxxxxxxxxxxx> Date: Mon, 3 May 2004 12:15:47 -0400 |
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>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: Re: [xsl] how to split one xml , Michael Kay | Thread | RE: [xsl] tail recursion and NaN, Jarno.Elovirta |
RE: Re: [xsl] how to split one xml , Michael Kay | Date | RE: Re: [xsl] how to split one xml , Qin Ding |
Month |