Re: Handling linebreaks

Subject: Re: Handling linebreaks
From: "Manuel Montoro" <mmontoro@xxxxxxxxxxx>
Date: Thu, 30 Nov 2000 09:23:23 +0100
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:when test="contains($texto, '&#x0A;')">
        <xsl:variable name="linea1"><xsl:value-of select="substring-
before($texto, '&#x0A;')" /></xsl:variable>
        <xsl:variable name="resto"><xsl:value-of select="substring-
after($texto, '&#x0A;')" /></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:value-of select="$texto" />

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
> 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 &#160; for whitespace)
> and if so, how do I do it???
> c)  Some other option??
> Jerry
> jerry@xxxxxxxxxxx
>  XSL-List info and archive:

Manuel Antonio Montoro Navarro
Responsable Equipo Desarrollo Internet

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

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:

Current Thread