XPath functions accept a variable number of dynamically typed parameters, and return a single dynamically typed result. XPath data types are implemented by XPathValue and its subclasses. The parameters passed by the query are therefore passed on to the XPathFunction as an Array of XPathValue, and the XPathFunction returns an XPathValue (which may be null).
A function which for some reason fails to evaluate (for example incorrect parameter count) should throw xpath.XPathEvaluationException.