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

Re: How does XML handle differing line break characters on dif


line break in xml
I keep biting my tongue, figuring that it *doesn't* matter, but the post
below will probably be archived, and it contains repetitions of some errors
that really annoy me ....

On Mon, Sep 08, 2003 at 11:09:12AM -0400, Roger L. Costello wrote:
>[This is an expanded version of the summary that I sent out a few
>minutes ago.  I thought that some people might find this a bit less
>terse and more understandable (plus I elaborated on some things).]
>
>Hi Folks,
>
>Different systems use different line break characters.  How do you
>handle this in XML?  Read on and find out.
>
>Consider this XML document: (line break characters are explicitly shown)

The end of line convention used in example document is not the usual
convention for any system that I know of.

\r\n == CRLF == ^M^J

\n\r == not encountered, but it would be LFCR if it were.

Sorry.  Utter pedantry, I suppose, but I keep gritting my teeth every time I
see it presented backwards, 'cause I just *know* that somewhere, someone is
going to take it for gospel and use LFCR as the line ending convention,
creating yet another "oh, you should be *lenient* in what you receive"
argument ....

><?xml version="1.0"?> \n\r
><Test> \n\r
>     <para xml:space="preserve">This is a \n\r
>     simple paragraph. What \n\r
>     do you think of it?</para> \n\r
></Test> \n\r
>
>When an XML parser reads in this document it "normalizes" ALL line
>breaks.  Thus, after normalization the XML document looks like this:
>
><?xml version="1.0"?> \n
><Test> \n
>     <para xml:space="preserve">This is a \n
>     simple paragraph. What \n
>     do you think of it?</para> \n
></Test> \n
>
>Things to note:
>
>1. All line breaks have been normalized to \n.
>
>Consequence: you don't have to be concerned about different platforms
>using different line break characters since all XML documents will have
>their line break characters normalized to \n regardless of the
>platform.  (So, if you're writing an XML Schema regex expression you can
>
>simply use \n to indicate line break, regardless of the platform.)
>
>2. The xml:space="preserve" attribute has no impact on line break
>normalization.
>
>3. Suppose that you want a line break character in your XML document,
>other than \n. For example, suppose that you want \r in your XML
>document.  By default, it would get normalized to \n.  To prevent this,
>use a character entity reference: &#xD;
>
>/Roger
>
>
>
>-----------------------------------------------------------------
>The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
>initiative of OASIS <http://www.oasis-open.org>
>
>The list archives are at http://lists.xml.org/archives/xml-dev/
>
>To subscribe or unsubscribe from this list use the subscription
>manager: <http://lists.xml.org/ob/adm.pl>
>

-- 
Amelia A. Lewis                    amyzing {at} talsever.com
How do you make a cat go moo?
Ask it: "Does a dog have the Buddha-nature?"

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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.