Calling JAXP XPath extension functions

The JAXP XPath interface includes an interface FunctionResolver which can be used to bind a function call appearing in the XPath expression to a user-written Java implementation of the interface java.xml.xpath.XPathFunction. The form in which parameters are passed to such a function, and the form in which it returns its results, are not precisely defined in the JAXP specification, so this section fills the gap. Note that the calling conventions are likely to differ from those used by other products.

The extension function is called by invoking the method XPathFunction.evaluate(), which takes a list of arguments, and returns the function result.

The arguments are therefore supplied as a list. Each item in this list represents one argument. The rules applied to convert arguments from XDM values to Java objects are the same as the rules for Java extension functions described at Converting Arguments to Java Extension Functions.

Similarly, the return value is converted to an XDM value using the rules given at Converting Java values to XDM values.