From a859f83154afe4a32b54ad0425166be1efbfd2a2 Mon Sep 17 00:00:00 2001 From: Konstantin Triger Date: Mon, 19 Feb 2007 14:12:46 +0000 Subject: [PATCH] * XmlDataReader.cs, XmlDataInferenceLoader.cs, XmlDiffLoader.cs: ignore attributes from "http://www.w3.org/XML/1998/namespace". * XmlConstants.cs: add constant for "http://www.w3.org/XML/1998/namespace". * XmlDataInferenceLoader.cs: track the added elements index to fix the added column ordinal. svn path=/trunk/mcs/; revision=73118 --- mcs/class/System.Data/System.Data/ChangeLog | 8 +++++ .../System.Data/System.Data/XmlConstants.cs | 3 ++ .../System.Data/XmlDataInferenceLoader.cs | 34 ++++++++++++++++--- .../System.Data/System.Data/XmlDataReader.cs | 6 +++- .../System.Data/System.Data/XmlDiffLoader.cs | 3 ++ .../System.Data/DataSetInferXmlSchemaTest.cs | 8 +++++ .../Test/System.Data/DataSetReadXmlTest.cs | 5 ++- 7 files changed, 59 insertions(+), 8 deletions(-) diff --git a/mcs/class/System.Data/System.Data/ChangeLog b/mcs/class/System.Data/System.Data/ChangeLog index 6521b2158d5..bd57205a7b1 100644 --- a/mcs/class/System.Data/System.Data/ChangeLog +++ b/mcs/class/System.Data/System.Data/ChangeLog @@ -1,3 +1,11 @@ +2007-02-19 Konstantin Triger + + * XmlDataReader.cs, XmlDataInferenceLoader.cs, XmlDiffLoader.cs: + ignore attributes from "http://www.w3.org/XML/1998/namespace". + * XmlConstants.cs: add constant for "http://www.w3.org/XML/1998/namespace". + * XmlDataInferenceLoader.cs: track the added elements index to fix the + added column ordinal. + 2006-12-11 Chris Toshok * DataView.cs: GetItemProperties should return an empty collection diff --git a/mcs/class/System.Data/System.Data/XmlConstants.cs b/mcs/class/System.Data/System.Data/XmlConstants.cs index b4fdd903cc6..9314805cbd3 100644 --- a/mcs/class/System.Data/System.Data/XmlConstants.cs +++ b/mcs/class/System.Data/System.Data/XmlConstants.cs @@ -49,6 +49,9 @@ internal class XmlConstants public const string SchemaNamespace = "http://www.w3.org/2001/XMLSchema"; public const string XmlnsNS = "http://www.w3.org/2000/xmlns/"; +#if NET_2_0 + public const string XmlNS = "http://www.w3.org/XML/1998/namespace"; +#endif //xs elements and values //TODO - these must exist somwhere else??? diff --git a/mcs/class/System.Data/System.Data/XmlDataInferenceLoader.cs b/mcs/class/System.Data/System.Data/XmlDataInferenceLoader.cs index 30d47cf6aae..dd1c62b2210 100644 --- a/mcs/class/System.Data/System.Data/XmlDataInferenceLoader.cs +++ b/mcs/class/System.Data/System.Data/XmlDataInferenceLoader.cs @@ -76,6 +76,9 @@ namespace System.Data public DataColumn SimpleContent; public DataColumn PrimaryKey; public DataColumn ReferenceKey; +#if NET_2_0 + public int lastElementIndex = -1; +#endif // Parent TableMapping public TableMapping ParentTable; @@ -255,6 +258,9 @@ namespace System.Data if (col != null) { if (col.ColumnMapping != MappingType.Element) throw new DataException (String.Format ("Column {0} is already mapped to {1}.", localName, col.ColumnMapping)); +#if NET_2_0 + table.lastElementIndex = table.Elements.IndexOf (col); +#endif return; } if (table.ChildTables [localName] != null) @@ -266,7 +272,11 @@ namespace System.Data col = new DataColumn (localName, typeof (string)); col.Namespace = el.NamespaceURI; col.Prefix = el.Prefix; +#if NET_2_0 + table.Elements.Insert (++table.lastElementIndex, col); +#else table.Elements.Add (col); +#endif } private void CheckExtraneousElementColumn (TableMapping parentTable, XmlElement el) @@ -347,7 +357,11 @@ namespace System.Data bool isElementRepeated = false; foreach (XmlAttribute attr in el.Attributes) { - if (attr.NamespaceURI == XmlConstants.XmlnsNS) + if (attr.NamespaceURI == XmlConstants.XmlnsNS +#if NET_2_0 + || attr.NamespaceURI == XmlConstants.XmlNS +#endif + ) continue; if (ignoredNamespaces != null && ignoredNamespaces.Contains (attr.NamespaceURI)) @@ -485,7 +499,11 @@ namespace System.Data } foreach (XmlAttribute attr in el.Attributes) { - if (attr.NamespaceURI == XmlConstants.XmlnsNS) + if (attr.NamespaceURI == XmlConstants.XmlnsNS +#if NET_2_0 + || attr.NamespaceURI == XmlConstants.XmlNS +#endif + ) continue; if (ignoredNamespaces != null && ignoredNamespaces.Contains (attr.NamespaceURI)) continue; @@ -524,7 +542,11 @@ namespace System.Data ArrayList ignoredNamespaces) { foreach (XmlAttribute attr in top.Attributes) { - if (attr.NamespaceURI == XmlConstants.XmlnsNS) + if (attr.NamespaceURI == XmlConstants.XmlnsNS +#if NET_2_0 + || attr.NamespaceURI == XmlConstants.XmlNS +#endif + ) continue; if (ignoredNamespaces != null && ignoredNamespaces.Contains (attr.NamespaceURI)) @@ -551,7 +573,11 @@ namespace System.Data private bool IsPossibleColumnElement (XmlElement el) { foreach (XmlAttribute attr in el.Attributes) { - if (attr.NamespaceURI == XmlConstants.XmlnsNS) + if (attr.NamespaceURI == XmlConstants.XmlnsNS +#if NET_2_0 + || attr.NamespaceURI == XmlConstants.XmlNS +#endif + ) continue; return false; } diff --git a/mcs/class/System.Data/System.Data/XmlDataReader.cs b/mcs/class/System.Data/System.Data/XmlDataReader.cs index 8cc749699f4..afffe10c476 100644 --- a/mcs/class/System.Data/System.Data/XmlDataReader.cs +++ b/mcs/class/System.Data/System.Data/XmlDataReader.cs @@ -193,7 +193,11 @@ namespace System.Data // Consume attributes if (reader.MoveToFirstAttribute ()) { do { - if (reader.NamespaceURI == XmlConstants.XmlnsNS) + if (reader.NamespaceURI == XmlConstants.XmlnsNS +#if NET_2_0 + || reader.NamespaceURI == XmlConstants.XmlNS +#endif + ) continue; ReadElementAttribute (row); } while (reader.MoveToNextAttribute ()); diff --git a/mcs/class/System.Data/System.Data/XmlDiffLoader.cs b/mcs/class/System.Data/System.Data/XmlDiffLoader.cs index 45efcb97dfa..2c7e085f15b 100644 --- a/mcs/class/System.Data/System.Data/XmlDiffLoader.cs +++ b/mcs/class/System.Data/System.Data/XmlDiffLoader.cs @@ -229,6 +229,9 @@ namespace System.Data { do { switch (reader.NamespaceURI) { case XmlConstants.XmlnsNS: +#if NET_2_0 + case XmlConstants.XmlNS: +#endif case XmlConstants.DiffgrNamespace: case XmlConstants.MsdataNamespace: case XmlConstants.MspropNamespace: diff --git a/mcs/class/System.Data/Test/System.Data/DataSetInferXmlSchemaTest.cs b/mcs/class/System.Data/Test/System.Data/DataSetInferXmlSchemaTest.cs index 8c513409c4a..fbbcf38e34c 100644 --- a/mcs/class/System.Data/Test/System.Data/DataSetInferXmlSchemaTest.cs +++ b/mcs/class/System.Data/Test/System.Data/DataSetInferXmlSchemaTest.cs @@ -324,9 +324,17 @@ namespace MonoTests.System.Data DataSet ds = GetDataSet (xml11, null); AssertDataSet ("ds", ds, "NewDataSet", 1, 0); DataTable dt = ds.Tables [0]; +#if NET_2_0 + AssertDataTable ("dt", dt, "root", 1, 0, 0, 0, 0, 0); +#else AssertDataTable ("dt", dt, "root", 2, 0, 0, 0, 0, 0); +#endif AssertDataColumn ("element", dt.Columns [0], "child_after_significant_space", true, false, 0, 1, "child_after_significant_space", MappingType.Element, typeof (string), DBNull.Value, String.Empty, -1, String.Empty, 0, String.Empty, false, false); +#if NET_2_0 + Assert.AreEqual (1, dt.Columns.Count, "xml:space is not treated as column"); +#else AssertDataColumn ("xml:space", dt.Columns [1], "space", true, false, 0, 1, "space", MappingType.Attribute, typeof (string), DBNull.Value, String.Empty, -1, "http://www.w3.org/XML/1998/namespace", 1, "xml", false, false); +#endif } [Test] diff --git a/mcs/class/System.Data/Test/System.Data/DataSetReadXmlTest.cs b/mcs/class/System.Data/Test/System.Data/DataSetReadXmlTest.cs index b0ef8216d90..15b91f0ec83 100644 --- a/mcs/class/System.Data/Test/System.Data/DataSetReadXmlTest.cs +++ b/mcs/class/System.Data/Test/System.Data/DataSetReadXmlTest.cs @@ -669,9 +669,6 @@ namespace MonoTests.System.Data } [Test] // bug #80045 -#if NET_2_0 - [Category ("NotWorking")] -#endif public void ColumnOrder () { string xml = "" + @@ -712,7 +709,9 @@ namespace MonoTests.System.Data } [Test] // bug #80048 +#if NET_1_1 [Category ("NotWorking")] +#endif public void XmlSpace () { string xml = "" + -- 2.25.1