[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Multiply Element Values
> 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|