[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Calculating cumulative values - another call for h

Subject: Re: Calculating cumulative values - another call for help
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Wed, 29 Aug 2007 09:40:00 +0100
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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.