pending.push(originalXPath.getRootExpr()); while (!pending.isEmpty()) { final Expr node = pending.pop();
/** * 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(); } }
@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()); }
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 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); }
private void init( NamespaceContext nsContext ) { xpath = new BaseXPath( text, null ).getRootExpr(); LOG.debug( "XPath: " + xpath ); } catch ( JaxenException e ) {
pending.push(originalXPath.getRootExpr()); while (!pending.isEmpty()) { final Expr node = pending.pop();