| Subject: RE: Multiply Element Values From: Kay Michael <Michael.Kay@xxxxxxx> Date: Tue, 18 Apr 2000 09:57:59 +0100 | 
> Task Breakdown:
> -------------
>   * need to multiply qty and price
>   * for each item in the table
>   * display the result in the table
>   * output of each line multiplied needs to be a number
>   * add all costs to get a total
> 
3 approaches:
1 - do the output of the table and the totalling as two separate operations.
The output is straightforward; for the totalling use a recursive template,
with the following pseudo-code:
template name="process-items"
  param item-list
  if $item-list <!-- is not empty -->
    var first = item-list[1]
    var total-of-rest
       call-template process-items with-param item-list[position()!=1]
    /var
    value-of $first/qty * $first/price + $total-of-rest
/template
2 - use the node-set() extension function (in Saxon and xt): create a result
tree fragment that contains the product of qty and price, convert this to a
node-set, and use the sum() function to get the total.
3 - risk being ostracised by the entire XSL community by using saxon:assign
which allows you to update variables.
Mike Kay
 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
| Current Thread | 
|---|
| 
 | 
| <- Previous | Index | Next -> | 
|---|---|---|
| Multiply Element Values, Rhonda Fischer | Thread | RE: Saxon 5.3, Kay Michael | 
| RE: position() problem with // axis, Kay Michael | Date | Re: position() problem with // axis, David Carlisle | 
| Month |