David Carlisle wrote:
> I don't think you'd fill the stack if you wrote
> the function such that the sequence of strings
> was built up in an additional argument to the
> function so that your xsl:choose just consisted
> of a single recursive call in the iteration case,
> and returning the full sequence, not nothing,
> in the end case.
I gave that approach a try. See below. Unfortunately, it generates the same
"Too many nested function calls" error. Did I implement your suggestion
correctly? /Roger
<xsl:function name="f:make-string-table-entries" as="element(String)*">
<xsl:param name="total-size" as="xs:integer" />
<xsl:param name="current-position" as="xs:integer" />
<xsl:param name="sourceSeq" as="element(Byte)*" />
<xsl:sequence select="f:make-string-table-entries-aux($total-size,
xs:integer(0), $current-position, $sourceSeq, ())" />
</xsl:function>
<xsl:function name="f:make-string-table-entries-aux" as="element(String)*">
<xsl:param name="total-size" as="xs:integer" />
<xsl:param name="current-size" as="xs:integer" />
<xsl:param name="current-position" as="xs:integer" />
<xsl:param name="sourceSeq" as="element(Byte)*" />
<xsl:param name="results" as="element(String)*" />
<xsl:choose>
<xsl:when test="$current-size ge $total-size">
<xsl:sequence select="$results" />
</xsl:when>
<xsl:otherwise>
<xsl:variable name="string"
select="f:make-element-from-null-terminated-string('String',
$current-position, $sourceSeq)" as="element(String)"/>
<xsl:variable name="length" select="string-length($string/text())
+ 1"/> <!-- add 1 for the null terminator -->
<xsl:sequence select="f:make-string-table-entries-aux($total-size,
xs:integer($current-size+$length),
xs:integer($current-position+$length),
$sourceSeq,
($results, $string))" />
</xsl:otherwise>
</xsl:choose>
</xsl:function>
|