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

RE: [xsl] simple question regarding xsl:key and value calculation


Subject: RE: [xsl] simple question regarding xsl:key and value calculation
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Mon, 25 Aug 2003 15:49:46 +0100

Consider

<book id="1">
  <author>John</author>
  <author>Jane</author>
  <author>Mary</author>
</book>
<book id="2">
  <author>John</author>
</book>
<book id="3">
  <author>John</author>
  <author>Jane</author>
</book>

<xsl:key name="k" match="book" use="author"/>

For book id=1, the value of the use attribute is a node-set containing
three author elements. Each element contributes one value to the key.
The value that it contributes is the string-value of the author element.
So the three key values for book id=1 are "John", "Jane", and "Mary".

So the value of key('k', 'Jane') is the set containing book id=1 and
book id=3.

Is that clearer?

Michael Kay


> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Robert P. J. Day
> Sent: 25 August 2003 11:47
> To: XSL List
> Subject: [xsl] simple question regarding xsl:key and value calculation
> 
> 
> 
>   when calculating the value of a key, kay (p. 243) states:
> 
>   "For each node that matches the pattern, the expression is evaluated
>   with that node as the current node ... and then:
> 
>    * If the result is a node-set, each node in the result contributes
>      one value for the key.  The value of the key is the string-value
>      for that node."
> 
> i'm just having trouble parsing this last sentence.  given a 
> node-set as a result, how exactly do the nodes in that 
> node-set determine the eventual key?  or is it keys?  since 
> that sentence seems a bit ambiguous.
> 
> rday
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


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



Current Thread
Keywords
xsl