PranasLu's Blog


Tip&Trick: Xslt and multi-line text in HTML, WordML

Filed under: Programming — Tags: , , , — pranaslu @ 10:19

The code below shows how to convert linebreak to <br/>. You can easily adopt this template to convert linebreak to anything else.

Use this template to substitude newlines in HTML:

<xsl:template name="br">
    <xsl:param name="text"/>
        <xsl:when test="contains($text,'
            <xsl:value-of select="substring-before($text,'
            <xsl:call-template name="br">
                <xsl:with-param name="text">
                    <xsl:value-of select="substring-after($text,'
            <xsl:value-of select="$text"/>

And call it upon your text item like this:

<xsl:call-template name="br">
    <xsl:with-param name="text" select="somenode/mytext"/>



Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at

%d bloggers like this: