Re: [xsl] Calculating cumulative values - another call for help

Subject: Re: [xsl] Calculating cumulative values - another call for help
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Thu, 30 Aug 2007 21:36:37 +0200
Andrew Welch wrote:
On 8/30/07, Simon Shutter <simon@xxxxxxxxxxx> wrote:
Sorry - I should have been more clear. Could one use something like
count(ancestor::set) instead?

Probably not the thing to use... but its hard to suggest what to do instead just from that sentence....

Just changing "n" to "3" is enough to make it work with your sample
input - if you're suggesting that set/@id isn't like it is in your
sample and you're having problems adapting the transform to work with
your actual input then post a more representative sample.

Just in case it is still of interest: in my solution, I walk the tree keeping a (kind of) hash any @x that is passed by. Meaning, it will work with any @x, and it does not matter whether these @x are numbers, strings, empty, in order or no order. It just counts the matching @x together.


When there are very many @x, you may want to optimize the distinct-values([original-list], [new-x]), because that may yield some extra performance penalty when it rolls into the 10000s different @x's.

In retrospective, do note that my solution will obviously be much harder to maintain than the concise version using sum(...) from Andrew. Though you can hide the complexity by putting a lot into custom user defined special home grown own breed xslt functions.

Cheers,
-- Abel Braaksma

Current Thread