The <xsl:fallback> Element

You use the XSLT 1.0 <xsl:fallback> element to indicate what to do if an extension element is not available. This element is enclosed in the extension element and is used if the extension element isn’t available.

The <xsl:fallback> element has no attributes, and encloses a template body.

In the following example, I create a fallback element inside the <redirect:write> element from the previous example. The <xsl:fallback> element will terminate processing with a message if the <redirect:write> element isn’t available:

 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:lxslt="http://xml.apache.org/xslt" xmlns:redirect="org.apache.xalan.lib.Redirect" extension-element-prefixes="redirect"> ...

Get Inside XSLT now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.