XSLT <xsl:fallback>
❮ Complete XSLT Element Reference
定义和用法
The <xsl:fallback> element specifies an alternate code to run if the XSL processor does not support an XSL element.(<xsl:fallback> 元素指定如果在 XSL 处理器不支持某个 XSL 元素时要运行的备用代码。)
语法
<xsl:fallback>
<!-- Content: template -->
</xsl:fallback>
属性
无
示例 1
This example is supposed to loop through each "title" element with a made up <xsl:loop> element. If the XSL processor does not support this element (which it does not), it will use the <:xsl:for-each> element instead(此示例用于循环遍历一个虚构的 <xsl:loop> 元素的每个“title”元素。如果 XSL 处理器不支持此元素(它确实不支持),它将改用 <:xsl:for-each> 元素。)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="catalog/cd">
<xsl:loop select="title">
<xsl:fallback>
<xsl:for-each select="title">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:fallback>
</xsl:loop>
</xsl:template>
</xsl:stylesheet>
❮ Complete XSLT Element Reference