XSLT » Functions » function-available

Syntax:
Boolean = function-available(function-name)
function-name
The function-name argument is simply the qname of the function that you wish to test. A qname is an XML name with an optional prefix. If the value is not of type string, it will automatically be converted to a string by the XPath string() function.

The function-available function is used to test whether the function specified in the argument is supported by the XSLT processor. Currently, this is important when dealing with proprietary functions. In the future, this function will gain additional importance when you have to content with more than one version of the W3C XSLT standard.

If the function is supported, true is returned. If the function is not supported, false is returned.
 
The following XSLT and XPath functions should return true if a processor supports the W3C XSLT standard.
 

boolean name
ceiling namespace-uri
concat normalize-space
contains not
count number
current position
document round
element-available starts-with
false string
floor string-length
format-number substring
function-available substring-after
generate-id substring-before
id sum
key system-property
lang translate
last true
local-name unparsed-entity-uri

Examples

Code:
version="1.0">
<xsl:template match="/">
<html>
<body>
<xsl:choose>
<xsl:when test="function-available('aardvark')">
<xsl:text>The aardvark function is available</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>The aardvark function is not available</xsl:text>
</xsl:otherwise>
</xsl:choose>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Output:
The aardvark function is not available
Explanation:

Here we test to see if the aardvark function is available. This is the code for xslt_example_functionavailable.xsl.

We use the DevGuru Staff List XML file for our example with the following header:
<?xml-stylesheet type="text/xsl" href="xslt_example_functionavailable.xsl"?>

Language(s): XSLT

See Also: