public Push ( |
||
nav | ||
return | void |
/// <summary> /// If the context node-set returns a node that is contained in the subtree of the previous node, /// then returning children of each node in "natural" order may not correspond to document order. /// Therefore, in order to guarantee document order, keep a stack in order to push the sibling of /// ancestor nodes. These siblings will not be returned until all of the descendants' children are /// returned first. /// </summary> private IteratorResult DocOrderMerge() { XmlNodeOrder cmp; Debug.Assert(_state == IteratorState.HaveCurrentHaveNext); // Compare location of navCurrent with navNext cmp = _navCurrent.ComparePosition(_navNext); // If navCurrent is before navNext in document order, // If cmp = XmlNodeOrder.Unknown, then navCurrent is before navNext (since input is is doc order) if (cmp == XmlNodeOrder.Before || cmp == XmlNodeOrder.Unknown) { // Then navCurrent can be returned (it is guaranteed to be first in document order) return(IteratorResult.HaveCurrentNode); } // If navCurrent is after navNext in document order, then delay returning navCurrent // Otherwise, discard navNext since it is positioned to the same node as navCurrent if (cmp == XmlNodeOrder.After) { _navStack.Push(_navCurrent); _navCurrent = _navNext; _navNext = null; } // Need next input node _state = IteratorState.HaveCurrentNeedNext; return(IteratorResult.NeedInputNode); }
private void PushAncestors() { _navStack.Reset(); do { _navStack.Push(_navCurrent.Clone()); }while (_navCurrent.MoveToParent()); // Pop the root of the tree, since MoveToFollowing calls will never return it _navStack.Pop(); }
/// <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()); } }
/// <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()); } }
private void PushAncestors() { Debug.Assert(_state == IteratorState.HaveCurrentHaveNext || _state == IteratorState.HaveCurrentNoNext); _navStack.Reset(); do { _navStack.Push(_navCurrent.Clone()); }while (_navCurrent.MoveToParent()); // Pop the root of the tree, since MoveToFollowing calls will never return it _navStack.Pop(); }
public void Create(XPathNavigator context, XmlNavigatorFilter filter) { // Start at root, which is always first node in the document _navCurrent = XmlQueryRuntime.SyncToNavigator(_navCurrent, context); _navCurrent.MoveToRoot(); _stack.Reset(); // If root node is not the ending node, if (!_navCurrent.IsSamePosition(context)) { // Push root onto the stack if it is not filtered if (!filter.IsFiltered(_navCurrent)) { _stack.Push(_navCurrent.Clone()); } // Push all matching nodes onto stack while (filter.MoveToFollowing(_navCurrent, context)) { _stack.Push(_navCurrent.Clone()); } } }
/// <summary> /// Initialize the NamespaceIterator. /// </summary> public void Create(XPathNavigator context) { // Push all of context's in-scope namespaces onto a stack in order to return them in document order // (MoveToXXXNamespace methods return namespaces in reverse document order) _navStack.Reset(); if (context.MoveToFirstNamespace(XPathNamespaceScope.All)) { do { // Don't return the default namespace undeclaration if (context.LocalName.Length != 0 || context.Value.Length != 0) { _navStack.Push(context.Clone()); } }while (context.MoveToNextNamespace(XPathNamespaceScope.All)); context.MoveToParent(); } }