[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: result = node1 * node2 and then get total of all t
> Hello everybody,I am new to this forum and new to xslt as > well.I have been > stuck with this problem for several days. > what I want to do is,to go through an xml file multiply rate > with value at > each level and print the product. It's a familiar problem... In XPath 2.0 the answer is sum(for $r in //rate return $r/@value * $r/@quantity) That will work in Saxon 7.0; but with any other processor you'll need at XSLT 1.0 solution. Which basically means writing a recursive named template. This should be called with a parameter that's a set of nodes; it should compute @value*@quantity for the first node, and add the result to the total for the remaining nodes, obtained by means of a recursive call. An alternative solution is to construct a temporary tree (result tree fragment) containing the computed values of @value*@quantity, and then use the sum() function over the nodes in this RTF, which you will need to process using the xx:node-set() extension function provided by your favourite XSLT processor. 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
|