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

one key or a whole bunch?

Subject: one key or a whole bunch?
From: Marina Sorreta <milkmandeg@xxxxxxxxx>
Date: Tue, 21 May 2002 01:25:28 -0700 (PDT)
key bunch
Hello,

I am looking for the most efficient way to use keys to
do the following.
My xml sample below:-

<SHOP>
<SPORTS>
..... <--- other stuff
.....
<SHELF_NO>4567</SHELF_NO>
.....
</SPORTS>
<LEISURE>
..... 
.....
<SHELF_NO>3344</SHELF_NO>
.....
</LEISURE>
<CLOTHES>
..... 
.....
<SHELF_NO>3344</SHELF_NO>
.....
</CLOTHES>
<GIFTS>
..... 
.....
<SHELF_NO>3344</SHELF_NO>
.....
</GIFTS>
</SHOP>

I need to get a count of all the groups of
<SHELF_NO>'s that are the same.
I need the output to be in the form (with the example
above):-

Shelf Groups   Number of Copies
0   0 <--i.e. no instance of no shelf number
1   1 <--i.e. 1 instance of just one unique shelf
number
2   0 <--i.e no instance of two shelf numbers the same
3   1 <--i.e. 1 instance where three shelf numbers
were the same
etc etc

So is the best way to have a key like: -
  
<xsl:key name="kShelf" match="SPORTS | LEISURE |
CLOTHES | GIFTS" use="SHELF_NO"/>

and a variable say

<xsl:variable name="vShelf"
                  select="SHOP/*[generate-id()
                                    =
                                    
generate-id(key('kShelf',
                                                     
SHELF_NO
                                                    
)[1]
                                                 )
                                    ]"/>

Then I get stuck as to how to iterate over them and
count the groups. 

Something like?

<xsl:for-each select="$vShelf">

<xsl:value-of select="count(key('kShelf', SHELF_NO))"
/> ??? just once or for all groups?
  
</xsl:for-each>

Any help gratefully received.

Thanks

Marina


__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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