[xsl] Re: Re: Grouping problem?

Subject: [xsl] Re: Re: Grouping problem?
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Wed, 23 Apr 2003 07:00:39 +0200
"Conal Tuohy" <conalt@xxxxxxxxxxxxxxx> wrote in message
> Hi Lars. I think you're right about the correct definition of the problem.
> So I still didn't have my conditions right.
> Here's my 3rd version of the recursive solution, which now produces the
> output as Benjamin's.
> I would guess that this recursive solution would be quicker (for documents
> larger than a certain size), but on the other hand perhaps it could
> stack-overflow problems on really large documents? As I understand it,
> tail-recursion is supposed to allow the XSLT interpreter to optimise the
> recursion by converting to it a loop, without pushing stack frames ... but
> don't know how many processors actually implement this? Does anyone know?
> my code below appropriate for this kind of optimisation?
> 4
> http://info.astrian.net/jargon/terms/t/tail_recursion.html :-)

You can use a DVC (Divide and Conquer) style algorithm here. Split a
node-set into two and recursively solve the problem on them.

Your recursive template must accept some initial accumulated number as a
parameter -- the sum of the last group of elements of the first half will be
passed as this initial accumulation to the template invocation that
processes the second half.

The recursion depth of a DVC algorithm is only log2(N).



Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread