RE: [xsl] Replacing character entities

Subject: RE: [xsl] Replacing character entities
From: "Bhaskar, Rajan" <RBhaskar@xxxxxxx>
Date: Mon, 14 Feb 2005 14:16:23 -0500
 what does "Scio me nihil scire"  mean?

-----Original Message-----
From: Joris Gillis [mailto:roac@xxxxxxxxxx]
Sent: Monday, February 14, 2005 1:39 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Replacing character entities

Tempore 19:07:22, die 02/14/2005 AD, hinc in  
xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Wagstaff, Jason  

> I have a text block that contains &#13; &#13; wherever the user wanted
> it to look like a paragraph break. I don't any have control over the
> input.
> Any ideas on how can I replace &#13; with <br/>? Or better still, use
> the &#13 to identify the paragraphs and wrap each <p>paragraph</p>?

Let's assume you have an XML with this node in it:

<text>Line1&#13;Line2&#13;other content</text>

And the desired output would be:
	<p>other content</p>

This can be achieved by applying a stylesheet like this:

<xsl:stylesheet xmlns:xsl="";  
<xsl:output method="xml" indent="yes"/>

<xsl:template match="text">
	<xsl:call-template name="par"/>

<xsl:template name="par">
	<xsl:param name="text" select="."/>
		<xsl:value-of select="substring-before(concat($text,'&#13;'),'&#13;')"/>
	<xsl:if test="contains($text,'&#13;')">
		<xsl:call-template name="par">
			<xsl:with-param name="text">
				<xsl:value-of select="substring-after($text,'&#13;')"/>


Joris Gillis (
"Scio me nihil scire"  - Socrates

XSL-List info and archive:
To unsubscribe, go to:
or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx>

Current Thread