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

RE: Alternate bg colors for table and address summaries

Subject: RE: Alternate bg colors for table and address summaries
From: "Paul Essex" <paul@xxxxxxxxxxxxxx>
Date: Wed, 1 Nov 2000 18:23:23 -0400 (EST)
bg colors
>Date: Wed, 25 Oct 2000 15:51:13 EDT
>From: "Robert Saylor" <rrsaylor@xxxxxxxxxxx>
>Subject: Alternate bg colors for table and address summaries

>Here is the dilemma,
>I want to have one summary return with a grey background and the other
>summary with a white background.

>Ive tried the position function and have had no luck perhaps its me as im
>new at this?

I think you're on the right track with the position function, although I
didn't see that code in the stylesheet you included with your message.

Take a look at page 367 in Michael Kay's XSLT book.  The very last entry in
the Examples table shows this method of determining whether a node's
position is even:

item[position() mod 2 = 0]

Use this in an xsl:when test something like this:

<xsl:choose>
  <xsl:when test="Summary[position() mod 2 = 0]>
    <xsl:call-template name="bgcolorgrey"/>
  </xsl:when>
  <xsl:otherwise>
    <xsl:call-template name="bgcolorwhite"/>
  </xsl:otherwise>
</xsl:choose>

You can then create two named templates to create the table rows, one
implementing a gray background and the other implementing a white
background.

I thought about a simpler way to do this, which would be to simply do the
test and set a variable value to the desired color, then use the variable
for the 'bgcolor' attribute of the <tr> tag.  I'm not sure if that would
work, though.  I'd be concerned if the variable would stay in scope after
you exit the xsl:choose, and I'm also not sure if it would be recreated for
each node processed in the xsl:for-each (although I think it would).
Perhaps someone more experienced than I am can comment on that.

Hope that helps!


Paul Essex
Software Developer
Bridgeway Software, Inc.





 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.