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]

Problem implementing grouping and sorting together


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() <
$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


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