cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ugo Cei <>
Subject Re: Converting linebreak to <br/>?
Date Thu, 27 May 2004 21:05:18 GMT
Il giorno 27/mag/04, alle 20:42, Stephan Coboos ha scritto:

> I'am using a flowscript to retrieve text from a form's textarea. This 
> text may contain some linebreaks \n. Now I want display the content 
> with line breaks in a html view. So I need to convert \n to <br/>. For 
> displaying the content of the textarea I'am using a JXTemplate. How I 
> can I transform linebreaks \n into the element <br/>? If i replace all 
> \n with <br/> in the html output I will get only &lt;br/&gt;. So I 
> have to include the <br/> into the SAX pipeline, but how? Is there a 
> easy way to do so (without building a new rome;-)?

       |  Replace newlines with <br>'s
       |  (Credits:
         <xsl:template name="substitute">
            <xsl:param name="string" />
            <xsl:param name="from" select="'&#xA;'" />
            <xsl:param name="to">
               <br />
               <xsl:when test="contains($string, $from)">
                  <xsl:value-of select="substring-before($string, 
$from)" />
                  <xsl:copy-of select="$to" />
                  <xsl:call-template name="substitute">
                     <xsl:with-param name="string"
$from)" />
                     <xsl:with-param name="from" select="$from" />
                     <xsl:with-param name="to" select="$to" />
                  <xsl:value-of select="$string" />

Ugo Cei -

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message