You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Simon Waddington <Si...@ZapNetworks.com> on 2000/03/07 21:47:17 UTC

XSL brainteaser...

I thought XSL was really powerful then I came across this problem and I'm
stuck.  Perhaps I'm just suffering from XSL writers block but how do I dow
the following:

Take a list of items like so:

<list>
  <item>Text</item>
  <item>More text</item>
  ... etc.
</list>

and convert it into a double column HTML table like so:

<table>
  <tr>
    <td>Text</td>
    <td>More text</td>
  </tr>
  <tr>
    ... etc.
  </tr>
</table>

(The items fill across the table first since that seems easiest to do...)



Re: XSL brainteaser...

Posted by Mike Engelhart <me...@earthtrip.com>.
Simon Waddington wrote:

> I thought XSL was really powerful then I came across this problem and I'm
> stuck.  Perhaps I'm just suffering from XSL writers block but how do I dow
> the following:
> 
> Take a list of items like so:
> 
> <list>
> <item>Text</item>
> <item>More text</item>
> ... etc.
> </list>
> 
> and convert it into a double column HTML table like so:
> 
> <table>
> <tr>
> <td>Text</td>
> <td>More text</td>
> </tr>
> <tr>
> ... etc.
> </tr>
> </table>
> 
> (The items fill across the table first since that seems easiest to do...)
> 
I don't have time to write a sample but try using something like:

 <xsl:when test="(position() mod 2)=0">
 </xsl:when>

to determine when to add a row.  The above syntax may not work but using
position() to figure out where you are in the list and mod to determine when
the next row should occur should work fine.

Mike