This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Alternate bg colors for table and address summaries
- To: <XSL-List at mulberrytech dot com>
- Subject: RE: Alternate bg colors for table and address summaries
- From: "Paul Essex" <paul at bridge-way dot com>
- Date: Wed, 1 Nov 2000 18:23:23 -0400 (EST)
- Reply-To: xsl-list at mulberrytech dot com
>Date: Wed, 25 Oct 2000 15:51:13 EDT
>From: "Robert Saylor" <rrsaylor@hotmail.com>
>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