This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: sum of products
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] sum of products
- From: "Zwetselaar M. van (Marco)" <Marco dot van dot Zwetselaar at nl dot fortis dot com>
- Date: Wed, 10 Oct 2001 16:04:49 +0200
- Reply-To: xsl-list at lists dot mulberrytech dot com
Steve,
> Is there another method that does not use node-set?
You could use this recursive template:
<xsl:template name="prod-sum">
<xsl:param name="sum">0</xsl:param>
<xsl:param name="nodes" />
<xsl:choose>
<xsl:when test="$nodes">
<xsl:call-template name="prod-sum">
<xsl:with-param name="sum"
select="$sum + number($nodes[1]/a) * number($nodes[1]/b)" />
<xsl:with-param name="nodes" select="$nodes[position()!=1]" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$sum" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Regards,
Marco
***************************DISCLAIMER***********************************
Deze e-mail is uitsluitend bestemd voor de geadresseerde(n).
Verstrekking aan en gebruik door anderen is niet toegestaan.
Fortis sluit iedere aansprakelijkheid uit die voortvloeit uit
electronische verzending.
This e-mail is intended exclusively for the addressee(s), and may
not be passed on to, or made available for use by any person
other than the addressee(s).
Fortis rules out any and every liability resulting from any
electronic transmission.
************************************************************************
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list