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 Miguel Tablado <mi...@gmail.com> on 2008/11/12 10:05:26 UTC

Table style

Hi all;

I need to create a style for tr elements that it paints tr backgrounds on
different colors depending on its positions.

I mean, I need tables with n+1 and n+2 rows with blank background and n+3
and n+4 rows with grey one.

I have found it for css, but it doesn't work in all browsers.

table tr:nth-child(2+4n) { background-color: #F0F0F0}
table tr:nth-child(3+4n) { background-color: #F0F0F0}

Thanks, 
Miguel Tablado
-- 
View this message in context: http://www.nabble.com/Table-style-tp20456514p20456514.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: Table style

Posted by Andreas Delmelle <an...@telenet.be>.
On 12 Nov 2008, at 10:05, Miguel Tablado wrote:

Hi

> I need to create a style for tr elements that it paints tr  
> backgrounds on
> different colors depending on its positions.

On the one hand, this is problematic, since there is no mechanism in  
XSL-FO that allows you to do that, but...

There is a chance this can be done in XSLT, since depending on the  
data, it may be possible to vary the table-row's background-color  
according to the position of the nodes in the source tree.

Say, if you have <datarow> elements, and each of those generates a  
separate table-row, you could do something like:

<for-each select="datarow">
   <fo:table-row>
     <xsl:attribute name="background-color">
       <xsl:variable name="checkpos" select="position() mod 4" />
       <xsl:choose>
         <!-- grey background for cells n+3 and n+4 -->
         <xsl:when test="(checkpos = 0) or (checkpos = 3)">#F0F0F0</ 
xsl:when>
         <!-- white background otherwise -->
         <xsl:otherwise>#FFFFFF</xsl:otherwise>
       </xsl:choose>
     </xsl:attribute>
     <!-- rest of processing -->
   </fo:table-row>
</xsl:for-each>


HTH!

Cheers

Andreas

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