Beispiel #1
0
        private bool IsOrderedSet()
        {
            for (int k = 0; k < _path.Length; k++)
            {
                XPath2ExprType exprType;
                if (_path[k].type == XPath2ExprType.Expr)
                {
                    if (k == 0)
                    {
                        continue;
                    }
                    FilterExprNode filterExpr = _path[k].node as FilterExprNode;
                    if (filterExpr == null)
                    {
                        return(false);
                    }
                    PathExprNode pathExpr = filterExpr[0] as PathExprNode;
                    if (pathExpr == null)
                    {
                        return(false);
                    }
                    exprType = pathExpr._path[0].type;
                }
                else
                {
                    exprType = _path[k].type;
                }
                switch (exprType)
                {
                case XPath2ExprType.Expr:
                case XPath2ExprType.Parent:
                case XPath2ExprType.Ancestor:
                case XPath2ExprType.AncestorOrSelf:
                case XPath2ExprType.Preceding:
                case XPath2ExprType.PrecedingSibling:
                    return(false);

                case XPath2ExprType.Descendant:
                case XPath2ExprType.DescendantOrSelf:
                case XPath2ExprType.Following:
                case XPath2ExprType.ChildOverDescendants:
                    if (k < _path.Length - 1)
                    {
                        for (int s = k + 1; s < _path.Length; s++)
                        {
                            if (_path[s].type != XPath2ExprType.Attribute &&
                                _path[s].type != XPath2ExprType.Namespace)
                            {
                                return(false);
                            }
                        }
                    }
                    break;
                }
            }
            return(true);
        }
Beispiel #2
0
        public static PathStep CreateFilter(XPath2Context context, object node, List <Object> predicateList)
        {
            if (predicateList.Count == 1)
            {
                AbstractNode predicate = AbstractNode.Create(context, predicateList[0]);
                ValueNode    numexpr   = predicate as ValueNode;
                if (numexpr != null && numexpr.Content is Integer)
                {
                    PathStep res = Create(context, node);
                    res.AddLast(new PathStep(numexpr.Content, XPath2ExprType.PositionFilter));
                    return(res);
                }
            }
            AbstractNode filterExpr = new FilterExprNode(context, node, predicateList);

            return(new PathStep(filterExpr));
        }