XSLT » Elements » xsl:fallback


The xsl:fallback element is designed to provide fallback code that can be run as an alternative when an XSLT processor fails to support an element.

Normally, when an XSLT element is not recognized by the XSLT processor an error occurs. The concept behind the xsl:fallback element is to provide a mechanism that will allow a procedure to keep running whenever an XSLT element is encountered that is not supported by an XSLT processor. For example, view these Microsoft proprietary elements. Undoubtedly, as XSLT becomes more mainstream, additional proprietary elements will become more common. A similar problem may also arise as newer and newer versions of XSLT become available and various elements are added or removed from the standard.
In the future, it may become commonplace to use the xsl:fallback element as a means of insuring portability between different browsers and XSLT processors.
This element has no attributes.
This is not a self-closing element. The separate closing element is mandatory.


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="5.0">
<xsl:template match="/">
<xsl:for-each select="devguru_staff/programmer">
NAME: <xsl:value-of select="name" />
<br />
NAME: Bugs Bunny
NAME: Daisy Duck
NAME: Minnie Mouse
NAME: Pluto
NAME: Porky Pig
NAME: Road Runner

We try to use the xsl:list-name element in XML version 5.0. This is the code for xslt_example_fallback.xsl.
We use the DevGuru Staff List XML file for our example with the following header:
<?xml-stylesheet type="text/xsl" href="xslt_example_fallback.xsl"?>

Language(s): XSLT

See Also: