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

RE: FW: Medal Table

Subject: RE: FW: Medal Table
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 14 Jan 2005 15:48:18 -0000
gavin lyons
Grouping problems like this are easy in XSLT 2.0

<xsl:for-each-group select="Table" group-by="nation">
 <p><xsl:value-of select="current-grouping-key()"/></p>
 <xsl:for-each-group select="current-group()" group-by="medal">
   <xsl:sort select="index-of(('Gold', 'Silver', 'Bronze'), medal)"/>
   <xsl:value-of select="count(current-group()), current-grouping-key()"/>
   <xsl:if test="position()!=last()">, </xsl:if>
 </xsl:for-each-group>
</xsl:for-each-group>

not tested.

Michael Kay
http://www.saxonica.com/


> -----Original Message-----
> From: Gavin Lyons (i386) [mailto:admin@xxxxxxxx] 
> Sent: 14 January 2005 15:19
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  FW: Medal Table
> 
> 
> Hello XSL-list,
> 
> I hope someone can provide some insight and help :)
> 
> I would like and hope to output Nations by the numbers of 
> Golds first, then
> Silver and then Bronze in this order.
> 
> like this
> AUT
> 	3 Gold, 1 Silver
> JAP	
> 	3 Gold
> GBR  
> 	2 Gold, 1 Bronze
> 
> I'm just not sure the best way to tackle the problem
> 
> With thanks,
> Gavin Lyons 
> http://www.i386.com
> 
> XSL
> ---
> 	<xsl:for-each select="Table[not (nation='')]">
> 		<xsl:sort select="nation" />			
> 			<xsl:variable name="nation"><xsl:value-of
> select="nation"/></xsl:variable>
> 			<xsl:value-of select="nation"/> <br/>
> 			- Gold <xsl:value-of
> select="count(../Table[medal='Gold' and nation=$nation])"/>
> 			- Silver <xsl:value-of
> select="count(../Table[medal='Silver' and nation=$nation])"/>
> 			- Bronze <xsl:value-of
> select="count(../Table[medal='Bronze' and nation=$nation])"/>
> 	</xsl:for-each>
> 
> XML
> ---
>   <Table>
>     <athlete>Jones John</athlete>
>     <nation>GBR</nation>
>     <location>Bormio</location>
>     <date>01/29/2005</date>
>     <medal>Gold</medal>
>     <discipline>Super-G</discipline>
>     <gender>Mens</gender>
>     <lastmodified></lastmodified>
>     <editedby></editedby>
>   </Table>
>   <Table>
>     <athlete>Burt Sample</athlete>
>     <nation>FRA</nation>
>     <location>Bormio</location>
>     <date>01/29/2005</date>
>     <medal>Silver</medal>
>     <discipline>Super-G</discipline>
>     <gender>Mens</gender>
>     <lastmodified></lastmodified>
>     <editedby></editedby>
>   </Table>
> 
> 
> 
> 
>  
> 
> -- 
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.300 / Virus Database: 265.6.10 - Release Date: 10/01/2005
>  
> 
> -- 
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.300 / Virus Database: 265.6.10 - Release Date: 10/01/2005

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.