[xsl] Transforming XML to HTML - preserving line breaks

Subject: [xsl] Transforming XML to HTML - preserving line breaks
From: "Adam Bailin" <ABAILIN@xxxxxxxxxxxxx>
Date: Wed, 16 Jul 2003 16:05:28 +0100
I am having difficulty dealing with text spread over several lines in an XML doc such as:

<info>
 This is some information.

 This is paragraph number two.

 There may be any number of paragraphs in this element.
</info>

I want to transform this into the following HTML:

<td>
 This is some information.<br/><br/>This is paragraph number two.<br/><br/>There may be any number of paragraphs in this element.
</td>

I am using a standard string replace template which is successfully replacing line breaks but if I use <br/> as the replacement string, it gets ignored. If I use <xsl:text><br/></xsl:text> I get the error message, "br is not allowed in this position in the stylesheet".

Here is the code:

<xsl:call-template name="replace-substring">
 <xsl:with-param name="original" select="oir:SETTINFO"></xsl:with-param>
 <xsl:with-param name="substring">&cr;</xsl:with-param>
 <xsl:with-param name="replacement"><xsl:text><br /></xsl:text></xsl:with-param>
</xsl:call-template>

where &cr; is declared: <!ENTITY cr "<xsl:text>
</xsl:text>">

I am using the latest xalan processor.

Does anyone know how to get round this?

Adam Bailin
Web Developer
Ofsted
Tel: 020 7421 5977



**********************************************************************
We cannot accept any liability for any loss or damage
sustained as a result of software viruses. It is your
responsibility to carry out such virus checking as is necessary before opening any attachment to
this message.

The information in this email and any files transmitted with
it may be of a confidential nature and is intended solely for
the addressees. If you are not the intended addressee, any
disclosure, copying or distribution by you is prohibited and
may be unlawful.

www.ofsted.gov.uk
**********************************************************************


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


Current Thread