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

RE: Grouping and Sorting on value inside group

Subject: RE: Grouping and Sorting on value inside group
From: "Hunsberger, Peter" <Peter.Hunsberger@xxxxxxxxxx>
Date: Wed, 12 Jun 2002 10:07:37 -0500
RE:  Grouping and Sorting on value inside group
> If you want to avoid using "//dataset" you could have a key like this:
> <xsl:key name="dset" match="dataset" use="'all'"/> 
> and access it using 
> select="key('dataset','all')"
> 
>> >>I finally found the answer.  Your use of [@dataid = 
>> current()/@dataid]
>> >>provided the missing clue:
>> >>
>> >>       <xsl:for-each select="(//dataset/*/*[generate-id() =
>> >>generate-id(key('dataids', concat(local-name(..),@dataId)))])">
>> >>          <xsl:sort select="parent::node()/*[local-name() = 
>> $sortcol and
>> >>@dataId = current()/@dataId]/value"/>
>
>
> I agree with Wendell that the whole generate-id() malarkey is redundant,
but
> it doesn't do the same thing as key('dataids',
> concat(local-name(..),@dataId))[1] because you will get every node that
> satisfies the predicate and not just the first one. 
> And every node in //dataset/*/* that has a @dataid will be in the 'dataid'
> key and satisify the predicate.

As I said in my reply to Wendell, I think this is why the generate-id works:
it groups the sets of elements by the matching dataid?

>
> So won't this work just as well:
> <xsl:for-each select="key('dataset','all')/*/*">
> 	

By itself, that returns everything ungrouped.  If I try to add grouping
logic to it I get nothing, I'm not sure why, but I'll spend some more time
trying to figure it out...

> The sort looks really cunning and probably is doing all the hard work here
> ;)

Hah, I wish, the group was returning the proper number of rows before I
every added the sort.  It just wasn't sorting them...

I'm afraid to admit this, but the more I work on this, the more confused I
get...

 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-2011 All Rights Reserved.