You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by "Sells, Fred" <fr...@adventistcare.org> on 2003/09/19 14:36:45 UTC

RE: table row color changing [spam-BCC][Faked From Address][html- removed]

according to the O'reilly book, the only way to increment a variable is to
call a template recursively.  I think I've seen an example of what you want
where they used a "count" and the mod function to alternate row color, but
don't recall the code.

-----Original Message-----
From: Ramon Maria Gallart [mailto:rgallart@asistemas.net]
Sent: Friday, September 19, 2003 6:03 AM
To: fop-user@xml.apache.org
Subject: table row color changing [spam-BCC][Faked From
Address][html-removed]
Importance: Low


Hi all.
 
Can anyone tell me the way to change the colors of a table rows? I mean,
the first in a color the next with other color, the next one with the
first color and so on... I've tried to do it using an external variable
but when i change it inside the loop it seems not to recognize it.
 
Thanks a lot.
 
Ramon Maria.

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


Alternating fo:table-row color CODE (Re: table row color changing)

Posted by Clay Leeds <cl...@medata.com>.
Ramon,

Hope this helps. Near the top of my xsl-fo document I set some 
xsl:variable so I can change the color throughout my FO (I also set up 
my fonts, font-size, heading font-size, page "background-color", etc. ;-p):

<!-- === BEGIN: set up variables === -->
<xsl:variable name="varNormalBGColor">#ffffff</xsl:variable>
<!-- varNormalBGColor | background-color for EOR - default:#ffffff 
(white) -->
<xsl:variable name="varAccentBGColor">#ccffff</xsl:variable>
<!-- varAccentBGColor | background-color for highlights (e.g., 
alternating ICD9/Bill Detail lines.) - default:#ccffff (teal) -->
<!-- === END: set up variables === -->

Then, for the fo:table-row elements I want to color, I process an 
xsl:for-each statement with this as the fo:table-row element:
										<xsl:for-each select="{## INSERT YOUR INCREMENTER ##}">
   <fo:table-row>
     <xsl:attribute name="background-color">
       <xsl:choose>
         <xsl:when test="(position() mod 2) = 0"><xsl:value-of 
select="$varAccentBGColor"/></xsl:when>
         <xsl:otherwise><xsl:value-of 
select="$varNormalBGColor"/></xsl:otherwise>
       </xsl:choose>
     </xsl:attribute>
     <fo:table-cell>
       <fo:block keep-with-next.within-page="always">
         <xsl:value-of select="{## INSERT SELECT ITEM FOR CELL 1 ##}"/>
       </fo:block>
     </fo:table-cell>
     <fo:table-cell>
       <fo:block padding-left="6pt" keep-with-next.within-page="always">
         <fo:inline font-size="4pt">&#160;</fo:inline>
         <xsl:value-of select="{## INSERT SELECT ITEM FOR CELL 2 ##}"/>
       </fo:block>
     </fo:table-cell>
   </fo:table-row>
</xsl:for-each>

Hope this helps!

Web Maestro Clay

Sells, Fred wrote:
> according to the O'reilly book, the only way to increment a variable is to
> call a template recursively.  I think I've seen an example of what you want
> where they used a "count" and the mod function to alternate row color, but
> don't recall the code.
> 
> -----Original Message-----
> From: Ramon Maria Gallart [mailto:rgallart@asistemas.net]
> Sent: Friday, September 19, 2003 6:03 AM
> To: fop-user@xml.apache.org
> Subject: table row color changing [spam-BCC][Faked From
> Address][html-removed]
> Importance: Low
> 
> 
> Hi all.
>  
> Can anyone tell me the way to change the colors of a table rows? I mean,
> the first in a color the next with other color, the next one with the
> first color and so on... I've tried to do it using an external variable
> but when i change it inside the loop it seems not to recognize it.
>  
> Thanks a lot.
>  
> Ramon Maria.



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org