System.Xml.Xsl.Runtime.XPathFollowingIterator.MoveFirst C# (CSharp) Method

MoveFirst() static private method

Position "nav" to the matching node which follows it in document order but is not a descendant node. Return false if this is no such matching node.
static private MoveFirst ( XmlNavigatorFilter filter, XPathNavigator nav ) : bool
filter XmlNavigatorFilter
nav System.Xml.XPath.XPathNavigator
return bool
        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;
        }
    }

Usage Example

Exemplo n.º 1
0
        private IteratorResult MoveFirst()
        {
            Debug.Assert(_state == IteratorState.HaveCurrentHaveNext || _state == IteratorState.HaveCurrentNoNext);

            if (!XPathFollowingIterator.MoveFirst(_filter, _navCurrent))
            {
                return(MoveFailed());
            }

            return(IteratorResult.HaveCurrentNode);
        }
XPathFollowingIterator