xsl-list
[Top] [All Lists]

RE: a*b, sum(c*d), sorted on <sort>

2002-12-04 09:30:18

I would use a use a temporay tree containing a sorted list of <item>
with the first part of the calculations complete, so you would have
something like:

<root>
  <item><a*b>20</a*b><sumCD>18</sumCD></item>
  <item><a*b>6</a*b><sumCD>40</sumCD></item>
  ....

Then produce your table by applying-templates to the temporary tree,
using sum() on the <sumCD> element to get the cumulative column.  

cheers
andrew 


Here is my XML:

<root>
 <item><a>1</a><b>2</b><c>2</c><d>7</d><sort>3</sort></item>
 <item><a>2</a><b>3</b><c>5</c><d>8</d><sort>2</sort></item>
 <item><a>3</a><b>4</b><c>1</c><d>2</d><sort>4</sort></item>
 <item><a>4</a><b>5</b><c>2</c><d>9</d><sort>1</sort></item>
</root>

For each <item> I need to produce a row containing
cells for a*b and cumulative c*d where the items
are taken sorted on <sort>:

 +-----+----------+
 | a*b | sum(c*d) |
 +-----+----------+
 |  20 |    18    |
 +-----+----------+
 |   6 |    58    |
 +-----+----------+
 |   2 |    72    |
 +-----+----------+
 |  12 |    74    |
 +-----+----------+

The above a gross simplification, but I would like to get input from
people on how they would structure the problem as it has a lot
more detail in reality. In a nutshell, I have both recursive and 
non-recursive calculations to perform in each row.



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




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



<Prev in Thread] Current Thread [Next in Thread>