[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Not grokking keys...

Subject: Re: Not grokking keys...
From: James Clark <jjc@xxxxxxxxxx>
Date: Thu, 22 Apr 1999 18:35:25 +0700
Re: Not grokking keys...
Guy_Murphy@xxxxxxxxxx wrote:
> 
> Hi.
> 
> Anyone care to explain, or give an example of the usage of keys?

You can think of it as a generalized form of id/idref.  It doesn't
require you to declare things as IDs in your doucment.  It allows IDs to
be specified in subelements as well as in attributes.  It doesn't
restrict IDs to be name tokens. It allows multiple independent
namespaces (*not* in the XML namespaces sense) of IDs.

Imagine you have a document like this:

<div>
<title>Introduction</title>
<p>...</p>
<p>For more information see <divref>Expressions</divref>.</p>
</div>
...
<div>
<title>Expressions</title>
<p>...</p>
</div>

Suppose you want to transform this to HTML and you want to number the
sections and also number the cross references to sections. Then you
could use something like:

<xsl:key name="titles" match="div" use="title"/>

<xsl:template match="divref">
  <xsl:for-each select="keyref('titles', .)">
     <xsl:number level="multi" match="div" format="1.1. "/>
  </xsl:for-each>
  <xsl:value-of select="."/>
</xsl:template>

James


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
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-2013 All Rights Reserved.