[xsl] find the sum over distinct nodes

Subject: [xsl] find the sum over distinct nodes
From: Osman Çınar Eren <Cinar.Eren@xxxxxxxxxxxxx>
Date: Thu, 18 Nov 2004 10:42:45 +0200
Hi,

I have such an XML nodeset:

<A>
        <B>
            <key>aa</key>
            <value>
                <v1>aa</v1>
                <v2>110</v2>
            </value>
        </B>
        <B>
            <key>bb</key>
            <value>
                <v1>bb</v1>
                <v2>10</v2>
            </value>
        </B>
        <B>
            <key>cc</key>
            <value>
                <v1>cc</v1>
                <v2>60</v2>
            </value>
        </B>
</A>

<A>
       <B>
            <key>bb</key>
            <value>
                <v1>bb</v1>
                <v2>40</v2>
            </value>
        </B>
        <B>
            <key>cc</key>
            <value>
                <v1>cc</v1>
                <v2>200</v2>
            </value>
        </B>
</A>

<A>
        <B>
            <key>dd</key>
            <value>
                <v1>dd</v1>
                <v2>60</v2>
            </value>
        </B>
</A>

what i try to do is to have the sum values over 'v2' values for distinct B
nodes.(distinct means for different key values.)
i would like to have such an XSL part:

<xsl:for-each select="$ZZZ[generate-id(.)]/???">
  <xsl:variable name="miktar" select="sum(v2)"/>
  <fo:table-row>
   <fo:table-cell>
      <fo:block text-align="left" font-size="8pt" >
           <xsl:value-of select='format-number($miktar, "###,###.00")'/>
      </fo:block>
   </fo:table-cell>
  </fo:table-row>

where $ZZZ is the nodeset which contrains the elements given above.

thanks in advance.
best regards..

Current Thread