Michael Giroux wrote:
> The following template attempts to convert new-lines to <br/>

Oldest FAQ in the book.

http://www.dpawson.co.uk/xsl/sect2/break.html
http://www.dpawson.co.uk/xsl/sect2/replace.html
http://skew.org/xml/stylesheets/linefeed2br/linefeed_to_br_demo_13.xsl

<xsl:template match="/">
  <xsl:call-template name="lf2br">
    <xsl:with-param name="s" select="'here is&#10;a string&#10;that 
contains&#10;some linefeeds'"/>
  </xsl:call-template>
</xsl:template>

<xsl:template name="lf2br">
  <xsl:param name="s"/>
  <xsl:choose>
    <xsl:when test="contains($s,'&#10;')">
      <xsl:value-of select="substring-before($s,'&#10;')"/>
      <br/>
      <xsl:call-template name="lf2br">
        <xsl:with-param name="s" select="substring-after($s,'&#10;')"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$s"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

In the future, please ask such questions on the xsl-list.
http://www.mulberrytech.com/xsl/xsl-list/

Mike

Reply via email to