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

Problem implementing grouping and sorting together

Subject: Problem implementing grouping and sorting together
From: Gary Bartlett <gary_a_bartlett@xxxxxxxxx>
Date: Tue, 16 Oct 2001 19:30:03 -0700 (PDT)
implementing sorting on xml
Greetings, 

I have a problem where I need to group elements and
then sort each group and finally group the sorted
elements for display purposes (to place a specific
number of elements per row).

Here is the approach that I have taken.  I appreciate
any pointers or suggestions as to how I can get the
sorting portion to work.

The first grouping is accomplished with a for-each
with a select "distinct" similar to the following:

//foo[not(.=preceding::foo)]

Inside the body of the for-each, I call a template
(name=processGroup) passing the distinct value as a
parameter.

The processGroup template creates a variable ($prices)
containing all of the elements matching the value
passed in the parameter.  I then use a technique that
I found documented on the Jenni site to perform the
second set of grouping.  This includes two
apply-templates, the first with:

select="$prices[position() mod $nbrPerLine = 1]"

and the second with

select=". | following-sibling::price[position() &lt;
$nbrPerLine]"

This works great - except that now I cannot come up
with a way to implement the sort.  

I have tried an additional apply-templates with a sort
from within the template that creates the $prices
variable. This sorts the elements - but then I can't
figure a way to pass this "set" to the template that
contains the "position() mod " style select above (the
template is receiving the sorted elements one at a
time - which doesn't quite cut it).

Thanks in advance for any help with this.

Gary Bartlett





__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.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.