xsl:fallback Element

The <xsl:fallback> element is designed to handle situations where the parser cannot handle an XSL element that may be part of a new version, or is otherwise an unrecognized extension. It works by calling template content that can provide a reasonable substitute to the behavior of the new element when encountered.

<xsl:fallback>
</xsl:fallback>

Attributes

None.

Element Information

Number of occurrences Unlimited
Parent elements Any element where the content is a template.
Child elements Any element that can occur in a template.

Remarks

When an XSL document is first loaded, the XSLT preparser performs validation on all XSL elements. If the version passed in the <xsl:stylesheet> element is greater than that supported by the parser, then whenever an unfamiliar element is encountered, the parser will execute the <xsl:fallback> children of that element (or simply not perform any action if the fallback has no content). If the element is supported, then the fallback templates are never instantiated. Likewise, if the version given in the style sheet is the same as that supported by the browser, then an error will be called.

Fallbacks are part of the forward-processing mechanism that XSLT uses for handling upgrades. By creating alternative ways of handling a command if an element is not supported, forward-processing guarantees that the code used is relatively robust and insensitive to differences in parser conformity.

In addition to handling versioning differences, the fallback function can also be used to handle elements defined by name space extensions. Because adding functionality to the base specification is typically very difficult, name space extensions let developers define functionality beyond that specified by the XSLT specification. If the name space is not supported (no definition for the name space is provided), or if a name space function or element is not defined, then the fallback mechanism can be used to provide alternate functionality.

To guarantee that the extension is interpreted within the XSLT operation, you need to set the extension-element-prefixes attribute in the <xsl:stylesheet> element so that it contains the name of the prefix to interpret. In addition, declare the name space for that prefix.

See Also

XSLT Elements | element-available Function | function-available Function | system-property Function

 Last updated on Saturday, April 10, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.