|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Sorting an unsorted list of (xml) children and packing
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








