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:

  • A node can be included in more than one key.
  • For a given key, a key value can be associated with more than one node.
  • The same key value can be associated with different nodes in different keys.

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.

Restriction

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

Stylus Studio API Documentation

Java API reference materials providing detailed information about Stylus Studio and other industry leading XML processing components.

Whitepaper: FIXML - Working with Complex Message Sets Defined Using XML Schema

The advanced XML Schema handling and presentation capabilities of Stylus Studio have valuable implications for users of industry-specific XML message sets.

Working with Tables in XSLT

This free video tutorial about working with XSL tables covers how to handle iteration and looping using xsl:for-each to create HTML reports driven by XML data.

Configuring the Java Runtime Engine or Java Development Kit

This page identifies the Stylus Studio modules that require Java runtime and Java compiler components, where you can download these Java components, and how to force Stylus Studio to detect new or changed Java components.

Stylus Most Wanted

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.