Re: [xsl] How to do for-each on nodeset returned by key() function

Subject: Re: [xsl] How to do for-each on nodeset returned by key() function
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 23 Sep 2002 22:01:08 +0100

> <xsl:key  name = "nodeInfoMap" match= "//nodeInfo" use = "name"/>

That's OK, although as always in match patterns, starting with // isn't
doing anything useful.


> Now when I do key('nodeInfoMap', @name) at some context, more than one nodes
> are returned. i.e.
> 
> count(key('nodeInfoMap', @name) ) > 1

if <xsl:value-of select="count(key('nodeInfoMap', @name) )"/> returns a
number greater than 1 then 
<xsl:for-each select="count(key('nodeInfoMap', @name) ">
_at the same point in the stylesheet_ will work over a node set of more
than one node.

> <xsl:for-each select='key('nodeInfoMap', @name)'> -- DID NOT WORK

Either you evaluated this at some place where @name does not result in a
valid key or id did work but teh body of teh for-each dis not evaluate
as you expected. Since you gave no context it's hard to guess which.


> <xsl:for-each select='key('nodeInfoMap', @name)//nodeInfo'> -- DID NOT
> WORK

That one will iterate over all the nodeInfo descendents of the nodeInfo
nodes that are returned by the key.  Yor nodeinfo nodes do not have any
nested nodeinfo elements, so thi sis empty.



So the first one should work if you are in a context where the name
attribute gives the key value, but your sample doc didn't seem to have
any such attribute.

David

_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.

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


Current Thread