XPathFactory factory = XPathFactory.newInstance();
XPath xpath = factory.newXPath();
// set the NamespaceContext to
// org.apache.xalan.extensions.ExtensionNamespaceContext
xpath.setNamespaceContext(new ExtensionNamespaceContext());
// set the XPathFunctionResolver to
// org.apache.xalan.extensions.XPathFunctionResolverImpl
xpath.setXPathFunctionResolver(new XPathFunctionResolverImpl());