internal bool IsRegionRadical(XmlBoundElement rowElem)
{
// You must pass a row element (which s/b associated w/ a DataRow)
Debug.Assert(rowElem.Row != null);
if (rowElem.ElementState == ElementState.Defoliated)
{
return true;
}
DataTable table = GetTableSchemaForElement(rowElem);
DataColumnCollection columns = table.Columns;
int iColumn = 0;
// check column attributes...
int cAttrs = rowElem.Attributes.Count;
for (int iAttr = 0; iAttr < cAttrs; iAttr++)
{
XmlAttribute attr = rowElem.Attributes[iAttr];
// only specified attributes are radical
if (!attr.Specified)
{
return false;
}
// only mapped attrs are valid
DataColumn schema = GetColumnSchemaForNode(rowElem, attr);
if (schema == null)
{
return false;
}
// check to see if column is in order
if (!IsNextColumn(columns, ref iColumn, schema))
{
return false;
}
// must have exactly one text node (XmlNodeType.Text) child
XmlNode fc = attr.FirstChild;
if (fc == null || fc.NodeType != XmlNodeType.Text || fc.NextSibling != null)
{
return false;
}
}
// check column elements
iColumn = 0;
XmlNode n = rowElem.FirstChild;
for (; n != null; n = n.NextSibling)
{
// only elements can exist in radically structured data
if (n.NodeType != XmlNodeType.Element)
{
return false;
}
XmlElement e = n as XmlElement;
// only checking for column mappings in this loop
if (GetRowFromElement(e) != null)
{
break;
}
// element's must have schema to be radically structured
DataColumn schema = GetColumnSchemaForNode(rowElem, e);
if (schema == null)
{
return false;
}
// check to see if column is in order
if (!IsNextColumn(columns, ref iColumn, schema))
{
return false;
}
// must have no attributes
if (e.HasAttributes)
{
return false;
}
// must have exactly one text node child
XmlNode fc = e.FirstChild;
if (fc == null || fc.NodeType != XmlNodeType.Text || fc.NextSibling != null)
{
return false;
}
}
// check for remaining sub-regions
for (; n != null; n = n.NextSibling)
{
// only elements can exist in radically structured data
if (n.NodeType != XmlNodeType.Element)
{
return false;
}
// element's must be regions in order to be radially structured
DataRow row = GetRowFromElement((XmlElement)n);
if (row == null)
{
return false;
}
}
return true;
}