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

Re: Fwd: xsl:key() and $variables.

Subject: Re: Fwd: xsl:key() and $variables.
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Mon, 24 Jul 2006 11:34:34 -0400
Re:  Fwd: xsl:key() and $variables.
At 10:20 PM 7/21/2006, Mike wrote:
I've never heard of xsl:key but the second illustration here:

http://www.cranesoftwrights.com/resources/xslkeys/index.htm

looks useful. It seems an xsl:key is like a variable containing
a list of elements that match the xpath expression. But the key()
function allows you to filter on that list further by providing a key
(overloaded term warning). So in the above illustration the xsl:key
statement builds a list of Employee elements and indicates that the SSN
child should be used when a key is supplied to the key() function. So
the key('people',@emp) call says, "fetch all elements in the 'people'
list using the SSN @emp.

Nice writeup.


 Presumably each Employee would have a unique
SSN and therefore the key() call will return one Element.

And if the SSN isn't unique -- or maybe your key value is the surname not the SSN -- you could get several Employees back, all with the same SSN, surname or what have you.


Hence the applicability of keys for de-duplicating and accordingly for grouping.

Note there's nothing you can do with a key that you can't do with brute-force XPath. But since the processor has the information up front to build an index, many expensive tree traversals are avoided and the application scaled much better.

Cheers,
Wendell

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.