Pop() public method

Pop the topmost navigator and return it
public Pop ( ) : XPathNavigator
return System.Xml.XPath.XPathNavigator
コード例 #1
0
        public bool MoveNext()
        {
            if (!_navStack.IsEmpty)
            {
                while (true)
                {
                    // Move to the next matching node that is before the top node on the stack in document order
                    if (_filter.MoveToFollowing(_navCurrent, _navStack.Peek()))
                    {
                        // Found match
                        return(true);
                    }

                    // Do not include ancestor nodes as part of the preceding axis
                    _navCurrent.MoveTo(_navStack.Pop());

                    // No more preceding matches possible
                    if (_navStack.IsEmpty)
                    {
                        break;
                    }
                }
            }

            return(false);
        }
コード例 #2
0
        public bool MoveNext()
        {
            if (_stack.IsEmpty)
            {
                return(false);
            }

            _navCurrent = _stack.Pop();
            return(true);
        }
コード例 #3
0
        /// <summary>
        /// Return true if the Current property is set to the next Preceding node in reverse document order.
        /// </summary>
        public bool MoveNext()
        {
            if (stack.IsEmpty)
            {
                return(false);
            }

            this.navCurrent = stack.Pop();
            return(true);
        }
コード例 #4
0
        public IteratorResult MoveNext(XPathNavigator input)
        {
            switch (_state)
            {
            case IteratorState.NeedCandidateCurrent:
                // If there are no more input nodes, then iteration is complete
                if (input == null)
                {
                    return(IteratorResult.NoMoreNodes);
                }

                // Save input node as current node
                _navCurrent = XmlQueryRuntime.SyncToNavigator(_navCurrent, input);

                // Scan for additional input nodes within the same document (since they are after navCurrent in docorder)
                _state = IteratorState.HaveCandidateCurrent;
                return(IteratorResult.NeedInputNode);

            case IteratorState.HaveCandidateCurrent:
                // If there are no more input nodes,
                if (input == null)
                {
                    // Then candidate node has been selected, and there are no further input nodes
                    _state = IteratorState.HaveCurrentNoNext;
                }
                else
                {
                    // If the input node is in the same document as the current node,
                    if (_navCurrent.ComparePosition(input) != XmlNodeOrder.Unknown)
                    {
                        // Then update the current node and get the next input node
                        _navCurrent = XmlQueryRuntime.SyncToNavigator(_navCurrent, input);
                        return(IteratorResult.NeedInputNode);
                    }

                    // Save the input node as navNext
                    _navNext = XmlQueryRuntime.SyncToNavigator(_navNext, input);
                    _state   = IteratorState.HaveCurrentHaveNext;
                }
                PushAncestors();
                break;
            }

            if (!_navStack.IsEmpty)
            {
                while (true)
                {
                    // Move to the next matching node that is before the top node on the stack in document order
                    if (_filter.MoveToFollowing(_navCurrent, _navStack.Peek()))
                    {
                        // Found match
                        return(IteratorResult.HaveCurrentNode);
                    }

                    // Do not include ancestor nodes as part of the preceding axis
                    _navCurrent.MoveTo(_navStack.Pop());

                    // No more preceding matches possible
                    if (_navStack.IsEmpty)
                    {
                        break;
                    }
                }
            }

            if (_state == IteratorState.HaveCurrentNoNext)
            {
                // No more nodes, so iteration is complete
                _state = IteratorState.NeedCandidateCurrent;
                return(IteratorResult.NoMoreNodes);
            }

            // Make next node the current node and start trying to find input node greatest in docorder
            _navCurrent = XmlQueryRuntime.SyncToNavigator(_navCurrent, _navNext);
            _state      = IteratorState.HaveCandidateCurrent;
            return(IteratorResult.HaveCurrentNode);
        }
コード例 #5
0
        /// <summary>
        /// Position this iterator to the next content or sibling node.  Return IteratorResult.NoMoreNodes if there are
        /// no more content or sibling nodes.  Return IteratorResult.NeedInputNode if the next input node needs to be
        /// fetched first.  Return IteratorResult.HaveCurrent if the Current property is set to the next node in the
        /// iteration.
        /// </summary>
        internal IteratorResult MoveNext(XPathNavigator input, bool isContent)
        {
            switch (_state)
            {
            case IteratorState.NeedCurrent:
                // If there are no more input nodes, then iteration is complete
                if (input == null)
                {
                    return(IteratorResult.NoMoreNodes);
                }

                // Save the input node as the current node
                _navCurrent = XmlQueryRuntime.SyncToNavigator(_navCurrent, input);

                // If matching child or sibling is found, then we have a current node
                if (isContent ? _filter.MoveToContent(_navCurrent) :
                    _filter.MoveToFollowingSibling(_navCurrent))
                {
                    _state = IteratorState.HaveCurrentNeedNext;
                }

                return(IteratorResult.NeedInputNode);

            case IteratorState.HaveCurrentNeedNext:
                if (input == null)
                {
                    // There are no more input nodes, so enter HaveCurrentNoNext state and return Current
                    _state = IteratorState.HaveCurrentNoNext;
                    return(IteratorResult.HaveCurrentNode);
                }

                // Save the input node as the next node
                _navNext = XmlQueryRuntime.SyncToNavigator(_navNext, input);

                // If matching child or sibling is found,
                if (isContent ? _filter.MoveToContent(_navNext) :
                    _filter.MoveToFollowingSibling(_navNext))
                {
                    // Then compare position of current and next nodes
                    _state = IteratorState.HaveCurrentHaveNext;
                    return(DocOrderMerge());
                }

                // Input node does not result in matching child or sibling, so get next input node
                return(IteratorResult.NeedInputNode);

            case IteratorState.HaveCurrentNoNext:
            case IteratorState.HaveCurrentHaveNext:
                // If the current node has no more matching siblings,
                if (isContent ? !_filter.MoveToNextContent(_navCurrent) :
                    !_filter.MoveToFollowingSibling(_navCurrent))
                {
                    if (_navStack.IsEmpty)
                    {
                        if (_state == IteratorState.HaveCurrentNoNext)
                        {
                            // No more input nodes, so iteration is complete
                            return(IteratorResult.NoMoreNodes);
                        }

                        // Make navNext the new current node and fetch a new navNext
                        _navCurrent = XmlQueryRuntime.SyncToNavigator(_navCurrent, _navNext);
                        _state      = IteratorState.HaveCurrentNeedNext;
                        return(IteratorResult.NeedInputNode);
                    }

                    // Pop new current node from the stack
                    _navCurrent = _navStack.Pop();
                }

                // If there is no next node, then no need to call DocOrderMerge; just return the current node
                if (_state == IteratorState.HaveCurrentNoNext)
                {
                    return(IteratorResult.HaveCurrentNode);
                }

                // Compare positions of current and next nodes
                return(DocOrderMerge());
            }

            Debug.Assert(false, "Invalid IteratorState " + _state);
            return(IteratorResult.NoMoreNodes);
        }