|
Subject: RE: [xsl] Formatting in an HTML table...DOWNwise! From: "Andrew Welch" <AWelch@xxxxxxxxxxxxxxx> Date: Wed, 2 Jul 2003 17:10:11 +0100 |
> I have the following XSLT (well, actually it's a snippet), which formats
> some data from XML nicely into an HTML table. However, the data is pasted
> left-to-right, while I'd like it better when it's put up-to-down first.
> Anyone knows of a solution for this? Thanks in advance!
You've almost got it, you just need a variable to hold the table height (in rows).
<xsl:variable name="tableHeight" select="4"/>
Then you want a new row for each <model> up to the table height:
<xsl:template match="modellen">
<table border="1">
<xsl:for-each select="model[position() < $tableHeight]">
<tr>
....
</tr>
</xsl:for-each>
</table>
</xsl:template>
Then on each row you want every nth sibling, depending on how many rows you have:
<xsl:for-each select=".|following-sibling::model[position() mod $tableHeight = 1]">
<td>
<xsl:apply-templates/>
</td>
</xsl:for-each>
So all together it looks like:
<xsl:template match="modellen">
<table border="1">
<xsl:for-each select="model[position() < $tableHeight]">
<tr>
<xsl:for-each select=".|following-sibling::model[position() mod $tableHeight = 1]">
<td>
<xsl:apply-templates/>
</td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</xsl:template>
cheers
andrew
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.491 / Virus Database: 290 - Release Date: 18/06/2003
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Formatting in an HTML tab, Patrick van Halderen | Thread | RE: [xsl] Formatting in an HTML tab, Andrew Welch |
| Re: [xsl] xsl:sort in old MSXML, Olivier Collioud | Date | RE: [xsl] Dynamic Sort Value Solved, Allistair Crossley |
| Month |