private bool IsDataSetElement (XmlSchemaElement el)
{
if (el.UnhandledAttributes != null) {
foreach (XmlAttribute attr in el.UnhandledAttributes) {
if (attr.LocalName == "IsDataSet" &&
attr.NamespaceURI == XmlConstants.MsdataNamespace) {
switch (attr.Value) {
case "true": // case sensitive
return true;
case "false":
break;
default:
throw new DataException (String.Format ("Value {0} is invalid for attribute 'IsDataSet'.", attr.Value));
}
}
}
}
if (schema.Elements.Count != 1)
return false;
if (!(el.SchemaType is XmlSchemaComplexType))
return false;
XmlSchemaComplexType ct = (XmlSchemaComplexType) el.SchemaType;
if (ct.AttributeUses.Count > 0)
return false;
XmlSchemaGroupBase gb = ct.ContentTypeParticle as XmlSchemaGroupBase;
if (gb == null || gb.Items.Count == 0)
return false;
foreach (XmlSchemaParticle p in gb.Items) {
if (ContainsColumn (p))
return false;
}
return true;
}