O'Reilly logo

XSLT, 2nd Edition by Doug Tidwell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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] boolean function-available($functionName as string)
[2.0] xs:boolean function-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> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required