Optional parameters
Function declarations in XSLT and XQuery can include optional parameters with a default value.
-
XQuery syntax:
declare function local:f($x as xs:dateTime, $y as xs:duration := xs:duration('PT0S')) as xs:dateTime -
XSLT syntax:
<xsl:function name="local:f" as="xs:dateTime> <xsl:param name="x" as="xs:dateTime" required="yes"/> <xsl:param name="x" as="xs:duration" required="no" select="xs:duration('PT0S')"/> </xsl:function>
If a parameter is optional, then all subsequent parameters must also be optional.
If two functions in a query or stylesheet have the same name, then they must have non-overlapping arity ranges. The arity range indicates the number of arguments that must be supplied in a call to the function: the minimum is the number of required parameters, the maximum is the number of required parameters plus optional parameters.