当前位置: 首页 > 网络学院 > XML相关教程 > XSL/XSLT > XSLT key() 函数
The key() function returns a node-set from the document, using the index specified by an <xsl:key> element.
key() 的作用是:使用由<xsl:key> 元素指定的index[索引],从当前文档中返回一个节点组。
node-set key(string, object) |
| 参数 | 描述 |
|---|---|
| string | Required. Specifies the name of an xsl:key element 必要参数。指定“xml:key element”的名称 |
| object | Required. A string to search for 必要参数。指定需要被搜索的字符 |
<?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> |
评论 (0) All