XSLT - テンプレート(xsl:template)Advertisement書式
<xsl:template match="パターン">
テンプレート
</xsl:template>
例
<xsl:template match="title">
<h1>
<xsl:apply-templates/>
</h1>
</xsl:template>
参照元 XML 内の title というノードに <h1>〜</h1> という書式を適用する。
サンプルコード
sample.xml
<?xml version="1.0" encoding="Shift_JIS"?>
<?xml-stylesheet type="text/xsl" href="./style.xsl"?>
<document>
<title>XSLT</title>
<body>XSLT&XML</body>
</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="title">
<h1>
<xsl:value-of select="."/>
</h1>
</xsl:template>
<xsl:template match="body">
<p>
<xsl:value-of select="."/>
</p>
</xsl:template>
</xsl:stylesheet>
生成されるコード
<h1>XSLT</h1> <p>XSLT&XML</p> Advertisement |
ショートカット・634トップページ・このカテゴリのトップページに戻る ・634ラボ サイト検索Y!ログール |