xsl-list
[Top] [All Lists]

RE: simple question regarding xsl:key and value calculation

2003-08-25 07:49:46
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(_at_)lists(_dot_)mulberrytech(_dot_)com 
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] 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



<Prev in Thread] Current Thread [Next in Thread>