[Mono-patches] mcs/class/System.Data/System.Data XmlSchemaDataImporter.cs,1.13,1.14 ChangeLog,1.190,1.191
Atsushi Enomoto ginga@kit.hi-ho.ne.jp
atsushi@mono-cvs.ximian.com
Thu, 20 May 2004 08:49:45 -0400 (EDT)
Update of /cvs/public/mcs/class/System.Data/System.Data
In directory mono-cvs.ximian.com:/tmp/cvs-serv8116
Modified Files:
XmlSchemaDataImporter.cs ChangeLog
Log Message:
2004-05-20 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaDataImporter.cs : Removed unused code and extra MonoTODO.
Fixed relation inference to consider attribute XPath.
Index: XmlSchemaDataImporter.cs
===================================================================
RCS file: /cvs/public/mcs/class/System.Data/System.Data/XmlSchemaDataImporter.cs,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- XmlSchemaDataImporter.cs 17 May 2004 17:01:57 -0000 1.13
+++ XmlSchemaDataImporter.cs 20 May 2004 12:49:43 -0000 1.14
@@ -531,19 +531,6 @@
return rel;
}
- /*
- private void HandleAttributes (XmlSchemaObjectCollection atts)
- {
- foreach (XmlSchemaObject attrObj in atts) {
- XmlSchemaAttribute attr = attrObj as XmlSchemaAttribute;
- if (attr != null)
- ImportColumnAttribute (attr);
- else
- HandleAttributes (((XmlSchemaAttributeGroup) attrObj).Attributes);
- }
- }
- */
-
private void ImportColumnGroupBase (XmlSchemaElement parent, XmlSchemaGroupBase gb)
{
foreach (XmlSchemaParticle p in gb.Items) {
@@ -643,7 +630,6 @@
}
}
- [MonoTODO]
private void FillDataColumnComplexElement (XmlSchemaElement parent, XmlSchemaElement el, DataColumn col)
{
if (targetElements.Contains (el))
@@ -670,7 +656,6 @@
relations.Add (rel);
}
- // FIXME: Add relation from this parent to child table
// If the element is not referenced one, the element will be handled later.
if (el.RefName == XmlQualifiedName.Empty)
targetElements.Add (el);
@@ -772,7 +757,6 @@
return;
// Handle restriction facets
- // FIXME: how to handle list and union??
XmlSchemaSimpleTypeRestriction restriction = st == null ? null : st.Content as XmlSchemaSimpleTypeRestriction;
if (restriction == null)
@@ -832,15 +816,21 @@
int i = 0;
foreach (XmlSchemaXPath Field in ic.Fields) {
string colName = Field.XPath;
- // FIXME: attribute XPath
- int index = colName.LastIndexOf (':');
+ bool isAttr = colName.Length > 0 && colName [0] == '@';
+ int index = colName.LastIndexOf (':', isAttr ? 1 : 0);
if (index > 0)
colName = colName.Substring (index + 1);
+ else if (isAttr)
+ colName = colName.Substring (1);
colName = XmlConvert.DecodeName (colName);
DataColumn col = dt.Columns [colName];
if (col == null)
throw new DataException (String.Format ("Invalid XPath selection inside field. Cannot find: {0}", tableName));
+ if (isAttr && col.ColumnMapping != MappingType.Attribute)
+ throw new DataException ("The XPath specified attribute field, but mapping type is not attribute.");
+ if (!isAttr && col.ColumnMapping != MappingType.Element)
+ throw new DataException ("The XPath specified simple element field, but mapping type is not simple element.");
cols [i] = dt.Columns [colName];
i++;
@@ -882,14 +872,21 @@
cols = new DataColumn [keyref.Fields.Count];
int i = 0;
foreach (XmlSchemaXPath Field in keyref.Fields) {
- // FIXME: attribute XPath
string colName = Field.XPath;
- int index = colName.LastIndexOf (':');
- if (index != -1)
+ bool isAttr = colName.Length > 0 && colName [0] == '@';
+ int index = colName.LastIndexOf (':', isAttr ? 1 : 0);
+ if (index > 0)
colName = colName.Substring (index + 1);
+ else if (isAttr)
+ colName = colName.Substring (1);
colName = XmlConvert.DecodeName (colName);
- cols [i] = dt.Columns [colName];
+ DataColumn col = dt.Columns [colName];
+ if (isAttr && col.ColumnMapping != MappingType.Attribute)
+ throw new DataException ("The XPath specified attribute field, but mapping type is not attribute.");
+ if (!isAttr && col.ColumnMapping != MappingType.Element)
+ throw new DataException ("The XPath specified simple element field, but mapping type is not simple element.");
+ cols [i] = col;
i++;
}
string name = keyref.Refer.Name;
Index: ChangeLog
===================================================================
RCS file: /cvs/public/mcs/class/System.Data/System.Data/ChangeLog,v
retrieving revision 1.190
retrieving revision 1.191
diff -u -d -r1.190 -r1.191
--- ChangeLog 19 May 2004 11:48:24 -0000 1.190
+++ ChangeLog 20 May 2004 12:49:43 -0000 1.191
@@ -1,3 +1,8 @@
+2004-05-20 Atsushi Enomoto <atsushi@ximian.com>
+
+ * XmlSchemaDataImporter.cs : Removed unused code and extra MonoTODO.
+ Fixed relation inference to consider attribute XPath.
+
2004-05-19 Atsushi Enomoto <atsushi@ximian.com>
* DataColumn.cs : Fixed set_Item[int]. Convert.ToInt64(DBNull.Value)