Table Row Attributes - background color

Having trouble installing Oxygen? Got a bug to report? Post it all here.
Boreas
Posts: 86
Joined: Wed Feb 09, 2011 10:43 pm

Table Row Attributes - background color

Post by Boreas »

Hello,

I was wondering if there is an attribute that can be set on a row to add a background color to that specific row? The table heading row does that, but I understand that we cannot use more than one tableheading row in a table.
We have long tables. We need the table heading row, but we would also need to add a background color to some of the rows. I was hoping to be able to use something like BGCOLOR="#99CCFF", or something similar.

Code: Select all


 <strow BGCOLOR="#99CCFF">
<stentry/>
<stentry/>
</strow>.
But apparently it is not supported. oXygen givens me the red line!

Is there a simple way to achieve this result this?

Kind regards

Carole
Radu
Posts: 9049
Joined: Fri Jul 09, 2004 5:18 pm

Re: Table Row Attributes - background color

Post by Radu »

Hi Carole,

You would need some kind of output customization for this.
For example in the DITA content you could set the color as an output class attribute:

Code: Select all

<strow outputclass="#99CCFF">
.....
If you want this for XHTML-based output you could have a custom CSS which matches the row and sets a background color to it.

If you want this for the PDF output you would need a PDF customization folder which would have an XSLT stylesheet overriding the template which matches a table row.
On the Oxygen XML Blog I explained a couple of weeks ago how to have table rows with alternating colors in the PDF output:

http://blog.oxygenxml.com/2015/06/dita- ... -with.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Boreas
Posts: 86
Joined: Wed Feb 09, 2011 10:43 pm

Re: Table Row Attributes - background color

Post by Boreas »

Hello,

your posts gave me the pointers to achieve what I wanted.
I have a plugin and I don't use a customisation folder.

So in tables-attr.xsl I added under:

Code: Select all

<xsl:attribute-set name="tbody.row">
</xsl:attribute-set>
This

Code: Select all

 <!--new attribute set to color a table row-->
<xsl:attribute-set name="color" use-attribute-sets="tbody.row">
<xsl:attribute name="background-color">#FAFAD2</xsl:attribute>
<xsl:attribute name="border-left-width">15pt</xsl:attribute>
</xsl:attribute-set>
In tables.xsl I added a condition based on an outputclass value.

Code: Select all

<!-- New condition to color a table row-->

<xsl:template match="*[contains(@class, ' topic/tbody ')]/*[contains(@class, ' topic/row ')]">
<xsl:choose>
<xsl:when test="contains(@outputclass, 'color')">
<fo:table-row xsl:use-attribute-sets="color">
<xsl:call-template name="commonattributes"/>
<xsl:apply-templates/>
</fo:table-row>
</xsl:when>
<xsl:otherwise>
<fo:table-row xsl:use-attribute-sets="tbody.row">
<xsl:call-template name="commonattributes"/>
<xsl:apply-templates/>
</fo:table-row>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

then in my table, for each row I whant to color I add:
<row outputclass="color">

This way I can pick the rows I want to color.
Best regards.
Carole
Post Reply