Newbie: CR/LF and tabs

Discussion in 'XML' started by Thorsten Kettner, Sep 19, 2003.

  1. Hi all,
    I've been told to write an xml file and I wonder if I can use CR/LF
    and tabs in the data (like in html's <pre></pre>).

    <?xml version="1.0" encoding="ISO-8859-15"?>
    <MYDATA>
    <MYLIST>Line 1
    Line 2
    Line 3</MYLIST>
    </MYDATA>

    Will the parser correctly return a string containing two linefeeds?

    Or should I use cr identifiers (like \n in Line1\nLine2\nLine3) and
    manually split the line that the parser gives me?

    I know this is a common question, sorry, but searching Google groups I
    didn't find the answer due to being a beginner and due to the fact
    that most questions target a certain parser, not xml in general.
     
    Thorsten Kettner, Sep 19, 2003
    #1
    1. Advertising

  2. In article <>,
    (Thorsten Kettner) wrote:

    >:Hi all,
    >:I've been told to write an xml file and I wonder if I can use CR/LF
    >:and tabs in the data (like in html's <pre></pre>).
    >:
    >:<?xml version="1.0" encoding="ISO-8859-15"?>
    >:<MYDATA>
    >: <MYLIST>Line 1
    >:Line 2
    >:Line 3</MYLIST>
    >:</MYDATA>
    >:
    >:Will the parser correctly return a string containing two linefeeds?
    >:
    >:Or should I use cr identifiers (like \n in Line1\nLine2\nLine3) and
    >:manually split the line that the parser gives me?
    >:
    >:I know this is a common question, sorry, but searching Google groups I
    >:didn't find the answer due to being a beginner and due to the fact
    >:that most questions target a certain parser, not xml in general.


    Keeping in mind that end of line marks are platform specific (that is,
    only Windows uses CR/LF), it's doubtful that any good parser would
    maintain those line breaks. If there's an encoded character that
    represents EOL and will be respected by a parser, I am not aware of it.

    In my experience, the lines you create will get written that way, but
    they'll be lost when you read the document the next time. Our app
    includes an editor for our own needs, and we decided that the only
    effective way to handle this was to put each "line" into its own element
    or attribute. It's more work to handle it when writing/reading, but it
    guaranteed the results.

    = Steve =
    --
    Steve W. Jackson
    Montgomery, Alabama
     
    Steve W. Jackson, Sep 19, 2003
    #2
    1. Advertising

  3. I think this is completely wrong.

    The only normalization the XML parser is allowed to do here is line end
    normalization (and that shouldn't be an issue at all).

    If this would be a problem, the <pre> element in XHTML wouldn't work. But it
    does.

    Julian


    "Steve W. Jackson" <> schrieb im Newsbeitrag
    news:-berlin.de...
    > In article <>,
    > (Thorsten Kettner) wrote:
    >
    > >:Hi all,
    > >:I've been told to write an xml file and I wonder if I can use CR/LF
    > >:and tabs in the data (like in html's <pre></pre>).
    > >:
    > >:<?xml version="1.0" encoding="ISO-8859-15"?>
    > >:<MYDATA>
    > >: <MYLIST>Line 1
    > >:Line 2
    > >:Line 3</MYLIST>
    > >:</MYDATA>
    > >:
    > >:Will the parser correctly return a string containing two linefeeds?
    > >:
    > >:Or should I use cr identifiers (like \n in Line1\nLine2\nLine3) and
    > >:manually split the line that the parser gives me?
    > >:
    > >:I know this is a common question, sorry, but searching Google groups I
    > >:didn't find the answer due to being a beginner and due to the fact
    > >:that most questions target a certain parser, not xml in general.

    >
    > Keeping in mind that end of line marks are platform specific (that is,
    > only Windows uses CR/LF), it's doubtful that any good parser would
    > maintain those line breaks. If there's an encoded character that
    > represents EOL and will be respected by a parser, I am not aware of it.
    >
    > In my experience, the lines you create will get written that way, but
    > they'll be lost when you read the document the next time. Our app
    > includes an editor for our own needs, and we decided that the only
    > effective way to handle this was to put each "line" into its own element
    > or attribute. It's more work to handle it when writing/reading, but it
    > guaranteed the results.
    >
    > = Steve =
    > --
    > Steve W. Jackson
    > Montgomery, Alabama
     
    Julian F. Reschke, Sep 19, 2003
    #3
  4. > Keeping in mind that end of line marks are platform specific (that is,
    > only Windows uses CR/LF), it's doubtful that any good parser would
    > maintain those line breaks. If there's an encoded character that
    > represents EOL and will be respected by a parser, I am not aware of it.


    On the contrary -- any conformant parser must normalize any combination of
    CR and NL to a single NL (
    )


    =====
    Cheers,

    Dimitre Novatchev.
    http://fxsl.sourceforge.net/ -- the home of FXSL
     
    Dimitre Novatchev, Sep 19, 2003
    #4
  5. (Thorsten Kettner) wrote in message news:<>...
    > Hi all,
    > I've been told to write an xml file and I wonder if I can use CR/LF
    > and tabs in the data (like in html's <pre></pre>).

    [snip]

    Thank you very much Steve, Julian and Dimitre for your answers.
     
    Thorsten Kettner, Sep 23, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. qwweeeit
    Replies:
    2
    Views:
    678
    qwweeeit
    Dec 14, 2005
  2. rantingrick

    Tabs -vs- Spaces: Tabs should have won.

    rantingrick, Jul 16, 2011, in forum: Python
    Replies:
    95
    Views:
    1,928
    Roy Smith
    Jul 19, 2011
  3. John Kopanas
    Replies:
    2
    Views:
    320
    Gregory Brown
    Jan 29, 2007
  4. droog

    Creating tabs in javascript (newbie)

    droog, May 5, 2004, in forum: Javascript
    Replies:
    3
    Views:
    100
    Michael Winter
    May 6, 2004
  5. Ga
    Replies:
    1
    Views:
    138
    Anno Siegel
    Dec 15, 2003
Loading...

Share This Page