[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Every other row with a different twist

Subject: Every other row with a different twist
From: Arni J Rognvaldsson <arni.rognvaldsson@xxxxxxxxxx>
Date: Tue, 16 Jan 2001 16:14:28 -0500
color every other row
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:

<person>
   <address>
      <city/>
      <tel/>
   </address>
   <employer>
      <name/>
      <tel/>
   </employer>
</person>

my stylesheet look like this:

<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>

   </table>
</xsl:template>

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.

Thanks,

Arni


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



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.