Subject: [xsl] How to sort and group using n-column table? From: Allister Jenks <arj@xxxxxxxxxxx> Date: Wed, 13 Nov 2002 21:50:06 +1300 |
Hi folks, I'm new to this list, not so new to XSL (been using it for a year or two, on and off). I found out recently how to take a collection of sibling elements and place them in an n-column table, using a construct such as the following: <xsl:for-each select="element[position() mod 3 = 1]"> <tr> <xsl:apply-templates select=".|following-sibling::element[position() < 3]"/> </tr> </xsl:for-each> ...and then a template which includes the <td> tags only for each element. This works just fine and can, of course, be adapted to any width. What I am having a problem with is to first sort the siblings, then place them in the table. Putting a sort in the for-each is no good as it will only sort the "position() mod 3" elements. Likewise putting a sort in the apply-templates only sorts the row. I tried creating a variable with the sorted elements by use of a for-each declaration with sort inside the variable definition, but this gives a result tree fragment and not a node set (as I just found out) and therefore I cannot further process it with standard XSL. I've seen techniques using CDATA to 'sneak' the <TR> and </TR> elements in in a procedural fashion using xsl:if constructs, but this strikes me as very untidy and 'cheating'. I have looked through the archives of this list and various FAQs and none of the examples under 'grouping' or 'tables' seem to cover my case - namely that the table is purely a means of saving vertical space by placing elements across the page. In most cases the examples' tables have meaning in their rows or columns. And in most cases where order is important, the data is already ordered! My requirement is more akin to simple 'multi-up' printing. Can anyone suggest an approach that uses standard XSL (I'm not sure whether my host has any extensions), and preferably not any kludges? If not, I suspect I'll resort to the CDATA approach, as at least it can be accomplished with standard XSL, albeit ugly. -- Regards, Allister. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Navigation using XPath, Jarno . Elovirta | Thread | RE: [xsl] How to sort and group usi, Jarno . Elovirta |
[xsl] Navigation using XPath, Chitra Lalita Madhwa | Date | Re: [xsl] sorting based on a variab, Kasper Nielsen |
Month |