throw new SAXException("Only xpointer scheme is supported ATM");
}
xPointerSchemeIndex += xPointerSchemeString.length();
int xPointerSchemeEndIndex = this.findBalancedEndIndex(xpointer, xPointerSchemeIndex, '(', ')');
XPathFactory xPathFactory = XPathFactory.newInstance();
XPath xPath = xPathFactory.newXPath();
int xmlnsSchemeIndex = xpointer.indexOf(xmlnsSchemeString);
if (xmlnsSchemeIndex >= 0) {
xmlnsSchemeIndex += xmlnsSchemeString.length();
int xmlnsSchemeEndIndex = this.findBalancedEndIndex(xpointer, xmlnsSchemeIndex, '(', ')');
String namespaceScheme = xpointer.substring(xmlnsSchemeIndex, xmlnsSchemeEndIndex);
final String[] namespaceSplit = namespaceScheme.split("=");
xPath.setNamespaceContext(new NamespaceContext() {
@Override
public String getNamespaceURI(String prefix) {
if (prefix.equals(namespaceSplit[0])) {
return namespaceSplit[1];
}
return null;
}
@Override
public String getPrefix(String namespaceURI) {
if (namespaceURI.equals(namespaceSplit[1])) {
return namespaceSplit[0];
}
return null;
}
@Override
public Iterator<String> getPrefixes(String namespaceURI) {
return null;
}
});
}
try {
return (NodeList) xPath.evaluate(xpointer.substring(xPointerSchemeIndex, xPointerSchemeEndIndex), node, XPathConstants.NODESET);
} catch (XPathExpressionException e) {
throw new SAXException(e);
}
}