Subject: [xsl] Sorting an unsorted list of (xml) children and packing them into rows From: TSchutzerWeissmann@xxxxxxxxxxxxxxxx Date: Thu, 1 Nov 2001 12:59:12 -0000 |
I had managed to extract a list of element names from XML, but wanted to distribute it across multiple columns of an HTML table. After a bit of the familiar head-banging "why can't I print out <tr> tags on their own?" I found out how to pack the names into rows of three, thanks to Jeni. The problem is that I want the names to be in alphabetical order either like so A B C D E F or A C E B D F Does anyone have any suggestions? My current solution is below but it seems inefficient and slow. Also, can I do a logical AND without having to nest <xsl:if>s? A big newbie thank you, Tom Weissmann <xsl:template match="Scoresheet"> <xsl:apply-templates select="Corporation" mode="down"/> </xsl:template> <xsl:template match="Corporation" mode="down"> <xsl:if test="position() mod 3=1"> <tr> <xsl:apply-templates select="../Corporation" mode="across"> <xsl:with-param name="row" select="position()"/> <xsl:sort select="@Name"/> </xsl:apply-templates> </tr> </xsl:if> </xsl:template> <xsl:template match="Corporation" mode="across"> <xsl:param name="row"/> <xsl:if test="position() >= $row"> <xsl:if test="position() <= $row + 2"> <td> <xsl:value-of select="@Name"/> </td> </xsl:if> </xsl:if> </xsl:template> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] I need tools XML/XSL/XSD , Jeni Tennison | Thread | Re: [xsl] Sorting an unsorted list , David Carlisle |
Re: [xsl] I need tools XML/XSL/XSD , Jeni Tennison | Date | Re: [xsl] Sorting an unsorted list , David Carlisle |
Month |