[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How to convert a recursive function to a loop, usi

Subject: Re: 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
Re:  How to convert a recursive function to a loop
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 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:when test="$current-size ge $total-size">
            <xsl:sequence select="$results" />
            <xsl:variable name="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,
                ($results, $string))" />


Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.