[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Calculating cumulative values - another call for h
On 8/29/07, Simon Shutter <simon@xxxxxxxxxxx> wrote: > Dear Experts, > > I've been aggregating numbers in XSLT 1.0 using the preceding-sibling:: axis > for nodes with the same parent. I now need to aggregate all the values that > precede the context node, even if they have different parents. For this I > added another attribute using the preceding:: axis (see XSLT 1.0 Stylesheet > below). Unfortunately, the transform is starting to groan under the weight > of all these O(n^2) operations. I have revisited an earlier solution > suggested by Dimitre Novatchev (see XSLT 2.0 Stylesheet below) that uses > FXSL. However, I'm not clear how I can adapt it to meet the new > requirements. Specifically, I would like to: > > a) generate attribute y3 that is a cumulative value based on all preceding > <point> elements > b) copy y1 from the input to the output - If you can use XSLT 2.0 then just do it in two passes - If you are stuck with 1.0 without the node-set extension then you could optimize it a little by processing <point> elements along the following-sibling axis passing the running total as you go (but that would require @x to have a limited number of possible values) - If you are using 1.0 + node-set extension then again just do two passes to avoid O(n^2) cheers andrew -- http://andrewjwelch.com
|
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
|