|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Formatting in an HTML table...DOWNwise!
> 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








