Examples of PathExpression


Examples of net.sf.saxon.expr.PathExpression

        if (!(subExpr instanceof PathExpression)) {
            return;
        }

        Document document = DOMUtils.toDOMDocument(contextNode);
        PathExpression pathExpr = (PathExpression) subExpr;
        Expression step = pathExpr.getFirstStep();

        while (step != null) {
            if (step instanceof AxisExpression) {
                AxisExpression axisExpr = (AxisExpression) step;

                NodeTest nodeTest = axisExpr.getNodeTest();

                if (!(nodeTest instanceof NameTest)) {
                    break;
                }

                NameTest nameTest = (NameTest) nodeTest;

                QName childName = getQualifiedName(nameTest.getFingerprint(),
                        namePool, contextUris);
               
                if (Axis.CHILD == axisExpr.getAxis()) {
                    if (NodeKindTest.ELEMENT.getNodeKindMask() != nameTest.getNodeKindMask()) {
                        break;
                    }
                 
                    NodeList children = ((Element) contextNode).getElementsByTagNameNS(childName.getNamespaceURI(),
                            childName.getLocalPart());
                    if ((children == null) || (children.getLength() == 0)) {
                        Node child = document.createElementNS(childName.getNamespaceURI(),
                                DOMUtils.getQualifiedName(childName));
                        contextNode.appendChild(child);
                        contextNode = child;
                    } else if (children.getLength() == 1) {
                        contextNode = children.item(0);
                    } else {
                        break;
                    }
                } else if (Axis.ATTRIBUTE == axisExpr.getAxis()) {
                    if (NodeKindTest.ATTRIBUTE.getNodeKindMask() != nameTest.getNodeKindMask()) {
                        break;
                    }
                   
                    Attr attribute = ((Element) contextNode).getAttributeNodeNS(childName.getNamespaceURI(), childName.getLocalPart());
                    if (attribute == null) {
                      attribute = document.createAttributeNS(childName.getNamespaceURI(), childName.getLocalPart());
                      ((Element) contextNode).setAttributeNode(attribute);
                      contextNode = attribute;
                    } else {
                      break;
                    }
                 
                } else {
                  break;
                }


            } else if (step instanceof ItemChecker) {
                ItemChecker itemChecker = (ItemChecker) step;
                Expression baseExpr = itemChecker.getBaseExpression();

                if (!(baseExpr instanceof VariableReference)) {
                    break;
                }
            } else {
                break;
            }

            if (pathExpr != null) {
                Expression remainingSteps = pathExpr.getRemainingSteps();

                if (remainingSteps instanceof PathExpression) {
                    pathExpr = (PathExpression) remainingSteps;
                    step = pathExpr.getFirstStep();
                } else if (remainingSteps instanceof AxisExpression) {
                    pathExpr = null;
                    step = (AxisExpression) remainingSteps;
                }
            } else {
View Full Code Here

Examples of org.jboss.dna.graph.property.PathExpression

                            }
                        }
                    }
                    String[] goodExpressionStrings = new String[pathExpressions.size()];
                    for (int i = 0; i != pathExpressions.size(); ++i) {
                        PathExpression expression = pathExpressions.get(i);
                        goodExpressionStrings[i] = expression.getExpression();
                    }
                    Map<String, Object> properties = new HashMap<String, Object>();
                    for (Property property : sequencerNode.getProperties()) {
                        Name propertyName = property.getName();
                        if (skipNamespaces.contains(propertyName.getNamespaceUri())) continue;
View Full Code Here

Examples of org.jboss.dna.graph.property.PathExpression

    private PathExpression expr;

    @Before
    public void beforeEach() throws Exception {
        expr = new PathExpression(".*");
    }
View Full Code Here

Examples of org.jboss.dna.jcr.xpath.XPath.PathExpression

                }
                prependDependentOrSelf = true;
            }
            relative = false;
        }
        PathExpression relativeExpr = parseRelativePathExpr(tokens);
        PathExpression result = new PathExpression(relative, relativeExpr.getSteps(), relativeExpr.getOrderBy());
        if (prependDependentOrSelf) {
            result.getSteps().add(0, new DescendantOrSelf());
        }
        return result;
    }
View Full Code Here

Examples of org.jboss.dna.jcr.xpath.XPath.PathExpression

            if (tokens.hasNext()) {
                steps.add(parseStepExpr(tokens));
            }
        }
        OrderBy orderBy = parseOrderBy(tokens); // may be null
        return new PathExpression(true, steps, orderBy);
    }
View Full Code Here

Examples of org.jboss.dna.jcr.xpath.XPath.PathExpression

            if (!nodeName.isWildcard()) {
                where.nodeName(alias).isEqualTo(nameFrom(nodeName));
            }
        } else {
            // Must be just a bunch of descendant-or-self, axis and filter steps ...
            translatePathExpressionConstraint(new PathExpression(true, path, null), where, alias);
        }
        return tableName;
    }
View Full Code Here

Examples of org.jboss.dna.jcr.xpath.XPath.PathExpression

                    // Now add the criteria ...
                    where.search(alias, value);
                    tableName = alias;
                } else if (param1 instanceof PathExpression) {
                    // refers to a descendant node ...
                    PathExpression pathExpr = (PathExpression)param1;
                    if (pathExpr.getLastStep().collapse() instanceof AttributeNameTest) {
                        AttributeNameTest attributeName = (AttributeNameTest)pathExpr.getLastStep().collapse();
                        pathExpr = pathExpr.withoutLast();
                        String searchTable = translatePredicate(pathExpr, tableName, where);
                        if (attributeName.getNameTest().isWildcard()) {
                            where.search(searchTable, value);
                        } else {
                            where.search(searchTable, nameFrom(attributeName.getNameTest()), value);
                        }
                    } else {
                        String searchTable = translatePredicate(param1, tableName, where);
                        where.search(searchTable, value);
                    }
                } else {
                    throw new InvalidQueryException(query,
                                                    "The first parameter of 'jcr:contains' must be a relative path (e.g., '.', an attribute name, a child name, etc.); therefore '"
                                                    + predicate + "' is not valid");
                }
            } else if (functionName.matches("jcr", "deref")) {
                throw new InvalidQueryException(query,
                                                "The 'jcr:deref' function is not required by JCR and is not currently supported; therefore '"
                                                + predicate + "' is not valid");
            } else {
                throw new InvalidQueryException(query,
                                                "Only the 'jcr:like' and 'jcr:contains' functions are allowed in a predicate; therefore '"
                                                + predicate + "' is not valid");
            }
        } else if (predicate instanceof PathExpression) {
            // Requires that the descendant node with the relative path does exist ...
            PathExpression pathExpr = (PathExpression)predicate;
            List<StepExpression> steps = pathExpr.getSteps();
            OrderBy orderBy = pathExpr.getOrderBy();
            assert steps.size() > 1; // 1 or 0 would have been collapsed ...
            Component firstStep = steps.get(0).collapse();
            if (firstStep instanceof ContextItem) {
                // Remove the context and retry ...
                return translatePredicate(new PathExpression(true, steps.subList(1, steps.size()), orderBy), tableName, where);
            }
            if (firstStep instanceof NameTest) {
                // Special case where this is similar to '[a/@id]'
                NameTest childName = (NameTest)firstStep;
                String alias = newAlias();
                builder.joinAllNodesAs(alias).onChildNode(tableName, alias);
                if (!childName.isWildcard()) {
                    where.nodeName(alias).isEqualTo(nameFrom(childName));
                }
                return translatePredicate(new PathExpression(true, steps.subList(1, steps.size()), orderBy), alias, where);
            }
            if (firstStep instanceof DescendantOrSelf) {
                // Special case where this is similar to '[a/@id]'
                String alias = newAlias();
                builder.joinAllNodesAs(alias).onDescendant(tableName, alias);
                return translatePredicate(new PathExpression(true, steps.subList(1, steps.size()), orderBy), alias, where);
            }
            // Add the join ...
            String alias = newAlias();
            builder.joinAllNodesAs(alias).onDescendant(tableName, alias);
            // Now add the criteria ...
View Full Code Here

Examples of org.jboss.dna.jcr.xpath.XPath.PathExpression

    protected PathExpression pathExpr( StepExpression... steps ) {
        return pathExpr(Arrays.asList(steps));
    }

    protected PathExpression pathExpr( List<StepExpression> steps ) {
        return new PathExpression(false, steps, null);
    }
View Full Code Here

Examples of org.jboss.dna.jcr.xpath.XPath.PathExpression

        return new PathExpression(false, steps, null);
    }

    protected PathExpression pathExpr( List<StepExpression> steps,
                                       OrderBy orderBy ) {
        return new PathExpression(false, steps, orderBy);
    }
View Full Code Here

Examples of org.jboss.dna.jcr.xpath.XPath.PathExpression

    protected PathExpression relativePathExpr( StepExpression... steps ) {
        return relativePathExpr(Arrays.asList(steps));
    }

    protected PathExpression relativePathExpr( List<StepExpression> steps ) {
        return new PathExpression(true, steps, null);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.