IsFiltered() public abstract method

Return true if the navigator's current node matches the filter condition.
public abstract IsFiltered ( XPathNavigator navigator ) : bool
navigator System.Xml.XPath.XPathNavigator
return bool
Exemplo n.º 1
0
        public bool MoveNext()
        {
            switch (_state)
            {
            case IteratorState.HaveCurrent:
                _state = IteratorState.NeedCurrent;
                return(true);

            case IteratorState.NeedCurrent:
                // Move to next following node which matches
                if (!_filter.MoveToFollowing(_navCurrent, _navEnd))
                {
                    // No more nodes unless ending node matches
                    if (_filter.IsFiltered(_navEnd))
                    {
                        _state = IteratorState.NoNext;
                        return(false);
                    }

                    _navCurrent.MoveTo(_navEnd);
                    _state = IteratorState.NoNext;
                }
                return(true);

            case IteratorState.HaveCurrentNoNext:
                _state = IteratorState.NoNext;
                return(true);
            }

            Debug.Assert(_state == IteratorState.NoNext, "Illegal state: " + _state);
            return(false);
        }
        /// <summary>
        /// Position this iterator to the next following node.  Return false if there are no more following nodes,
        /// or if the end node has been reached.  Return true if the Current property is set to the next node in
        /// the iteration.
        /// </summary>
        public bool MoveNext()
        {
            switch (this.state)
            {
            case IteratorState.HaveCurrent:
                this.state = IteratorState.NeedCurrent;
                return(true);

            case IteratorState.NeedCurrent:
                // Move to next following node which matches
                if (!this.filter.MoveToFollowing(this.navCurrent, this.navEnd))
                {
                    // No more nodes unless ending node matches
                    if (filter.IsFiltered(this.navEnd))
                    {
                        this.state = IteratorState.NoNext;
                        return(false);
                    }

                    this.navCurrent.MoveTo(this.navEnd);
                    this.state = IteratorState.NoNext;
                }
                return(true);

            case IteratorState.HaveCurrentNoNext:
                this.state = IteratorState.NoNext;
                return(true);
            }

            Debug.Assert(this.state == IteratorState.NoNext, "Illegal state: " + this.state);
            return(false);
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
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;
            }
        }
Exemplo n.º 5
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));
        }
Exemplo n.º 6
0
        public void Create(XPathNavigator context, XmlNavigatorFilter filter)
        {
            _filter     = filter;
            _navCurrent = XmlQueryRuntime.SyncToNavigator(_navCurrent, context);
            _navEnd     = XmlQueryRuntime.SyncToNavigator(_navEnd, context);
            _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.
            _useCompPos = _filter.IsFiltered(context);
        }
Exemplo n.º 7
0
        public bool MoveNext()
        {
            if (_haveCurrent)
            {
                _haveCurrent = false;
                return(true);
            }

            while (_navCurrent.MoveToParent())
            {
                if (!_filter.IsFiltered(_navCurrent))
                {
                    return(true);
                }
            }

            // Iteration is complete
            return(false);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Initialize the DescendantIterator (no possibility of duplicates).
        /// </summary>
        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));
        }
Exemplo n.º 9
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));
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
0
        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);
        }
        /// <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());
                }
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// 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.
        /// </summary>
        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;
        }
Exemplo n.º 14
0
        /// <summary>
        /// Initialize the ParentIterator.
        /// </summary>
        public void Create(XPathNavigator context, XmlNavigatorFilter filter) {
            // Save context node as current node
            this.navCurrent = XmlQueryRuntime.SyncToNavigator(this.navCurrent, context);

            // Attempt to find a matching parent node
            this.haveCurrent = (this.navCurrent.MoveToParent()) && (!filter.IsFiltered(this.navCurrent));
        }
Exemplo n.º 15
0
        /// <summary>
        /// Initialize the AncestorIterator.
        /// </summary>
        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));
        }
Exemplo n.º 16
0
        /// <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());
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Initialize the NodeRangeIterator (no possibility of duplicates).
        /// </summary>
        public void Create(XPathNavigator start, XmlNavigatorFilter filter, XPathNavigator end) {
            // Save start node as current node and save ending node
            this.navCurrent = XmlQueryRuntime.SyncToNavigator(this.navCurrent, start);
            this.navEnd = XmlQueryRuntime.SyncToNavigator(this.navEnd, end);
            this.filter = filter;

            if (start.IsSamePosition(end)) {
                // Start is end, so only return node if it is not filtered
                this.state = !filter.IsFiltered(start) ? IteratorState.HaveCurrentNoNext : IteratorState.NoNext;
            }
            else {
                // Return nodes until end is reached
                this.state = !filter.IsFiltered(start) ? IteratorState.HaveCurrent : IteratorState.NeedCurrent;
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Initialize the PrecedingSiblingDocOrderIterator.
        /// </summary>
        public void Create(XPathNavigator context, XmlNavigatorFilter filter)
        {
            _filter = filter;
            _navCurrent = XmlQueryRuntime.SyncToNavigator(_navCurrent, context);
            _navEnd = XmlQueryRuntime.SyncToNavigator(_navEnd, context);
            _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.
            _useCompPos = _filter.IsFiltered(context);
        }