[Mono-bugs] [Bug 59154][Wis] New - XmlTextWriter.WriteRaw("") doesn't prevent xml declaration

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 27 May 2004 03:32:02 -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 jaak@zd.com.pl.

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

--- shadow/59154	2004-05-27 03:32:02.000000000 -0400
+++ shadow/59154.tmp.23702	2004-05-27 03:32:02.000000000 -0400
@@ -0,0 +1,53 @@
+Bug#: 59154
+Product: Mono: Class Libraries
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: Sys.XML
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: jaak@zd.com.pl               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: XmlTextWriter.WriteRaw("") doesn't prevent xml declaration
+
+The following snippet behaves differently under Mono vs .NET:
+===================
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+class C1 {
+	public static void Main() {
+		XmlTextWriter xtw = new XmlTextWriter(Console.Out);
+		XmlSerializer ser = new XmlSerializer(typeof(int));
+		xtw.WriteRaw("");
+		ser.Serialize(xtw, 1);
+	}
+}
+===================
+
+Under .NET it displays: 
+
+<int>1</int>
+
+Under Mono it displays: 
+
+<?xml version="1.0" encoding="iso-8859-1"?><int>1</int>
+
+The key here is the 
+
+xtw.WriteRaw("");
+
+Under .NET it changes the writer state to "Prolog" so that the xml
+declaration isn't output by the serializer. I'm not sure if this is
+documented anywhere, but I tested it Mono/CVS and .NET 1.0.3705, 1.1.4322
+and 2.0.40301 and the results are as described above.
+
+Without this feature I found it difficult to serialize the object into a
+StringWriter without the <?xml?> declaration.