xsl:key

Declares a key for a document.

Format

<xsl:key name="qname"  
match = "pattern"  
use = "use" /> 

Description

Keys provide a way to work with documents that contain an implicit cross-reference structure. A stylesheet declares a key for a document with the xsl:key instruction.

The xsl:key instruction must be a top-level element. It has no contents, but it specifies three attributes.

Replace qname with the name of the key. You must specify a qualified name.

Replace pattern with a pattern that identifies one or more nodes that have this key. In other words, the nodes in the document that match the pattern are included in the key. The default is node().

Replace use with an expression that you want to use for the key values. The XSLT processor evaluates the expression once for each node in the set identified by pattern.

Each key name represents a separate, independent set of identifiers. Each node included in a key is associated with a set of string key values. These values result from evaluating the use expression with that node as the current node.

A document can contain multiple keys with the same node and the same key name, but with different key values. A document can contain multiple keys with the same key name and value, but with different nodes. In other words:

The value of a key can be an arbitrary string. It need not be a name.

Use the XSLT key() function to retrieve the list of nodes included in a given key that have given key values. See Finding an Element with a Particular Key.

You cannot specify multiple declarations for the same key in a stylesheet. Stylus Studio expects to remove this restriction in a future release.

Learn XSLT and XQuery Profiling

Stylus Studio's Profiler can help you evaluate the performance of your XQuery and XSLT. Automatically generated, customizable, easy-to-read HTML reports provide insight into performance bottlenecks.

XQuery Integration

Learn how new XQuery technologies can simplify legacy data integration by leveraging industry standards, proven open-source XML processing components, and Stylus Studio's integrated XQuery & XML tools.

XML Schema Mapping

Stylus Studio includes a visual XML Schema-to-XML Schema mapping tool that allows you to easily implement sophisticated XML data mappings involving multiple data sources and customized data processing using either XSLT or XQuery code.

Using DTD in Microsoft Applications

Learn how to integrate DTD's into your Microsoft applications using MSXML or System.XML DTD processing components.

Stylus Most Wanted

 
Free Stylus Studio XML Training:
W3C Member