public XPath parseXPath(String s) throws SAXPathException { return new BaseXPath(s, this); }
private BaseXPath createXPath(final String xpathQueryString, final Navigator navigator) throws JaxenException { final BaseXPath xpath = new BaseXPath(xpathQueryString, navigator); if (properties.size() > 1) { final SimpleVariableContext vc = new SimpleVariableContext(); for (Entry<PropertyDescriptor<?>, Object> e : properties.entrySet()) { final String propName = e.getKey().name(); if (!"xpath".equals(propName)) { final Object value = e.getValue(); vc.setVariableValue(propName, value != null ? value.toString() : null); } } xpath.setVariableContext(vc); } return xpath; } }
@Override @SuppressWarnings("unchecked") public List<Node> findChildNodesWithXPath(String xpathString) throws JaxenException { return new BaseXPath(xpathString, new DocumentNavigator()).selectNodes(this); }
LOGGER.finest("evaluator=" + evaluator); XPath xpath = new BaseXPath(xPath, new DocumentNavigator()); if (LOGGER.isLoggable(Level.FINEST)) { LOGGER.finest("xpath=" + xpath);
xpath = xpathCache.get(xpathQuery); if (xpath == null) { xpath = new BaseXPath(xpathQuery, FM_DOM_NAVIGATOR); xpath.setNamespaceContext(customNamespaceContext); xpath.setFunctionContext(FM_FUNCTION_CONTEXT);
@Override public final XPath parseXPath(String path) throws SAXPathException { return new BaseXPath(path, this); }
/** * @param expression The XPath expression * @param filter The coercion filter * @param variables The XPath variable context * @param namespaces The XPath namespace context */ public JaxenCompiled(String expression, Filter<T> filter, Map<String, Object> variables, Namespace[] namespaces) { super(expression, filter, variables, namespaces); try { xPath = new BaseXPath(expression, navigator); } catch (JaxenException e) { throw new IllegalArgumentException("Unable to compile '" + expression + "'. See Cause.", e); } xPath.setNamespaceContext(this); xPath.setVariableContext(this); }
/** * Compiles and sets the XPath expression wrapped by this object. * * @param expr * the XPath expression to wrap. * @throws JDOMException * if the XPath expression is invalid. */ private void setXPath(String expr) throws JDOMException { try { xPath = new BaseXPath(expr, navigator); xPath.setNamespaceContext(navigator); } catch (Exception ex1) { throw new JDOMException("Invalid XPath expression: \"" + expr + "\"", ex1); } }
/** * Returns a parsed form of the given xpath string, which will be suitable for queries on * documents that use the same navigator as this one. * * @param xpath the XPath expression * @return Returns a new XPath expression object. * @throws SAXPathException if the string is not a syntactically correct XPath expression * @see XPath */ public XPath parseXPath(String xpath) throws SAXPathException { return new BaseXPath(xpath, this); }
private AstNodeXPathQuery(String xpath) { try { expression = new BaseXPath(xpath, astNodeNavigator); } catch (JaxenException e) { throw Throwables.propagate(e); } }
private AstNodeXPathQuery(String xpath) { try { expression = new BaseXPath(xpath, astNodeNavigator); } catch (JaxenException e) { throw new RuntimeException(e); } }
private BaseXPath createXPath(final String xpathQueryString, final Navigator navigator) throws JaxenException { final BaseXPath xpath = new BaseXPath(xpathQueryString, navigator); if (properties.size() > 1) { final SimpleVariableContext vc = new SimpleVariableContext(); for (Entry<PropertyDescriptor<?>, Object> e : properties.entrySet()) { final String propName = e.getKey().name(); if (!"xpath".equals(propName)) { final Object value = e.getValue(); vc.setVariableValue(propName, value != null ? value.toString() : null); } } xpath.setVariableContext(vc); } return xpath; } }
/** * Returns the namespace prefixes that are used in the given XPath 1.0 expression. * <p> * If the expression is not a valid XPath expression, the empty set is returned. * </p> * * @param text * xpath expression, must not be <code>null</code> * @return namespace prefixes used in the expression, never <code>null</code>, but can be empty */ public static Set<String> extractPrefixes( String text ) { try { return extractPrefixes( new BaseXPath( text, null ).getRootExpr() ); } catch ( JaxenException e ) { // not an XPath expression return Collections.emptySet(); } }
@Override @SuppressWarnings("unchecked") public List<Node> findChildNodesWithXPath(String xpathString) throws JaxenException { return new BaseXPath(xpathString, new DocumentNavigator()).selectNodes(this); }
@SuppressWarnings("unchecked") public String getElementNameWithPredicates() throws JaxenException { BaseXPath baseXPath = new BaseXPath(xPath, new DocumentNavigator()); Expr rootExpr = baseXPath.getRootExpr(); LocationPath locationPath = (LocationPath) rootExpr; List<Step> steps = locationPath.getSteps(); Step lastStep = steps.get(steps.size() - 1); return MCRNodeBuilder.simplify(lastStep.getText()); }
private Element createRootElement(String xPath) throws JaxenException { BaseXPath baseXPath = new BaseXPath(xPath, new DocumentNavigator()); LocationPath lp = (LocationPath) (baseXPath.getRootExpr()); NameStep nameStep = (NameStep) (lp.getSteps().get(0)); String prefix = nameStep.getPrefix(); Namespace ns = prefix.isEmpty() ? Namespace.NO_NAMESPACE : MCRConstants.getStandardNamespace(prefix); return new Element(nameStep.getLocalName(), ns); }
public static List<QName> extractQNames( XPath xpath ) { List<QName> list = new ArrayList<QName>(); try { Expr expr = new BaseXPath( xpath.getXPath(), null ).getRootExpr(); if ( expr instanceof LocationPath ) { LocationPath lp = (LocationPath) expr; for ( Object o : lp.getSteps() ) { findQName( list, (Step) o, xpath.getNamespaceContext() ); } } } catch ( JaxenException e ) { // not a proper xpath } return list; }
private void init( NamespaceContext nsContext ) { xpath = new BaseXPath( text, null ).getRootExpr(); LOG.debug( "XPath: " + xpath ); } catch ( JaxenException e ) {
public static XPath getXPath(String path, Map<String, String> namespaces, Map<QName, Function> functions, Map<QName, Object> variables) throws JaxenException { DocumentNavigator nav = new DocumentNavigator(); XPath contextpath = new BaseXPath(path, nav); if (namespaces != null) { for (Map.Entry<String, String> entry : namespaces.entrySet()) { contextpath.addNamespace(entry.getKey(), entry.getValue()); } } if (functions != null) { contextpath.setFunctionContext(getFunctionContext(functions, (SimpleFunctionContext)contextpath .getFunctionContext())); } if (variables != null) contextpath.setVariableContext(getVariableContext(variables, (SimpleVariableContext)contextpath .getVariableContext())); return contextpath; }
xpath = xpathCache.get(xpathQuery); if (xpath == null) { xpath = new BaseXPath(xpathQuery, FM_DOM_NAVIGATOR); xpath.setNamespaceContext(customNamespaceContext); xpath.setFunctionContext(FM_FUNCTION_CONTEXT);