fallback.xsl 스타일시트는 XML 문서에 대한 대체 처리 방법을 제공합니다. fallback.xsl 스타일시트는 가상 <xsl:import-table>
요소가 있는 XML 문서를 처리하려고 시도합니다. 이 요소는 현재 버전의 파서에서 지원되지 않기 때문에 문서는 대체 요소 내에 있는 스크립트를 사용하여 처리됩니다.
XML 파일(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 파일(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>
출력
이 시나리오에서는 현재 버전의 파서에서 <xsl:import-table>
요소를 사용하여 테이블을 만들 수 없기 때문에 <xsl:fallback>
요소를 사용하여 다음 테이블이 생성됩니다.
Adam Barr |
222 Cherry |
555-797-2355 |
Jeff Adell |
730 Elm |
555-797-5555 |
참고 항목
참조
system-property 함수
element-available 함수
function-available 함수