<value-of />で文字列を書き出す練習
<value-of>の練習のためのサンプル。
【sample016.xml】
<?xml version="1.0" encoding="Shift_JIS" ?>
<?xml-stylesheet href="sample016.xsl" type="text/xsl" ?>
<社員名簿>
<社員>
<社員番号>001</社員番号>
<名前>井上健語</名前>
<年齢>38</年齢>
<性別>男</性別>
</社員>
<社員>
<社員番号>002</社員番号>
<名前>山田太郎</名前>
<年齢>35</年齢>
<性別>男</性別>
</社員>
<社員>
<社員番号>003</社員番号>
<名前>中田英俊</名前>
<年齢>28</年齢>
<性別>男</性別>
</社員>
<社員>
<社員番号>004</社員番号>
<名前>菊池絵里子</名前>
<年齢>25</年齢>
<性別>女</性別>
</社員>
<社員>
<社員番号>005</社員番号>
<名前>吉田美子</名前>
<年齢>30</年齢>
<性別>女</性別>
</社員>
</社員名簿>
【sample016.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>value-ofで文字列を書き出す</title>
</head>
<body>
<p><xsl:apply-templates /></p>
</body>
</html>
</xsl:template>
<xsl:template match="社員">
<p>社員の
<span style="color:blue;"><xsl:value-of select="名前" /></span>
を発見しました
</p>
</xsl:template>
</xsl:stylesheet>
【結果】