XSL/CSS for-each results in a table

Discussion in 'HTML' started by =?UTF-8?B?TWFydGluIFDDtnBwaW5n?=, Nov 29, 2006.

  1. Hello,

    I´ve a little design/coding/layout problem.

    I´m getting xml data in a for-each loop with:

    <xsl:for-each select="/data">
    <xsl:sort select="@freq" data-type="number" order="descending" />
    <xsl:value-of select="." />(<xsl:value-of select="@freq" />)<br/>
    </xsl:for-each>

    As you can see with the <br/>-Tag every single value is written in a new
    line.

    Now I want to transfer this result into a table with 3 columns.

    How can I do that?

    I thought to write use a variable i and working with modulo like this:

    <table>
    <xsl:param name="z">1</xsl:param>
    <xsl:for-each select="conceptlist/concept">
    <xsl:choose>
    <xsl:when test="$z%3==1">
    <tr>
    <td>
    <xsl:sort select="@rank" data-type="number" order="descending" />
    <xsl:value-of select="@name" /> (<xsl:value-of select="@rank"/>);
    </td>
    </xsl:when>
    <xsl:when test="$z%3==0">

    <td>
    <xsl:sort select="@rank" data-type="number" order="descending" />
    <xsl:value-of select="@name" /> (<xsl:value-of select="@rank"/>);
    </td>
    </tr>
    </xsl:when>
    <xsl:eek:therwise>
    <td>
    <xsl:sort select="@rank" data-type="number" order="descending" />
    <xsl:value-of select="@name" /> (<xsl:value-of select="@rank"/>);
    </td>
    </xsl:eek:therwise>
    <xsl:with-param name="z" select="$z+1"/>
    </xsl:choose>
    </xsl:for-each>
    </table>

    Of course this lines of code do not work because I cannot _not-nested_
    syntax like this:

    <xsl:when test="$z%3==1">
    <tr>
    <td>
    <xsl:sort select="@rank" data-type="number" order="descending" />
    <xsl:value-of select="@name" /> (<xsl:value-of select="@rank"/>);
    </td>
    </xsl:when>


    because the start tag "<tr>" is closed by the tag "</xsl:when>" which
    will result an error.

    But I do not have any other idea to create a 3-column-table with using
    xsl:for-each.


    How do you do that?



    Regards,

    Martin
    =?UTF-8?B?TWFydGluIFDDtnBwaW5n?=, Nov 29, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Blair
    Replies:
    1
    Views:
    409
    Eliyahu Goldin
    Aug 3, 2005
  2. Sparko
    Replies:
    0
    Views:
    409
    Sparko
    Jul 9, 2004
  3. Tjerk Wolterink

    xsl:for-each for each 3 elements problem

    Tjerk Wolterink, Nov 3, 2004, in forum: XML
    Replies:
    3
    Views:
    426
    Tjerk Wolterink
    Nov 3, 2004
  4. Replies:
    1
    Views:
    3,598
    A. Bolmarcich
    May 27, 2005
  5. Yas
    Replies:
    0
    Views:
    480
Loading...

Share This Page