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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

  • Table style Miguel Tablado
    • Re: Table style Andreas Delmelle

Reply via email to