XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 27th, 2004, 02:33 PM
khwang's Avatar
khwang khwang is offline
Über nübe
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Babylon 4
Posts: 240 khwang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 27 sec
Reputation Power: 6
XSL: applying style to alternating rows

I'd like to generate a simple HTML table, where every second row is light grey. How can I do this with XSL?
__________________
Hello, old friend...

Reply With Quote
  #2  
Old February 27th, 2004, 03:47 PM
MattSidesinger's Avatar
MattSidesinger MattSidesinger is offline
Java PHP Oracle Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: C-Bus OH-IO
Posts: 204 MattSidesinger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 26 sec
Reputation Power: 5
Send a message via AIM to MattSidesinger
In your CSS just define oddRow and evenRow.

This can go in a template that matches a data element that belongs in a row:
Code:
	<xsl:variable name="rowClass">
		<xsl:call-template name="getTableRowClass"/>
	</xsl:variable>

	<tr class="{$rowClass}">
             ...
        </tr>


Here is the common template that would most likely be put in an imported file:
Code:
<xsl:template name="getTableRowClass">

	<xsl:choose>
		<xsl:when test="position() mod 2 = 1">
			<xsl:text>oddRow</xsl:text>
		</xsl:when>
		<xsl:otherwise>
			<xsl:text>evenRow</xsl:text>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

Reply With Quote
  #3  
Old February 27th, 2004, 10:36 PM
khwang's Avatar
khwang khwang is offline
Über nübe
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Babylon 4
Posts: 240 khwang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 27 sec
Reputation Power: 6
Awesome! That's exactly what I need.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > XSL: applying style to alternating rows


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT