internal bool MoveToNamespace(string name)
{
_parentOfNS = _node as XmlBoundElement;
//only need to check with _node, even if _column is not null and its mapping type is element, it can't have attributes
if (_parentOfNS == null)
return false;
string attrName = name;
if (attrName == "xmlns")
attrName = "xmlns:xmlns";
if (attrName != null && attrName.Length == 0)
attrName = "xmlns";
RealFoliate();
XmlNode node = _node;
XmlNodeType nt = node.NodeType;
XmlAttribute attr = null;
XmlBoundElement be = null;
while (node != null)
{
//check current element node
be = node as XmlBoundElement;
if (be != null)
{
if (be.IsFoliated)
{
attr = be.GetAttributeNode(name, StrReservedXmlns);
if (attr != null)
{
MoveTo(attr);
return true;
}
}
else
{//defoliated so that we need to search through its column
DataRow curRow = be.Row;
if (curRow == null)
return false;
//going through its attribute columns
DataColumn curCol = PreviousColumn(curRow, null, true);
while (curCol != null)
{
if (curCol.Namespace == StrReservedXmlns && curCol.ColumnName == name)
{
MoveTo(be, curCol, false);
return true;
}
curCol = PreviousColumn(curRow, curCol, true);
}
}
}
//didn't find it, try the next element anccester.
do
{
node = node.ParentNode;
} while (node != null && node.NodeType != XmlNodeType.Element);
}
//nothing happens, the name doesn't exist as a namespace node.
_parentOfNS = null;
return false;
}