[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Alternating rows with multiple tables
How to alternate background colors in a style sheet that displays multiple tables so that the first row of each table is "white"? As seen below, this snippet of code uses "position() mod 2" to determine which background color to use. HOWEVER, this code is used within a template and is called repeatedly to display multiple tables in the same document. And I want the first row of every table to be "white" [#FFFFFF] with subsequent rows alternating colors. The problem is that if the first table has an odd number of rows, then "position() mod 2" will cause the first row of the second table to be the wrong color. That is, if the first row of the first table is white, then the first row of the second table will be black. How do I get around this problem? <xsl:param name="mission_id"></xsl:param> <hr/> <h2>Hierarchy for Mission #<B><U><xsl:value-of select="$mission_id"/></U></B></h2> <table border="0" bgcolor="white"> <xsl:for-each select="*/tasked_country_segment/service_tasked_segment/task_unit_and_loca tion_segment"> <xsl:if test ="aircraft_mission_data_segment/aircraft_mission_data/package_identificati on!=''"> <xsl:if test="aircraft_mission_data_segment/aircraft_mission_data/mission_number=$ mission_id"> <tr> <xsl:attribute name="BGCOLOR"> <xsl:choose> <xsl:when test="position() mod 2 = 1">#FFFFFF</xsl:when> <xsl:when test="position() mod 2 = 0">#DBDBDB</xsl:when> </xsl:choose> </xsl:attribute> <td><xsl:value-of select="aircraft_mission_data_segment/aircraft_mission_data/package_identi fication"/></td> </tr> </xsl:if> </xsl:if> </xsl:for-each> </table> </xsl:template> </xsl:stylesheet> David Dymm SAIC 304 284-9000 x228 304 284-9001 [fax] Dymm@xxxxxxxxx XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|