XSLT - テンプレートの呼び出し(xsl:call-template)Advertisement書式<xsl:call-template name="テンプレート名"/> 例
<xsl:call-template name="title"/>
(略)
<xsl:template name="title">
処理
</xsl:template>
サンプルコード
sample.xml
<?xml version="1.0" encoding="Shift_JIS"?>
<?xml-stylesheet type="text/xsl" href="./style.xsl"?>
<document>
<book id="10">
<title>AAA</title>
<price>4000</price>
</book>
<book id="20">
<title>BBB</title>
<price>1000</price>
</book>
<book id="30">
<title>CCC</title>
<price>2000</price>
</book>
<book id="40">
<title>DDD</title>
<price>1500</price>
</book>
<book id="50">
<title>EEE</title>
<price>500</price>
</book>
</document>
style.xsl
<?xml version="1.0" encoding="Shift_JIS"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="document">
<html>
<head>
<title>XSLT</title>
</head>
<body>
<ul>
<xsl:call-template name="title"/>
</ul>
</body>
</html>
</xsl:template>
<xsl:template name="title">
<xsl:for-each select="book/price">
<li><xsl:value-of select="."/></li>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
生成されるコード
<html>
<head>
<title>XSLT</title>
</head>
<body>
<ul>
<li>4000</li>
<li>1000</li>
<li>2000</li>
<li>1500</li>
<li>500</li>
</ul>
</body>
</html>
Advertisement |
ショートカット・634・634ブログ ・このカテゴリのトップページに戻る ・Incubator(Pukiwiki) ・634ラボ UIコレクションギャラリー ZO-3ジェネレーター サイト検索Y!ログールビリヤード |