Page 1 of 1
Docbook PDF output Table customization
Posted: Fri Jan 18, 2013 11:51 am
by Felix
Good morning!
I created a DocBook5 file with Oxygen XML Editor 14.1.
Now I need some customized tables for the PDF output.
I want to customize the backgroundcolor, font-size and font-color.
I don't want to customize all tables.
I tried to figure out how to do that.
I created a customization layer. My Idea was to write a template with the table customizations and add it to the customization layer. But that's my problem because I'm not very familiar with xslt and xsl-fo coding.
Can I use the "role"-attribute to customize a table e.g.
Code: Select all
<xsl:template match="para"[@role='customtable']">
?
And what is the code for customizing the backgroundcolor, font-size and font-color?
I use the informaltables because I don't want to have table headlines.
Best regards from Germany
Re: Docbook PDF output Table customization
Posted: Fri Jan 18, 2013 5:25 pm
by sorin_ristache
Hello,
In your Docbook customization layer you should add a template based on your table marker, which is
@role='customtable', similar with the following template from the file
[Oxygen-install-dir]/frameworks/docbook/xsl/fo/htmltbl.xsl:
Code: Select all
<xsl:template match="d:table|d:informaltable" mode="htmlTable">
For example if you want to set the color and font size for all the table cells you can set them on the
fo:table element:
Code: Select all
<xsl:template match="d:table[@role='customtable']|d:informaltable[@role='customtable']" mode="htmlTable">
...
<fo:table background-color="yellow" font-size="24" color="blue">
This example is for the HTML table model in the Docbook XML documents. If you are not familiar with XSLT and XSL-FO I recommend avoiding the CALS table model because it seems harder to customize. The customization process is similar but more complicated in the XSLT stylesheet.
Regards,
Sorin
Re: Docbook PDF output Table customization
Posted: Tue Jan 22, 2013 12:15 pm
by Felix
Hello sorin,
thank you for your quick respond.
I think that's what I need.
I tried to implement it but I get errors using the HTML table model.
My table inside my docbook-file looks like this:
Code: Select all
<informaltable role="customtable">
<tbody>
<tr>
<td>Text</td>
<td>Text</td>
<td><mediaobject><imageobject><imagedata fileref="images/test.png"></imagedata><imageobject></mediaobject></td>
</tr>
</tbody>
</informaltable>
The table is ok until I add the "role"-attribute. If I add the "role"-attribute to the "informaltable"-element I get the following error-message from the validator: "E [Jing] element 'tbody' not allowed here; expected element 'alt', 'indexterm', 'info', mediaobject','textobject' or 'tgroup'".
If I add for example the "alt"-element the message still appears.
Any ideas what's the problem with the "role"-attribute?
Regards
Felix
Re: Docbook PDF output Table customization
Posted: Tue Jan 22, 2013 2:12 pm
by sorin_ristache
Hi Felix,
Felix wrote:The table is ok until I add the "role"-attribute. If I add the "role"-attribute to the "informaltable"-element I get the following error-message from the validator: "E [Jing] element 'tbody' not allowed here; expected element 'alt', 'indexterm', 'info', mediaobject','textobject' or 'tgroup'".
In fact
informaltable is a CALS table and if you add the
role attribute the content model of the
informaltable element required by the Docbook schema is changed. I suggest using a
table instead of an
informaltable, that is the HTML table model instead of the CALS model:
Code: Select all
<table role="customtable">
<caption/>
<tbody>
<tr>
<td>Text</td>
<td>Text</td>
<td>
<mediaobject>
<imageobject>
<imagedata fileref="images/test.png"/>
</imageobject>
</mediaobject>
</td>
</tr>
</tbody>
</table>
Regards,
Sorin
Re: Docbook PDF output Table customization
Posted: Thu Jan 24, 2013 1:40 pm
by Felix
Yesss the table-element works!
Thank you very much sorin!