<xsl:for-each>の動作確認用テスト2

<xsl:for-each>は使っている。<xsl:for-each>要素内では、 コンテキストノードが定食要素になる。このため、 <xsl:value-of select="." />で定食要素の内容が書き出されている。 別途、定食用に用意したテンプレートは使われていないことに注目。
【sample023.xml】
<?xml version="1.0" encoding="Shift_JIS" ?>
<?xml-stylesheet href="sample023.xsl" type="text/xsl" ?>
<定食メニュー>
	<定食>焼肉定食</定食>
	<定食>マーボ定食</定食>
	<定食>餃子定食</定食>
	<定食>ラーメン定食</定食>
</定食メニュー>


【sample023.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><xsl:for-each>の動作確認用テスト1</title>
	</head>
	<body>
		<xsl:for-each select="定食">
			<p style="color:red;"><xsl:value-of select="."/></p>
		</xsl:for-each>
	</body>
	</html>
</xsl:template>

<xsl:template match="定食">
	<p style="color:blue;">定食が発見されました</p>
</xsl:template>

</xsl:stylesheet>


【結果】