XSLT FUNCTION:  function-available

Boolean = function-available(function-name)
 
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

 
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.
 
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"?>
and we name it: xslt_example_functionavailable.xml
 
We test to see if the aardvark function is available.
 
Code for xslt_example_functionavailable.xsl:
 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 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:
 
Click to view output in separate window.

 
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information