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

Re: How to do for-each on nodeset returned by key() fu

Subject: Re: 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

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.


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


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.
First Name
Last Name
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.