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

RE: Re: outputing tags

Subject: RE: Re: outputing tags
From: Edward.Middleton@xxxxxxxxxxx
Date: Mon, 6 Jan 2003 19:25:42 +0900
xsl xa
>I am curious to know how others handle a situation I discribed
>above.  I believe that I am going to run into this problem in
>many places and would like to know the best solution.  Or at
>least the auther of the replies best solution.
>
>I do NOT feel that relying on the tradition linebreak is a
>good idea.  I figured the best thing to do is denote a line
>break in my XML the same way HTML denotes a line break.
>Espically considering the target output is HTML.

If you are using a text editor to edit your XML files you might want to use a line-feed.

The details about line break handling in XML from the specification
http://www.w3.org/TR/1998/REC-xml-19980210#sec-line-ends
2.11 End-of-Line Handling

XML parsed entities are often stored in computer files which, for editing convenience, are organized into lines. These lines are typically separated by some combination of the characters carriage-return (#xD) and line-feed (#xA).

To simplify the tasks of applications, wherever an external parsed entity or the literal entity value of an internal parsed entity contains either the literal two-character sequence "#xD#xA" or a standalone literal #xD, an XML processor must pass to the application the single character #xA. (This behavior can conveniently be produced by normalizing all line breaks to #xA on input, before parsing.) 


This is how you would convert a line-feed characters to <br/>.  If you do this you will need to be careful not to have nodes that contain only line-feed because they will be removed by the xml parser before it gets to be processed.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
	<xsl:template match="text()[contains(.,'&#xA;')]">
		<xsl:value-of select="substring-before(.,'&#xA;')"/><br/><xsl:value-of select="substring-after(.,'&#xA;')"/>
	</xsl:template>
</xsl:stylesheet>

Edward Middleton

 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.