|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Calculating a sum of rounded numbers
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!
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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








