[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
At 02:45 PM 5/9/2002, you wrote:
I assume you mean "value" instead of "measure" above. Try this:
...
You can further enhance it by making the pattern '##' an argument or using modes instead of call-template. HTH!
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Re: [xsl] Calculating a sum of rounded numbers
Subject: Re: [xsl] Calculating a sum of rounded numbers From: Greg Faron <gfaron@xxxxxxxxxxxxxxxxxx> Date: Thu, 09 May 2002 15:45:00 -0600 |
At 02:45 PM 5/9/2002, you wrote:
I tried <xsl:value-of select="format-number(sum(format-number(//measure),'##')" />
I assume you mean "value" instead of "measure" above. Try this:
<xsl:variable name="mysum"> <xsl:call-template name="sum-rounded-values"> <xsl:with-param name="value" select="//value" /> </xsl:call-template> </xsl:variable> <xsl:value-of select="format-number($mysum)" />
...
<xsl:template name="sum-rounded-values"> <xsl:param name="value" /> <xsl:param name="_sum" select="0" /> <xsl:choose> <xsl:when test="value"> <xsl:call-template name="sum-rounded-values"> <xsl:with-param name="value" select="$value[position() > 1]" /> <xsl:with-param name="_sum" select="$_sum + format-number($value[1], '##')" /> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$_sum" /> </xsl:otherwise> </xsl:choose> </xsl:template>
You can further enhance it by making the pattern '##' an argument or using modes instead of call-template. HTH!
Greg Faron Integre Technical Publishing Co.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Calculating a sum of roun, Michael Kay | Thread | RE: [xsl] Calculating a sum of roun, Nik Krimm |
Re: [xsl] Dealing with footnotes, Wendell Piez | Date | Re: [xsl] passing intermediate resu, paul morgan |
Month |