[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

Subject: Sorting an unsorted list of (xml) children and packing them into rows
From: TSchutzerWeissmann@xxxxxxxxxxxxxxxx
Date: Thu, 1 Nov 2001 12:59:12 -0000
unsorted list
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() &lt;= $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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.