You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Stephan Coboos <cr...@gmx.net> on 2004/05/27 20:42:54 UTC
Converting linebreak to
?
Hello,
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 <br/>. 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;-)?
Thank you.
Regards
Stephan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Converting linebreak to
?
Posted by Ugo Cei <ug...@apache.org>.
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 <br/>. 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: http://www.dpawson.co.uk/xsl/sect2/break.html)
+-->
<xsl:template name="substitute">
<xsl:param name="string" />
<xsl:param name="from" select="'
'" />
<xsl:param name="to">
<br />
</xsl:param>
<xsl:choose>
<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"
select="substring-after($string,
$from)" />
<xsl:with-param name="from" select="$from" />
<xsl:with-param name="to" select="$to" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$string" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
--
Ugo Cei - http://beblogging.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Converting linebreak to
?
Posted by Tony Collen <co...@umn.edu>.
Stephan Coboos wrote:
> Hello,
>
> 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 <br/>. 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;-)?
You could probably write a transformer to do it.
Tony
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Converting linebreak to
?
Posted by Suzan Foster <su...@nerocmediaware.nl>.
Stephan Coboos wrote:
>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 <br/>. 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;-)?
>
>
If the text contains no markup which needs to be rendered why not wrap
it between pre tags? That would certainly save you from having to worry
about newlines.
groetjes, su.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org