Example #1
0
 public void Create(XPathNavigator input, XmlNavigatorFilter filter)
 {
     // Save input node as current node
     _navCurrent = XmlQueryRuntime.SyncToNavigator(_navCurrent, input);
     _filter     = filter;
     PushAncestors();
 }
Example #2
0
 public void Create(XPathNavigator input, XmlNavigatorFilter filter)
 {
     // Save input node as current node
     _navCurrent = XmlQueryRuntime.SyncToNavigator(_navCurrent, input);
     _filter     = filter;
     _needFirst  = true;
 }
Example #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));
        }
Example #4
0
        /// <summary>
        /// There are a limited number of types, so create all possible XmlNavTypeFilter objects just once.
        /// </summary>
        private static XmlNavigatorFilter[] CreateTypeFilters()
        {
            var filters = new XmlNavigatorFilter[(int)XPathNodeType.Comment + 1];

            filters[(int)XPathNodeType.Element] = new XmlNavTypeFilter(XPathNodeType.Element);
            filters[(int)XPathNodeType.Text]    = new XmlNavTypeFilter(XPathNodeType.Text);
            filters[(int)XPathNodeType.ProcessingInstruction] = new XmlNavTypeFilter(XPathNodeType.ProcessingInstruction);
            filters[(int)XPathNodeType.Comment] = new XmlNavTypeFilter(XPathNodeType.Comment);
            return(filters);
        }
Example #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));
        }
        /// <summary>
        /// Initialize the XPathPrecedingIterator (no possibility of duplicates).
        /// </summary>
        public void Create(XPathNavigator context, XmlNavigatorFilter filter)
        {
            XPathPrecedingDocOrderIterator wrapped = new XPathPrecedingDocOrderIterator();

            wrapped.Create(context, filter);

            // Fetch all preceding nodes in document order and push them onto the stack
            while (wrapped.MoveNext())
            {
                stack.Push(wrapped.Current.Clone());
            }
        }
Example #7
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);
        }
        /// <summary>
        /// Initialize the AncestorDocOrderIterator (return ancestor nodes in document order, no possibility of duplicates).
        /// </summary>
        public void Create(XPathNavigator context, XmlNavigatorFilter filter, bool orSelf)
        {
            AncestorIterator wrapped = new AncestorIterator();

            wrapped.Create(context, filter, orSelf);

            // Fetch all ancestor nodes in reverse document order and push them onto the stack
            while (wrapped.MoveNext())
            {
                stack.Push(wrapped.Current.Clone());
            }
        }
        /// <summary>
        /// Initialize the DescendantIterator (no possibility of duplicates).
        /// </summary>
        public void Create(XPathNavigator input, XmlNavigatorFilter filter, bool orSelf) {
            // Save input node as current node
            this.navCurrent = XmlQueryRuntime.SyncToNavigator(this.navCurrent, input);
            this.filter = filter;

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

            // If self node matches, then return it first
            this.hasFirst = (orSelf && !this.filter.IsFiltered(this.navCurrent));
        }
Example #10
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;
            }
        }
Example #11
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));
        }
Example #12
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());
                }
            }
        }
        /// <summary>
        /// Initialize the AncestorIterator.
        /// </summary>
        public void Create(XPathNavigator context, XmlNavigatorFilter filter, bool orSelf) {
            this.filter = filter;

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

            // If self node matches, then next call to MoveNext() should return it
            // Otherwise, MoveNext() will fetch next ancestor
            this.haveCurrent = (orSelf && !this.filter.IsFiltered(this.navCurrent));
        }
        /// <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));
        }
Example #16
0
 /// <summary>
 /// Initialize the DescendantIterator (merge multiple sets of descendant nodes in document order and remove duplicates).
 /// </summary>
 public void Create(XmlNavigatorFilter filter, bool orSelf)
 {
     _filter = filter;
     _state = IteratorState.NoPrevious;
     _orSelf = orSelf;
 }
 /// <summary>
 /// Initialize the DescendantIterator (merge multiple sets of descendant nodes in document order and remove duplicates).
 /// </summary>
 public void Create(XmlNavigatorFilter filter, bool orSelf)
 {
     this.filter = filter;
     this.state  = IteratorState.NoPrevious;
     this.orSelf = orSelf;
 }
 /// <summary>
 /// Initialize the XPathPrecedingDocOrderIterator (return preceding nodes in document order, no possibility of duplicates).
 /// </summary>
 public void Create(XPathNavigator input, XmlNavigatorFilter filter) {
     // Save input node as current node
     this.navCurrent = XmlQueryRuntime.SyncToNavigator(this.navCurrent, input);
     this.filter = filter;
     PushAncestors();
 }
        /// <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());
            }
        }
        /// <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;
        }
        /// <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);
        }
        /// <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;
            }
        }
Example #23
0
 /// <summary>
 /// Initialize the FollowingSiblingMergeIterator.
 /// </summary>
 public void Create(XmlNavigatorFilter filter)
 {
     this.wrapped.Create(filter);
 }
Example #24
0
 /// <summary>
 /// Initialize the ContentMergeIterator (merge multiple sets of content nodes in document order and remove duplicates).
 /// </summary>
 public void Create(XmlNavigatorFilter filter) {
     this.filter = filter;
     this.navStack.Reset();
     this.state = IteratorState.NeedCurrent;
 }
Example #25
0
 /// <summary>
 /// Initialize the ContentMergeIterator (merge multiple sets of content nodes in document order and remove duplicates).
 /// </summary>
 public void Create(XmlNavigatorFilter filter)
 {
     _filter = filter;
     _navStack.Reset();
     _state = IteratorState.NeedCurrent;
 }
Example #26
0
 /// <summary>
 /// Initialize the ContentMergeIterator (merge multiple sets of content nodes in document order and remove duplicates).
 /// </summary>
 public void Create(XmlNavigatorFilter filter)
 {
     this.filter = filter;
     this.navStack.Reset();
     this.state = IteratorState.NeedCurrent;
 }
        /// <summary>
        /// Initialize the AncestorDocOrderIterator (return ancestor nodes in document order, no possibility of duplicates).
        /// </summary>
        public void Create(XPathNavigator context, XmlNavigatorFilter filter, bool orSelf) {
            AncestorIterator wrapped = new AncestorIterator();

            wrapped.Create(context, filter, orSelf);

            // Fetch all ancestor nodes in reverse document order and push them onto the stack
            while (wrapped.MoveNext())
                stack.Push(wrapped.Current.Clone());
        }
 /// <summary>
 /// Initialize the XPathFollowingIterator (no possibility of duplicates).
 /// </summary>
 public void Create(XPathNavigator input, XmlNavigatorFilter filter) {
     // Save input node as current node
     this.navCurrent = XmlQueryRuntime.SyncToNavigator(this.navCurrent, input);
     this.filter = filter;
     this.needFirst = true;
 }
Example #29
0
 /// <summary>
 /// Initialize the FollowingSiblingIterator.
 /// </summary>
 public void Create(XPathNavigator context, XmlNavigatorFilter filter)
 {
     this.navCurrent = XmlQueryRuntime.SyncToNavigator(this.navCurrent, context);
     this.filter     = filter;
 }
 /// <summary>
 /// Initialize the FollowingSiblingMergeIterator.
 /// </summary>
 public void Create(XmlNavigatorFilter filter) {
     this.wrapped.Create(filter);
 }
Example #31
0
 public void Create(XmlNavigatorFilter filter)
 {
     _filter = filter;
     _state  = IteratorState.NeedCandidateCurrent;
 }
        /// <summary>
        /// Initialize the XPathPrecedingIterator (no possibility of duplicates).
        /// </summary>
        public void Create(XPathNavigator context, XmlNavigatorFilter filter) {
            XPathPrecedingDocOrderIterator wrapped = new XPathPrecedingDocOrderIterator();

            wrapped.Create(context, filter);

            // Fetch all preceding nodes in document order and push them onto the stack
            while (wrapped.MoveNext())
                stack.Push(wrapped.Current.Clone());
        }
Example #33
0
 public void Create(XmlNavigatorFilter filter, bool orSelf)
 {
     _filter = filter;
     _state  = IteratorState.NoPrevious;
     _orSelf = orSelf;
 }
 /// <summary>
 /// Initialize the XPathPrecedingMergeIterator (merge multiple sets of preceding nodes in document order and remove duplicates).
 /// </summary>
 public void Create(XmlNavigatorFilter filter) {
     this.filter = filter;
     this.state = IteratorState.NeedCandidateCurrent;
 }
 /// <summary>
 /// Initialize the PrecedingSiblingIterator.
 /// </summary>
 public void Create(XPathNavigator context, XmlNavigatorFilter filter) {
     this.navCurrent = XmlQueryRuntime.SyncToNavigator(this.navCurrent, context);
     this.filter = filter;
 }
 /// <summary>
 /// Initialize the DescendantIterator (merge multiple sets of descendant nodes in document order and remove duplicates).
 /// </summary>
 public void Create(XmlNavigatorFilter filter, bool orSelf) {
     this.filter = filter;
     this.state = IteratorState.NoPrevious;
     this.orSelf = orSelf;
 }
Example #37
0
 /// <summary>
 /// Initialize the ContentMergeIterator (merge multiple sets of content nodes in document order and remove duplicates).
 /// </summary>
 public void Create(XmlNavigatorFilter filter)
 {
     _filter = filter;
     _navStack.Reset();
     _state = IteratorState.NeedCurrent;
 }