|
Subject: Re: [xsl] How to convert a recursive function to a loop, using XSLT2.0? From: "Costello, Roger L. costello@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 10 May 2019 16:30:10 -0000 |
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>
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] How to convert a recursiv, Dimitre Novatchev dn | Thread | [xsl] What is the most efficient XP, Costello, Roger L. c |
| Re: [xsl] How to convert a recursiv, Syd Bauman s.bauman@ | Date | Re: [xsl] Breaking paragraphs one l, Terry Badger terry_b |
| Month |