This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
big recursive function
- From: jon wa <jonni at gmx dot co dot uk>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Wed, 28 Nov 2001 12:25:52 +0100 (MET)
- Subject: [xsl] big recursive function
- Reply-to: xsl-list at lists dot mulberrytech dot com
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, ' '), ' ')"/>
<xsl:call-template name="format">
<xsl:with-param name="table">
<xsl:value-of select="substring-after($table, ' ')"/>
</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