|
[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
>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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








