You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "George M. Pieri" <ge...@wcom.com> on 2001/04/20 16:53:43 UTC
Replacing carriage returns and StackOverflow
It appears that the only way to replace carriage returns
with <BR /> is to do a recursive call but....when I do my
call I get a
java.lang.StackOverflowException....
Is there any way around this ? I am using Cocoon 1.8 running
on Tomcat.
Thanks in advance!
Calling the Recursive function
====================================
<xsl:template match="blurb">
<p><b>Example 1: Text is normalized</b> <br />
<xsl:call-template name="normalize-text">
<xsl:with-param name="text" select="info"/>
</xsl:call-template>
</p>
<p><b>Example 2: Text is not normalized</b> <br />
<xsl:value-of select="info" />
</p>
</xsl:template>
Recursive function that replace Carriage Returns
=====================================
<!-- template that does a search & replace -->
<xsl:template name="normalize-text">
<xsl:param name="text"/>
<xsl:variable name="replace"> </xsl:variable>
<xsl:choose>
<xsl:when test="contains($text, $replace)">
<xsl:value-of select="substring-before($text, $replace)"/>
<xsl:text disable-output-escaping="yes"><br /></xsl:text>
<xsl:call-template name="normalize-text">
<xsl:with-param name="text"
select="substring-after($text, $replace)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>