new poster / conditionals in for-each

Subject: new poster / conditionals in for-each
From: "Chris Reeves" <noverant@xxxxxxxxxxx>
Date: Wed, 19 Jan 2000 11:14:33 EST
Im a new poster as well as a new xml/xsl developer so take it easy on me. I've been using xsl all of four weeks and to this point I've been able to get it to do what i need - but now I've come across a problem. The root of the problem may very well be that I am treating xsl as a cgi application which I probably shouldn't be doing, but it makes sense to me that I would be able to do the following.

I want to do conditional processing based on the position of an element within a xsl:for-each? That is, if this is the first iteration of the xsl:for-each, i want to do x, and if its the second, i want to do y.
Specifically, I am trying to alternate the bgcolor of a row for each iteration of the for-each loop.
My xml looks like this:


<session>
	<location>some location</location>
	<location>some location</location>
	<location>some location</location>
	<location>some location</location>
</session>

My output is in an html table and i want to do something similar to this:

<xsl:for-each select="session">
	<if current loop is divisible by 2>
		<tr bgcolor="ffffff">
	<if it isn't>
		<tr bgcolor="e0e0e0">
	</if>
	. . .
</xsl:for-each>

Thanks for any help. Also, any suggestions as far as good literature would be much appreciated. I have XML Design and Implementation by Paul Spencer, and it may be a good book, but my experience with other languages is that there is usually a definitive developers 'bible' which stands heads above the rest. Is there such a reference for web specific xml/xsl?

thanks for any help,
Chris
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread