Subject: [xsl] Every other row with a different twist|
From: Arni J Rognvaldsson <arni.rognvaldsson@xxxxxxxxxx>
Date: Tue, 16 Jan 2001 16:14:28 -0500
I'm sorry if this has already been discussed to death, I tried searching the list, but found nothing close enough. Like a lot of other people I'm trying to color every other table row. Normally I would do this with position() mod 2, but in this case that's not practical.
<person> <address> <city/> <tel/> </address> <employer> <name/> <tel/> </employer> </person>
<xsl:template match="person"> <table>
<xsl:if test="boolean(address/name)"> <tr> <td>Person's home city:</td> <td><xsl:value-of select="address/name"/></td> </tr> </xsl:if>
<xsl:if test="boolean(employer/name)"> <tr> <td>Person's employer:</td> <td><xsl:value-of select="employer/name"/></td> </tr> </xsl:if>
<xsl:if test="boolean(employer/tel)"> <tr> <td>Employer's telephone number:</td> <td><xsl:value-of select="employer/tel"/></td> </tr> </xsl:if>
Notice that the number of rows in the output will vary depending on the existence of the nodes in the input xml. Also note that I'm not using all the elements in the input. Lastly, the labels in the first td in each block are completely arbitrary.
Now, of course the client would like to color every other row. I'm stumped, can't figure out a way to do it. Any help would be very much appreciated, I don't mind cheating, rewriting the above in any way or whatever, as long as it does not require changes to the html data (this is only one page, there are more). Of course, this might be impossible :-( I'm running XalanJ version 1.2.2 under Apache JServ.