public static XPath getXPath(String path,
Map<String, String> namespaces,
Map<QName, Function> functions,
Map<QName, Object> variables) throws JaxenException {
DocumentNavigator nav = new DocumentNavigator();
XPath contextpath = new BaseXPath(path, nav);
if (namespaces != null) {
for (Map.Entry<String, String> entry : namespaces.entrySet()) {
contextpath.addNamespace(entry.getKey(), entry.getValue());
}
}
if (functions != null) {
contextpath.setFunctionContext(getFunctionContext(functions, (SimpleFunctionContext)contextpath
.getFunctionContext()));
}
if (variables != null)
contextpath.setVariableContext(getVariableContext(variables, (SimpleVariableContext)contextpath
.getVariableContext()));
return contextpath;
}