List of usage examples for org.apache.commons.jxpath JXPathInvalidSyntaxException getMessage
public String getMessage()
From source file:org.commonjava.maven.galley.maven.model.view.MavenXmlView.java
/** * Retrieve the first node matching the given XPath expression, including the inheritance hierarchy documents * up to the specified maxDepth (if maxDepth < 0, consider the full inheritance hierarchy). Also include * any mix-in documents in the search. If cachePath is true, compile the XPath instance and cache it for * reuse in future queries. If the XPath expression resolves to something other than a text value, * retrieve the text() child.//from www . j ava 2 s .c om * <br/> * Do NOT resolve Maven-style expressions on the resulting value. * <br/> * If the XPath expression is listed as local-only (specified when the view is constructed), do NOT search * beyond the current document. * * @param path The XPath expression * @param cachePath If true, compile this XPath expression and cache for future use * @param maxDepth Max ancestry depth to search. If < 0, search all ancestors. */ public String resolveXPathToRawString(final String path, final boolean cachePath, final int maxDepth) throws GalleyMavenRuntimeException { String result = null; // try // { // final XPathExpression expression = xpath.getXPath( path, cachePath ); int maxAncestry = maxDepth; for (final String pathPrefix : localOnlyPaths) { if (path.startsWith(pathPrefix)) { maxAncestry = 0; break; } } // logger.info( "Resolving: {}", path ); int ancestryDepth = 0; for (final DocRef<T> dr : stack) { if (maxAncestry > -1 && ancestryDepth > maxAncestry) { break; } try { result = (String) dr.getDocContext().getValue(path); } catch (final JXPathInvalidSyntaxException e) { logger.debug("[ABORT XPath] Error resolving '{}' from '{}': {}", e, path, dr.getSource(), e.getMessage()); return null; } catch (final JXPathException e) { logger.debug("[SKIP XPath-Doc] Error resolving '{}' from '{}': {}", e, path, dr.getSource(), e.getMessage()); continue; } // result = (Node) expression.evaluate( dr.getDoc(), XPathConstants.NODE ); // logger.info( "Value of '{}' at depth: {} is: {}", path, ancestryDepth, result ); if (result != null) { break; } ancestryDepth++; } if (result == null) { for (final MavenXmlMixin<T> mixin : mixins) { if (mixin.matches(path)) { result = mixin.getMixin().resolveXPathToRawString(path, true, maxAncestry); // logger.info( "Value of '{}' in mixin: {} is: '{}'", path, mixin ); } if (result != null) { break; } } } // } // catch ( final XPathExpressionException e ) // { // throw new GalleyMavenRuntimeException( "Failed to retrieve content for xpath expression: {}. Reason: {}", e, path, e.getMessage() ); // } return result; }