Re: [xml] newline in xmlTextWriter on win32

On 12/08/04 21:35, Michael Culbertson wrote:

On Wed, 11 Aug 2004, Igor Zlatkovic wrote:

This conversion done by the C runtime has been deactivated in libxml on
purpose. The problem was that under some bizarre conditions,
xmlParseFile() followed by a xmlSaveFile() modified the data. It
replaced every \n with \r\n, even if it allready was a \r\n, ending up
with \r\r\n. One did the read-write again and it became \r\r\r\n.

Hmm.. this is interesting since according to XML specification (as was
pointed out recently in an other message on this list), xmlParseFile()
should have converted all \r\n sequences in the input file to \n.  Then,
when the file was output through xmlSaveFile() the C library would convert
all of the single \n characters to the \r\n sequence.

May I ask what sort of bizarre conditions caused the duplication?  The
change to binary write mode occurred in version 1.107 of xmlIO.c (20 Jul
2003).  I checked the mailing list archive around that date and didn't see
any discussion on this.  If there was any, could you point me in that

That was long ago, strike me if I know the details still. Someone reported a mysterious multiplication of line ends and I could reproduce that with libxml which was current somewhere in late 2001 or early 2002.

But that wasn't the reason for the change to xmlio.c in 2003. The reason for that was discussed on libxslt list, if I remember well. Could look into the archives, but there is no need. Look at this:

  <?xml version="1.0"?>
    <xsl:output method="text"/>
    <xsl:template match="/">

Take this and transform any XML document with it, using xsltproc, and add the -o option to save the result in a file. The resulting file must be exactly two bytes long and contain the sequence \r\n, on all platforms. If libxml would allow the runtime to convert the newlines, the result would be a \r\r\n file on Windows, clearly making the processor a broken one, on that platform.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]