[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: carriage return in XML ---> <br /> in HTML - how ?

Subject: RE: carriage return in XML ---> <br /> in HTML - how ?
From: "Jarno Elovirta" <jarno@xxxxxxxxxxxxxx>
Date: Fri, 22 Sep 2000 11:45:24 +0300
xsl replace carriage return
> Any ideas someone ?

How about an edited version of the solution from
http://www.dpawson.freeserve.co.uk/xsl/replace.html#N25057:

[c:\temp]type test.xml
<?xml version="1.0"?>
<Text>
    This is where the actual article starts. The article contains
    several paragraphs.

    Paragaraphs are separated by Carriage returns or Linefeeds, not by Tags
</Text>

[c:\temp]type test.xsl
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" />

<xsl:template match="@*|node()">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="text()">
   <xsl:call-template name="break" />
</xsl:template>

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

</xsl:stylesheet>

[c:\temp]saxon test.xml test.xsl
<?xml version="1.0" encoding="utf-8"?><Text><br/>    This is where the
actual article starts. The article contains<br/>    several
paragraphs.<br/><br/>    Paragaraphs are separated by Carriage returns or
Linefeeds, not by Tags<br/></Text>

Cheers,

Jarno - The Smiths: Meat Is Murder


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.