473,544 Members | 1,539 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>The se are the comments</comments>
<comment_headin g>This is comment heading</comment_heading >

<comment_info >
<comments>The se are the more comments</comments>
<comment_headin g>This is another comment heading</comment_heading >

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 1286
ge********@gmai l.com:

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?


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

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

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

Hope this was helpful.

Best regards,

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

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 DocBook chunk stylesheet, but it seems to me that retaining the structural markup of XML formats (i.e., the marking out of salient properties of a text...
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
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
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 (2 numbers) a "/" will appear. i tried to catch it with currentcellchanged event and by overriding a procces but the problem is that while i'm still...
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... where people post actual solutions to complex problems they have found that work. This group, and groups like it will exist for Q/A, but a dedicated...
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. : MyApp.exe "Go"
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 program these neat little programs in, like Skype, Yahoo IM, AOL IM, GAIM, Weatherbug, all these neato programs... I'd like to do some programming...
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 boxes in a form that look up values in another table. The idea is that while the user will select a text answer, it will be entered into the table...
by: wajiha | last post by:
plz send me some question for beginners related to funtions
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 A1 is less then or equal to 499, deliver B1*1, if A1 is equal to or less than 999 but more than and including 500, deliver B1*2, If A1 is equal to or...
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...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
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. ...
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...
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
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...
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
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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...

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.