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

[xsl] sum of products


Subject: [xsl] sum of products
From: "Steve Renshaw" <renshaw_steve@xxxxxxxxxxx>
Date: Wed, 10 Oct 2001 09:50:09 +0000

How do you write the xpath to calculate the sum or a*b for the
following xml limiting <data> items to those with a value of
say id="2". For the following xml:

<items>
<item>
 <data id="1"><a> 1</a><b> 2</b><c> 3</c></data>
 <data id="2"><a> 4</a><b> 5</b><c> 6</c></data>
 <data id="3"><a> 7</a><b> 8</b><c> 9</c></data>
</item>
<item>
 <data id="1"><a> 2</a><b> 3</b><c> 4</c></data>
 <data id="2"><a> 5</a><b> 6</b><c> 7</c></data>
 <data id="3"><a> 8</a><b> 9</b><c>10</c></data>
</item>
<item>
 <data id="1"><a> 3</a><b> 4</b><c> 5</c></data>
 <data id="2"><a> 6</a><b> 7</b><c> 8</c></data>
 <data id="3"><a> 9</a><b>10</b><c>11</c></data>
</item>
</items>

The sum I need calculated is:

        1st   2nd   3rd
        item  item  item
  Sum = 4*5 + 5*6 + 6*7


_________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list




Current Thread
Keywords