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:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old July 21st, 2002, 02:54 AM
getchoo getchoo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2002
Posts: 20 getchoo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
creating every other row with green background

Hi

Just wondering how would I create a table the at displays every other row (odd row) cells as green using and <xsl:if> below is my code

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">

<HTML>
<BODY>
<p align="left"><font color="#FF0000"><strong>Airport Flight Schedule Leslie Ho</strong></font></p>
<div align="left">
<TABLE border="1">
<tr>
<th rowspan="2">Airline</th>
<th colspan="4">To</th>
<th colspan="3">From</th>
</tr>
<tr>
<th>Airport</th>
<th>Date</th>
<th>ATime</th>
<th>Price($)</th>
<th>Airport</th>
<th>Date</th>
<th>Dtime</th>
</tr>
<xsl:for-each select="FLIGHT_SCHEDULE/FLIGHT">
<xsl:sort select="TO/DATE" data-type="text" order="ascending"/>

<TR>
<TD><xsl:value-of select="AIRLINE"/><xsl:value-of select="AIRLINE/@number"/></TD>
<TD><xsl:value-of select="TO/AIRPORT"/></TD>
<TD><xsl:value-of select="TO/DATE"/></TD>
<TD><xsl:value-of select="TO/ATIME"/></TD>
<TD><xsl:value-of select="TO/PRICE"/></TD>
<TD><xsl:value-of select="FROM/AIRPORT"/></TD>
<TD><xsl:value-of select="FROM/DATE"/></TD>
<TD><xsl:value-of select="FROM/DTIME"/></TD>
</TR>
</xsl:for-each>
</TABLE>
<font color="#336633"><xsl:text></xsl:text></font></div>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>

thanx

getchoo

Reply With Quote
  #2  
Old July 23rd, 2002, 11:17 PM
jkd jkd is offline
CF sMod
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Location: Maine, USA (a.k.a. Boonies)
Posts: 242 jkd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 43 sec
Reputation Power: 9
Send a message via ICQ to jkd Send a message via AIM to jkd Send a message via Yahoo to jkd
I'd think something like:

<xsl:for-each select="FLIGHT_SCHEDULE/FLIGHT">
<xsl:sort select="TO/DATE" data-type="text" order="ascending"/>

<TR>
<xsl:attribute name="style">
<xsl:if test="position() mod 2 = 0">
background-color: evencolor;
</xsl:if>
<xsl:if test="position() mod 2 = 1">
background-color: oddcolor;
</xsl:if>
</xsl:attribute>

Would do it.

FYI, the CSS3 spec calls for an :nth-child psuedo-class, which would make this definable through CSS and not require any extra markup:

tr:nth-child(odd) {
background-color: gray;
}

This is one CSS3 selector though that Mozilla doesn't support.
(Well, nor does any other web browser in existance)
__________________
Jason Contact Me
Super moderator @ CodingForums

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > creating every other row with green background


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 5 hosted by Hostway