How is it possible to customize the colors in a table

<oXygen/> general issues.
BogdanM777
Posts: 68
Location: Canada

How is it possible to customize the colors in a table

Thu Jun 18, 2015 6:44 pm

Hi,

I came right now upon another thing I need to solve in my DITA "quest".
I was able before, with the tools I was using, to determine the color of the border of a table, as well as of its cells.
I was also able to have the table display with alternate colors, for easier reading of the lines (e.g. alternate colors for the lines, white/light blue or white/lite gray).
I was wondering if this would be also possible in DITA using oXygene.

Thank you.
Radu
Posts: 4854

Re: How is it possible to customize the colors in a table

Fri Jun 19, 2015 9:23 am

Hi Bogdan,

This XSLT stylesheet creates the XSL-FO elements for DITA tables:

OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT/plugins/org.dita.pdf2/xsl/fo/tables.xsl

those XSL-FO table elements use attribute sets from this XSLT stylesheet:

OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT/plugins/org.dita.pdf2/cfg/fo/attrs/tables-attr.xsl

So you can try to perform various XSLT customizations.

There are two types of DITA tables, CALS table and simple table and that XSLT stylesheet has templates for both.

For the alternate coloring, probably in the template:

Code: Select all

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


could for example count using XPath the number of sibling rows before the current row and use that number to decide on the used color.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
BogdanM777
Posts: 68
Location: Canada

Re: How is it possible to customize the colors in a table

Fri Jun 19, 2015 3:59 pm

Thank you very much Radu.
Do you know some documentation/book that deals with the configuration of XSLT files?
I found already those files that need to be configured, and I already managed to get the color I want for the header, however I did not find anything regarding the frame color, or something regarding the alternating colors of rows of the table. I know this is a little to much cosmetic done to a table, however if possible, it would be awesome.
I am using CALS table because it offers me more customization options.
Eventually, if you could give me an example as how I could change those files, it would be awesome!
Thank you again.
Radu
Posts: 4854

Re: How is it possible to customize the colors in a table

Mon Jun 22, 2015 11:23 am

Hi Bogdan,

There is a book called DITA For Print which should have quite a lot of PDF customization scenarios:

http://xmlpress.net/publications/dita/dita-for-print/

Of course, the possibilities to customize the output are infinite so a book cannot cover any possible scenario.

I blogged here a possible solution to your questions:

http://blog.oxygenxml.com/2015/06/dita-ot-pdf-customization-tables-with.html

Regards
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
BogdanM777
Posts: 68
Location: Canada

Re: How is it possible to customize the colors in a table

Mon Jun 22, 2015 3:24 pm

Thank you so much Radu!
I will study the blog, and will let you know how it goes, OK?
Have a great one!
BogdanM777
Posts: 68
Location: Canada

Re: How is it possible to customize the colors in a table

Mon Jun 22, 2015 5:13 pm

Radu,

I did the changes suggested by you in the blog, and the only thing that worked was the color of the borders (top, bottom, left & right), however the column and row separators are still black.
Regarding the Customization process, I did the changes suggested by you, however after I changed the where customization.dir is pointing to the location where my folder was residing, I ran a build, and I received an error message at build. I changed value="${dita.plugin.org.dita.pdf2.dir}/Customization" inside build.xml to value="${dita.plugin.org.dita.pdf2.dir}/GCustomization" copied my folder inside the ...plugins/org.dita.pdf2and it did not go well. As soon as I changed it back to Customization, it worked again, but the rows remained white.
I tried to just copy the catalog.xml and the custom.xsl files inside the Customization folder and I received again error messages, so I deleted them to get back to normal.
So I am not sure if I made a mistake or there is something more I have to do.
Please advise.
Thank you.
BogdanM777
Posts: 68
Location: Canada

Re: How is it possible to customize the colors in a table

Mon Jun 22, 2015 5:37 pm

Radu,

I managed to get the results I wanted (with the alternate row colors), however I did the changes directly in the table.xsl file, as I want all the tables in our documentations to look the same.
I just bypassed the Customization part.
I also forgot to mention our architecture here.
I have oXygen installed on one of my VM, and I do the build (for test purposes) on my host machine where I have DITA-OT installed.
I do this because the build will not be done here (unless it is for test purposes) but remotely at the company HQ. I transfer my DITA projects via SVN to their server, and they do the build.
Therefore I tried to modify the DITA-OT files to match our demands. I commented all the changes so that if they need to revert or change something, they will be able to find the places where those changes need to be done.
For some reason, the Customization part did not quite work for me, I do not know why.
Anyway, if you would find a solution just for the column/rows separators so that I have the same color as for the frame of the table, it would be awesome!
Thank you.
Radu
Posts: 4854

Re: How is it possible to customize the colors in a table

Tue Jun 23, 2015 9:41 am

Hi Bogdan,

For some reason, the Customization part did not quite work for me, I do not know why.


You probably did something wrong, not sure what, I don't have enough details.
The customization folder can be used either from a location external to the DITA Open Toolkit location or it can be contributed via a DITA Open Toolkit PDF customization plugin.
So if you were making changes directly to the folder DITA-OT\plugins\org.dita.pdf2\Customization, that is not the proper way to do things.

Anyway, if you would find a solution just for the column/rows separators so that I have the same color as for the frame of the table, it would be awesome!


I think that each cell has its own border settings.
So you could also try to overwrite the template which outputs each cell like:

Code: Select all

    <xsl:template match="*[contains(@class, ' topic/tbody ')]/*[contains(@class, ' topic/row ')]/*[contains(@class, ' topic/entry ')]">
        <fo:table-cell xsl:use-attribute-sets="tbody.row.entry">
            <xsl:call-template name="commonattributes"/>
            <xsl:call-template name="applySpansAttrs"/>
            <xsl:call-template name="applyAlignAttrs"/>
            <xsl:call-template name="generateTableEntryBorder"/>
            <xsl:choose>
                <xsl:when test="(count(ancestor-or-self::*[contains(@class, ' topic/row ')]/preceding-sibling::*[contains(@class, ' topic/row ')]) mod 2) = 0">
                    <!-- Even row -->
                    <xsl:attribute name="border-top-color">blue</xsl:attribute>
                    <xsl:attribute name="border-bottom-color">blue</xsl:attribute>
                    <xsl:attribute name="border-right-color">blue</xsl:attribute>
                    <xsl:attribute name="border-left-color">blue</xsl:attribute>
                </xsl:when>
                <xsl:otherwise>
                    <!-- Odd row -->
                </xsl:otherwise>
            </xsl:choose>
           
            <fo:block xsl:use-attribute-sets="tbody.row.entry__content">
                <xsl:call-template name="processEntryContent"/>
            </fo:block>
        </fo:table-cell>
    </xsl:template>


Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
BogdanM777
Posts: 68
Location: Canada

Re: How is it possible to customize the colors in a table

Tue Jun 23, 2015 4:04 pm

Thank you so much Radu!
It worked!
As for the other things mentioned in the ticket, I tried my best to follow instructions (and believe me I am very good at following instructions), and it did not quite work for me.
Anyways, I needed to establish a standard outlook for all our pdf docs, so it is OK as it is right now.
Thank you again.

Return to “Other Issues”

Who is online

Users browsing this forum: No registered users and 4 guests