Re: Funky Summation

Subject: Re: Funky Summation
From: Paul Tchistopolskii <paul@xxxxxxx>
Date: Sat, 16 Sep 2000 00:23:34 -0700
----- Original Message ----- 
From: Alexey Gokhberg <alexei@xxxxxxxxxx>

> 
> AND A BIT MORE GENERAL QUESTION:
> 
> Is it possible to implement running counters in pure 100% XSLT, without
> using proprietary extensions?

There is no updateable variables in XSLT.

But there is general pattern for 'counter' :

template accumulator ( list ) {

    $first element = take first element of the list ( position() = 1 )
    $rest list = take the rest of the list ( position() > 1 )

    $total-of-rest  =  {
            if ( $rest ) { 
                 call accumulator(  $rest )
            } else {
                <!-- nothing. End of loop. -->
            }
    }

    <xsl:value-of select = " $first + $total-of-rest " />
}


Invokation: 

template( list-to-process )

>From my point of view, the answer is : 

"Yes, it is always possible to implement running counters 
in pure 100% XSLT"

Rgds.Paul.

PS. I wish I understand the question.



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


Current Thread