SyncToNavigator() static private method

Position navThis to the same location as navThat.
static private SyncToNavigator ( XPathNavigator navigatorThis, XPathNavigator navigatorThat ) : XPathNavigator
navigatorThis System.Xml.XPath.XPathNavigator
navigatorThat System.Xml.XPath.XPathNavigator
return System.Xml.XPath.XPathNavigator
Esempio n. 1
0
 public void Create(XPathNavigator input, XmlNavigatorFilter filter)
 {
     // Save input node as current node
     _navCurrent = XmlQueryRuntime.SyncToNavigator(_navCurrent, input);
     _filter     = filter;
     _needFirst  = true;
 }
Esempio n. 2
0
 /// <summary>
 /// Initialize the NodeKindContentIterator.
 /// </summary>
 public void Create(XPathNavigator context, XPathNodeType nodeType)
 {
     Debug.Assert(nodeType != XPathNodeType.Attribute && nodeType != XPathNodeType.Namespace);
     _navCurrent = XmlQueryRuntime.SyncToNavigator(_navCurrent, context);
     _nodeType   = nodeType;
     _needFirst  = true;
 }
Esempio n. 3
0
 /// <summary>
 /// Initialize the ElementContentIterator.
 /// </summary>
 public void Create(XPathNavigator context, string localName, string ns)
 {
     this.navCurrent = XmlQueryRuntime.SyncToNavigator(this.navCurrent, context);
     this.localName  = localName;
     this.ns         = ns;
     this.needFirst  = true;
 }
Esempio n. 4
0
 public void Create(XPathNavigator input, XmlNavigatorFilter filter)
 {
     // Save input node as current node
     _navCurrent = XmlQueryRuntime.SyncToNavigator(_navCurrent, input);
     _filter     = filter;
     PushAncestors();
 }
Esempio n. 5
0
 /// <summary>
 /// Initialize the ElementContentIterator.
 /// </summary>
 public void Create(XPathNavigator context, string localName, string ns)
 {
     _navCurrent = XmlQueryRuntime.SyncToNavigator(_navCurrent, context);
     _localName  = localName;
     _ns         = ns;
     _needFirst  = true;
 }
Esempio n. 6
0
        public void Create(XPathNavigator context, XmlNavigatorFilter filter)
        {
            // Save context node as current node
            _navCurrent = XmlQueryRuntime.SyncToNavigator(_navCurrent, context);

            // Attempt to find a matching parent node
            _haveCurrent = (_navCurrent.MoveToParent()) && (!filter.IsFiltered(_navCurrent));
        }
Esempio n. 7
0
        public void Create(XPathNavigator context, XmlNavigatorFilter filter, bool orSelf)
        {
            _filter = filter;

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

            // If self node matches, then next call to MoveNext() should return it
            // Otherwise, MoveNext() will fetch next ancestor
            _haveCurrent = (orSelf && !_filter.IsFiltered(_navCurrent));
        }
Esempio n. 8
0
        /// <summary>
        /// Initialize the PrecedingSiblingDocOrderIterator.
        /// </summary>
        public void Create(XPathNavigator context, XmlNavigatorFilter filter)
        {
            this.filter     = filter;
            this.navCurrent = XmlQueryRuntime.SyncToNavigator(this.navCurrent, context);
            this.navEnd     = XmlQueryRuntime.SyncToNavigator(this.navEnd, context);
            this.needFirst  = true;

            // If the context node will be filtered out, then use ComparePosition to
            // determine when the context node has been passed by.  Otherwise, IsSamePosition
            // is sufficient to determine when the context node has been reached.
            this.useCompPos = this.filter.IsFiltered(context);
        }
Esempio n. 9
0
        public void Create(XPathNavigator start, XmlNavigatorFilter filter, XPathNavigator end)
        {
            // Save start node as current node and save ending node
            _navCurrent = XmlQueryRuntime.SyncToNavigator(_navCurrent, start);
            _navEnd     = XmlQueryRuntime.SyncToNavigator(_navEnd, end);
            _filter     = filter;

            if (start.IsSamePosition(end))
            {
                // Start is end, so only return node if it is not filtered
                _state = !filter.IsFiltered(start) ? IteratorState.HaveCurrentNoNext : IteratorState.NoNext;
            }
            else
            {
                // Return nodes until end is reached
                _state = !filter.IsFiltered(start) ? IteratorState.HaveCurrent : IteratorState.NeedCurrent;
            }
        }
Esempio n. 10
0
        public void Create(XPathNavigator input, XmlNavigatorFilter filter, bool orSelf)
        {
            // Save input node as current node
            _navCurrent = XmlQueryRuntime.SyncToNavigator(_navCurrent, input);
            _filter     = filter;

            // Position navEnd to the node at which the descendant scan should terminate
            if (input.NodeType == XPathNodeType.Root)
            {
                _navEnd = null;
            }
            else
            {
                _navEnd = XmlQueryRuntime.SyncToNavigator(_navEnd, input);
                _navEnd.MoveToNonDescendant();
            }

            // If self node matches, then return it first
            _hasFirst = (orSelf && !_filter.IsFiltered(_navCurrent));
        }
Esempio n. 11
0
        public IteratorResult MoveNext(XPathNavigator input)
        {
            if (_state != IteratorState.NeedDescendant)
            {
                if (input == null)
                {
                    return(IteratorResult.NoMoreNodes);
                }

                // Descendants of the input node will be duplicates if the input node is in the subtree
                // of the previous root.
                if (_state != IteratorState.NoPrevious && _navRoot.IsDescendant(input))
                {
                    return(IteratorResult.NeedInputNode);
                }

                // Save input node as current node and end of input's tree in navEnd
                _navCurrent = XmlQueryRuntime.SyncToNavigator(_navCurrent, input);
                _navRoot    = XmlQueryRuntime.SyncToNavigator(_navRoot, input);
                _navEnd     = XmlQueryRuntime.SyncToNavigator(_navEnd, input);
                _navEnd.MoveToNonDescendant();

                _state = IteratorState.NeedDescendant;

                // If self node matches, then return it
                if (_orSelf && !_filter.IsFiltered(input))
                {
                    return(IteratorResult.HaveCurrentNode);
                }
            }

            if (_filter.MoveToFollowing(_navCurrent, _navEnd))
            {
                return(IteratorResult.HaveCurrentNode);
            }

            // No more descendants, so transition to NeedCurrent state and get the next input node
            _state = IteratorState.NeedCurrent;
            return(IteratorResult.NeedInputNode);
        }
        /// <summary>
        /// Initialize the PrecedingIterator (no possibility of duplicates).
        /// </summary>
        public void Create(XPathNavigator context, XmlNavigatorFilter filter)
        {
            // Start at root, which is always first node in the document
            this.navCurrent = XmlQueryRuntime.SyncToNavigator(this.navCurrent, context);
            this.navCurrent.MoveToRoot();

            // If root node is not the ending node,
            if (!this.navCurrent.IsSamePosition(context))
            {
                // Push root onto the stack if it is not filtered
                if (!filter.IsFiltered(this.navCurrent))
                {
                    this.stack.Push(this.navCurrent.Clone());
                }

                // Push all matching nodes onto stack
                while (filter.MoveToFollowing(this.navCurrent, context))
                {
                    this.stack.Push(this.navCurrent.Clone());
                }
            }
        }
Esempio n. 13
0
 public void Create(XPathNavigator context, string value)
 {
     _navCurrent = XmlQueryRuntime.SyncToNavigator(_navCurrent, context);
     _idrefs     = XmlConvert.SplitString(value);
     _idx        = -1;
 }
Esempio n. 14
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);
        }
Esempio n. 15
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);

                // Still must check next input node to see if is a descendant of this one
                _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;
                    return(MoveFirst());
                }

                // If input node is in the subtree of the candidate node, then use the input node instead
                if (_navCurrent.IsDescendant(input))
                {
                    goto case IteratorState.NeedCandidateCurrent;
                }

                // Found node on which to perform following scan.  Now skip past all input nodes in the same document.
                _state = IteratorState.HaveCurrentNeedNext;
                goto case IteratorState.HaveCurrentNeedNext;

            case IteratorState.HaveCurrentNeedNext:
                // 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;
                    return(MoveFirst());
                }

                // Skip input node unless it's in a different document than the node on which the following scan was performed
                if (_navCurrent.ComparePosition(input) != XmlNodeOrder.Unknown)
                {
                    return(IteratorResult.NeedInputNode);
                }

                // Next node is in a different document, so save it
                _navNext = XmlQueryRuntime.SyncToNavigator(_navNext, input);
                _state   = IteratorState.HaveCurrentHaveNext;
                return(MoveFirst());
            }

            if (!_filter.MoveToFollowing(_navCurrent, null))
            {
                return(MoveFailed());
            }

            return(IteratorResult.HaveCurrentNode);
        }
Esempio n. 16
0
 /// <summary>
 /// Initialize the ContentIterator.
 /// </summary>
 public void Create(XPathNavigator context)
 {
     _navCurrent = XmlQueryRuntime.SyncToNavigator(_navCurrent, context);
     _needFirst  = true;
 }
Esempio n. 17
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);
        }
Esempio n. 18
0
 /// <summary>
 /// Initialize the FollowingSiblingIterator.
 /// </summary>
 public void Create(XPathNavigator context, XmlNavigatorFilter filter)
 {
     this.navCurrent = XmlQueryRuntime.SyncToNavigator(this.navCurrent, context);
     this.filter     = filter;
 }