/** Retrieve the root expression of the internal * compiled form of this XPath expression. * * <p> * Internally, Jaxen maintains a form of Abstract Syntax * Tree (AST) to represent the structure of the XPath expression. * This is normally not required during normal consumer-grade * usage of Jaxen. This method is provided for hard-core users * who wish to manipulate or inspect a tree-based version of * the expression. * </p> * * @return the root of the AST of this expression */ public Expr getRootExpr() { return xpath.getRootExpr(); }
/** Select all nodes that match this XPath * expression on the given Context object. * If multiple nodes match, multiple nodes * will be returned in document-order, as defined by the XPath * specification. If the expression selects a non-node-set * (i.e. a number, boolean, or string) then a List * containing just that one object is returned. * </p> * * @param context the Context which gets evaluated * * @return the node-set of all items selected * by this XPath expression * @throws JaxenException if an XPath error occurs during expression evaluation * */ protected List selectNodesForContext(Context context) throws JaxenException { List list = this.xpath.asList( context ); return list; }
/** Retrieve the Jaxen XPath expression tree, optionally * simplified. * * <p> * This method is only valid once <code>XPathReader.parse(...)</code> * successfully returned. * </p> * * @param shouldSimplify ???? * * @return the XPath expression tree */ public XPathExpr getXPathExpr(boolean shouldSimplify) { if ( shouldSimplify && ! this.simplified ) { this.xpath.simplify(); this.simplified = true; } return this.xpath; }
public static Pattern parse(String text) throws JaxenException, org.jaxen.saxpath.SAXPathException { if ( USE_HANDLER ) { XPathReader reader = XPathReaderFactory.createReader(); PatternHandler handler = new PatternHandler(); handler.setXPathFactory( new DefaultXPathFactory() ); reader.setXPathHandler( handler ); reader.parse( text ); return handler.getPattern(); } else { XPathReader reader = XPathReaderFactory.createReader(); JaxenHandler handler = new JaxenHandler(); handler.setXPathFactory( new DefaultXPathFactory() ); reader.setXPathHandler( handler ); reader.parse( text ); Pattern pattern = convertExpr( handler.getXPathExpr().getRootExpr() ); return pattern.simplify(); } }
Expr expr = xpath.getRootExpr(); if (!(expr instanceof LocationPath)) { throw new SAXPathException("Invalid XPath expression '" + xpathExpression + "'. Selector must be a LocationPath expression. Is '" + expr.getText() + "'.");
Expr expr = xpath.getRootExpr(); if (!(expr instanceof LocationPath)) { throw new SAXPathException("Invalid XPath expression '" + xpathExpression + "'. Selector must be a LocationPath expression. Is '" + expr.getText() + "'.");
Expr expr = xpath.getRootExpr(); if (!(expr instanceof LocationPath)) { throw new SAXPathException("Invalid XPath expression '" + xpathExpression + "'. Selector must be a LocationPath expression. Is '" + expr.getText() + "'.");
Expr expr = xpath.getRootExpr(); if (!(expr instanceof LocationPath)) { throw new SAXPathException("Invalid XPath expression '" + xpathExpression + "'. Selector must be a LocationPath expression. Is '" + expr.getText() + "'.");
Expr expr = xpath.getRootExpr(); if (!(expr instanceof LocationPath)) { throw new SAXPathException("Invalid XPath expression '" + xpathExpression + "'. Selector must be a LocationPath expression. Is '" + expr.getText() + "'.");
static @NonNull JaxenXPath create(final @NonNull Converter<String, QNameModule> converter, final @NonNull SchemaPath schemaPath, final @NonNull String xpath) throws JaxenException { final @NonNull Expr parsed; try { final XPathReader reader = new org.jaxen.saxpath.base.XPathReader(); final JaxenHandler handler = new JaxenHandler(); reader.setXPathHandler(handler); reader.parse(xpath); parsed = handler.getXPathExpr().getRootExpr(); } catch (org.jaxen.saxpath.XPathSyntaxException e) { throw new XPathSyntaxException(e); } catch (SAXPathException e) { throw new JaxenException(e); } LOG.debug("Compiled {} to expression {}", xpath, parsed); new ExprWalker(new ExprListener() { // FIXME: perform expression introspection to understand things like apex, etc. }).walk(parsed); return new JaxenXPath(converter, schemaPath, parsed); }
static @NonNull JaxenXPath create(final @NonNull Converter<String, QNameModule> converter, final @NonNull SchemaPath schemaPath, final @NonNull String xpath) throws JaxenException { final @NonNull Expr parsed; try { final XPathReader reader = new org.jaxen.saxpath.base.XPathReader(); final JaxenHandler handler = new JaxenHandler(); reader.setXPathHandler(handler); reader.parse(xpath); parsed = handler.getXPathExpr().getRootExpr(); } catch (org.jaxen.saxpath.XPathSyntaxException e) { throw new XPathSyntaxException(e); } catch (SAXPathException e) { throw new JaxenException(e); } LOG.debug("Compiled {} to expression {}", xpath, parsed); new ExprWalker(new ExprListener() { // FIXME: perform expression introspection to understand things like apex, etc. }).walk(parsed); return new JaxenXPath(converter, schemaPath, parsed); }