This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

effiecient use of keys


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))"
/> ???
  
</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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]