internal SeekableXPathNavigator CreateMessageNavigator(Message message, bool matchBody) { SeekableXPathNavigator navigator = message.GetNavigator(matchBody, this.maxNodes); navigator.MoveToRoot(); return(navigator); }
private void SelectDescendants(SeekableXPathNavigator contextNode, NodeSequence destSequence) { int num = 1; if (contextNode.MoveToFirstChild()) { while (num > 0) { if (this.MatchQName(contextNode)) { destSequence.Add(contextNode); } if (contextNode.MoveToFirstChild()) { num++; } else if (!contextNode.MoveToNext()) { while (num > 0) { contextNode.MoveToParent(); num--; if (contextNode.MoveToNext()) { break; } } } } } }
public override bool MoveNext() { if (null == this.data.seq) { // User is trying to use an iterator that is out of scope. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.QueryIteratorOutOfScope))); } if (this.index < this.data.seq.Count) { if (null == this.nav) { // We haven't aquired the navigator we will use for this iterator yet. this.nav = (SeekableXPathNavigator)this.data.seq[this.index].GetNavigator().Clone(); } else { this.nav.CurrentPosition = this.data.seq[this.index].GetNavigatorPosition(); } this.index++; return(true); } this.index++; this.nav = null; return(false); }
internal override void InvokeInternal(ProcessingContext context, int argCount) { context.PushFrame(); int iterationCount = context.IterationCount; if (iterationCount > 0) { string soapUri = context.Processor.SoapUri; if (soapUri == null) { Message contextMessage = context.Processor.ContextMessage; if (contextMessage == null) { SeekableXPathNavigator contextNode = context.Processor.ContextNode; long currentPosition = contextNode.CurrentPosition; soapUri = ExtractFromNavigator(contextNode); contextNode.CurrentPosition = currentPosition; } else { soapUri = contextMessage.Version.Envelope.Namespace; } context.Processor.SoapUri = soapUri; } context.Push(soapUri, iterationCount); } }
internal void Set(SeekableXPathNavigator node, int position, int size) { this.node = new QueryNode(node); this.position = position; this.size = size; this.flags = NodeSequenceItemFlags.None; }
internal override void InvokeInternal(ProcessingContext context, int argCount) { StackFrame topArg = context.TopArg; SeekableXPathNavigator contextNode = context.Processor.ContextNode; long currentPosition = contextNode.CurrentPosition; while (topArg.basePtr <= topArg.endPtr) { string str = context.PeekString(topArg.basePtr); NodeSequence val = context.CreateSequence(); if (XPathMessageFunction.MoveToHeader(contextNode) && contextNode.MoveToFirstChild()) { do { long num2 = contextNode.CurrentPosition; string str2 = XPathMessageFunctionActor.ExtractFromNavigator(contextNode); contextNode.CurrentPosition = num2; if (str2 == str) { val.Add(contextNode); } }while (contextNode.MoveToNext()); } context.SetValue(context, topArg.basePtr, val); topArg.basePtr++; } contextNode.CurrentPosition = currentPosition; }
internal override void InvokeInternal(ProcessingContext context, int argCount) { context.PushFrame(); int iterationCount = context.IterationCount; if (iterationCount > 0) { string toHeader = context.Processor.ToHeader; if (toHeader == null) { Message contextMessage = context.Processor.ContextMessage; if (contextMessage == null) { SeekableXPathNavigator contextNode = context.Processor.ContextNode; long currentPosition = contextNode.CurrentPosition; toHeader = ExtractFromNavigator(contextNode); contextNode.CurrentPosition = currentPosition; } else { Uri to = contextMessage.Headers.To; if (to == null) { toHeader = contextMessage.Version.Addressing.Anonymous; } else { toHeader = to.AbsoluteUri; } } context.Processor.ToHeader = toHeader; } context.Push(toHeader, iterationCount); } }
internal SafeSeekableNavigator(SeekableXPathNavigator navigator, int nodeCountMax) { this.navigator = navigator; this.counter = this; this.nodeCount = nodeCountMax; this.nodeCountMax = nodeCountMax; }
internal override void InvokeInternal(ProcessingContext context, int argCount) { context.PushFrame(); int iterationCount = context.IterationCount; if (iterationCount > 0) { string messageId = context.Processor.MessageId; if (messageId == null) { Message contextMessage = context.Processor.ContextMessage; if (contextMessage == null) { SeekableXPathNavigator contextNode = context.Processor.ContextNode; long currentPosition = contextNode.CurrentPosition; messageId = ExtractFromNavigator(contextNode); contextNode.CurrentPosition = currentPosition; } else { UniqueId id = contextMessage.Headers.MessageId; if (id == null) { messageId = string.Empty; } else { messageId = id.ToString(); } } context.Processor.MessageId = messageId; } context.Push(messageId, iterationCount); } }
internal override void InvokeInternal(ProcessingContext context, int argCount) { int iterationCount = context.IterationCount; context.PushSequenceFrame(); if (iterationCount > 0) { NodeSequence seq = context.CreateSequence(); seq.StartNodeset(); SeekableXPathNavigator contextNode = context.Processor.ContextNode; long currentPosition = contextNode.CurrentPosition; if (XPathMessageFunction.MoveToAddressingHeader(contextNode, "ReplyTo")) { seq.Add(contextNode); } seq.StopNodeset(); context.PushSequence(seq); for (int i = 1; i < iterationCount; i++) { seq.refCount++; context.PushSequence(seq); } contextNode.CurrentPosition = currentPosition; } }
internal override Opcode Eval(ProcessingContext context) { StackFrame topSequenceArg = context.TopSequenceArg; Value[] sequences = context.Sequences; bool sequenceStackInUse = context.SequenceStackInUse; context.PushSequenceFrame(); for (int i = topSequenceArg.basePtr; i <= topSequenceArg.endPtr; i++) { NodeSequence sequence = sequences[i].Sequence; if (sequence.Count == 0) { if (!sequenceStackInUse) { context.PushSequence(NodeSequence.Empty); } } else { NodeSequenceItem[] items = sequence.Items; for (int j = 0; j < sequence.Count; j++) { SeekableXPathNavigator contextNode = items[j].GetNavigator(); NodeSequence destSequence = context.CreateSequence(); destSequence.StartNodeset(); base.criteria.Select(contextNode, destSequence); destSequence.StopNodeset(); context.PushSequence(destSequence); } } } return(base.next); }
/// <summary> /// Execute matches over the given seekable navigator. If the navigator is not safe, wrap it with one that is /// </summary> internal FilterResult Match(SeekableXPathNavigator navigator, ICollection <MessageFilter> matches) { // If the matcher places restrictions on the # of nodes we will inspect, and the navigator passed does // not do any nodecounting itself, we must make that navigator safe by wrapping it if (this.maxNodes < int.MaxValue) { navigator = this.CreateSafeNavigator(navigator); } QueryProcessor processor = this.CreateProcessor(); processor.MatchSet = matches; processor.EnsureFilterCollection(); try { processor.Eval(this.query, navigator); } catch (XPathNavigatorException e) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(e.Process(this.query)); } catch (NavigatorInvalidBodyAccessException e) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(e.Process(this.query)); } return(new FilterResult(processor)); }
internal void Eval(Opcode block, SeekableXPathNavigator navigator) { this.result = false; this.ContextNode = navigator; this.ContextMessage = null; this.Eval(block); }
public bool Match(SeekableXPathNavigator navigator) { if (navigator == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("navigator"); } return(this.ProcessResult(this.matcher.Match(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 void Add(SeekableXPathNavigator node) { if (this.count == this.items.Length) { this.Grow(this.items.Length * 2); } this.position++; this.items[this.count++].Set(node, this.position, this.sizePosition); }
internal void Set(SeekableXPathNavigator node, int position, int size) { Fx.Assert(position > 0, ""); Fx.Assert(null != node, ""); this.node = new QueryNode(node); this.position = position; this.size = size; this.flags = NodeSequenceItemFlags.None; }
internal void Eval(Opcode block, Message message, bool matchBody) { this.result = false; this.ContextNode = null; this.ContextMessage = message; this.MatchBody = matchBody; this.Eval(block); this.message = null; this.contextNode = null; }
internal override Opcode Eval(NodeSequence sequence, SeekableXPathNavigator node) { if ((base.next != null) && ((base.next.Flags & OpcodeFlags.CompressableSelect) != OpcodeFlags.None)) { return this.criteria.Select(node, sequence, (SelectOpcode) base.next); } sequence.StartNodeset(); this.criteria.Select(node, sequence); sequence.StopNodeset(); return base.next; }
internal override Opcode Eval(ProcessingContext context) { StackFrame topFrame = context.TopSequenceArg; SeekableXPathNavigator node = null; Value[] sequences = context.Sequences; for (int i = topFrame.basePtr; i <= topFrame.endPtr; ++i) { // Each NodeSequence will generate a new one, but only if the source FilterSequence isn't empty // If the source FilterSequence is empty, release it and replace it with an empty sequence NodeSequence sourceSeq = sequences[i].Sequence; int sourceSeqCount = sourceSeq.Count; if (sourceSeqCount == 0) { context.ReplaceSequenceAt(i, NodeSequence.Empty); context.ReleaseSequence(sourceSeq); } else { NodeSequenceItem[] items = sourceSeq.Items; if (sourceSeq.CanReuse(context)) { node = items[0].GetNavigator(); sourceSeq.Clear(); sourceSeq.StartNodeset(); this.criteria.Select(node, sourceSeq); sourceSeq.StopNodeset(); } else { NodeSequence newSeq = null; for (int item = 0; item < sourceSeqCount; ++item) { node = items[item].GetNavigator(); Fx.Assert(null != node, ""); if (null == newSeq) { newSeq = context.CreateSequence(); } newSeq.StartNodeset(); this.criteria.Select(node, newSeq); newSeq.StopNodeset(); } context.ReplaceSequenceAt(i, (null != newSeq) ? newSeq : NodeSequence.Empty); context.ReleaseSequence(sourceSeq); } } } return(this.next); }
internal bool Equals(SeekableXPathNavigator navigator) { string str = navigator.LocalName; if (this.name.Length == str.Length && this.name == str) { str = navigator.NamespaceURI; return(this.ns.Length == str.Length && this.ns == str); } return(false); }
internal override Opcode Eval(NodeSequence sequence, SeekableXPathNavigator node) { if ((base.next != null) && ((base.next.Flags & OpcodeFlags.CompressableSelect) != OpcodeFlags.None)) { return(this.criteria.Select(node, sequence, (SelectOpcode)base.next)); } sequence.StartNodeset(); this.criteria.Select(node, sequence); sequence.StopNodeset(); return(base.next); }
internal FilterResult Match(SeekableXPathNavigator navigator) { if (this.IsAlwaysMatch) { return(new FilterResult(true)); } if (this.IsFxFilter) { return(new FilterResult(this.MatchFx(navigator))); } return(base.Match(navigator, null)); }
internal void Add(XPathNodeIterator iter) { while (iter.MoveNext()) { SeekableXPathNavigator current = iter.Current as SeekableXPathNavigator; if (current == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, System.ServiceModel.SR.GetString("QueryMustBeSeekable"))); } this.Add(current); } }
internal override Opcode Eval(ProcessingContext context) { SeekableXPathNavigator contextNode = context.Processor.ContextNode; bool flag = this.Match(contextNode); context.Processor.Result = flag; if ((flag && (base.item != null)) && (context.Processor.MatchSet != null)) { context.Processor.MatchSet.Add((MessageFilter)base.item); } return(base.next); }
internal SeekableXPathNavigator CreateSafeNavigator(SeekableXPathNavigator navigator) { INodeCounter counter = navigator as INodeCounter; if (counter != null) { counter.CounterMarker = this.maxNodes; counter.MaxCounter = this.maxNodes; return(navigator); } navigator = new SafeSeekableNavigator(navigator, this.maxNodes); return(navigator); }
internal override Opcode Eval(NodeSequence sequence, SeekableXPathNavigator node) { if (this.next == null || 0 == (this.next.Flags & OpcodeFlags.CompressableSelect)) { // The next opcode is not a compressible select. Complete the select operation and return the next opcode sequence.StartNodeset(); this.criteria.Select(node, sequence); sequence.StopNodeset(); return(this.next); } return(this.criteria.Select(node, sequence, (SelectOpcode)this.next)); }
public bool GetMatchingValue(SeekableXPathNavigator navigator, out TFilterData data) { if (navigator == null) { throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("navigator"); } if (this.CanMatch) { return(this.ProcessMatch(this.iqMatcher.Match(navigator, null), out data)); } data = default(TFilterData); return(false); }
internal override Opcode Eval(ProcessingContext context) { context.PushFrame(); int count = context.IterationCount; if (count > 0) { object o = this.variable.Evaluate(this.xsltContext); if (o == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new QueryProcessingException(QueryProcessingError.Unexpected, SR.GetString(SR.QueryVariableNull))); } switch (this.type) { case ValueDataType.Boolean: context.Push((bool)o, count); break; case ValueDataType.Double: context.Push((double)o, count); break; case ValueDataType.String: context.Push((string)o, count); break; case ValueDataType.Sequence: XPathNodeIterator iter = (XPathNodeIterator)o; NodeSequence seq = context.CreateSequence(); while (iter.MoveNext()) { SeekableXPathNavigator nav = iter.Current as SeekableXPathNavigator; if (nav != null) { seq.Add(nav); } else { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new QueryProcessingException(QueryProcessingError.Unexpected, SR.GetString(SR.QueryMustBeSeekable))); } } context.Push(seq, count); break; default: throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, SR.GetString(SR.QueryVariableTypeNotSupported, this.variable.VariableType.ToString()))); } } return(this.next); }
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 Add(XPathNodeIterator iter) { while (iter.MoveNext()) { SeekableXPathNavigator nav = iter.Current as SeekableXPathNavigator; if (nav != null) { this.Add(nav); } else { throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, SR.GetString(SR.QueryMustBeSeekable))); } } }
internal bool MatchQName(SeekableXPathNavigator node) { switch (((NodeQNameType) ((byte) (this.qnameType & NodeQNameType.Standard)))) { case NodeQNameType.Name: if (node.NamespaceURI.Length != 0) { return false; } return this.qname.EqualsName(node.LocalName); case NodeQNameType.Standard: { string localName = node.LocalName; if ((this.qname.name.Length != localName.Length) || !(this.qname.name == localName)) { return false; } localName = node.NamespaceURI; if (this.qname.ns.Length != localName.Length) { return false; } return (this.qname.ns == localName); } } if (this.qnameType == NodeQNameType.Empty) { return true; } NodeQNameType type2 = (NodeQNameType) ((byte) (this.qnameType & NodeQNameType.Wildcard)); if (type2 != NodeQNameType.NameWildcard) { return (type2 == NodeQNameType.Wildcard); } return this.qname.EqualsNamespace(node.NamespaceURI); }
internal bool MatchType(SeekableXPathNavigator node) { QueryNodeType nodeType; switch (node.NodeType) { default: return false; case XPathNodeType.Root: nodeType = QueryNodeType.Root; break; case XPathNodeType.Attribute: nodeType = QueryNodeType.Attribute; break; case XPathNodeType.Element: nodeType = QueryNodeType.Element; break; case XPathNodeType.Comment: nodeType = QueryNodeType.Comment; break; case XPathNodeType.Text: case XPathNodeType.Whitespace: case XPathNodeType.SignificantWhitespace: nodeType = QueryNodeType.Text; break; case XPathNodeType.ProcessingInstruction: nodeType = QueryNodeType.Processing; break; } return (nodeType == (this.type & nodeType)); }
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 virtual Opcode Eval(NodeSequence sequence, SeekableXPathNavigator node) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected)); }
internal SafeSeekableNavigator(SafeSeekableNavigator nav) { this.navigator = (SeekableXPathNavigator)nav.navigator.Clone(); this.counter = nav.counter; }
internal bool MatchQName(SeekableXPathNavigator node) { // Is this a standard qname test.. with known names and namespaces switch (this.qnameType & NodeQNameType.Standard) { default: break; case NodeQNameType.Name: // Selection criteria did not specify a namespace. Then, if the node supplies a namespace, we know // that the criteria cannot possibly match return (0 == node.NamespaceURI.Length && this.qname.EqualsName(node.LocalName)); case NodeQNameType.Standard: string str = node.LocalName; if (this.qname.name.Length == str.Length && this.qname.name == str) { str = node.NamespaceURI; return (this.qname.ns.Length == str.Length && this.qname.ns == str); } return false; } if (NodeQNameType.Empty == this.qnameType) { return true; } // Maybe a wildcard switch (this.qnameType & NodeQNameType.Wildcard) { default: break; case NodeQNameType.NameWildcard: return this.qname.EqualsNamespace(node.NamespaceURI); case NodeQNameType.Wildcard: return true; } return false; }
internal override Opcode Eval(NodeSequence sequence, SeekableXPathNavigator node) { if (this.next == null || 0 == (this.next.Flags & OpcodeFlags.CompressableSelect)) { // The next opcode is not a compressible select. Complete the select operation and return the next opcode sequence.StartNodeset(); this.criteria.Select(node, sequence); sequence.StopNodeset(); return this.next; } return this.criteria.Select(node, sequence, (SelectOpcode)this.next); }
internal bool Match(SeekableXPathNavigator node) { return (this.MatchType(node) && this.MatchQName(node)); }
void SelectDescendants(SeekableXPathNavigator contextNode, NodeSequence destSequence) { int level = 1; if (!contextNode.MoveToFirstChild()) { return; } while (level > 0) { // Don't need type check. All child nodes allowed. if (this.MatchQName(contextNode)) { destSequence.Add(contextNode); } if (contextNode.MoveToFirstChild()) { ++level; } else if (contextNode.MoveToNext()) { } else { while (level > 0) { contextNode.MoveToParent(); --level; if (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 bool Equals(SeekableXPathNavigator navigator) { string str = navigator.LocalName; if (this.name.Length == str.Length && this.name == str) { str = navigator.NamespaceURI; return (this.ns.Length == str.Length && this.ns == str); } return false; }
internal FilterResult Match(SeekableXPathNavigator navigator) { if (this.IsAlwaysMatch) { return new FilterResult(true); } if (this.IsFxFilter) { return new FilterResult(this.MatchFx(navigator)); } return base.Match(navigator, null); }
internal virtual void Init(SeekableXPathNavigator navigator, int nodeCountMax) { this.navigator = navigator; this.nodeCount = nodeCountMax; this.counter = this; }
internal QueryNode(SeekableXPathNavigator node) { this.node = node; this.nodePosition = node.CurrentPosition; }