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

Re: Replace newline characters(\n) with <br>

Subject: Re: Replace newline characters(\n) with <br>
From: "Joerg Heinicke" <joerg.heinicke@xxxxxx>
Date: Thu, 21 Mar 2002 01:24:00 +0100
replace newline
You can search the archives for 'replace' or 'recursive templates', such
questions are quite often.

<xsl:template match="message">
    <xsl:call-template name="replace">
        <xsl:with-param name="string" select="."/>
    </xsl:call-template>
</xsl:template>

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

Regards,

Joerg


> Hello,
>
>   I have the a simple Xml document as shown below
>
> <xml version="1.0">
> <message>
> string1
> string2
> string3
> </Message>
>
> Technically, the strings are separated by newlines. Now when i write an
XSL
> for this document, i want to replace all the newlines with <br> so that
> these strings appear in three lines in the output.
>
> Thanks,
>
>
> Arun Ramadoss
> Professional
> Software Engineer II
> E*TRADE Financial
> w 650-331-6307


 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.