public static List evaluate (Context context, Object arg) throws FunctionCallException { List contextNodes = context.getNodeSet(); if (contextNodes.size() == 0) return Collections.EMPTY_LIST; Navigator nav = context.getNavigator(); String xpathString; if ( arg instanceof String ) xpathString = (String)arg; else xpathString = StringFunction.evaluate(arg, nav); try { XPath xpath = nav.parseXPath(xpathString); ContextSupport support = context.getContextSupport(); xpath.setVariableContext( support.getVariableContext() ); xpath.setFunctionContext( support.getFunctionContext() ); xpath.setNamespaceContext( support.getNamespaceContext() ); return xpath.selectNodes( context.duplicate() ); } catch ( org.jaxen.saxpath.SAXPathException e ) { throw new FunctionCallException(e.toString()); } } }