XSLTキー()関数
定義と使用法
キー()関数:指定されたインデックスを使用してます。<xsl key>要素は、ドキュメントからのノードのセットを返します。
文法
node-set key(string, object)
パラメータ
参数 | 描述 |
---|---|
string | 必需。规定 xsl:key 元素的名称。 |
object | 必需。要搜索的字符串。 |
例1
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="cdlist" match="cd" use="title" />
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="key('cdlist', 'Empire Burlesque')">
<p>
Title: <xsl:value-of select="title" />
<br />
Artist: <xsl:value-of select="artist" />
<br />
Price: <xsl:value-of select="price" />
</p>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="cdlist" match="cd" use="title" />
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="key('cdlist', 'Empire Burlesque')">
<p>
Title: <xsl:value-of select="title" />
<br />
Artist: <xsl:value-of select="artist" />
<br />
Price: <xsl:value-of select="price" />
</p>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
XMLファイルを表示し 、 XSLファイルを表示し 、 結果を表示します 。
完全なXSLT関数リファレンスオブジェクト