[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Formatting in an HTML table...DOWNwise!

Subject: RE: Formatting in an HTML table...DOWNwise!
From: "Andrew Welch" <AWelch@xxxxxxxxxxxxxxx>
Date: Wed, 2 Jul 2003 17:10:11 +0100
html tab

> 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() &lt; $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() &lt; $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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.