473,785 Members | 2,557 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Alternating table row colors WITHOUT using position()

Is there a way to alternate table row colors without using the
position() mod 2 trick? I'm in a series of nested xsl:for-each
elements, about 3 deep, and I want to alternate the table row
color all the way through. position() resets to 1 whenever
the inner for-each loops around, of course.

Example code:

<xsl:for-each select="/games/game[count(. | key('platforms' , platform)[1]) = 1]">
<xsl:sort select="platfor m"/>
<xsl:variable name="platform" select="platfor m"/>
<xsl:for-each select="/games/game[date = $date][region = $region][platform = $platform]">
<xsl:sort select="title"/>
<tr class="???????" bgcolor="?????? ?">
<td>
<xsl:choose>
<xsl:when test="position( ) = 1"><xsl:valu e-of select="platfor m"/></xsl:when>
<xsl:otherwise> &nbsp;</xsl:otherwise>
</xsl:choose>
</td>
<td><a href="{path}/data/{id}.html"><xsl :value-of select="title"/></a></td>
<td><xsl:valu e-of select="genre"/></td>
</tr>
</xsl:for-each>
</xsl:for-each>

-rs-
Jul 20 '05 #1
2 6195
This can be done in two steps:

Step1:

<xsl:variable name="vrtfMyRow s">
<!-- All your processing here but not creating the table -->
<xsl:for-each select="/games/game[count(. | key('platforms' , platform)[1]) = 1]"> <xsl:sort select="platfor m"/>
<xsl:variable name="platform" select="platfor m"/>
<xsl:for-each select="/games/game[date = $date][region = $region][platform = $platform]"> <xsl:sort select="title"/> <xsl:copy-of select="."/> </xsl:for-each>
</xsl:for-each>
</xsl:variable>

Step2:

<xsl:for-each select="ext:nod e-set($vrtfMyRows )/*">
<!-- Produce the table with alternating rows using position() mod 2 -->
</xsl:for-each>

=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

"Ralph Snart" <sn***@nospam.c om> wrote in message
news:sl******** **********@clut tered.com... Is there a way to alternate table row colors without using the
position() mod 2 trick? I'm in a series of nested xsl:for-each
elements, about 3 deep, and I want to alternate the table row
color all the way through. position() resets to 1 whenever
the inner for-each loops around, of course.

Example code:

<xsl:for-each select="/games/game[count(. | key('platforms' , platform)[1]) = 1]"> <xsl:sort select="platfor m"/>
<xsl:variable name="platform" select="platfor m"/>
<xsl:for-each select="/games/game[date = $date][region = $region][platform = $platform]"> <xsl:sort select="title"/>
<tr class="???????" bgcolor="?????? ?">
<td>
<xsl:choose>
<xsl:when test="position( ) = 1"><xsl:valu e-of select="platfor m"/></xsl:when> <xsl:otherwise> &nbsp;</xsl:otherwise>
</xsl:choose>
</td>
<td><a href="{path}/data/{id}.html"><xsl :value-of select="title"/></a></td> <td><xsl:valu e-of select="genre"/></td>
</tr>
</xsl:for-each>
</xsl:for-each>

-rs-

Jul 20 '05 #2
On Sat, 2 Aug 2003 12:15:40 +0200, Dimitre Novatchev <dn********@yah oo.com> wrote:
<xsl:for-each select="ext:nod e-set($vrtfMyRows )/*">


is it possible to do this without ext:node-set? i use sablotron which doesn't
support that extension.

-rs-
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
2896
by: LRW | last post by:
Is there some way to make a table have alternating colors for rows when you're generating the table data with a WHILE statement? You know, row 1 has a gray BG, row 2 is white, row 3 is gray, 4 is white, etc, for as long as there's data. Here's what I'm using right now: $query_RSwho = "SELECT * FROM tbl_indv ORDER BY name ASC"; $RSwho = @mysql_query($query_RSwho, $connection) or die("Couldn't query: " .. mysql_error()); while...
1
4578
by: Alistair Birch | last post by:
Hi I want rows of a table to appear in alternating background colours. Having looked around the web I can't find any solution apart from waiting for the next version of CSS, so I tried building one myself, but I need some help to finish it. I use the getAttribute('rowIndex') to return the position of a row within the table and apply modulo 2 to return a 0 or 1 indicating an even or odd row number, from which I apply the alternating...
47
18905
by: Matt Kruse | last post by:
http://www.mattkruse.com/temp/css_expressions.html One of the standard CSS questions is "how can I shade every other table row a different color with CSS?" The answers are usually 1) you can't (yet), 2) put a class on every other tr, or 3) use javascript to do the styling for you. Well, I've been playing the CSS expressions quite a bit lately and I've found a much simpler solution which works in IE5.5+, using "expressions". If
9
2695
by: Max Weebler | last post by:
Hi, I have a datagrid built that has an alternating item style that sets the backcolor and ForeColor of its rows. I have 4 template columns. One of them has a LinkButton embedded in it to perform updates. All the styles that are set are being followed by all templated columns with the exception for the update column. The update column does set the BackColor appropriately but when setting its ForeColor the LinkButton's color is blue and...
1
1316
by: Steve Bottoms | last post by:
Hi, all! How does one prevent table cell background colors from alternating between grey and white? I've dropped a basic table control on an ASP.Net page (using VB.Net codebehind), and dynamically creating rows and cells. However, I can't seem to get the blasted thing to stop alternating the background colors on every other row! I've tried setting the cell.BackColor property, but the value is just getting ignored! Also tried on...
5
3346
by: | last post by:
I'm making admin forms. I'm wondering if there is a way to have the server programmatically assign alternating colors in a regular table (not a datalist control). I notice ASP.NET 2 offers a runat="server" attribute on tables, leading me to believe that this should be possible. Any ideas? I'm using C#. Thanks, -KF
3
1568
clintw
by: clintw | last post by:
Hi all, I've been doing my head in trying to get this to work, but I keep running into a snag. Basically I have a database table with a list of events for the year, with fields for Month, Event Description, FullDate (used for sorting). When I input the result set into a HTML table, this works fine, alternating backgrounds colors for the individual rows is no problem - my problem comes in trying to alternate the background colors by Month...
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10356
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10161
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9958
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8986
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5390
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4058
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2890
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.