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

Re: key() now has 3 arguments ... right

Subject: Re: key() now has 3 arguments ... right
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 26 Apr 2012 09:32:04 +0100
Re:  key() now has 3 arguments ... right
On 26/04/2012 05:38, ihe onwuka wrote:
although I get that there is some difference,
given the working example I cannot perceive that it matters.

I'm not sure what I can do to make it clearer but (except for very special types of key definition) there is essentially no similarity between the two match expressions and they match completely dofferent elements.


I'll stick to the 2 argument form as then it is legal and we don't have to guess what it means, and the same differences apply there.

given

<xsl:key name="k" match="abc" use="@zzz"/>




match="key('k','123')"


This matches those nodes (which will be abc elements with attribute zzz = 123) returned by the key.

match="*[key('k','123')]"

This matches every element in the document if any element is returned by the key '123'. Note this is completely different from the behaviour of the first match. So it matches <hello/> if the document has an element <abc zzz="123"/> and does not match anything otherwise.


match="*[. intersect key(,'k','123')]"


This is the same as the first one (since we know in advance that the key only returns elements) and matches elements returned by the key.


match="*[key('k',.)]"


This matches elements if there is any element (not necessarily this element) returned by the key. So if <z>yyy</z> is matched if there is any element anywhere in the document of the form <abc zzz="yyy">

match="*[. intersect key(,'k',.)]"

This matches an element if _it_ is returned by looking up its own value in the key so it matches elements whose string value is equal to its zzz atttribute, for example <abc zzz="qqq">qqq</abc>

David



________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. ________________________________________________________________________


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.