Hi folks !

I have text in a database with \n characters in it.
I want to produce HTML and keep LF in my presentation.
So I have to convert \n to <BR>

I can't replace with < and > characters because they can be confusing 
for the parser , am I right ?
In order to see if my template is ok, I tried it but I have a 
StackOverFlowError ! (replacing \n with BR )
Any help is appreciated

Thanks

Sébastien






Here is what I did :

<xsl:template name="remplaceCaracDansChaine">
    <xsl:param name="chaineEntrante"/><!--Input String-->
    <xsl:param name="caracEntrant"/>    <!--what I want to be replaced-->
    <xsl:param name="caracSortant"/><!--the new piece of string-->
    <xsl:choose>
        <xsl:when test="contains($chaineEntrante,caracEntrant)">
            <xsl:value-of 
select="concat(substring-before($chaineEntrante,$caracEntrant),$caracSortant)"/>
    <xsl:call-template name="remplaceCaracDansChaine">
    <xsl:with-param name="chaineEntrante" 
select="substring-after($chaineEntrante,$caracEntrant)"/>
    <xsl:with-param name="caracEntrant" select="$caracEntrant"/>
    <xsl:with-param name="caracSortant" select="$caracSortant"/>
    </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
        <xsl:value-of select="$chaineEntrante"/>
    </xsl:otherwise>
    </xsl:choose>
</xsl:template>

Then, I call it like that :
<xsl:variable name="monTexte"><xsl:value-of 
select="/page/rowfiche/texte"/></xsl:variable> <!--value coming from my 
XML-->
<xsl:variable name="texteBR"><!--the destination variable with modified 
text-->
    <xsl:call-template name="remplaceCaracDansChaine">
        <xsl:with-param name="chaineEntrante" select="string($monTexte)"/>
        <xsl:with-param name="caracEntrant" select="n"/>
        <xsl:with-param name="caracSortant" select="BR"/><!--I can't use 
<BR> because of < and > characters-->
    </xsl:call-template>
</xsl:variable>

<xsl:value-of select="$texteBR"/><!--print the transformed string-->


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>

Reply via email to