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;
        }
Esempio n. 3
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);
        }
        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;
        }