指定した要素にだけテンプレートを適用
<xsl:apply-templates select="日本|フランス|ブラジル"/>で
下のテンプレートが、この3つの要素にだけ適用されている。
*を指定しているが、適用する要素を明示した場合は、指定外の
要素には適用されない。
【sample008.xml】
<?xml version="1.0" encoding="Shift_JIS" ?>
<?xml-stylesheet href="sample008.xsl" type="text/xsl" ?>
<国リスト>
<日本>Japan</日本>
<アメリカ>United States of America</アメリカ>
<韓国>Korea</韓国>
<フランス>France</フランス>
<イギリス>United Kingdom</イギリス>
<ブラジル>Brazil</ブラジル>
</国リスト>
【sample008.xsl】
<?xml version="1.0" encoding="Shift_JIS" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="Shift_JIS" />
<xsl:template match="国リスト">
<html>
<head><title>指定した要素にだけテンプレートを適用</title></head>
<body>
<xsl:apply-templates select="日本|フランス|ブラジル"/>
</body>
</html>
</xsl:template>
<xsl:template match="*">
<h2>その国は<xsl:value-of select="." />!</h2>
</xsl:template>
</xsl:stylesheet>
【結果】