OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] How does XML handle differing line break characters on dif

[ Lists Home | Date Index | Thread Index ]

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?"




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS