[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 19:23:19 +0700
Re: Not grokking keys...
Kay Michael wrote:
> 
> > Anyone care to explain, or give an example of the usage of
> > keys? The spec description of keys just isn't clicking wiht me.
> >
> I'm glad I'm not the only one!
> 
> The match and name attributes are fairly obvious:
> 
> xsl:key(match="Employee|Contractor" name="SSN") says I want to be able to
> find Employee and Contractor elements using their SSN attribute. (It seems a
> key has to be an attribute, we can't find things using the value of child
> elements).
> 
> It's the "use" attribute that's thoroughly obscure. I've stared at it but
> can't see why it's there, let alone why it's mandatory.

It's the "use" attribute not the "name" attributes that tells you what
to use to find elements.  The "name" attribute tells you what xsl:key
definitions to use for a particular keyref() or key() function call.

Suppose you have

<Employee>
<SSN>6789</SSN>
<Name>Michael Kay</Name>
<ManagedBy>1234</ManagedBy>
</Employee>

<Employee>
<SSN>1234</SSN>
<Name>John Smith</Name>
</Employee>

then you might do:

<xsl:key match="Employee|Contractor" name="people" use="SSN"/>

<xsl:template match="ManagedBy">
 <xsl:value-of select="keyref('people',.)/Name"/>
</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.