Hi Marcel,
In DocBook 4.5, the role attribute is not permitted on the colspec element.
However, it is for DocBook 5. So you could add role attributes to colspec and
test for them.
There is a utility template named 'inherited.table.attribute' that can find an
attribute value for an entry or from any of its table ancestors. It will also
check the colspec for the entry's column, since some properties like align can
be set there. So you can customize the template name 'table.cell.properties' to
fetch the value of the 'role' attribute and add properties based on its value.
This snippet shows how it can be done:
<xsl:template name="table.cell.properties">
<xsl:param name="bgcolor.pi" select="''"/>
<xsl:param name="rowsep.inherit" select="1"/>
<xsl:param name="colsep.inherit" select="1"/>
<xsl:param name="col" select="1"/>
<xsl:param name="valign.inherit" select="''"/>
<xsl:param name="align.inherit" select="''"/>
<xsl:param name="char.inherit" select="''"/>
<!-- Add this variable -->
<xsl:variable name="role.attribute">
<xsl:call-template name="inherited.table.attribute">
<xsl:with-param name="entry" select="."/>
<xsl:with-param name="attribute" select="'role'"/>
<xsl:with-param name="colnum" select="$col"/>
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="ancestor::d:tgroup">
<xsl:if test="$bgcolor.pi != ''">
<xsl:attribute name="background-color">
<xsl:value-of select="$bgcolor.pi"/>
</xsl:attribute>
</xsl:if>
<!-- Add this test -->
<xsl:if test="$role.attribute = 'colspecrole'">
<xsl:attribute name="background-color">
<xsl:value-of select="'#AEEEEE'"/>
</xsl:attribute>
</xsl:if>
...
Bob Stayton
Sagehill Enterprises
[email protected]
----- Original Message -----
From: Marcel Tromp
To: Bob Stayton
Cc: [email protected]
Sent: Saturday, April 04, 2009 11:10 PM
Subject: Re: [docbook-apps] Table Header Column Formatting
Correct, I am looking at print output.
I was hoping to be able to do column specific formatting based on defining a
role in the colspec. This does not seem possible, correct?
As an alternative, I have been trying to put a role on 'entry', but have not
been successful. How do I change table.cell.properties based on an attribute of
an ancestor?
Regards,
Marcel
--
On Sun, Mar 29, 2009 at 8:14 PM, Bob Stayton <[email protected]> wrote:
Hi,
I presume you are asking about printed output, not HTML output.
There is a named template that handles the format properties on each table
cell, and another to apply format properties to the fo:block inside each cell.
These are described in these two sections of my book:
http://www.sagehill.net/docbookxsl/PrintTableStyles.html#table.cell.properties
http://www.sagehill.net/docbookxsl/PrintTableStyles.html#table.cell.block.properties
You could customize these using additional xpath selectors. The existing
template uses "ancestor::thead" to test for table header cells. You could use
"count(preceding-sibling::entry) = 0" to detect first cells in each row.
Bob Stayton
Sagehill Enterprises
[email protected]
----- Original Message -----
From: Marcel Tromp
To: [email protected]
Sent: Saturday, March 28, 2009 10:10 PM
Subject: [docbook-apps] Table Header Column Formatting
Is there an easy way do define a stylesheet that will format the cells in
a header column the same way the cells are formatting in a header (thead) row?
Marcel
--