[Mono-bugs] [Bug 60469][Wis] New - XSD from DataSet generated not valid
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Sat, 19 Jun 2004 16:19:10 -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 pbaena@uol.com.ar.
http://bugzilla.ximian.com/show_bug.cgi?id=60469
--- shadow/60469 2004-06-19 16:19:10.000000000 -0400
+++ shadow/60469.tmp.17680 2004-06-19 16:19:10.000000000 -0400
@@ -0,0 +1,125 @@
+Bug#: 60469
+Product: Mono: Class Libraries
+Version: unspecified
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Wishlist
+Component: Sys.Data
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: pbaena@uol.com.ar
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: XSD from DataSet generated not valid
+
+With these example from MSDN:
+
+using System;
+using System.Data;
+
+class TEst
+{
+ public static void Main ()
+ {
+
+ DataSet OriginalDataSet = new DataSet("myDataSet");
+ OriginalDataSet.Namespace= "NetFrameWork";
+ DataTable myTable = new DataTable("myTable");
+ DataColumn c1 = new DataColumn("id", Type.GetType("System.Int32"));
+ c1.AutoIncrement= true;
+ DataColumn c2 = new DataColumn("item");
+ myTable.Columns.Add(c1);
+ myTable.Columns.Add(c2);
+ OriginalDataSet.Tables.Add(myTable);
+ // Add ten rows.
+ DataRow newRow;
+ for(int i = 0; i < 10; i++){
+ newRow = myTable.NewRow();
+ newRow["item"]= "item " + i;
+ myTable.Rows.Add(newRow);
+ }
+ OriginalDataSet.AcceptChanges();
+ // Print out values of each table in the DataSet using the
+ // function defined below.
+ PrintValues(OriginalDataSet, "Original DataSet");
+ // Write the XML schema and data to file with FileStream.
+ string xmlFilename = "myXmlDocument2.xml";
+ // Create FileStream
+ System.IO.FileStream fsWriteXml = new System.IO.FileStream
+ (xmlFilename, System.IO.FileMode.Create);
+ // Create an XmlTextWriter to write the file.
+ System.Xml.XmlTextWriter xmlWriter = new System.Xml.XmlTextWriter
+ (fsWriteXml, System.Text.Encoding.ASCII);
+ // Use WriteXml to write the document.
+ OriginalDataSet.WriteXml(xmlWriter);
+ // Close the FileStream.
+ fsWriteXml.Close();
+
+System.IO.StreamWriter xmlSW = new
+System.IO.StreamWriter("Customers.xsd");
+OriginalDataSet.WriteXmlSchema(xmlSW);
+xmlSW.Close();
+
+ }
+
+private static void PrintValues(DataSet ds, string label){
+ Console.WriteLine("\n" + label);
+ foreach(DataTable t in ds.Tables){
+ Console.WriteLine("TableName: " + t.TableName);
+ foreach(DataRow r in t.Rows){
+ foreach(DataColumn c in t.Columns){
+ Console.Write("\t " + r[c] );
+ }
+ Console.WriteLine();
+ }
+ }
+}
+
+}
+
+
+The generated Customers.xsd in Mono is:
+
+<?xml version="1.0" encoding="utf-8"?>
+<xs:schema xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
+xmlns:mstns="NetFrameWork" id="myDataSet" elementFormDefault="qualified"
+attributeFormDefault="qualified" targetNamespace="NetFrameWork"
+xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="myDataSet" msdata:IsDataSet="true" msdata:Locale="">
+ <xs:complexType>
+ <xs:choice maxOccurs="unbounded">
+ <xs:element ref="myTable" />
+ </xs:choice>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
+
+
+while it should be (as generated in .NET):
+
+<?xml version="1.0" encoding="utf-8"?>
+<xs:schema id="myDataSet" targetNamespace="NetFrameWork"
+xmlns:mstns="NetFrameWork" xmlns="NetFrameWork"
+xmlns:xs="http://www.w3.org/2001/XMLSchema"
+xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
+attributeFormDefault="qualified" elementFormDefault="qualified">
+ <xs:element name="myDataSet" msdata:IsDataSet="true">
+ <xs:complexType>
+ <xs:choice maxOccurs="unbounded">
+ <xs:element name="myTable">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="id" msdata:AutoIncrement="true"
+type="xs:int" minOccurs="0" />
+ <xs:element name="item" type="xs:string" minOccurs="0" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:choice>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>