[xsl] sorting and grouping - can't get it to work

Subject: [xsl] sorting and grouping - can't get it to work
From: Andreas Waechter <A.Waechter@xxxxxxxxx>
Date: Mon, 2 Jul 2001 10:00:10 +0200
Hello all,

this is my last attempt to get some reaction to my question - previous
attempts to post to this list did not give me any reactions - I did not even
see my own posting to the list, perhaps this is normal (though when I
answered someones post I got my post back from the list). But I also did not
get any answer so I suspect my postings did never arrive.

Now for my question

I have a little problem with data I want to sort and then place into a
two-column table 
(two of the sorted data items in each row).

I am a XML/XSL-Newbie so please forgive me if I ask a too simple question
for you experts.
Here is my problem in detail - I hope I provided all the info you need.

With data like this
    <item> <name>John</name> </item>
    <item> <name>Ed</name>   </item>
    <item> <name>Bill</name> </item>
    <item> <name>Al</name>   </item>
    <item> <name>Tim</name> </item>
    <item> <name>George</name>   </item>
I want to get a sorted table with two columns like

By using

<xsl:template match="data/item">
        <xsl:for-each select="item[position() mod 2 = 1]">
                <xsl:apply-templates select=". |
                <xsl:if test="not(following-sibling::item[position()=1])">

<xsl:template match="item">
	<td><xsl:value-of select="name"/></td>

I managed to get 

i.e. I figured out how to place two consecutive item names in two cells of
one row.
I even managed to fill the last row with an empty cell should the number of
items be odd.

I also know - in principle - how to sort (<xsl:sort select="name"/>).
I just don't know where to place the sort.
If I place it in the existing for-each I get a very confusing "order", 
if I place it in the existing apply-templates, only the two items within
each rows get sorted (as I expected it)

But what I really need is that the sorting of the item takes place before I
start selecting some of them to start rows.
I looked through the FAQ under sorting, grouping and sorting and tables and
also searched the archives but did not find a solution. Forgive me if I
overlooked something.

I don't think it should matter in this case but the software I use to
interprete my XML+XSL files is the Apache module from the XALAN software
(Xalan C++ version 1.1.0).
Could anyone please help? Thanks in advance.

Andreas Waechter

Andreas Waechter        Tel.: +49 (089) 55 24 04-43
Logics Software GmbH    Fax:  +49 (089) 55 24 04-44
Schwanthalerstr. 9-11   mailto:a.waechter@xxxxxxxxx
80336 München           http://www.logics.de

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread