private XPathExpr ParseFilterExpression()
        {
            XPathExpr expr = this.ParsePrimaryExpression();

            if (expr == null)
            {
                return(null);
            }
            XPathExpr expr2 = new XPathExpr(XPathExprType.Filter, expr.ReturnType);

            expr2.Add(expr);
            XPathExpr expr3 = this.ParsePredicateExpression();

            if (expr3 == null)
            {
                return(expr);
            }
            this.EnsureReturnsNodeSet(expr);
            expr2.Add(expr3);
            while ((expr3 = this.ParsePredicateExpression()) != null)
            {
                expr2.Add(expr3);
            }
            return(expr2);
        }
Example #2
0
        XPathExpr ParseFilterExpression()
        {
            XPathExpr primaryExpr = this.ParsePrimaryExpression();

            if (null == primaryExpr)
            {
                return(null);
            }

            XPathExpr filterExpr = new XPathExpr(XPathExprType.Filter, primaryExpr.ReturnType);

            filterExpr.Add(primaryExpr);

            XPathExpr predicate = this.ParsePredicateExpression();

            if (null != predicate)
            {
                EnsureReturnsNodeSet(primaryExpr);

                //XPathExpr filterExpr = new XPathExpr(XPathExprType.Filter, ValueDataType.Sequence);

                //filterExpr.Add(primaryExpr);
                filterExpr.Add(predicate);

                // Read in any additional predicates
                while (null != (predicate = this.ParsePredicateExpression()))
                {
                    filterExpr.Add(predicate);
                }

                return(filterExpr);
            }

            return(primaryExpr);
        }
Example #3
0
        XPathExpr ParsePathExpression()
        {
            XPathExpr pathExpr = this.ParseLocationPath();

            if (null != pathExpr)
            {
                return(pathExpr);
            }

            // Perhaps we have a filter expression
            XPathExpr filterExpr = this.ParseFilterExpression();

            if (null != filterExpr)
            {
                if (null != this.NextToken(XPathTokenID.Slash))
                {
                    EnsureReturnsNodeSet(filterExpr);

                    // Is this a complex filter expression.. i.e. followed by further selections..
                    XPathExprList relPath = this.ParseRelativePath();
                    if (null == relPath)
                    {
                        this.ThrowError(QueryCompileError.InvalidLocationPath);
                    }

                    XPathExpr relPathExpr = new XPathExpr(XPathExprType.RelativePath, ValueDataType.Sequence, relPath);

                    pathExpr = new XPathExpr(XPathExprType.Path, ValueDataType.Sequence);
                    pathExpr.Add(filterExpr);
                    pathExpr.Add(relPathExpr);
                }
                else if (null != this.NextToken(XPathTokenID.DblSlash))
                {
                    EnsureReturnsNodeSet(filterExpr);

                    XPathExprList relPath = this.ParseRelativePath();
                    if (null == relPath)
                    {
                        this.ThrowError(QueryCompileError.InvalidLocationPath);
                    }

                    XPathExpr relPathExpr = new XPathExpr(XPathExprType.RelativePath, ValueDataType.Sequence, relPath);
                    pathExpr = new XPathExpr(XPathExprType.Path, ValueDataType.Sequence);
                    pathExpr.Add(filterExpr);
                    pathExpr.Add(new XPathStepExpr(new NodeSelectCriteria(QueryAxisType.DescendantOrSelf, NodeQName.Empty, QueryNodeType.All)));
                    pathExpr.Add(relPathExpr);
                }
                else
                {
                    pathExpr = filterExpr;
                }
            }

            return(pathExpr);
        }
        private XPathExpr ParsePathExpression()
        {
            XPathExpr expr = this.ParseLocationPath();

            if (expr != null)
            {
                return(expr);
            }
            XPathExpr expr2 = this.ParseFilterExpression();

            if (expr2 == null)
            {
                return(expr);
            }
            if (this.NextToken(XPathTokenID.Slash) != null)
            {
                this.EnsureReturnsNodeSet(expr2);
                XPathExprList subExpr = this.ParseRelativePath();
                if (subExpr == null)
                {
                    this.ThrowError(QueryCompileError.InvalidLocationPath);
                }
                XPathExpr expr3 = new XPathExpr(XPathExprType.RelativePath, ValueDataType.Sequence, subExpr);
                expr = new XPathExpr(XPathExprType.Path, ValueDataType.Sequence);
                expr.Add(expr2);
                expr.Add(expr3);
                return(expr);
            }
            if (this.NextToken(XPathTokenID.DblSlash) != null)
            {
                this.EnsureReturnsNodeSet(expr2);
                XPathExprList list2 = this.ParseRelativePath();
                if (list2 == null)
                {
                    this.ThrowError(QueryCompileError.InvalidLocationPath);
                }
                XPathExpr expr4 = new XPathExpr(XPathExprType.RelativePath, ValueDataType.Sequence, list2);
                expr = new XPathExpr(XPathExprType.Path, ValueDataType.Sequence);
                expr.Add(expr2);
                expr.Add(new XPathStepExpr(new NodeSelectCriteria(QueryAxisType.DescendantOrSelf, NodeQName.Empty, QueryNodeType.All)));
                expr.Add(expr4);
                return(expr);
            }
            return(expr2);
        }
        XPathExpr ParsePathExpression()
        {
            XPathExpr pathExpr = this.ParseLocationPath();

            if (null != pathExpr)
            {
                return pathExpr;
            }

            // Perhaps we have a filter expression
            XPathExpr filterExpr = this.ParseFilterExpression();
            if (null != filterExpr)
            {
                if (null != this.NextToken(XPathTokenID.Slash))
                {
                    EnsureReturnsNodeSet(filterExpr);

                    // Is this a complex filter expression.. i.e. followed by further selections..
                    XPathExprList relPath = this.ParseRelativePath();
                    if (null == relPath)
                    {
                        this.ThrowError(QueryCompileError.InvalidLocationPath);
                    }

                    XPathExpr relPathExpr = new XPathExpr(XPathExprType.RelativePath, ValueDataType.Sequence, relPath);

                    pathExpr = new XPathExpr(XPathExprType.Path, ValueDataType.Sequence);
                    pathExpr.Add(filterExpr);
                    pathExpr.Add(relPathExpr);
                }
                else if (null != this.NextToken(XPathTokenID.DblSlash))
                {
                    EnsureReturnsNodeSet(filterExpr);

                    XPathExprList relPath = this.ParseRelativePath();
                    if (null == relPath)
                    {
                        this.ThrowError(QueryCompileError.InvalidLocationPath);
                    }

                    XPathExpr relPathExpr = new XPathExpr(XPathExprType.RelativePath, ValueDataType.Sequence, relPath);
                    pathExpr = new XPathExpr(XPathExprType.Path, ValueDataType.Sequence);
                    pathExpr.Add(filterExpr);
                    pathExpr.Add(new XPathStepExpr(new NodeSelectCriteria(QueryAxisType.DescendantOrSelf, NodeQName.Empty, QueryNodeType.All)));
                    pathExpr.Add(relPathExpr);
                }
                else
                {
                    pathExpr = filterExpr;
                }
            }

            return pathExpr;
        }
        XPathExpr ParseFilterExpression()
        {
            XPathExpr primaryExpr = this.ParsePrimaryExpression();

            if (null == primaryExpr)
            {
                return null;
            }

            XPathExpr filterExpr = new XPathExpr(XPathExprType.Filter, primaryExpr.ReturnType);
            filterExpr.Add(primaryExpr);

            XPathExpr predicate = this.ParsePredicateExpression();

            if (null != predicate)
            {
                EnsureReturnsNodeSet(primaryExpr);

                //XPathExpr filterExpr = new XPathExpr(XPathExprType.Filter, ValueDataType.Sequence);

                //filterExpr.Add(primaryExpr);
                filterExpr.Add(predicate);

                // Read in any additional predicates
                while (null != (predicate = this.ParsePredicateExpression()))
                {
                    filterExpr.Add(predicate);
                }

                return filterExpr;
            }

            return primaryExpr;
        }
 private XPathExpr ParsePathExpression()
 {
     XPathExpr expr = this.ParseLocationPath();
     if (expr != null)
     {
         return expr;
     }
     XPathExpr expr2 = this.ParseFilterExpression();
     if (expr2 == null)
     {
         return expr;
     }
     if (this.NextToken(XPathTokenID.Slash) != null)
     {
         this.EnsureReturnsNodeSet(expr2);
         XPathExprList subExpr = this.ParseRelativePath();
         if (subExpr == null)
         {
             this.ThrowError(QueryCompileError.InvalidLocationPath);
         }
         XPathExpr expr3 = new XPathExpr(XPathExprType.RelativePath, ValueDataType.Sequence, subExpr);
         expr = new XPathExpr(XPathExprType.Path, ValueDataType.Sequence);
         expr.Add(expr2);
         expr.Add(expr3);
         return expr;
     }
     if (this.NextToken(XPathTokenID.DblSlash) != null)
     {
         this.EnsureReturnsNodeSet(expr2);
         XPathExprList list2 = this.ParseRelativePath();
         if (list2 == null)
         {
             this.ThrowError(QueryCompileError.InvalidLocationPath);
         }
         XPathExpr expr4 = new XPathExpr(XPathExprType.RelativePath, ValueDataType.Sequence, list2);
         expr = new XPathExpr(XPathExprType.Path, ValueDataType.Sequence);
         expr.Add(expr2);
         expr.Add(new XPathStepExpr(new NodeSelectCriteria(QueryAxisType.DescendantOrSelf, NodeQName.Empty, QueryNodeType.All)));
         expr.Add(expr4);
         return expr;
     }
     return expr2;
 }
 private XPathExpr ParseFilterExpression()
 {
     XPathExpr expr = this.ParsePrimaryExpression();
     if (expr == null)
     {
         return null;
     }
     XPathExpr expr2 = new XPathExpr(XPathExprType.Filter, expr.ReturnType);
     expr2.Add(expr);
     XPathExpr expr3 = this.ParsePredicateExpression();
     if (expr3 == null)
     {
         return expr;
     }
     this.EnsureReturnsNodeSet(expr);
     expr2.Add(expr3);
     while ((expr3 = this.ParsePredicateExpression()) != null)
     {
         expr2.Add(expr3);
     }
     return expr2;
 }