Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2006-06

xml line endings

6 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Colin Western
to Vincent Snijders
Vincent Snijders wrote 12 lines
Hi, I saw in the log message of revision http://www.freepascal.org/cgi-bin/viewcvs.cgi?diff_format=l&rev=3784&sortby=date&view=rev that the xml units now use native line ending. Previously I noticed they were using #10 for line-ending and was told this was conform the xml specifications. Does this change mean, that valid xml files can only be generated on *nix from now on?

I submitted the change because I find it convenient to occasionally edit the xml data files from my program as text, and (for example) notepad does not like unix line endings. Looking at the spec:

<http://www.w3.org/TR/REC-xml/#sec-line-ends>

it says:

"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, the XML processor MUST behave as if it normalized all line breaks in external parsed entities (including the document entity) on input, before parsing, by translating both the two-character sequence #xD #xA and any #xD that is not followed by #xA to a single #xA character."

which I read as allowing any line ending, and it is the reader's responsibility to normalize the line ending.

Colin

Reply by email

Vincent Snijders
to Colin Western
Colin Western wrote 37 lines
Vincent Snijders wrote: > Hi, > > I saw in the log message of revision > http://www.freepascal.org/cgi-bin/viewcvs.cgi?diff_format=l&rev=3784&sortby=date&view=rev > > that the xml units now use native line ending. > > Previously I noticed they were using #10 for line-ending and was told > this was conform the xml specifications. > > Does this change mean, that valid xml files can only be generated on > *nix from now on? I submitted the change because I find it convenient to occasionally edit the xml data files from my program as text, and (for example) notepad does not like unix line endings. Looking at the spec: <http://www.w3.org/TR/REC-xml/#sec-line-ends> it says: "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, the XML processor MUST behave as if it normalized all line breaks in external parsed entities (including the document entity) on input, before parsing, by translating both the two-character sequence #xD #xA and any #xD that is not followed by #xA to a single #xA character." which I read as allowing any line ending, and it is the reader's responsibility to normalize the line ending.

OK. Thanks, for looking that up.

So that means that external files may have all common line endings, but after parsing it should #A.

Then I have no problem with the patch.

Thanks for the clarification.

Vincent

Reply by email

Vincent Snijders
to Vincent Snijders
Vincent Snijders wrote 47 lines
Colin Western wrote: > Vincent Snijders wrote: > >> Hi, >> >> I saw in the log message of revision >> http://www.freepascal.org/cgi-bin/viewcvs.cgi?diff_format=l&rev=3784&sortby=date&view=rev >> >> that the xml units now use native line ending. >> >> Previously I noticed they were using #10 for line-ending and was told >> this was conform the xml specifications. >> >> Does this change mean, that valid xml files can only be generated on >> *nix from now on? > > > > I submitted the change because I find it convenient to occasionally > edit the xml data files from my program as text, and (for example) > notepad does not like unix line endings. Looking at the spec: > > <http://www.w3.org/TR/REC-xml/#sec-line-ends> > > it says: > > "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, the XML processor MUST behave > as if it normalized all line breaks in external parsed entities > (including the document entity) on input, before parsing, by > translating both the two-character sequence #xD #xA and any #xD that > is not followed by #xA to a single #xA character." > > which I read as allowing any line ending, and it is the reader's > responsibility to normalize the line ending. OK. Thanks, for looking that up. Then I have no problem with the patch. Thanks for the clarification.

On second thought, xmlread still contains:

// TODO: Linefeed handling according to W3C
   if FCurChar = #10 then
   begin
     Inc(FLine);
     FColumn := 0;
   end
   else
     Inc(FColumn);

Can files created by xmlwrite on win32, be read with xmlread on *nix?

Vincent

Reply by email

Michael Van Canneyt
to Vincent Snijders: I saw in the log message of revision http://www.freepascal.org/cgi-bin/viewcvs.cgi?diff_fo…
Vincent Snijders wrote 8 lines
Hi, I saw in the log message of revision http://www.freepascal.org/cgi-bin/viewcvs.cgi?diff_format=l&rev=3784&sortby=date&view=rev that the xml units now use native line ending. Previously I noticed they were using #10 for line-ending and was told this was conform the xml specifications.

Actually, this is a response to a bug report requesting for native line-endings.

Does this change mean, that valid xml files can only be generated on *nix from now on?

Does someone know what the XML specs have to say about this ? Then we can see what to do.

Michael.

Reply by email

Michael Van Canneyt
to Vincent Snijders: OK. Thanks, for looking that up. So that means that external files may have all common…
Vincent Snijders wrote 22 lines
> "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, the XML processor MUST behave as > if it normalized all line breaks in external parsed entities (including > the document entity) on input, before parsing, by translating both the > two-character sequence #xD #xA and any #xD that is not followed by #xA to > a single #xA character." > > which I read as allowing any line ending, and it is the reader's > responsibility to normalize the line ending. OK. Thanks, for looking that up. So that means that external files may have all common line endings, but after parsing it should #A. Then I have no problem with the patch. Thanks for the clarification.

Hmmm. Should have read these posts first prior to answering.

I'm not sure that the reader does the transformation, though.

Michael.

Reply by email