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

RE: Generating HTML table

Subject: RE: Generating HTML table
From: cknell@xxxxxxxxxx
Date: Fri, 05 Mar 2004 09:54:17 -0500
xsl modulo operator
Yes, I did one of these a few years ago. You will want to use the modulo operator on the value of the context node's position(). Here's how it's done:

<xsl:template match="/">
 <table>
   <xsl:for-each select="items/item">
     <xsl:choose>
       <xsl:when test="position() mod 4 = 1">
         <tr>
           <td><xsl:value-of select="."/></td>
           <td><xsl:value-of select="following-sibling::*[1]"/></td>
           <td><xsl:value-of select="following-sibling::*[2]"/></td>
           <td><xsl:value-of select="following-sibling::*[3]"/></td>
         </tr>
       </xsl:when>
       <xsl:otherwise></xsl:otherwise>
     </xsl:choose>
   </xsl:for-each>
 </table>
</xsl:template
-- 
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     Andreas Lindahl <andreas.lindahl@xxxxxxxxxx>
Sent:     Fri, 5 Mar 2004 13:10:32 +0100
To:       "'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'" <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject:   Generating HTML table

Hi

My XML file looks like this:

<items>
	<item>Item 1</item>
	<item>Item 2</item>
	<item>Item 3</item>
	<item>Item 4</item>
	<item>Item 5</item>
	<item>Item 6</item>
	...
</item>

And I would like to create an HTML table which looks like this, from my XML
file:

<table>
	<tr>
		<td>
			Item 1
			Item 5
		</td>
		<td>
			Item 2
			Item 6
		</td>
		<td>
			Item 3
		</td>
		<td>
			Item 4
		</td>
	</tr>
</table>

I.e. four columns which are "populated" with items horisontally.

Is this possible to do with XSLT?

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list




 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.