Page 1 of 1

Docbook XSL overrules templates for adding class to td

Posted: Fri May 15, 2020 4:15 pm
by michelvandenburg
Hello everyone,

I am busy transforming DocBook XML to EPUB3 and HTML.
I want to add a class to table cells (td).

The input:

Code: Select all

<td role="breedte-50">
This is my XSL template in the customization layer:

Code: Select all

  <xsl:template match="td[@role = 'breedte-50']">
    <td xmlns="http://www.w3.org/1999/xhtml" class="breedte-50">
      <xsl:copy-of select="@*[local-name() != 'role' and local-name() != 'class']"/>
      <xsl:apply-templates/>
    </td>
  </xsl:template>
The expected out is:

Code: Select all

<td class="breedte-50">
Unfortunately, DocBook XSL ignores this rule and just places <td> in the output.

Does anyone know why this happens? Is it possible to add classes to <td>?

Thanks in advance!

Michel

Re: Docbook XSL overrules templates for adding class to td

Posted: Mon May 18, 2020 7:38 am
by Radu
Dear Michel,

Your XSLT customization is applied over DocBook content. DocBook has two types of tables, CALS tables and HTML tables. For CALS tables the cell name is "entry" and for HTML tables the cell name is "td". In your case are all the DocBook tabes HTML-tables?
You can try to add an xsl:message inside the "xsl:template", when publishing it should show up if your template is called. Otherwise it means your XSLT template is not called at all.
We (the Oxygen team) do not work much with DocBook, there seems to be a small section in the DocBook XSLT customization manual about generating custom @class attribute values:

http://sagehill.net/docbookxsl/HtmlCust ... lassValues

Also there is a DocBook Mailing list:

https://docbook.org/guidelines

on which you can ask DocBook specific questions, it has lots of people registered on it who use DocBook everyday.

Regards,
Radu

Re: Docbook XSL overrules templates for adding class to td

Posted: Mon Sep 14, 2020 3:15 pm
by michelvandenburg
Dear Radu,

Thank you for your reply. I've found that the custom class value works for most of the elements, except for tables. I've contacted Norman Walsh, who probably knows everything there is to know about the docbook XSL files.

Kind regards,

Michel