[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] key() now has 3 arguments ... right

Subject: Re: [xsl] key() now has 3 arguments ... right
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 26 Apr 2012 09:32:04 +0100

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.


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


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


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.


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>


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