This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Handling linebreaks
- To: xsl-list at mulberrytech dot com
- Subject: Re: Handling linebreaks
- From: "Manuel Montoro" <mmontoro at novasoft dot es>
- Date: Thu, 30 Nov 2000 09:23:23 +0100
- Organization: Novasoft
- Reply-To: xsl-list at mulberrytech dot com
Try this template. It accepts one param (texto) as the text to
transform and generates a <br /> for each carriage return.
<xsl:template name="brize">
<xsl:param name="texto" />
<xsl:choose>
<xsl:when test="contains($texto, '
')">
<xsl:variable name="linea1"><xsl:value-of select="substring-
before($texto, '
')" /></xsl:variable>
<xsl:variable name="resto"><xsl:value-of select="substring-
after($texto, '
')" /></xsl:variable>
<xsl:value-of select="$linea1" />
<xsl:if test="$resto">
<br />
<xsl:call-template name="brize"><xsl:with-param
name="texto" select="$resto" /></xsl:call-template>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$texto" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Kind Regards
On 29 Nov 2000, at 17:30, Jerry Luna wrote:
> Currently I have an XML file with an element similar to the following:
>
> <CONTENT>text text text text
> text text text text
>
> text text text text
> text text
> </CONTENT>
>
>
> What is the best way to preserve the linespacing when I transform this
> XML file to HTML?
>
> a) Should I insert tags to associate with the linebreaks when building
> the XML content? If I do this, how would I know when I run into those
> tags when I use <xsl:value-of select="CONTENT">?
>
> b) Or should I sent ascii characters (such as   for whitespace)
> and if so, how do I do it???
>
> c) Some other option??
>
> Jerry
> jerry@eredyne.com
>
>
>
>
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
--------------------------------------------------
Manuel Antonio Montoro Navarro
Responsable Equipo Desarrollo Internet
NOVASOFT SOFTWARE FACTORY
Avda. de la Axarquía,29
Apdo. de Correos 174
29730 Rincón de la Victoria
Málaga (España)
Tlf: +34 902 310031
Fax: +34 902 310041
mmontoro@novasoft.es
http://www.novasoftsf.com
Pensamiento del Dia:
Dicen que el mono es tan inteligente que no habla para que
no lo hagan trabajar
Rene Descartes.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list