Did you take a look to saxon:iterate ?


On Thu, May 7, 2009 at 12:22 PM, David Carlisle <davidc@nag.co.uk> wrote:

I have a stylesheet that uses a sibling-recursion walk over a "tree"
but hits this "too many nested function calls" error on a real user
case, see for example:


Is it possible to increase this limit via the api, or avoid it using
some particular recursion idiom?

It seems to always bite at around a few hundred calls. The templates
don't hit a stack limit as (most of them) are tail recursive, looking

<xsl:template mode="d:html d:gxml" match="start">
<xsl:param name="s" select="()"/>
 <start name="{@name}" s="{$s}">
  <xsl:copy-of select="attrib"/>
 <xsl:apply-templates mode="#current"  select="following-sibling::node()[1]">
  <xsl:with-param  name="s" select="(string(@name),$s)"/>

but the recursion on following-sibling::node()[1] is killing the

The tree in question is gratuitously flat. A root node that just
contains a child sequence consisting of text nodes and empty element
nodes (or a single child node which is simply copied as above), so no
depth at all and template application just proceeds sideways. I can't
easily use for-each as I need to pass data from one call to another (the
stack of currently open elements, $s above)

I could send a test case if needed that just processes one of the
intermediate passes implemented in the htmlparse.xsl.


The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs.

The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
saxon-help mailing list archived at http://saxon.markmail.org/