internal SeekableXPathNavigator CreateMessageNavigator(Message message, bool matchBody) { SeekableXPathNavigator navigator = message.GetNavigator(matchBody, this.maxNodes); navigator.MoveToRoot(); return(navigator); }
internal SeekableXPathNavigator CreateMessageNavigator(Message message, bool matchBody) { SeekableXPathNavigator nav = message.GetNavigator(matchBody, this.maxNodes); // Position the navigator at the root element // This allows a caller to run relative XPaths on message nav.MoveToRoot(); return(nav); }
internal Opcode Select(SeekableXPathNavigator contextNode, NodeSequence destSequence, SelectOpcode next) { Opcode opcode = next.Next; switch (this.type) { case QueryNodeType.Root: contextNode.MoveToRoot(); return(next.Eval(destSequence, contextNode)); case QueryNodeType.Element: if (contextNode.MoveToFirstChild()) { do { if ((XPathNodeType.Element == contextNode.NodeType) && this.MatchQName(contextNode)) { long currentPosition = contextNode.CurrentPosition; opcode = next.Eval(destSequence, contextNode); contextNode.CurrentPosition = currentPosition; } }while (contextNode.MoveToNext()); } return(opcode); case QueryNodeType.ChildNodes: if (contextNode.MoveToFirstChild()) { do { if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } }while (contextNode.MoveToNext()); } return(opcode); } if (QueryAxisType.Self != this.axis.Type) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected)); } if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { long num = contextNode.CurrentPosition; opcode = next.Eval(destSequence, contextNode); contextNode.CurrentPosition = num; } return(opcode); }
internal override Opcode Eval(ProcessingContext context) { // The query processor object also serves as the query document root int iterationCount = context.IterationCount; Opcode returnOpcode = this.next; // A root is always an initial step context.PushSequenceFrame(); NodeSequence seq = context.CreateSequence(); if (this.next != null && 0 != (this.next.Flags & OpcodeFlags.CompressableSelect)) { SeekableXPathNavigator node = context.Processor.ContextNode; node.MoveToRoot(); returnOpcode = this.next.Eval(seq, node); while (returnOpcode != null && 0 != (returnOpcode.Flags & OpcodeFlags.CompressableSelect)) { returnOpcode = returnOpcode.Next; } } else { // Roots do not have any qnames.. seq.StartNodeset(); SeekableXPathNavigator node = context.Processor.ContextNode; node.MoveToRoot(); seq.Add(node); seq.StopNodeset(); } if (seq.Count == 0) { context.ReleaseSequence(seq); seq = NodeSequence.Empty; } for (int i = 0; i < iterationCount; ++i) { context.PushSequence(seq); } if (iterationCount > 1) { seq.refCount += iterationCount - 1; } return(returnOpcode); }
internal override Opcode Eval(ProcessingContext context) { int iterationCount = context.IterationCount; Opcode next = base.next; context.PushSequenceFrame(); NodeSequence empty = context.CreateSequence(); if ((base.next != null) && ((base.next.Flags & OpcodeFlags.CompressableSelect) != OpcodeFlags.None)) { SeekableXPathNavigator contextNode = context.Processor.ContextNode; contextNode.MoveToRoot(); next = base.next.Eval(empty, contextNode); while ((next != null) && ((next.Flags & OpcodeFlags.CompressableSelect) != OpcodeFlags.None)) { next = next.Next; } } else { empty.StartNodeset(); SeekableXPathNavigator node = context.Processor.ContextNode; node.MoveToRoot(); empty.Add(node); empty.StopNodeset(); } if (empty.Count == 0) { context.ReleaseSequence(empty); empty = NodeSequence.Empty; } for (int i = 0; i < iterationCount; i++) { context.PushSequence(empty); } if (iterationCount > 1) { empty.refCount += iterationCount - 1; } return(next); }
internal Opcode Select(SeekableXPathNavigator contextNode, NodeSequence destSequence, SelectOpcode next) { Opcode returnOpcode = next.Next; switch (this.type) { default: if (QueryAxisType.Self == this.axis.Type) { if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { long position = contextNode.CurrentPosition; returnOpcode = next.Eval(destSequence, contextNode); contextNode.CurrentPosition = position; } } else { throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected)); } break; case QueryNodeType.ChildNodes: // Select children of arbitrary type off the context node if (contextNode.MoveToFirstChild()) { do { // Select the node if its type and qname matches if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } } while (contextNode.MoveToNext()); } break; case QueryNodeType.Element: // Select child elements if (contextNode.MoveToFirstChild()) { do { // Children could have non element nodes in line // Select the node if it is an element and the qname matches if (XPathNodeType.Element == contextNode.NodeType && this.MatchQName(contextNode)) { long position = contextNode.CurrentPosition; returnOpcode = next.Eval(destSequence, contextNode); contextNode.CurrentPosition = position; } } while (contextNode.MoveToNext()); } break; case QueryNodeType.Root: contextNode.MoveToRoot(); returnOpcode = next.Eval(destSequence, contextNode); break; } return returnOpcode; }
internal void Select(SeekableXPathNavigator contextNode, NodeSequence destSequence) { switch (this.type) { default: if (QueryAxisType.Self == this.axis.Type) { if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } } else if (QueryAxisType.Descendant == this.axis.Type) { SelectDescendants(contextNode, destSequence); } else if (QueryAxisType.DescendantOrSelf == this.axis.Type) { destSequence.Add(contextNode); SelectDescendants(contextNode, destSequence); } else if (QueryAxisType.Child == this.axis.Type) { // Select children of arbitrary type off the context node if (contextNode.MoveToFirstChild()) { do { // Select the node if its type and qname matches if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } } while (contextNode.MoveToNext()); } } else if (QueryAxisType.Attribute == this.axis.Type) { if (contextNode.MoveToFirstAttribute()) { do { // Select the node if its type and qname matches if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); // you can't have multiple instances of an attibute with the same qname // Stop once one was found // UNLESS WE HAVE A WILDCARD OFCOURSE! if (0 == (this.qnameType & NodeQNameType.Wildcard)) { break; } } } while (contextNode.MoveToNextAttribute()); } } else { throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected)); } break; case QueryNodeType.Attribute: // Select attributes off the context Node if (contextNode.MoveToFirstAttribute()) { do { if (this.MatchQName(contextNode)) { destSequence.Add(contextNode); // you can't have multiple instances of an attibute with the same qname // Stop once one was found // UNLESS WE HAVE A WILDCARD OFCOURSE! if (0 == (this.qnameType & NodeQNameType.Wildcard)) { break; } } } while (contextNode.MoveToNextAttribute()); } break; case QueryNodeType.ChildNodes: if (QueryAxisType.Descendant == this.axis.Type) { // Select descendants of arbitrary type off the context node SelectDescendants(contextNode, destSequence); } else { // Select children of arbitrary type off the context node if (contextNode.MoveToFirstChild()) { do { // Select the node if its type and qname matches if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } } while (contextNode.MoveToNext()); } } break; case QueryNodeType.Element: if (QueryAxisType.Descendant == this.axis.Type) { // Select descendants of arbitrary type off the context node SelectDescendants(contextNode, destSequence); } else if (QueryAxisType.DescendantOrSelf == this.axis.Type) { destSequence.Add(contextNode); SelectDescendants(contextNode, destSequence); } else if (contextNode.MoveToFirstChild()) { do { // Children could have non element nodes in line // Select the node if it is an element and the qname matches if (XPathNodeType.Element == contextNode.NodeType && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } } while (contextNode.MoveToNext()); } break; case QueryNodeType.Root: contextNode.MoveToRoot(); destSequence.Add(contextNode); break; case QueryNodeType.Text: // Select child text nodes if (contextNode.MoveToFirstChild()) { do { // Select the node if its type matches // Can't just do a comparison to XPathNodeType.Text since whitespace nodes // count as text if (this.MatchType(contextNode)) { destSequence.Add(contextNode); } } while (contextNode.MoveToNext()); } break; } }
internal Opcode Select(SeekableXPathNavigator contextNode, NodeSequence destSequence, SelectOpcode next) { Opcode returnOpcode = next.Next; switch (this.type) { default: if (QueryAxisType.Self == this.axis.Type) { if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { long position = contextNode.CurrentPosition; returnOpcode = next.Eval(destSequence, contextNode); contextNode.CurrentPosition = position; } } else { throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected)); } break; case QueryNodeType.ChildNodes: // Select children of arbitrary type off the context node if (contextNode.MoveToFirstChild()) { do { // Select the node if its type and qname matches if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } }while (contextNode.MoveToNext()); } break; case QueryNodeType.Element: // Select child elements if (contextNode.MoveToFirstChild()) { do { // Children could have non element nodes in line // Select the node if it is an element and the qname matches if (XPathNodeType.Element == contextNode.NodeType && this.MatchQName(contextNode)) { long position = contextNode.CurrentPosition; returnOpcode = next.Eval(destSequence, contextNode); contextNode.CurrentPosition = position; } } while (contextNode.MoveToNext()); } break; case QueryNodeType.Root: contextNode.MoveToRoot(); returnOpcode = next.Eval(destSequence, contextNode); break; } return(returnOpcode); }
internal void Select(SeekableXPathNavigator contextNode, NodeSequence destSequence) { switch (this.type) { default: if (QueryAxisType.Self == this.axis.Type) { if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } } else if (QueryAxisType.Descendant == this.axis.Type) { SelectDescendants(contextNode, destSequence); } else if (QueryAxisType.DescendantOrSelf == this.axis.Type) { destSequence.Add(contextNode); SelectDescendants(contextNode, destSequence); } else if (QueryAxisType.Child == this.axis.Type) { // Select children of arbitrary type off the context node if (contextNode.MoveToFirstChild()) { do { // Select the node if its type and qname matches if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } }while (contextNode.MoveToNext()); } } else if (QueryAxisType.Attribute == this.axis.Type) { if (contextNode.MoveToFirstAttribute()) { do { // Select the node if its type and qname matches if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); // you can't have multiple instances of an attibute with the same qname // Stop once one was found // UNLESS WE HAVE A WILDCARD OFCOURSE! if (0 == (this.qnameType & NodeQNameType.Wildcard)) { break; } } }while (contextNode.MoveToNextAttribute()); } } else { throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected)); } break; case QueryNodeType.Attribute: // Select attributes off the context Node if (contextNode.MoveToFirstAttribute()) { do { if (this.MatchQName(contextNode)) { destSequence.Add(contextNode); // you can't have multiple instances of an attibute with the same qname // Stop once one was found // UNLESS WE HAVE A WILDCARD OFCOURSE! if (0 == (this.qnameType & NodeQNameType.Wildcard)) { break; } } }while (contextNode.MoveToNextAttribute()); } break; case QueryNodeType.ChildNodes: if (QueryAxisType.Descendant == this.axis.Type) { // Select descendants of arbitrary type off the context node SelectDescendants(contextNode, destSequence); } else { // Select children of arbitrary type off the context node if (contextNode.MoveToFirstChild()) { do { // Select the node if its type and qname matches if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } }while (contextNode.MoveToNext()); } } break; case QueryNodeType.Element: if (QueryAxisType.Descendant == this.axis.Type) { // Select descendants of arbitrary type off the context node SelectDescendants(contextNode, destSequence); } else if (QueryAxisType.DescendantOrSelf == this.axis.Type) { destSequence.Add(contextNode); SelectDescendants(contextNode, destSequence); } else if (contextNode.MoveToFirstChild()) { do { // Children could have non element nodes in line // Select the node if it is an element and the qname matches if (XPathNodeType.Element == contextNode.NodeType && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } }while (contextNode.MoveToNext()); } break; case QueryNodeType.Root: contextNode.MoveToRoot(); destSequence.Add(contextNode); break; case QueryNodeType.Text: // Select child text nodes if (contextNode.MoveToFirstChild()) { do { // Select the node if its type matches // Can't just do a comparison to XPathNodeType.Text since whitespace nodes // count as text if (this.MatchType(contextNode)) { destSequence.Add(contextNode); } }while (contextNode.MoveToNext()); } break; } }
internal Opcode Select(SeekableXPathNavigator contextNode, NodeSequence destSequence, SelectOpcode next) { Opcode opcode = next.Next; switch (this.type) { case QueryNodeType.Root: contextNode.MoveToRoot(); return next.Eval(destSequence, contextNode); case QueryNodeType.Element: if (contextNode.MoveToFirstChild()) { do { if ((XPathNodeType.Element == contextNode.NodeType) && this.MatchQName(contextNode)) { long currentPosition = contextNode.CurrentPosition; opcode = next.Eval(destSequence, contextNode); contextNode.CurrentPosition = currentPosition; } } while (contextNode.MoveToNext()); } return opcode; case QueryNodeType.ChildNodes: if (contextNode.MoveToFirstChild()) { do { if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } } while (contextNode.MoveToNext()); } return opcode; } if (QueryAxisType.Self != this.axis.Type) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected)); } if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { long num = contextNode.CurrentPosition; opcode = next.Eval(destSequence, contextNode); contextNode.CurrentPosition = num; } return opcode; }
internal void Select(SeekableXPathNavigator contextNode, NodeSequence destSequence) { switch (this.type) { case QueryNodeType.Root: contextNode.MoveToRoot(); destSequence.Add(contextNode); return; case QueryNodeType.Attribute: if (contextNode.MoveToFirstAttribute()) { do { if (this.MatchQName(contextNode)) { destSequence.Add(contextNode); if (((byte) (this.qnameType & NodeQNameType.Wildcard)) == 0) { return; } } } while (contextNode.MoveToNextAttribute()); } return; case QueryNodeType.Element: if (QueryAxisType.Descendant != this.axis.Type) { if (QueryAxisType.DescendantOrSelf == this.axis.Type) { destSequence.Add(contextNode); this.SelectDescendants(contextNode, destSequence); return; } if (contextNode.MoveToFirstChild()) { do { if ((XPathNodeType.Element == contextNode.NodeType) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } } while (contextNode.MoveToNext()); } return; } this.SelectDescendants(contextNode, destSequence); return; case QueryNodeType.Text: if (contextNode.MoveToFirstChild()) { do { if (this.MatchType(contextNode)) { destSequence.Add(contextNode); } } while (contextNode.MoveToNext()); } return; case QueryNodeType.ChildNodes: if (QueryAxisType.Descendant == this.axis.Type) { this.SelectDescendants(contextNode, destSequence); return; } if (contextNode.MoveToFirstChild()) { do { if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } } while (contextNode.MoveToNext()); } return; } if (QueryAxisType.Self == this.axis.Type) { if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } } else if (QueryAxisType.Descendant == this.axis.Type) { this.SelectDescendants(contextNode, destSequence); } else if (QueryAxisType.DescendantOrSelf == this.axis.Type) { destSequence.Add(contextNode); this.SelectDescendants(contextNode, destSequence); } else if (QueryAxisType.Child == this.axis.Type) { if (contextNode.MoveToFirstChild()) { do { if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } } while (contextNode.MoveToNext()); } } else { if (QueryAxisType.Attribute != this.axis.Type) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected)); } if (contextNode.MoveToFirstAttribute()) { do { if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); if (((byte) (this.qnameType & NodeQNameType.Wildcard)) == 0) { return; } } } while (contextNode.MoveToNextAttribute()); } } }
internal void Select(SeekableXPathNavigator contextNode, NodeSequence destSequence) { switch (this.type) { case QueryNodeType.Root: contextNode.MoveToRoot(); destSequence.Add(contextNode); return; case QueryNodeType.Attribute: if (contextNode.MoveToFirstAttribute()) { do { if (this.MatchQName(contextNode)) { destSequence.Add(contextNode); if (((byte)(this.qnameType & NodeQNameType.Wildcard)) == 0) { return; } } }while (contextNode.MoveToNextAttribute()); } return; case QueryNodeType.Element: if (QueryAxisType.Descendant != this.axis.Type) { if (QueryAxisType.DescendantOrSelf == this.axis.Type) { destSequence.Add(contextNode); this.SelectDescendants(contextNode, destSequence); return; } if (contextNode.MoveToFirstChild()) { do { if ((XPathNodeType.Element == contextNode.NodeType) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } }while (contextNode.MoveToNext()); } return; } this.SelectDescendants(contextNode, destSequence); return; case QueryNodeType.Text: if (contextNode.MoveToFirstChild()) { do { if (this.MatchType(contextNode)) { destSequence.Add(contextNode); } }while (contextNode.MoveToNext()); } return; case QueryNodeType.ChildNodes: if (QueryAxisType.Descendant == this.axis.Type) { this.SelectDescendants(contextNode, destSequence); return; } if (contextNode.MoveToFirstChild()) { do { if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } }while (contextNode.MoveToNext()); } return; } if (QueryAxisType.Self == this.axis.Type) { if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } } else if (QueryAxisType.Descendant == this.axis.Type) { this.SelectDescendants(contextNode, destSequence); } else if (QueryAxisType.DescendantOrSelf == this.axis.Type) { destSequence.Add(contextNode); this.SelectDescendants(contextNode, destSequence); } else if (QueryAxisType.Child == this.axis.Type) { if (contextNode.MoveToFirstChild()) { do { if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } }while (contextNode.MoveToNext()); } } else { if (QueryAxisType.Attribute != this.axis.Type) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected)); } if (contextNode.MoveToFirstAttribute()) { do { if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); if (((byte)(this.qnameType & NodeQNameType.Wildcard)) == 0) { return; } } }while (contextNode.MoveToNextAttribute()); } } }