XSLT - 値の参照 (xsl:value-of)Advertisement書式<xsl:value-of select="値を取得するノード"/>指定したノードの値を取得する。 例<xsl:value-of select="."/> サンプルコード
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="document">
<html>
<head>
<title>XSLT</title>
</head>
<body>
<xsl:apply-templates select="title"/>
<xsl:apply-templates select="body"/>
</body>
</html>
</xsl:template>
<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>
生成されるコード
<html> <head> <title>XSLT</title> </head> <body> <h1>XSLT</h1> <p>XSLT&XML</p> </body> </html> Advertisement |
ショートカット・634トップページ・このカテゴリのトップページに戻る ・634ラボ サイト検索Y!ログール |