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

Transforming XML to HTML - preserving line breaks

Subject: Transforming XML to HTML - preserving line breaks
From: "Adam Bailin" <ABAILIN@xxxxxxxxxxxxx>
Date: Wed, 16 Jul 2003 16:05:28 +0100
adam bailin
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

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.