internal static bool MoveFirst(XmlNavigatorFilter filter, XPathNavigator nav) {
// Attributes and namespace nodes include descendants of their owner element in the set of following nodes
if (nav.NodeType == XPathNodeType.Attribute || nav.NodeType == XPathNodeType.Namespace) {
if (!nav.MoveToParent()) {
// Floating attribute or namespace node that has no following nodes
return false;
}
if (!filter.MoveToFollowing(nav, null)) {
// No matching following nodes
return false;
}
}
else {
// XPath spec doesn't include descendants of the input node in the following axis
if (!nav.MoveToNonDescendant())
// No following nodes
return false;
// If the sibling does not match the node-test, find the next following node that does
if (filter.IsFiltered(nav)) {
if (!filter.MoveToFollowing(nav, null)) {
// No matching following nodes
return false;
}
}
}
// Success
return true;
}
}