I shouldn't pursue a saxon:assign solution. It's getting
more and more difficult to keep this instruction working as the optimizer gets
cleverer, and at some stage I will almost certainly give up the
This "too many nested calls" message is really just a
polite way of reporting a StackOverflowError: it means that something is
recursing too deeply (and that tail call optimization isn't dealing
with it). Do you know how deep the recursion is?
If you can't make the recursive call
tail-recursive, then the usual remedy is to try to find a way of doing it
using divide-and-conquer recursion rather than head-tail recursion. I'd need to
see the code to advise.
One thing that prevents tail-call optimization kicking in
is dynamic type checking of template results. From previous specimens of your
code, I think you're using "as" attributes on xsl:template quite extensively. It
might be an idea to try removing these from the recursive templates to see what
happens. (Hint: rename the attributes as xxx:as to comment them out, where
xxx is some namespace). Alternatively, you could try replacing the recursive
template by a recursive function - this is one area where templates and
functions still behave a bit differently.
I've been using Template recursion in order to
iterate over the N instances
of a node in a big input document, each node
creating a separate result-document.
Haven't had any problem to date,
even with big files (100Mo) and around 100 output documents.
But I just
ran into a case of "StackOverflowError":
SXLM0001: Too many nested
apply-templates calls. The stylesheet is probably looping.
looping, but over the nodes that I need to output, not in error.
thought that I'd try the Saxon extensions that allow iteration, to wit the
extension and the "saxon:assignable" attribute to
xsl:variable, along with "saxon:assign".
I noticed that the 8.4
documentation says that "saxon:assign" may go away in the future.
in spite of repeated attempts and tweaks, I couldn't get saxon:assign to
my global variable remained a constant
<xsl:variable name="topCurTradePart" select="0" saxon:assignable="yes"
<saxon:while test="$topCurTradePart lt
Note: I tried both the "select" and "expr"
attributes to saxon:assign.
So I'm in a corner and I'm curious what I
-- Try to pursue the "saxon:assign" workaround, in the hopes
of making it work
-- Modify a configuration (which?) in order to keep from
having StackOverFlow exception in a normal recursion.