To see that the problem with Generator functions in xslt is a bit more complicated compare two functions.
The first one is quoted from the earlier post:
<xsl:function name="t:generate" as="xs:integer*"> <xsl:param name="value" as="xs:integer"/> <xsl:sequence select="$value"/> <xsl:sequence select="t:generate($value * 2)"/> </xsl:function>
It does not work in Saxon: crashes with out of memory.
The second one is slightly modified version of the same function:
<xsl:function name="t:generate" as="xs:integer*"> <xsl:param name="value" as="xs:integer"/> <xsl:sequence select="$value + 0"/> <xsl:sequence select="t:generate($value * 2)"/> </xsl:function>
It's working without problems. In first case Saxon decides to cache all function's output, in the second case it decides to evaluate data lazily on demand.
It seems that optimization algorithms implemented in Saxon are so plentiful and complex that at times they fool one another. :-)
See also: Generator functions
Remember Me
a@href@title, b, blockquote@cite, em, i, strike, strong, sub, super, u