Yếu tố <xsl:fallback> trong XSLT
Định nghĩa và cách sử dụng
Yếu tố <xsl:fallback> quy định mã thay thế được thực thi khi bộ xử lý XSL không hỗ trợ yếu tố XSL.
Cú pháp
<xsl:fallback> <!-- Nội dung: template --> </xsl:fallback>
Thuộc tính
None
Mô hình
Ví dụ 1
Ví dụ này ban đầu muốn sử dụng một yếu tố虚构 <xsl:loop> để lặp qua mỗi yếu tố "title" . Nếu bộ xử lý XSL không hỗ trợ yếu tố đó (nó thực sự không hỗ trợ), sẽ sử dụng yếu tố <:xsl:for-each> thay thế:
<?xml version="1.0" encoding="ISO-8859-1"?> <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>