Name
function-available()
Determines if a given function is available to the XSLT processor. This function allows you to design stylesheets that react gracefully if a particular extension function is not available.
Syntax
[1.0] booleanfunction-available($functionName as string)[2.0] xs:booleanfunction-available($functionName as xs:string,$arity as xs:integer?)
Inputs
The function’s name. The name is usually qualified with a namespace; if the namespace of the function name is nonnull, the function is an extension function. Otherwise, the function is assumed to be one of the functions defined in the XSLT or XPath specifications.
[2.0] XSLT 2.0’s version of this
function also has an arity argument. This
lets you specify how many parameters a function accepts. For
example, function-available('ora:greatFunction',
2) might return true,
while function-available('ora:greatFunction',
3) might return false. If you try to call function-available('me:my-function', 2) with an XSLT 1.0
processor, you’ll get a runtime error.
Output
The boolean value true if
the function is available; false otherwise.
Defined in
[1.0] XSLT section 15, “Fallback.”
[2.0] XSLT section 18.1, “Extension Functions.”
Example
We’ll use the following XML document to test the function-available()
function:
<?xml version="1.0"?>
<!-- favorites.xml --> <list> <title>A few of my favorite albums</title> <listitem>A Love Supreme</listitem> <listitem>Beat Crazy</listitem> <listitem>Here Come the Warm Jets</listitem> <listitem>Kind of Blue</listitem> ...Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access