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

Re: Grouping problem

Subject: Re: Grouping problem
From: Andrew Welch <andrew.j.welch@xxxxxxxxx>
Date: Mon, 15 Aug 2011 14:55:27 +0100
Re:  Grouping problem
In your example output, where should the pair:

<pair>
      <player>player1</player>
      <player>player4</player>
</pair>

go?



On 15 August 2011 14:38, graham.heath <graham.heath@xxxxxxxxx> wrote:
> Hello mega brains,
>
> I have an xml grouping problem that has so far defeated me.
>
> Given the xml
> <pairings>
> <pair>
>       <player>player1</player>
>       <player>player2</player>
> </pair>
> <pair>
>       <player>player1</player>
>       <player>player3</player>
> </pair>
> <pair>
>       <player>player1</player>
>       <player>player4</player>
> </pair>
> <pair>
>       <player>player2</player>
>       <player>player3</player>
> </pair>
> <pair>
>       <player>player2</player>
>       <player>player4</player>
> </pair>
> <pair>
>       <player>player3</player>
>       <player>player4</player>
> </pair>
> </pairings>
>
> is it possible to group pairs such that each player occurs only once in
each
> group?
> <table>
> <pair>
>       <player>player1</player>
>       <player>player2</player>
> </pair>
> <pair>
>       <player>player3</player>
>       <player>player4</player>
> </pair>
> </table>
> <table>
> <pair>
>       <player>player1</player>
>       <player>player3</player>
> </pair>
> <pair>
>       <player>player2</player>
>       <player>player4</player>
> </pair>
> </table>
>
> I was of the opinion that some form of xsl:for-each-group would suffice but
> have been unable to devise a group-by expression that works..
>    <xsl:for-each-group select="pairings/pair"
> group-by="count(distinct-values(player))=1">
>      <table>
>        <xsl:apply-templates select="current-group() "/>
>      </table>
>    </xsl:for-each-group>
>
> Many thanks
>
> Hector
>
>



--
Andrew Welch
http://andrewjwelch.com

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.