XSLT » Functions » element-available

Boolean = element-available('qname')
The mandatory qname argument is the qname of the element to be tested. It is commonly enclosed by single quotes.

The element-available function is used to determine if the XSLT processor will support the use of the XSLT element cited in the argument. Currently, this is important when dealing with proprietary elements. In the future, this function will gain additional importance when you have to contend with more than one version of the W3C XSLT standard.

If the element is supported, true is returned. If the element is not supported, false is returned.
The xsl:fallback function is designed to provide fallback code that can be run as an alternative when an XSLT processor fails to support an element.
This test only applies to instruction elements, which are elements that can occur in a template body. The current W3C version of XSLT has 18 instruction elements. They are:

xsl:apply-imports xsl:fallback
xsl:apply-templates xsl:for-each
xsl:attributes xsl:if
xsl:call-template xsl:message
xsl:choose xsl:number
xsl:comment xsl:processing instruction
xsl:copy xsl:text
xsl:copy-of xsl:value-of
xsl:element xsl:variable


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<xsl:when test="element-available('xsl:aardvark')">
<xsl:text>The xsl:aardvark element is available</xsl:text>
<xsl:text>The xsl:aardvark element is not available</xsl:text>
The xsl:aardvark element is not available

We test to see if the xsl:aardvark element is available. This is the code for xslt_example_elementavailable.xsl.
We use the DevGuru Staff List XML file for our example with the following header:
<?xml-stylesheet type="text/xsl" href="xslt_example_element avaiable.xsl"?>

Language(s): XSLT

See Also: