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

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 2 Sep 2004 15:59:47 -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 lluis@ximian.com.

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

--- shadow/62076	2004-07-29 03:29:18.000000000 -0400
+++ shadow/62076.tmp.13256	2004-09-02 15:59:47.000000000 -0400
@@ -1,22 +1,21 @@
 Bug#: 62076
 Product: Mono: Class Libraries
 Version: unspecified
-OS: 
+OS: unknown
 OS Details: 
 Status: NEW   
 Resolution: 
-Severity: 
+Severity: Unknown
 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 
@@ -69,6 +68,61 @@
 personAsString));
    XmlLinebreakStruc p2= (XmlLinebreakStruc )ser.Deserialize( memStream);
    memStream.Close();
    Assert.AreEqual( "One\ntwo\nthree\nfour", p2.Name);
  }		
 }
+
+------- Additional Comments From lluis@ximian.com  2004-09-02 15:59 -------
+Looks like there is a missing feature in XmlTextReader, which is used
+by the serializer to read the data. In MS.NET setting the
+Normalization property to true makes the reader to convert CR+LF to LF.
+
+This is a simple test case:
+
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Xml;
+using System.Xml.Serialization;
+
+public class MonoTests
+{
+	public static void Main ()
+	{
+		string s = "One\rtwo\nthree\r\nfour";
+		string t = "<hi>" + s + "</hi>";
+		
+		Console.WriteLine ("Before:");
+		Dump (s);
+		XmlTextReader r = new XmlTextReader (new StringReader (t));
+		r.WhitespaceHandling = WhitespaceHandling.Significant;
+		
+		r.Normalization = true;
+		
+		s = r.ReadElementString ("hi");
+		Console.WriteLine ("After:");
+		Dump (s);
+	}
+	
+	public static void Dump (string s)
+	{
+		foreach (char c in s)
+			Console.Write((int)c + " ");
+		Console.WriteLine ();
+	}
+}
+
+The output in MS.NET is:
+
+Before:
+79 110 101 13 116 119 111 10 116 104 114 101 101 13 10 102 111 117 114
+After :
+79 110 101 10 116 119 111 10 116 104 114 101 101 10 102 111 117 114
+
+In Mono:
+
+Before:
+79 110 101 13 116 119 111 10 116 104 114 101 101 13 10 102 111 117 114
+After :
+79 110 101 13 116 119 111 10 116 104 114 101 101 13 10 102 111 117 114
+