Browse Source

2008-06-12 Atsushi Enomoto <[email protected]>

	* DataSet.cs, DataTable.cs, XmlSchemaDataImporter.cs : constraints
	  on missing tables are ignored when reading a DataTable schema.
	  Fixes part of DataTableTest.ReadXmlSchema() test.


svn path=/trunk/mcs/; revision=105688
Atsushi Eno 17 years ago
parent
commit
78dab26aa2

+ 12 - 6
mcs/class/System.Data/System.Data/ChangeLog

@@ -1,3 +1,9 @@
+2008-06-12  Atsushi Enomoto  <[email protected]>
+
+	* DataSet.cs, DataTable.cs, XmlSchemaDataImporter.cs : constraints
+	  on missing tables are ignored when reading a DataTable schema.
+	  Fixes part of DataTableTest.ReadXmlSchema() test.
+
 2008-05-30  Marek Habersack  <[email protected]>
 
 	* Constraint.cs: do not use synthetized event accessors (to avoid
@@ -252,7 +258,7 @@
 	* DataTable.cs (WriteXmlSchema): Using XmlTextWriter instead of
 	XmlWriter, solved the File Sharing IO Exception.
 
-2006-11-28 	Hubert FONGARNAND, Frédéric Mestayer <[email protected]>
+2006-11-28 	Hubert FONGARNAND, FrAcdAcric Mestayer <[email protected]>
 
 	* DataColumnCollection.cs : Improved Column searching when not
 	using exact column name (case sensitivity). Fixes bug # 80075.
@@ -3097,7 +3103,7 @@
 	* IDataSources.cs:
 		New 1.2 class added
 
-2003-11-21  Pedro Martínez Juliá  <[email protected]>
+2003-11-21  Pedro Martinez Julia  <[email protected]>
 
 	* DataRow.cs: Detached row can be accesible (new rows from data
 	table are detached). Closes but #51263.
@@ -3111,7 +3117,7 @@
 	*UniqueConstraint.cs : throw correct exception.
 	
 
-2003-11-09  Pedro Martínez Juliá  <[email protected]>
+2003-11-09  Pedro Martinez Julia  <[email protected]>
 
 	* DataRow.cs: Use RemoveInternal instead of Remove because the last
 	one uses Delete and AcceptChanges.
@@ -3120,7 +3126,7 @@
 	method from the row are called. Added an internal method that will
 	be used by DataRow to "physically" remove the row from the list.
 
-2003-11-09  Pedro Martínez Juliá  <[email protected]>
+2003-11-09  Pedro Martinez Julia  <[email protected]>
 
 	* DataRowCollection.cs: To follow the specification: Remove and
 	RemoveAt should remove the row. But needed to call DeletingDataRow
@@ -3129,7 +3135,7 @@
 	* DataRow.cs: Don't call DeletingDataRow when it is called by the
 	method Table.Rows.Remove.
 
-2003-11-09  Pedro Martínez Juliá  <[email protected]>
+2003-11-09  Pedro Martinez Julia  <[email protected]>
 
 	* DataRowCollection.cs: Make the row be deleted by itself. If not,
 	it fails because we need to call OnRowDeleting and OnRowDeleted. It
@@ -3682,7 +3688,7 @@
 	is added to collection before it hava TableName. So using 
 	HashTable is impossible.
 	
-2002-11-19  Carlos Guzmán Álvarez <[email protected]>
+2002-11-19  Carlos Guzman Alvarez <[email protected]>
 
 	* DataRow.cs: an object that is equal to null 
 	should be allowed to be set in this indexer too

+ 1 - 1
mcs/class/System.Data/System.Data/DataSet.cs

@@ -949,7 +949,7 @@ namespace System.Data
 		public void ReadXmlSchema (XmlReader reader)
 		{
 #if true
-			new XmlSchemaDataImporter (this, reader).Process ();
+			new XmlSchemaDataImporter (this, reader, true).Process ();
 #else
 			XmlSchemaMapper SchemaMapper = new XmlSchemaMapper (this);
 			SchemaMapper.Read (reader);

+ 1 - 1
mcs/class/System.Data/System.Data/DataTable.cs

@@ -2208,7 +2208,7 @@ namespace System.Data {
 				return;
 
 			DataSet ds = new DataSet ();
-			new XmlSchemaDataImporter (ds, reader).Process ();
+			new XmlSchemaDataImporter (ds, reader, false).Process ();
 			DataTable target = null;
 			if (TableName == String.Empty) {
 				if (ds.Tables.Count > 0)

+ 10 - 3
mcs/class/System.Data/System.Data/XmlSchemaDataImporter.cs

@@ -304,6 +304,7 @@ namespace System.Data
 		#region Fields
 
 		DataSet dataset;
+		bool forDataSet;
 		XmlSchema schema;
 
 		ArrayList relations = new ArrayList ();
@@ -324,9 +325,10 @@ namespace System.Data
 
 		// .ctor()
 
-		public XmlSchemaDataImporter (DataSet dataset, XmlReader reader)
+		public XmlSchemaDataImporter (DataSet dataset, XmlReader reader, bool forDataSet)
 		{
 			this.dataset = dataset;
+			this.forDataSet = forDataSet;
 			dataset.DataSetName = "NewDataSet"; // Initialize always
 			schema = XmlSchema.Read (reader, null);
 			if (reader.NodeType == XmlNodeType.EndElement && reader.LocalName == "schema" && reader.NamespaceURI == XmlSchema.Namespace)
@@ -1037,8 +1039,13 @@ namespace System.Data
 			string tableName = c.TableName;
 			
 			DataTable dt = dataset.Tables [tableName];
-			if (dt == null)
-				throw new DataException (String.Format ("Invalid XPath selection inside selector. Cannot find: {0}", tableName));
+			if (dt == null) {
+				if (forDataSet)
+					throw new DataException (String.Format ("Invalid XPath selection inside selector. Cannot find: {0}", tableName));
+				else
+					// nonexistent table name. .NET ignores it for DataTable.ReadXmlSchema().
+					return;
+			}
 
 			DataColumn [] cols = new DataColumn [c.Columns.Length];
 			for (int i = 0; i < cols.Length; i++) {