The purpose of the <xsl:key>
element is to define an index
on information in the input file, so that the XSLT processor
can retrieve that information more efficiently than by
searching the entire file. This is admittedly an
advanced feature, but can be very useful for larger projects.
You must give each key a name, using the name attribute, that will be
used to refer to it later. Two more attributes describe
which nodes to index, and what text to use as the index:
matchTo define which nodes of the input document are
indexed, use attribute match=",
where m"m is an XPath expression
describing a node set.
useTo define what content strings are indexed, set
this attribute to an XPath expression that describes
some content relative to the nodes described by the
match attribute.
For example, suppose you have a document with
<river> elements that
have a map attribute
that you'll be referring to elsewhere. You might set up
a key called river-map-key by placing this
element inside your stylesheet:
<xsl:key name="river-map-key" match="river" use="@map"/>