Re: Running totals

Subject: Re: Running totals
From: Steve Tinney <stinney@xxxxxxxxxxxxx>
Date: Tue, 28 Dec 1999 11:44:28 -0500
The likely way to do this, then, is to move whatever processing
you are doing into a tail-recursive function, and pass the running
total in each time as a parameter:

  <xsl:template name="do-whatever">
  <xsl:param name="running-total" select="0"/>
  [do-whatever-processing]
  <xsl:if test="[some-do-i-go-again-test]">
    <xsl:call-template name="do-whatever">
    <xsl:with-param name="running-total"
select="$running-total+@value"/>
    </xsl:call-template>
  </xsl:if>
  </xsl:template>

 Steve

Jon Smirl wrote:
> 
> Computing the sum of the preceding elements on each line for 2000 rows takes
> 2000 * (2000/2) = 2 million operations. If I can figure out a way to carry
> the total along I can do it in 2,000 operations.
> 
> I can always write an extension function to do this but I was trying to do
> it with pure XSL.
> 
> Jon Smirl
> jonsmirl@xxxxxxxxxxxx
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

-- 
----------------------------------------------------------------------
Steve Tinney                                        Babylonian Section
                                 *   University of Pennsylvania Museum
stinney@xxxxxxxxxxxxx                          Phila, PA. 215-898-4047


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


Current Thread