473,512 Members | 15,363 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question about xslt:for-each

Hello everyone. I have a pretty straight forward question:

I have some data stored in an XMl document in the format of:

<comment_info>
<comments>These are the comments</comments>
<comment_heading>This is comment heading</comment_heading>
</comment_info>

<comment_info>
<comments>These are the more comments</comments>
<comment_heading>This is another comment heading</comment_heading>
</comment_info>

and I am using an xslt:for-each command to create an .html page. I am
putting each comment_info section into it's own table on the .html
page. My question is how would I alternate table background colors of
these tables? For example I would want the 1,3,5... tables to have a
certain background color and the 2,4,6... tables to have another
background color. Is there some sort of function I can use to determine
if the comment_info block being returned is even or odd? I was even
thinking of placing the background color into the xml document itself,
but I would still need to know which background color I should insert
(again, is the comment_info block even or odd). I welcome any ideas.
Thank you.

Jul 27 '05 #1
2 1282
ge********@gmail.com:

//snip
My question is how would I alternate table background colors of
these tables? For example I would want the 1,3,5... tables to have a
certain background color and the 2,4,6... tables to have another
background color. Is there some sort of function I can use to determine
if the comment_info block being returned is even or odd?

//snip

Use XPath function position() and operator "mod" to check division
remainder:

<xsl:for-each select="select-statement">
<xsl:choose>
<xsl:when test="position() mod 2 = 0">
<!--do something here-->
</xsl:when>
<xsl:otherwise>
<!-- do something different here-->
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>

This solution actually gives you the possibility to use any nmber of
colours.
To sort nodes use <xsl:sort>.

Hope this was helpful.

Best regards,
Sorrow.

PS. This is my first post to this group, so a great welcome to you all. I
hope I'll learn much here :)
Jul 27 '05 #2
AWESOME. Worked like a charm. Thanks!

Jul 29 '05 #3

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

Similar topics

9
1845
by: Jeff Rubard | last post by:
I am curious to know whether anyone has experience using XSLT for web XML (non-XHTML) styling, either with CSS or standalone. I myself have engaged in rather unsuccessful experiments with the...
2
1083
by: gdevah | last post by:
Hi , I was looking for xslt to rearrang the order of attibutes within a node. xml to xml translation... <obj d="xslt" a="me" c="to" b="new"/> <prop c="it" b="does" a="how" d="matter"/> to
1
4547
by: Norm | last post by:
Hi, I've got a VBA Access application, and I want to remove the "Type a question for help" box from the menubar? How can I do this? Thanks, Norm
4
1115
by: Gidi | last post by:
hello, i'm asking this question for the third time because i got two answers but the were no good. i have dataGrid and one of the cell contains date. now i want that after the user entered 2 char...
4
1327
by: David Waz... | last post by:
about another news group... These news groups are always pleas for help... How about a news group like: Microsoft.Public.DotNet.Solutions.Framework.aspnet or some other such structure......
13
1464
by: Ghislain Tanguay | last post by:
I have a compiled vb.net app and I want to give the user a choice to launch it from the start line command and pass it a parameter or not. How can I do that in my code? Is it possible? Ex. :...
4
1950
by: K8CPA | last post by:
Hi Guys, I've got a question from a stupid question from a clueless computer operator's standpoint. I use Windows XP. SP2, and I've got all these neat little programs. What language do they...
14
1330
by: Jason.A.Oliver | last post by:
Okay this will hopefully be my last question for awhile since I've had a bunch over the last few weeks. Thank you all for being patient with me:) Last major obstacle is trying to set up combo...
3
1281
by: wajiha | last post by:
plz send me some question for beginners related to funtions
24
2925
by: joeldault | last post by:
Question For Microsoft Access Data Base -------------------------------------------------------------------------------- I am Trying to create a single formula that would do the following: If...
0
7252
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,...
0
7432
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...
1
7093
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7517
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...
0
5676
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,...
1
5077
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3230
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...
1
791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
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...

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.