[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] sum of products


Subject: RE: [xsl] sum of products
From: "Zwetselaar M. van (Marco)" <Marco.van.Zwetselaar@xxxxxxxxxxxxx>
Date: Wed, 10 Oct 2001 16:04:49 +0200

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



Current Thread