[xsl] Every other row with a different twist

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.

My xml can be represented like this:


my stylesheet look like this:

<xsl:template match="person">

      <xsl:if test="boolean(address/name)">
            <td>Person's home city:</td>
            <td><xsl:value-of select="address/name"/></td>

      <xsl:if test="boolean(employer/name)">
            <td>Person's employer:</td>
            <td><xsl:value-of select="employer/name"/></td>

      <xsl:if test="boolean(employer/tel)">
            <td>Employer's telephone number:</td>
            <td><xsl:value-of select="employer/tel"/></td>


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
Of course, this might be impossible :-(
I'm running XalanJ version 1.2.2 under Apache JServ.



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

Current Thread