[fpc-devel] xml line endings

Vincent Snijders vsnijders at quicknet.nl
Sun Jun 4 18:13:11 CEST 2006


Vincent Snijders wrote:
> 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



More information about the fpc-devel mailing list