/// <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; }
public virtual bool MoveToFollowing(XPathNodeType type, XPathNavigator end) { XPathNavigator other = this.Clone(); int contentKindMask = GetContentKindMask(type); if (end != null) { switch (end.NodeType) { case XPathNodeType.Attribute: case XPathNodeType.Namespace: end = end.Clone(); end.MoveToNonDescendant(); break; } } switch (this.NodeType) { case XPathNodeType.Attribute: case XPathNodeType.Namespace: if (this.MoveToParent()) { break; } return false; } Label_005C: if (!this.MoveToFirstChild()) { do { if (this.MoveToNext()) { goto Label_007E; } } while (this.MoveToParent()); this.MoveTo(other); return false; } Label_007E: if ((end != null) && this.IsSamePosition(end)) { this.MoveTo(other); return false; } if (((((int) 1) << this.NodeType) & contentKindMask) == 0) { goto Label_005C; } return true; }
public virtual bool MoveToFollowing(XPathNodeType type, XPathNavigator end) { XPathNavigator navSave = Clone(); int mask = XPathNavigatorEx.GetContentKindMask(type); if (end != null) { switch (end.NodeType) { case XPathNodeType.Attribute: case XPathNodeType.Namespace: // Scan until we come to the next content-typed node // after the attribute or namespace node end = end.Clone(); end.MoveToNonDescendant(); break; } } switch (NodeType) { case XPathNodeType.Attribute: case XPathNodeType.Namespace: if (!MoveToParent()) { return false; } break; } do { if (!MoveToFirstChild()) { // Look for next sibling while (true) { if (MoveToNext()) break; if (!MoveToParent()) { // Restore previous position and return false MoveTo(navSave); return false; } } } // Have we reached the end of the scan? if (end != null && IsSamePosition(end)) { // Restore previous position and return false MoveTo(navSave); return false; } } while (((1 << (int)NodeType) & mask) == 0); return true; }
public virtual bool MoveToFollowing(string localName, string namespaceURI, XPathNavigator end) { XPathNavigator other = this.Clone(); if (end != null) { switch (end.NodeType) { case XPathNodeType.Attribute: case XPathNodeType.Namespace: end = end.Clone(); end.MoveToNonDescendant(); break; } } switch (this.NodeType) { case XPathNodeType.Attribute: case XPathNodeType.Namespace: if (this.MoveToParent()) { break; } return false; } Label_0055: if (!this.MoveToFirstChild()) { do { if (this.MoveToNext()) { goto Label_0077; } } while (this.MoveToParent()); this.MoveTo(other); return false; } Label_0077: if ((end != null) && this.IsSamePosition(end)) { this.MoveTo(other); return false; } if (((this.NodeType != XPathNodeType.Element) || (localName != this.LocalName)) || (namespaceURI != this.NamespaceURI)) { goto Label_0055; } return true; }
public virtual bool MoveToFollowing(string localName, string namespaceURI, XPathNavigator end) { XPathNavigator navSave = Clone(); if (end != null) { switch (end.NodeType) { case XPathNodeType.Attribute: case XPathNodeType.Namespace: // Scan until we come to the next content-typed node // after the attribute or namespace node end = end.Clone(); end.MoveToNonDescendant(); break; } } switch (NodeType) { case XPathNodeType.Attribute: case XPathNodeType.Namespace: if (!MoveToParent()) { return false; } break; } do { if (!MoveToFirstChild()) { // Look for next sibling while (true) { if (MoveToNext()) break; if (!MoveToParent()) { // Restore previous position and return false MoveTo(navSave); return false; } } } // Have we reached the end of the scan? if (end != null && IsSamePosition(end)) { // Restore previous position and return false MoveTo(navSave); return false; } } while (NodeType != XPathNodeType.Element || localName != LocalName || namespaceURI != NamespaceURI); return true; }