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>
<xslaram name="z">1</xslaram>
<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>
<xsltherwise>
<td>
<xsl:sort select="@rank" data-type="number" order="descending" />
<xsl:value-of select="@name" /> (<xsl:value-of select="@rank"/>);
</td>
</xsltherwise>
<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
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>
<xslaram name="z">1</xslaram>
<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>
<xsltherwise>
<td>
<xsl:sort select="@rank" data-type="number" order="descending" />
<xsl:value-of select="@name" /> (<xsl:value-of select="@rank"/>);
</td>
</xsltherwise>
<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