Function calls
A function call in XPath 2.0 takes the form F ( arg1, arg2, ...). In
general, the function name is a QName.
A library of core functions is defined in the XPath and XSLT specifications (in versions 2.0, 3.0, 3.1, and 4.0). For details of these functions, including notes on their implementation in this Saxon release, see the Function library. Additional functions are available (in a special namespace) as Saxon extensions: these are also listed in the Function library, with some further information in the Extensions section.
Further functions may be implemented by the user, either as XSLT stylesheet functions (see xsl:function), as XQuery functions, or as Java extension functions (see the Extensibility mechanisms section). From XPath 3.0, anonymous functions can also be created directly in an expression using an inline function expression.
XPath 3.0 introduces dynamic function calls: EXPR ( arg1, arg2, ...) where
EXPR is an expression that evaluates to a function item.
When converting an argument of a function call to the declared type of the function parameter the rules that are used are defined in the XPath specifications. From XPath 4.0, these rules are called the coercion rules, previously they were known as the function conversion rules. For information on the further changes in these rules in 4.0, see coercion rules.
Keyword arguments
From XPath 4.0, in a static function call, arguments may be supplied either by position or by name. The call must have zero or more positional parameters followed by zero or more keyword parameters. For example:
sort(//employee, key := fn{xs:decimal(@salary)})Although keywords will often be used for optional parameters as in this example, there is no rule requiring this. Whether a parameter is optional or required, the corresponding argument may be supplied either positionally or by keyword. (Implemented from Saxon 12.)
Keywords can also be used in a partial function application, for example: f(x
:= ?, y := ?). (Implemented from Saxon 13.)