XSLT
key()
function
The complete XSLT function reference object
Definitions and usages
The key() function returns the node set from the document by using the index number specified by the element.
Grammar
node-set key(string, object)
Parameters
parameter
|
describe
|
string
|
Required.Specify the name of the XSL: KEY element.
|
object
|
Required.String to search.
|
Instance 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>
The complete XSLT function reference object
Related articles
XSLT and lt;xsl: key.gt; elements