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;
        }
Пример #2
0
        public override void Trim()
        {
            // Trim stacks
            base.Trim();
            // Trim local pools individually
            QueryBranchResultSet result = this.resultPool;

            while (null != result)
            {
                result.Trim();
                result = result.Next;
            }
            NodeSequence sequence = this.sequencePool;

            while (null != sequencePool)
            {
                sequencePool.Trim();
                sequence = sequence.Next;
            }
            ProcessingContext context = this.contextPool;

            while (null != context)
            {
                context.Trim();
                context = context.Next;
            }
        }
        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;
                            }
                        }
                    }
                }
            }
        }
Пример #4
0
        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 void ReleaseSequence(ProcessingContext context)
        {
            Fx.Assert(null != context && this.type == ValueDataType.Sequence && null != this.sequence, "");

            context.ReleaseSequence(this.sequence);
            this.sequence = null;
        }
Пример #6
0
        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;
            }
        }
 public SafeNodeSequenceIterator(NodeSequence seq, ProcessingContext context) : base(seq)
 {
     this.context = context;
     this.seq = seq;
     Interlocked.Increment(ref this.seq.refCount);
     this.context.Processor.AddRef();
 }
Пример #8
0
        internal static void BooleanLang(ProcessingContext context)
        {
            StackFrame topArg         = context.TopArg;
            StackFrame topSequenceArg = context.TopSequenceArg;

            Value[] sequences = context.Sequences;
            while (topSequenceArg.basePtr <= topSequenceArg.endPtr)
            {
                NodeSequence sequence = sequences[topSequenceArg.basePtr++].Sequence;
                for (int i = 0; i < sequence.Count; i++)
                {
                    string    strA            = context.PeekString(topArg.basePtr).ToUpperInvariant();
                    QueryNode node            = sequence.Items[i].Node;
                    long      currentPosition = node.Node.CurrentPosition;
                    node.Node.CurrentPosition = node.Position;
                    string strB = node.Node.XmlLang.ToUpperInvariant();
                    node.Node.CurrentPosition = currentPosition;
                    if ((strA.Length == strB.Length) && (string.CompareOrdinal(strA, strB) == 0))
                    {
                        context.SetValue(context, topArg.basePtr++, true);
                    }
                    else if (((strB.Length > 0) && (strA.Length < strB.Length)) && (strB.StartsWith(strA, StringComparison.Ordinal) && (strB[strA.Length] == '-')))
                    {
                        context.SetValue(context, topArg.basePtr++, true);
                    }
                    else
                    {
                        context.SetValue(context, topArg.basePtr++, false);
                    }
                }
                topSequenceArg.basePtr++;
            }
        }
Пример #9
0
        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);
        }
Пример #10
0
        internal override void Match(int valIndex, ref Value val, QueryBranchResultSet results)
        {
            QueryBranch branch = null;

            if (ValueDataType.Sequence == val.Type)
            {
                NodeSequence sequence = val.Sequence;
                for (int i = 0; i < sequence.Count; ++i)
                {
                    branch = this[sequence.Items[i].NumberValue()];
                    if (null != branch)
                    {
                        results.Add(branch, valIndex);
                    }
                }
            }
            else
            {
                branch = this[val.ToDouble()];
                if (null != branch)
                {
                    results.Add(branch, valIndex);
                }
            }
        }
Пример #11
0
        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);
                    }
                }
            }
        }
Пример #12
0
        internal override void Match(int valIndex, ref Value val, QueryBranchResultSet results)
        {
            QueryBranch branch = null;

            if (ValueDataType.Sequence == val.Type)
            {
                NodeSequence sequence = val.Sequence;
                for (int i = 0; i < sequence.Count; i++)
                {
                    branch = this[sequence.Items[i].StringValue()];
                    if (branch != null)
                    {
                        results.Add(branch, valIndex);
                    }
                }
            }
            else
            {
                branch = this[val.String];
                if (branch != null)
                {
                    results.Add(branch, valIndex);
                }
            }
        }
        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);
        }
 internal NodesetIterator(NodeSequence sequence)
 {
     this.sequence = sequence;
     this.items = sequence.Items;
     this.index = -1;
     this.indexStart = -1;
 }
 public SafeNodeSequenceIterator(NodeSequence seq, ProcessingContext context) : base(seq)
 {
     this.context = context;
     this.seq     = seq;
     Interlocked.Increment(ref this.seq.refCount);
     this.context.Processor.AddRef();
 }
Пример #16
0
 internal void Update(ProcessingContext context, NodeSequence val)
 {
     if (ValueDataType.Sequence == this.type)
     {
         context.ReleaseSequence(this.sequence);
     }
     this.Sequence = val;
 }
Пример #17
0
 internal NodesetIterator(NodeSequence sequence)
 {
     Fx.Assert(null != sequence, "");
     this.sequence   = sequence;
     this.items      = sequence.Items;
     this.index      = -1;
     this.indexStart = -1;
 }
 internal void ReleaseSequenceToPool(NodeSequence sequence)
 {
     if (NodeSequence.Empty != sequence)
     {
         sequence.Reset(this.sequencePool);
         this.sequencePool = sequence;
     }
 }
Пример #19
0
 internal void Add(ref NodeSequenceItem item)
 {
     if (this.sequence == null)
     {
         this.sequence = this.context.CreateSequence();
         this.sequence.StartNodeset();
     }
     this.sequence.Add(ref item);
 }
Пример #20
0
 internal void Push(NodeSequence val)
 {
     this.stack.stackPtr++;
     if (this.stack.NeedsGrowth)
     {
         this.GrowStack(1);
     }
     this.buffer.buffer[this.stack.stackPtr].Sequence     = val;
     this.buffer.buffer[this.frames.stackPtr].FrameEndPtr = this.stack.stackPtr;
 }
        internal static int GetContextSize(NodeSequence sequence, int itemIndex)
        {
            int size = sequence.items[itemIndex].Size;

            if (size <= 0)
            {
                return(sequence.items[-size].Size);
            }
            return(size);
        }
 internal bool Compare(NodeSequence sequence, RelationOperator op)
 {
     for (int i = 0; i < sequence.count; i++)
     {
         if (this.Compare(ref sequence.items[i], op))
         {
             return(true);
         }
     }
     return(false);
 }
Пример #23
0
        internal static void NodesetName(ProcessingContext context)
        {
            StackFrame arg = context.TopArg;

            while (arg.basePtr <= arg.endPtr)
            {
                NodeSequence sequence = context.PeekSequence(arg.basePtr);
                context.SetValue(context, arg.basePtr, sequence.Name);
                arg.basePtr++;
            }
        }
        internal NodeSequence PopSequence()
        {
            NodeSequence sequencePool = this.sequencePool;

            if (sequencePool != null)
            {
                this.sequencePool = sequencePool.Next;
                sequencePool.Next = null;
            }
            return(sequencePool);
        }
 internal NodeSequence CreateSequence()
 {
     NodeSequence sequence = this.processor.PopSequence();
     if (sequence == null)
     {
         sequence = new NodeSequence();
     }
     sequence.OwnerContext = this;
     sequence.refCount++;
     return sequence;
 }
Пример #26
0
        internal NodeSequence PopSequence()
        {
            NodeSequence sequence = this.sequencePool;

            if (null != sequence)
            {
                this.sequencePool = sequence.Next;
                sequence.Next     = null;
            }
            return(sequence);
        }
 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;
 }
Пример #28
0
        internal static void NodesetNamespaceUri(ProcessingContext context)
        {
            StackFrame topArg = context.TopArg;

            while (topArg.basePtr <= topArg.endPtr)
            {
                NodeSequence sequence = context.PeekSequence(topArg.basePtr);
                context.SetValue(context, topArg.basePtr, sequence.Namespace);
                topArg.basePtr++;
            }
        }
 internal void ReleaseSequence(NodeSequence sequence)
 {
     if (this == sequence.OwnerContext)
     {
         sequence.refCount--;
         if (sequence.refCount == 0)
         {
             this.processor.ReleaseSequenceToPool(sequence);
         }
     }
 }
Пример #30
0
        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 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);
        }
Пример #32
0
 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 NodeSequence CreateSequence()
        {
            NodeSequence sequence = this.processor.PopSequence();

            if (sequence == null)
            {
                sequence = new NodeSequence();
            }
            sequence.OwnerContext = this;
            sequence.refCount++;
            return(sequence);
        }
 internal static int GetContextSize(NodeSequence sequence, int itemIndex)
 {
     int size = sequence.items[itemIndex].Size;
     if (size <= 0)
     {
         return sequence.items[-size].Size;
     }
     return size;
 }
Пример #35
0
 internal static double Double(NodeSequence sequence)
 {
     Fx.Assert(null != sequence, "");
     return QueryValueModel.Double(sequence.StringValue());
 }
Пример #36
0
 internal NodeSequence PopSequence()
 {
     NodeSequence sequence = this.sequencePool;
     if (null != sequence)
     {
         this.sequencePool = sequence.Next;
         sequence.Next = null;
     }
     return sequence;
 }
Пример #37
0
        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;
                        }
                    }
                }
            }
        }
Пример #38
0
        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);
        }
Пример #39
0
        internal void ReleaseSequence(ProcessingContext context)
        {
            Fx.Assert(null != context && this.type == ValueDataType.Sequence && null != this.sequence, "");

            context.ReleaseSequence(this.sequence);
            this.sequence = null;
        }
Пример #40
0
 internal static string String(NodeSequence sequence)
 {
     Fx.Assert(null != sequence, "");
     return sequence.StringValue();
 }
 internal void ReleaseSequenceToPool(NodeSequence sequence)
 {
     if (NodeSequence.Empty != sequence)
     {
         sequence.Reset(this.sequencePool);
         this.sequencePool = sequence;
     }
 }
Пример #42
0
 internal static bool Boolean(NodeSequence sequence)
 {
     Fx.Assert(null != sequence, "");
     return sequence.IsNotEmpty;
 }
Пример #43
0
 internal static bool Equals(NodeSequence x, double y)
 {
     return x.Equals(y);
 }
Пример #44
0
 internal void SetValue(ProcessingContext context, int index, NodeSequence val)
 {
     this.valueStack.SetValue(this, index, val);
 }
Пример #45
0
 internal static bool Equals(NodeSequence x, string y)
 {
     return x.Equals(y);
 }
Пример #46
0
 internal static bool Compare(NodeSequence x, NodeSequence y, RelationOperator op)
 {
     Fx.Assert(null != x, "");
     return x.Compare(y, op);
 }
Пример #47
0
 internal static bool Compare(NodeSequence x, bool y, RelationOperator op)
 {
     Fx.Assert(null != x, "");
     return QueryValueModel.Compare(QueryValueModel.Boolean(x), y, op);
 }
Пример #48
0
 internal static bool Compare(string x, NodeSequence y, RelationOperator op)
 {
     Fx.Assert(null != y, "");
     switch (op)
     {
         default:
             return y.Compare(x, op);
         case RelationOperator.Ge:
             return y.Compare(x, RelationOperator.Le);
         case RelationOperator.Gt:
             return y.Compare(x, RelationOperator.Lt);
         case RelationOperator.Le:
             return y.Compare(x, RelationOperator.Ge);
         case RelationOperator.Lt:
             return y.Compare(x, RelationOperator.Gt);
     }
 }
Пример #49
0
 internal static bool Compare(bool x, NodeSequence y, RelationOperator op)
 {
     Fx.Assert(null != y, "");
     return QueryValueModel.Compare(x, QueryValueModel.Boolean(y), op);
 }
 internal NodeSequence PopSequence()
 {
     NodeSequence sequencePool = this.sequencePool;
     if (sequencePool != null)
     {
         this.sequencePool = sequencePool.Next;
         sequencePool.Next = null;
     }
     return sequencePool;
 }
Пример #51
0
 internal void ReleaseSequence(NodeSequence sequence)
 {
     Fx.Assert(null != sequence, "");
     if (this == sequence.OwnerContext)
     {
         sequence.refCount--;
         Fx.Assert(sequence.refCount >= 0, "");
         if (0 == sequence.refCount)
         {
             this.processor.ReleaseSequenceToPool(sequence);
         }
     }
 }
Пример #52
0
 internal void ReplaceSequenceAt(int index, NodeSequence sequence)
 {
     this.sequenceStack.ReplaceAt(index, sequence);
     this.nodeCount = -1;
 }
 internal void Reset(NodeSequence nextSeq)
 {
     this.count = 0;
     this.refCount = 0;
     this.next = nextSeq;
 }
 internal bool Compare(NodeSequence sequence, RelationOperator op)
 {
     for (int i = 0; i < sequence.count; i++)
     {
         if (this.Compare(ref sequence.items[i], op))
         {
             return true;
         }
     }
     return false;
 }
Пример #55
0
        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;
            }
        }
Пример #56
0
 internal void Clear()
 {
     this.type = ValueDataType.None;
     this.sequence = null;
 }
Пример #57
0
        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;
        }
Пример #58
0
 internal void Update(ProcessingContext context, NodeSequence val)
 {
     if (ValueDataType.Sequence == this.type)
     {
         context.ReleaseSequence(this.sequence);
     }
     this.Sequence = val;
 }
 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;
 }