List of usage examples for javax.xml.xpath XPath getXPathFunctionResolver
public XPathFunctionResolver getXPathFunctionResolver();
From source file:org.apache.camel.builder.xml.XPathBuilder.java
protected XPathExpression createXPathExpression() throws XPathExpressionException, XPathFactoryConfigurationException { XPath xPath = getXPathFactory().newXPath(); xPath.setNamespaceContext(getNamespaceContext()); xPath.setXPathVariableResolver(getVariableResolver()); XPathFunctionResolver parentResolver = getFunctionResolver(); if (parentResolver == null) { parentResolver = xPath.getXPathFunctionResolver(); }//from ww w . j av a 2s. c o m xPath.setXPathFunctionResolver(createDefaultFunctionResolver(parentResolver)); return xPath.compile(text); }
From source file:sf.net.experimaestro.manager.js.XPMObject.java
/** * Runs an XPath// w w w . j av a2 s. com * * @param path * @param xml * @return * @throws javax.xml.xpath.XPathExpressionException */ static public Object js_xpath(String path, Object xml) throws XPathExpressionException { Node dom = (Node) JSUtils.toDOM(null, xml); XPath xpath = XPathFactory.newInstance().newXPath(); xpath.setNamespaceContext(new NSContext(dom)); XPathFunctionResolver old = xpath.getXPathFunctionResolver(); xpath.setXPathFunctionResolver(new XPMXPathFunctionResolver(old)); XPathExpression expression = xpath.compile(path); String list = (String) expression.evaluate( dom instanceof Document ? ((Document) dom).getDocumentElement() : dom, XPathConstants.STRING); return list; }