[Mono-bugs] [Bug 62076][Nor] New - Xml deserialization does not follow w3c recommendations?

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 29 Jul 2004 03:29:18 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by monobugs@radeldudel.de.

http://bugzilla.ximian.com/show_bug.cgi?id=62076

--- shadow/62076	2004-07-29 03:29:18.000000000 -0400
+++ shadow/62076.tmp.25848	2004-07-29 03:29:18.000000000 -0400
@@ -0,0 +1,74 @@
+Bug#: 62076
+Product: Mono: Class Libraries
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.XML
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: monobugs@radeldudel.de               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Xml deserialization does not follow w3c recommendations?
+
+Description of Problem:
+On deserializing xml data Mono's XmlSerializer does keep the line breaks 
+just like they had been on serialisation.
+It is very nice and clean behaviour, but as far as I understand them the 
+w3c recommendations for parsing xml say line breaks should be handled 
+differently
+
+From http://www.w3.org/TR/REC-xml/#sec-line-ends :
+
+"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."
+
+So, as I understand it the w3c recommendation would be to change every 
+linebreak into \n. I am not sure if this is wanted, though, since 
+preserving the line breaks as they are seems a good thing to me, but 
+sticking to the w3c recommendations might be a better thing to do, not?
+
+
+NUnit testcase to reproduce the problem:
+--------- 
+using NUnit.Framework;
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Xml.Serialization;
+
+namespace Sam.Tests
+{
+ [TestFixture] 
+ public class MonoTests
+ {
+  public struct XmlLinebreakStruc
+  {
+   public String  Name;
+  }
+
+  [Test] public void TestXmlLinebreak1()
+  {
+   XmlLinebreakStruc p1= new XmlLinebreakStruc();
+   p1.Name= "One\rtwo\nthree\r\nfour";
+   XmlSerializer ser= new XmlSerializer( typeof( XmlLinebreakStruc));
+   MemoryStream memStream= new MemoryStream();
+   ser.Serialize( memStream, p1);
+   memStream.Close();
+   String personAsString= System.Text.Encoding.UTF8.GetString( 
+memStream.ToArray());
+   memStream= new MemoryStream( System.Text.Encoding.UTF8.GetBytes( 
+personAsString));
+   XmlLinebreakStruc p2= (XmlLinebreakStruc )ser.Deserialize( memStream);
+   memStream.Close();
+   Assert.AreEqual( "One\ntwo\nthree\nfour", p2.Name);
+ }		
+}