Subject: RE: [xsl] populating table with sorted elements From: cknell@xxxxxxxxxx Date: Sat, 29 Jul 2006 12:09:32 -0400 |
It's hard to see how you would do this in one step in XSLT 1.0. What you need is a tree of sorted nodes to which you will apply the formatting template. So: 1) Produce a tree of nodes sorted in the order you want. 2) Apply the formatting template to the tree of sorted nodes. In XSLT 1.0 you will either break the process into two steps, producing an intermediate document containing the sorted nodes, then applying the second stylesheet to the intermediate document, or use a node-set extension (details depend on which XSLT processor you are using) which will produce an in-memory tree of nodes that you can apply the template to. In XSLT 2.0 you could simply create a variable to hold the tree of sorted nodes without requiring an extension or an intermediate document. The EXSLT library may contain something useful. http://www.exslt.org/exsl/functions/node-set/index.html -- Charles Knell cknell@xxxxxxxxxx - email -----Original Message----- From: Christian Marc Schmidt <christianmarc@xxxxxxxxx> Sent: Sat, 29 Jul 2006 10:43:07 -0400 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: [xsl] populating table with sorted elements I am a newcomer to XML/XSLT and am struggling with a bit of code in which I am attempting to populate a six-column table, while allowing an xsl:sort. Here is a section of my current code: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> .. <table width="970" border="0" cellspacing="0" cellpadding="0"> <xsl:for-each select="xml/work/*[position() mod 6 = 1]"> <tr> <xsl:apply-templates select=".|following-sibling::*[position() < 6]" /> </tr> </xsl:for-each> </table> .. The XML structure I've set up looks like this: <xml> <work> <piece> </piece> <piece> </piece> ... </work> </xml> How would I go about adding sort functionality? It seems like it would be easy enough, yet all of my attempts so far have failed... Any suggestions would be much appreciated! Christian
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] populating table with sor, Michael Kay | Thread | [xsl] Transquery and XSL-T 2.0, bryan rasmussen |
Re: [xsl] Occurences of comma-separ, Mukul Gandhi | Date | Re: [xsl] Occurences of comma-separ, Mukul Gandhi |
Month |