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

Re: XML List to Multi-column HTML transformation

Subject: Re: XML List to Multi-column HTML transformation
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 26 Nov 2003 14:54:48 GMT
html select multi column
> I imagine I need to do something clever involving the use of 
> 
> 	/MyElement[ position() mod X ] 
> where X is the no. of columns I require.

Columns not rows.
But since you know it's three you don't really need that at all, just
something like


<table>
<xsl:variable name="r" select="ceiling(count(MyElement) div 3)"/>
<xsl:for-each select="MyElement[position() &lt; $r">
<tr>
<td><xsl:apply-templates select="."/></td>
<td><xsl:apply-templates select="following-sibling::MyElement[$r]"/></td>
<td><xsl:apply-templates select="following-sibling::MyElement[2*$r]"/></td>
</tr>
</xsl:for-each>
</table>


If you don't know in advance it's three (or even if you do) then 
you could replace the three td elements above with

<xsl:for-each select=".|following-sibling::MyElement[position() mod $r = 0]">
<td><xsl:apply-templates select="."/></td>
</xsl:for-each>

david

-- 
http://www.dcarlisle.demon.co.uk/matthew

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

 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.