PrefixResolverDefault prefixResolver = new PrefixResolverDefault((contextNode.getNodeType() == Node.DOCUMENT_NODE)
? ((Document)contextNode).getDocumentElement() :
contextNode);
// Create the XPath object.
XPath xpath = new XPath();
// Create a XPath parser.
XPathProcessorImpl parser = new XPathProcessorImpl(xpathSupport);
parser.initXPath(xpath, str, prefixResolver);
// Execute the XPath, and have it return the result
return xpath.execute(xpathSupport, contextNode, prefixResolver);
}