XSL/CSS for-each results in a table

G

Guest

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top