XSLT xsl:key Element
Complete XSLT Element Reference Manual
Definition and Usage
The xsl:key element is a top-level element that declares a named key (that is, a name/value pair assigned to specified elements in an XML document). The key is used in the style sheet through the key() function, helping you efficiently access the assigned elements in complex XML documents.
**Note:** A key does not have to be unique!
Syntax
name="name" match="pattern" use="expression"/> Suppose you have an XML file named "persons.xml": You can define a key in the XSL file as follows: To find the person with id="050676", use this code (in the XSL file): xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> Id: Name: property
property
Value
Description
name
name
Required. Specifies the name of the key.
match
pattern
Required. Defines the nodes to which the key is applied.
use
expression
Required. Specifies the expression to use as the value of the key for each node.
Example 1
Complete XSLT Element Reference Manual