[Mono-bugs] [Bug 61233][Nor] Changed - DataSet::ExtendedProperties not written on DataSet::WriteXml

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 5 Aug 2004 06:02:05 -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 dev@6wardlaw.freeserve.co.uk.

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

--- shadow/61233	2004-07-17 01:53:51.000000000 -0400
+++ shadow/61233.tmp.7889	2004-08-05 06:02:05.000000000 -0400
@@ -112,6 +112,97 @@
   <Foo>
     <col1>foo</col1>
   </Foo>
 </NewDataSet>
 
 Can you provide example code that shows differences between MS and mono?
+
+------- Additional Comments From dev@6wardlaw.freeserve.co.uk  2004-08-05 06:02 -------
+Hi,
+
+You need to specify that the schema is written when you output the 
+XML. Try this example on both Mono and Windows:
+
+using System;
+using System.Data;
+
+public class Test
+{
+	public static void Main ()
+	{
+		DataSet ds = new DataSet ();
+		ds.ExtendedProperties[ "version" ] = "version 2.1";
+		DataTable dt = new DataTable ("Foo");
+		dt.Columns.Add ("col1");
+		dt.Rows.Add (new object [] {"foo"});
+		ds.Tables.Add (dt);
+		ds.WriteXml ( Console.Out, 
+XmlWriteMode.WriteSchema );
+
+		Console.ReadLine( );
+	}
+}
+
+
+The resulting executable, when run on MS.Net:
+
+<NewDataSet>
+  <xs:schema id="NewDataSet" xmlns="" 
+xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" 
+xmlns:msprop="urn:schemas-microsoft-com:xml-msprop">
+    <xs:element name="NewDataSet" msdata:IsDataSet="true" 
+msdata:Locale="en-GB"msprop:version="version 2.1">
+      <xs:complexType>
+        <xs:choice maxOccurs="unbounded">
+          <xs:element name="Foo">
+            <xs:complexType>
+              <xs:sequence>
+                <xs:element name="col1" type="xs:string" 
+minOccurs="0" />
+              </xs:sequence>
+            </xs:complexType>
+          </xs:element>
+        </xs:choice>
+      </xs:complexType>
+    </xs:element>
+  </xs:schema>
+  <Foo>
+    <col1>foo</col1>
+  </Foo>
+</NewDataSet>
+
+When run on Mono on Fedora Core using mono-1.0:
+
+<NewDataSet>
+  <xs:schema xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" 
+id="NewDataSet" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+    <xs:element name="NewDataSet" msdata:IsDataSet="true" 
+msdata:Locale="en-GB">
+      <xs:complexType>
+        <xs:choice maxOccurs="unbounded">
+          <xs:element name="Foo">
+            <xs:complexType>
+              <xs:sequence>
+                <xs:element minOccurs="0" name="col1" 
+type="xs:string" />
+              </xs:sequence>
+            </xs:complexType>
+          </xs:element>
+        </xs:choice>
+      </xs:complexType>
+    </xs:element>
+  </xs:schema>
+  <Foo>
+    <col1>foo</col1>
+  </Foo>
+</NewDataSet>
+
+
+Notice that the extended data is stored in the data set element. 
+It's a bit messy looking but it is quite useful ( especially for 
+storing version numbers!! )
+
+Thanks.
+
+
+