docbook-apps

  • 1.  Alternate color of table rows.

    Posted 03-31-2014 18:09
    Hi,

    i used following syntax as follows:

    <xsl:template name="table.row.properties">

    <xsl:variable name="tabstyle">
    <xsl:call-template name="tabstyle"/>
    </xsl:variable>

    <xsl:variable name="bgcolor">
    <xsl:call-template name="dbfo-attribute">
    <xsl:with-param name="pis"
    select="processing-instruction('dbfo')"/>
    <xsl:with-param name="attribute" select="'bgcolor'"/>
    </xsl:call-template>
    </xsl:variable>

    <xsl:variable name="rownum">
    <xsl:number from="d:tgroup" count="d:row"/>
    </xsl:variable>

    <xsl:choose>
    <xsl:when test="$bgcolor != ''">
    <xsl:attribute name="background-color">
    <xsl:value-of select="$bgcolor"/>
    </xsl:attribute>
    </xsl:when>


    <xsl:when test="$rownum mod 2 != 0">
    <xsl:attribute name="background-color">#EEEEEE</xsl:attribute>
    </xsl:when>
    </xsl:when>

    </xsl:choose>
    </xsl:template>


    The problem that i am facing is that the *above code is setting the
    background color of the entry of the thead also* which i don't want*. *

    I think $rownum mod 2 != 0 is treating row 1 of thead also and coloring it.
    How can i prevent this?

    Thanks and Regards,
    Anmol



  • 2.  Re: [docbook-apps] Alternate color of table rows.

    Posted 03-31-2014 18:50
    Hi Anmol,
    In the xsl:number element, change d:tgroup to d:tbody, and add a new
    clause to the xsl:choose before the 'striped' test:

    <xsl:choose>
    ...
    <xsl:when test="ancestor::d:thead">

    </xsl:when>
    ...

    Bob Stayton
    Sagehill Enterprises
    bobs@sagehill.net

    On 3/31/2014 11:08 AM, anmol gupta wrote:
    > Hi,
    >
    > i used following syntax as follows:
    >
    > <xsl:template name="table.row.properties">
    >
    > <xsl:variable name="tabstyle">
    > <xsl:call-template name="tabstyle"/>
    > </xsl:variable>
    >
    > <xsl:variable name="bgcolor">
    > <xsl:call-template name="dbfo-attribute">
    > <xsl:with-param name="pis"
    > select="processing-instruction('dbfo')"/>
    > <xsl:with-param name="attribute" select="'bgcolor'"/>
    > </xsl:call-template>
    > </xsl:variable>
    >
    > <xsl:variable name="rownum">
    > <xsl:number from="d:tgroup" count="d:row"/>
    > </xsl:variable>
    >
    > <xsl:choose>
    > <xsl:when test="$bgcolor != ''">
    > <xsl:attribute name="background-color">
    > <xsl:value-of select="$bgcolor"/>
    > </xsl:attribute>
    > </xsl:when>
    >
    >
    > <xsl:when test="$rownum mod 2 != 0">
    > <xsl:attribute name="background-color">#EEEEEE</xsl:attribute>
    > </xsl:when>
    > </xsl:when>
    >
    > </xsl:choose>
    > </xsl:template>
    >
    >
    > The problem that i am facing is that the *above code is setting the
    > background color of the entry of the thead also* which i don't want*. *
    >
    > I think $rownum mod 2 != 0 is treating row 1 of thead also and coloring it.
    > How can i prevent this?
    >
    > Thanks and Regards,
    > Anmol
    >