Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - XSLT Reference

Example of <xsl:fallback>

The fallback.xsl style sheet provides alternate processing for an XML document. The fallback.xsl style sheet attempts to process the XML document with a hypothetical <xsl:import-table> element. Because this element is not supported in the current version of the parser, the document is alternately processed with the script inside the fallback element.

Note To test this example, you need to use a script. For more information, see Initiate XSLT in a Script.

XML File (records.xml)

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="fallback.xsl"?>
<records>
    <record>
        <name>Adam Barr</name>
        <address>222 Cherry</address>
        <phone>555-797-2355</phone>
    </record>
    <record>
        <name>Jeff Adell</name>
        <address>730 Elm</address>
        <phone>555-797-5555</phone>
    </record>
</records>

XSLT File (fallback.xsl)

<?xml version="1.0"?>
<xsl:stylesheet version="1.1"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >

  <xsl:template match="/">
     <HTML>
     <HEAD><TITLE>Output Table</TITLE></HEAD>
     <BODY>
     <xsl:import-table href="blah.html" name="sample">
        <xsl:fallback>
        <p>
            This version of the parser does not support the creation of a
            table with the 'xsl:import-table' element, so the following 
            table has been generated using the 'fallback' element.
        </p>
          <table border='2'>
            <xsl:for-each select='records/record'>
              <tr>
                <td><xsl:value-of select='name'/></td>
                <td><xsl:value-of select='address'/></td>
                <td><xsl:value-of select='phone'/></td>
              </tr>
            </xsl:for-each>
          </table>
        </xsl:fallback>
      </xsl:import-table>
      </BODY>
    </HTML> 
  </xsl:template>

</xsl:stylesheet>

Output

In this scenario, the current version of the parser does not support the creation of a table with the <xsl:import-table> element, so the following table is generated using the <xsl:fallback> element:

Adam Barr 222 Cherry 555-797-2355
Jeff Adell 730 Elm 555-797-5555

See Also

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