xsl-list
[Top] [All Lists]

Re: [xsl] displaying a list in a multi-column table

2008-01-25 07:05:24
On 25/01/2008, Michael Tracey Zellmann 
<tracey(_dot_)zellmann(_at_)gmail(_dot_)com> wrote:
I have a list of words, possibly 3500 to 7000 in length, in
alphabetical order. I need to display them in an HTML page in a table
of four columns. The first quarter of the words should be in the first
column, the second quarter in the second column, etc. Since the total
may not be divisible by four, the final column may be incomplete.
Let's say the input is of the form:
<wordList>
  <word>aaron</word>
  <word>abated</word>
  <word>abatement</word>
  ..
</wordList>

How can I do this with an XSLT transform?

I can use XSLT 2.0

That's good... in which case you can do:

    <xsl:for-each-group select="$wordlist"
group-starting-with="*[position() mod 4 = 1]">
          <tr>
            <xsl:for-each select="current-group()">
              <td><xsl:value-of select="."/></td>       
            </xsl:for-each>
          </tr>         
    </xsl:for-each-group>


cheers
-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--