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, "RelatesTo")) { seq.Add(contextNode); while (XPathMessageFunction.MoveToAddressingHeaderSibling(contextNode, "RelatesTo")) { 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) { if (!context.LoadVariable(this.expr.Variable)) { context.PushSequenceFrame(); NodeSequence seq = context.CreateSequence(); seq.Add(context.Processor.ContextNode); context.PushSequence(seq); int marker = context.Processor.CounterMarker; try { this.expr.Eval(context); } catch (XPathNavigatorException e) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(e.Process(this)); } catch (NavigatorInvalidBodyAccessException e) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(e.Process(this)); } context.Processor.CounterMarker = marker; context.PopSequenceFrame(); context.PopSequenceFrame(); context.LoadVariable(this.expr.Variable); } return(this.next); }
internal static void IterateAndPushSequences(ProcessingContext context) { StackFrame topSequenceArg = context.TopSequenceArg; Value[] sequences = context.Sequences; context.PushFrame(); while (topSequenceArg.basePtr <= topSequenceArg.endPtr) { NodeSequence sequence = sequences[topSequenceArg.basePtr++].Sequence; if (sequence.Count == 0) { context.PushSequence(NodeSequence.Empty); } else { for (int i = 0; i < sequence.Count; i++) { NodeSequence sequence2 = context.CreateSequence(); sequence2.StartNodeset(); sequence2.Add(ref sequence.Items[i]); sequence2.StopNodeset(); context.Push(sequence2); } } } }
internal static void IterateAndPushSequences(ProcessingContext context) { StackFrame sequences = context.TopSequenceArg; Value[] sequenceBuffer = context.Sequences; context.PushFrame(); while (sequences.basePtr <= sequences.endPtr) { NodeSequence sourceSeq = sequenceBuffer[sequences.basePtr++].Sequence; int count = sourceSeq.Count; if (count == 0) { context.PushSequence(NodeSequence.Empty); } else { for (int item = 0; item < sourceSeq.Count; ++item) { NodeSequence newSequence = context.CreateSequence(); newSequence.StartNodeset(); newSequence.Add(ref sourceSeq.Items[item]); newSequence.StopNodeset(); context.Push(newSequence); } } } }
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; }
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; } } } } } }
internal override Opcode Eval(ProcessingContext context) { context.PushContextSequenceFrame(); NodeSequence seq = context.CreateSequence(); seq.StartNodeset(); seq.Add(context.Processor.ContextNode); seq.StopNodeset(); context.PushSequence(seq); return(base.next); }
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 override Opcode Eval(ProcessingContext context) { context.PushFrame(); int iterationCount = context.IterationCount; if (iterationCount > 0) { object obj2 = this.variable.Evaluate(this.xsltContext); if (obj2 == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new QueryProcessingException(QueryProcessingError.Unexpected, System.ServiceModel.SR.GetString("QueryVariableNull"))); } switch (this.type) { case ValueDataType.Boolean: context.Push((bool)obj2, iterationCount); goto Label_013A; case ValueDataType.Double: context.Push((double)obj2, iterationCount); goto Label_013A; case ValueDataType.Sequence: { XPathNodeIterator iterator = (XPathNodeIterator)obj2; NodeSequence sequence = context.CreateSequence(); while (iterator.MoveNext()) { SeekableXPathNavigator current = iterator.Current as SeekableXPathNavigator; if (current == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new QueryProcessingException(QueryProcessingError.Unexpected, System.ServiceModel.SR.GetString("QueryMustBeSeekable"))); } sequence.Add(current); } context.Push(sequence, iterationCount); goto Label_013A; } case ValueDataType.String: context.Push((string)obj2, iterationCount); goto Label_013A; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, System.ServiceModel.SR.GetString("QueryVariableTypeNotSupported", new object[] { this.variable.VariableType.ToString() }))); } Label_013A: return(base.next); }
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); }
/// <summary> /// Union algorithm: /// 1. Add both sequences of items to a newly created sequence /// 2. Sort the items based on document position /// 3. Renumber positions in this new unionized sequence /// </summary> internal NodeSequence Union(ProcessingContext context, NodeSequence otherSeq) { NodeSequence seq = context.CreateSequence(); SortedBuffer <QueryNode, QueryNodeComparer> buff = new SortedBuffer <QueryNode, QueryNodeComparer>(staticQueryNodeComparerInstance); for (int i = 0; i < this.count; ++i) { buff.Add(this.items[i].Node); } for (int i = 0; i < otherSeq.count; ++i) { buff.Add(otherSeq.items[i].Node); } for (int i = 0; i < buff.Count; ++i) { seq.Add(buff[i]); } seq.RenumberItems(); return(seq); /* * // PERF, [....], I think we can do the merge ourselves and avoid the sort. * // Need to verify that the sequences are always in document order. * for(int i = 0; i < this.count; ++i) * { * seq.AddCopy(ref this.items[i]); * } * * for(int i = 0; i < otherSeq.count; ++i) * { * seq.AddCopy(ref otherSeq.items[i]); * } * * seq.SortNodes(); * seq.RemoveDuplicates(); * * return seq; */ }
internal NodeSequence Union(ProcessingContext context, NodeSequence otherSeq) { NodeSequence sequence = context.CreateSequence(); SortedBuffer <QueryNode, QueryNodeComparer> buffer = new SortedBuffer <QueryNode, QueryNodeComparer>(staticQueryNodeComparerInstance); for (int i = 0; i < this.count; i++) { buffer.Add(this.items[i].Node); } for (int j = 0; j < otherSeq.count; j++) { buffer.Add(otherSeq.items[j].Node); } for (int k = 0; k < buffer.Count; k++) { sequence.Add(buffer[k]); } sequence.RenumberItems(); return(sequence); }
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); }
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; } } } } }
public override object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext) { string actor = ToString(args[0]); string e = string.Format(CultureInfo.InvariantCulture, "/s11:Envelope/s11:Header/*[@s11:actor='{0}'] | /s12:Envelope/s12:Header/*[@s12:role='{1}']", actor, actor); XPathExpression expr = docContext.Compile(e); expr.SetContext(xsltContext); return docContext.Evaluate(expr); #if NO // PERF, [....], I drafted this implementation before we found out that a bug in the Fx implementation would // prevent us from constructing an XPathNodeIterator that they would accept. I'm keeping it // around in the hope that I will be able to use it by M5.4. If not, it will be deleted. XPathNavigator basicNav = docContext.Clone(); SeekableXPathNavigator nav = basicNav as SeekableXPathNavigator; if(nav == null) { nav = new GenericSeekableNavigator(basicNav); } string actor = (string)args[0]; NodeSequence seq = new NodeSequence(); XPathNodeIterator result = new NodeSequenceIterator(seq); nav.MoveToRoot(); if(!nav.MoveToFirstChild()) { return result; } if(nav.LocalName != "Envelope") { return result; } if(nav.NamespaceURI == XPathMessageContext.S11NS) { // Move to Header if(nav.MoveToFirstChild() && nav.LocalName == "Header" && nav.NamespaceURI == XPathMessageContext.S11NS) { // Move to first Header block if(nav.MoveToFirstChild()) { // Iterate over header blocks do { if(nav.MoveToAttribute("actor", XPathMessageContext.S11NS)) { if(nav.Value == actor) { seq.Add(nav); } nav.MoveToParent(); } } while(nav.MoveToNext()); } } } else if(nav.NamespaceURI == XPathMessageContext.S12NS) { // Move to Header if(nav.MoveToFirstChild() && nav.LocalName == "Header" && nav.NamespaceURI == XPathMessageContext.S12NS) { // Move to first Header block if(nav.MoveToFirstChild()) { // Iterate over header blocks do { if(nav.MoveToAttribute("role", XPathMessageContext.S12NS)) { if(nav.Value == actor) { seq.Add(nav); } nav.MoveToParent(); } } while(nav.MoveToNext()); } } } return result; #endif }
internal override Opcode Eval(ProcessingContext context) { XPathNavigator nav = context.Processor.ContextNode; if (nav != null && context.Processor.ContextMessage != null) { ((SeekableMessageNavigator)nav).Atomize(); } if (this.argCount == 0) { context.PushFrame(); int count = context.IterationCount; if (count > 0) { object ret = this.function.Invoke(this.xsltContext, NullArgs, nav); switch (this.function.ReturnType) { case XPathResultType.String: context.Push((string)ret, count); break; case XPathResultType.Number: context.Push((double)ret, count); break; case XPathResultType.Boolean: context.Push((bool)ret, count); break; case XPathResultType.NodeSet: NodeSequence seq = context.CreateSequence(); XPathNodeIterator iter = (XPathNodeIterator)ret; seq.Add(iter); context.Push(seq, count); break; default: // This should never be reached throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, SR.GetString(SR.QueryFunctionTypeNotSupported, this.function.ReturnType.ToString()))); } } } else { // PERF, [....], see if we can cache these arrays to avoid allocations object[] xsltArgs = new object[this.argCount]; int iterationCount = context.TopArg.Count; for (int iteration = 0; iteration < iterationCount; ++iteration) { for (int i = 0; i < this.argCount; ++i) { StackFrame arg = context[i]; Fx.Assert(iteration < arg.Count, ""); switch (this.function.ArgTypes[i]) { case XPathResultType.String: xsltArgs[i] = context.PeekString(arg[iteration]); break; case XPathResultType.Number: xsltArgs[i] = context.PeekDouble(arg[iteration]); break; case XPathResultType.Boolean: xsltArgs[i] = context.PeekBoolean(arg[iteration]); break; case XPathResultType.NodeSet: NodeSequenceIterator iter = new NodeSequenceIterator(context.PeekSequence(arg[iteration])); xsltArgs[i] = iter; this.iterList.Add(iter); break; default: // This should never be reached throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, SR.GetString(SR.QueryFunctionTypeNotSupported, this.function.ArgTypes[i].ToString()))); } } object ret = this.function.Invoke(this.xsltContext, xsltArgs, nav); if (this.iterList != null) { for (int i = 0; i < this.iterList.Count; ++i) { this.iterList[i].Clear(); } this.iterList.Clear(); } switch (this.function.ReturnType) { case XPathResultType.String: context.SetValue(context, context[this.argCount - 1][iteration], (string)ret); break; case XPathResultType.Number: context.SetValue(context, context[this.argCount - 1][iteration], (double)ret); break; case XPathResultType.Boolean: context.SetValue(context, context[this.argCount - 1][iteration], (bool)ret); break; case XPathResultType.NodeSet: NodeSequence seq = context.CreateSequence(); XPathNodeIterator iter = (XPathNodeIterator)ret; seq.Add(iter); context.SetValue(context, context[this.argCount - 1][iteration], seq); break; default: // This should never be reached throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, SR.GetString(SR.QueryFunctionTypeNotSupported, this.function.ReturnType.ToString()))); } } for (int i = 0; i < this.argCount - 1; ++i) { context.PopFrame(); } } return(this.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 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 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 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 override Opcode Eval(ProcessingContext context) { XPathNavigator contextNode = context.Processor.ContextNode; if ((contextNode != null) && (context.Processor.ContextMessage != null)) { ((SeekableMessageNavigator)contextNode).Atomize(); } if (this.argCount == 0) { context.PushFrame(); int iterationCount = context.IterationCount; if (iterationCount > 0) { object obj2 = this.function.Invoke(this.xsltContext, NullArgs, contextNode); switch (this.function.ReturnType) { case XPathResultType.Number: context.Push((double)obj2, iterationCount); goto Label_03F6; case XPathResultType.String: context.Push((string)obj2, iterationCount); goto Label_03F6; case XPathResultType.Boolean: context.Push((bool)obj2, iterationCount); goto Label_03F6; case XPathResultType.NodeSet: { NodeSequence sequence = context.CreateSequence(); XPathNodeIterator iter = (XPathNodeIterator)obj2; sequence.Add(iter); context.Push(sequence, iterationCount); goto Label_03F6; } } throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, System.ServiceModel.SR.GetString("QueryFunctionTypeNotSupported", new object[] { this.function.ReturnType.ToString() }))); } } else { object[] args = new object[this.argCount]; int count = context.TopArg.Count; for (int i = 0; i < count; i++) { for (int k = 0; k < this.argCount; k++) { StackFrame frame = context[k]; switch (this.function.ArgTypes[k]) { case XPathResultType.Number: args[k] = context.PeekDouble(frame[i]); break; case XPathResultType.String: args[k] = context.PeekString(frame[i]); break; case XPathResultType.Boolean: args[k] = context.PeekBoolean(frame[i]); break; case XPathResultType.NodeSet: { NodeSequenceIterator item = new NodeSequenceIterator(context.PeekSequence(frame[i])); args[k] = item; this.iterList.Add(item); break; } default: throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, System.ServiceModel.SR.GetString("QueryFunctionTypeNotSupported", new object[] { this.function.ArgTypes[k].ToString() }))); } } object obj3 = this.function.Invoke(this.xsltContext, args, contextNode); if (this.iterList != null) { for (int m = 0; m < this.iterList.Count; m++) { this.iterList[m].Clear(); } this.iterList.Clear(); } switch (this.function.ReturnType) { case XPathResultType.Number: { StackFrame frame4 = context[this.argCount - 1]; context.SetValue(context, frame4[i], (double)obj3); break; } case XPathResultType.String: { StackFrame frame3 = context[this.argCount - 1]; context.SetValue(context, frame3[i], (string)obj3); break; } case XPathResultType.Boolean: { StackFrame frame5 = context[this.argCount - 1]; context.SetValue(context, frame5[i], (bool)obj3); break; } case XPathResultType.NodeSet: { NodeSequence val = context.CreateSequence(); XPathNodeIterator iterator3 = (XPathNodeIterator)obj3; val.Add(iterator3); StackFrame frame6 = context[this.argCount - 1]; context.SetValue(context, frame6[i], val); break; } default: throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, System.ServiceModel.SR.GetString("QueryFunctionTypeNotSupported", new object[] { this.function.ReturnType.ToString() }))); } } for (int j = 0; j < (this.argCount - 1); j++) { context.PopFrame(); } } Label_03F6: return(base.next); }
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()); } } }