@Test public void shouldParsePathExpressionWithNameTestsAndWildcardAndPropertyExistence() { assertThat(parser.parsePathExpr(tokenize("/jcr:root/a/b/*[@prop]")), is(pathExpr(axisStep(nameTest("jcr", "root")), axisStep(nameTest("a")), axisStep(nameTest("b")), axisStep(wildcard(), attributeNameTest(nameTest("prop")))))); }
protected PathExpression parsePathExpr( TokenStream tokens ) { boolean relative = true; boolean prependDependentOrSelf = false; if (tokens.canConsume('/')) { if (tokens.canConsume('/')) { if (!tokens.hasNext()) { throw new ParsingException(tokens.previousPosition(), "' } 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; }
XPathParser { protected PathExpression parsePathExpr( TokenStream tokens ) { boolean relative = true; boolean prependDependentOrSelf = false; if (tokens.canConsume('/')) { if (tokens.canConsume('/')) { if (!tokens.hasNext()) { throw new ParsingException(tokens.previousPosition(), "' } 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; } }
XPathParser { protected PathExpression parsePathExpr( TokenStream tokens ) { boolean relative = true; boolean prependDependentOrSelf = false; if (tokens.canConsume('/')) { if (tokens.canConsume('/')) { if (!tokens.hasNext()) { throw new ParsingException(tokens.previousPosition(), "' } 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; } XPathParser( TypeSystem context ); }
XPathParser { protected PathExpression parsePathExpr( TokenStream tokens ) { boolean relative = true; boolean prependDependentOrSelf = false; if (tokens.canConsume('/')) { if (tokens.canConsume('/')) { if (!tokens.hasNext()) { throw new ParsingException(tokens.previousPosition(), "' } 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; } XPathParser( TypeSystem context ); Component parseXPath( String xpath ); }
XPathParser { protected PathExpression parsePathExpr( TokenStream tokens ) { boolean relative = true; boolean prependDependentOrSelf = false; if (tokens.canConsume('/')) { if (tokens.canConsume('/')) { if (!tokens.hasNext()) { throw new ParsingException(tokens.previousPosition(), "' } 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; } XPathParser( TypeSystem context ); Component parseXPath( String xpath );  }