I'll try... Here is a function that, once converted to the form shown here (from an easier-to-read version that unfortunately composed the recursive call as part of a sequence), saved an enormous amount of memory for our application:

    <xsl:function name="util:cumulative-list" as="xs:double*">
        <xsl:param name="sum0" as="xs:double"/>
        <xsl:param name="list" as="xs:double*"/>
        <xsl:sequence select="util:cumulative-list-2((), $list)"/>
    </xsl:function>
   
    <xsl:function name="util:cumulative-list-2" as="xs:double*">
        <xsl:param name="list" as="xs:double*"/>
        <xsl:param name="list-remainder" as="xs:double*"/>
        <xsl:choose>
            <xsl:when test="not(exists($list-remainder))">
                <xsl:sequence select="$list"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:sequence select="util:cumulative-list-2(
                    if (empty($list)) then
                        (0, $list-remainder[1])
                    else
                        ($list, $list[last()] + $list-remainder[1]),
                        remove($list-remainder, 1)
                )"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:function>   

Here is how it is called:

        <xsl:variable name="e-cumulative-list" select="util:cumulative-list(0, $sorted-event-list/event/@e)"/>


Cary Millsap
http://method-r.com
http://carymillsap.blogspot.com


On Mon, Feb 23, 2009 at 10:25 AM, Dave Pawson <dave.pawson@gmail.com> wrote:
2009/2/23 Michael Kay <mike@saxonica.com>:
> The maximum recursion depth basically depends on the amount of stack space
> available in the Java VM, which is difficult to change.
>
> You need to look at whether there is a way of coding this that takes
> advantage of tail recursion, to avoid consuming stack space.
>
> Michael Kay
> http://www.saxonica.com/


As an example of 'working' XSLT for efficiency using tail recursion
that would be a great example
for the FAQ Michael/anyone?


regards



--
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
http://www.dpawson.co.uk

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/saxon-help