[xsl] html table of sorted element names

Subject: [xsl] html table of sorted element names
From: Saverio Perugini <sperugin@xxxxxxxxxxxxxxxx>
Date: Thu, 30 Oct 2003 23:32:08 -0500 (EST)

I'd like to produce a 4 column HTML table where the
text contained in each <td> element is alphabetically
sorted from cell (1,1) to cell (n,4),
where n is the required number of rows.

The following is an attempt:

<xsl:template match="/db">
   <xsl:if test="*[some condition]">
      <xsl:variable name="sortedelements">
         <xsl:for-each select="*">
            <xsl:sort data-type="text" select="name()"/>
            <xsl:copy-of select="."/>

      <xsl:variable name="sortedelementsNodeSet"
         <xsl:for-each select="$sortedelementsNodeSet[position() mod 4 = 1]">
               <xsl:for-each select=".|following-sibling::node()[position() &lt; 4]">
                   <td><xsl:value-of select="name()"/></td>

While this produces a table, not all rows contain four columns, and even
worse, the text contained in the <td>'s is not sorted across all <td>'s.

I am using libxslt, which supports the node-set() exslt function.
Does anyone see what is going wrong here?


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread