internal bool MoveToNextNamespace(XPathNamespaceScope namespaceScope)
{
RealFoliate();
Debug.Assert(_parentOfNS != null);
XmlNode node = _node;
//first check within the same boundelement
if (_column != null)
{
Debug.Assert(_column.Namespace == StrReservedXmlns);
if (namespaceScope == XPathNamespaceScope.Local && _parentOfNS != _node) //already outside scope
return false;
XmlBoundElement be = _node as XmlBoundElement;
Debug.Assert(be != null);
DataRow curRow = be.Row;
Debug.Assert(curRow != null);
DataColumn curCol = PreviousColumn(curRow, _column, true);
while (curCol != null)
{
if (curCol.Namespace == StrReservedXmlns)
{
MoveTo(be, curCol, false);
return true;
}
curCol = PreviousColumn(curRow, curCol, true);
}
//didn't find it in this loop
if (namespaceScope == XPathNamespaceScope.Local)
return false;
//try its ancesstor
do
{
node = node.ParentNode;
} while (node != null && node.NodeType != XmlNodeType.Element);
}
else if (_node.NodeType == XmlNodeType.Attribute)
{
XmlAttribute attr = (XmlAttribute)(_node);
Debug.Assert(attr != null);
node = attr.OwnerElement;
if (node == null)
return false;
if (namespaceScope == XPathNamespaceScope.Local && _parentOfNS != node) //already outside scope
return false;
if (MoveToNextNamespace((XmlBoundElement)node, null, attr))
return true;
//didn't find it
if (namespaceScope == XPathNamespaceScope.Local)
return false;
do
{
node = node.ParentNode;
} while (node != null && node.NodeType != XmlNodeType.Element);
}
// till now, node should be the next accesstor (bound) element of the element parent of current namespace node (attribute or data column)
while (node != null)
{
//try the namespace attributes from the same element
XmlBoundElement be = node as XmlBoundElement;
if (MoveToNextNamespace(be, null, null))
return true;
//no more namespace attribute under the same element
do
{
node = node.ParentNode;
} while (node != null && node.NodeType == XmlNodeType.Element);
}
//didn't find the next namespace, thus return
if (namespaceScope == XPathNamespaceScope.All)
{
MoveTo(_doc._attrXml, null, false);
return true;
}
return false;
}