Fix some bugs in recognizing the kind of xml we are parsing.
authorEran Domb <eran@mono-cvs.ximian.com>
Sun, 8 Feb 2004 10:11:31 +0000 (10:11 -0000)
committerEran Domb <eran@mono-cvs.ximian.com>
Sun, 8 Feb 2004 10:11:31 +0000 (10:11 -0000)
svn path=/trunk/mcs/; revision=22875

mcs/class/System.Data/System.Data/ChangeLog
mcs/class/System.Data/System.Data/DataSet.cs

index 2b6bf0005cfcb20448aa11b22d02da86ad81ff6d..64e1d113ab7cf2986db01a1a6c6da0f88bea1232 100644 (file)
@@ -1,3 +1,7 @@
+2004-02-08 Eran Domb <erand@mainsoft.com>
+
+       * DataSet.cs: Fix some bugs in ReadXml().
+
 2004-02-04 Lluis Sanchez Gual <lluis@ximian.com>
 
        * DataSet.cs: Added missing method that broke the build.
index 82ebd6d17e1ab91e9662e37babc4f5d54c811349..dd63a062564f3d3e535fc46a26648286b7c73a58 100644 (file)
@@ -786,20 +786,39 @@ namespace System.Data {
                        if (r.LocalName == "xml")
                                r.MoveToContent();
 
-                       /*\
-                        *  If document is diffgram we will use diffgram
-                       \*/
-                       if (r.LocalName == "diffgram")
+                       // The document can be diffgram if :
+                       // 1. The first element is diffgram.
+                       if (r.LocalName == "diffgram") {
+                               return ReadXml (r, XmlReadMode.DiffGram);
+                       }
+
+                       bool schemaRead = false;
+                       if (r.LocalName == "schema") {
+                               ReadXmlSchema (r);
+                               r.MoveToContent();
+                               schemaRead = true;
+                       }
+                       
+                       // If we read the schema the next element can be a diffgram
+                       // that is what happen in web services soap message.
+                       if (schemaRead && r.LocalName == "diffgram") {
                                return ReadXml (r, XmlReadMode.DiffGram);
+                       }
                        
                        // Get the DataSet name.
+                       // if this xml is not diffgram then the first element will be the 
+                       // DataSet name.
                        string dataSetName = XmlConvert.DecodeName (r.LocalName);
                        DataSetName = dataSetName;
                        
                        r.ReadStartElement ();
                        r.MoveToContent();
                        
-                       bool schemaRead = false;
+                       
+                       // After reading the dataset name there can be three scenarios:
+                       // 1. The next part will be the schema of the dataset.
+                       // 2. The next part will be the data of the dataset using diffgram.
+                       // 3. The next part will be the data of tha dataset without diffgram.
                        // Check if the current element is the schema
                        if (r.LocalName == "schema") {
                                ReadXmlSchema (r);
@@ -807,17 +826,19 @@ namespace System.Data {
                                schemaRead = true;
                        }
                        
+                       // check if the data was written in a diffgram mode.
                        if (r.LocalName == "diffgram") {
                                return ReadXml (r, XmlReadMode.DiffGram);
                        }
                        
-                       // If the schema has been read we should read the rest of the document
+                       // If the schema has been read we should read the rest data of the dataset
+                       // with ignoreschema mode.
                        if (schemaRead) {
                                ReadXml (r, XmlReadMode.IgnoreSchema, false);
                                return XmlReadMode.ReadSchema;
                        }
                        
-                       // Read with inferschema.
+                       // Read the data of the dataset with inferschema.
                        return ReadXml (r, XmlReadMode.InferSchema, false);
 
                }