Subject: [xsl] Alternate sort order of subelements based on previous parent element From: "Philipp Kursawe" <LukeSky77@xxxxxxx> Date: Thu, 1 Sep 2005 03:00:25 +0200 |
Hello fellow XSLT users, I have run into a problem solving the following sophisticated (at least for me) task: There is a list of items each containing two nodes "row" and "col". First the list has to be ordered ASCENDING by "rows". Next step is to sort the list items of each "row" by its "col" node where the ordering direction changes when the row is different to the previous. Sample XML: <items> <item row="300" col="2" /> <item row="300" col="57" /> <item row="304" col="110" /> <item row="301" col="25" /> <item row="301" col="120" /> <item row="335" col="27" /> <item row="327" col="50" /> <item row="304" col="1" /> </items> Expected result XML after transformation: <items> <!-- Order by col DESCENDING --> <item row="300" col="57" /> <item row="300" col="2" /> <!-- Row change, now order by col ASCENDING --> <item row="301" col="25" /> <item row="301" col="120" /> <!-- Row change, revers order direction of col again --> <item row="304" col="110" /> <item row="304" col="1" /> <item row="327" col="50" /> <item row="335" col="27" /> </items> Ordering and grouping by the row is the easy part. But how do I reverse the ordering everytime the row changes? It should work with whatever order direction of the "col" attribute I am starting. If doing this kind of operation based on attributes is too difficult it would be also possible to convert the attributes to nodes. I am stuck here since using "xsl:if" inside "xsl:sort" is not permitted. Anybody got an Idea? Thanks in advance, Phil
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XSL Unique values, Joris Gillis | Thread | [no subject], Unknown |
Re: [xsl] Sorting problem, Jay Bryant | Date | RE: [xsl] Conditional merge of 2 XM, Thomas Tarpin-Lyonne |
Month |