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

big recursive function

Subject: big recursive function
From: jon wa <jonni@xxxxxxxxx>
Date: Wed, 28 Nov 2001 12:25:52 +0100 (MET)
xsl recursive function
i have an xhtml file as input which i convert to plain text output. for
<pre> tags i have to output as is but indent every line by 4 spaces. no
problem...

if the string $table is not empty then print 4 spaces and the string up to
the first LF then call itself again with the rest of the string.

<xsl:template name="format">
<xsl:param name="table"/>
  <xsl:choose>
    <xsl:when test="string-length($table) > 0">
<xsl:value-of select="'    '"/><xsl:value-of
select="concat(substring-before($table, '&#10;'), '&#10;')"/>
      <xsl:call-template name="format">
        <xsl:with-param name="table">
          <xsl:value-of select="substring-after($table, '&#10;')"/>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:when>
  </xsl:choose>
</xsl:template>

my problem then comes when i have a big pre section to process. the function
recurses so many times that my parser (gnome libxslt) throws an error. it
seems as tho i can increase the depth that it will recurse but i haven't found
a way to do it with the perl interface i'm using.

so my question is, is my function the right way of going about things? i
just assumed that heavy recursion was ok and i have done some other heavy
functions in the past. or is there another way to make the function more efficient?

thanks!

-- 
Sent through GMX FreeMail - http://www.gmx.net


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.