Docbook XSL overrules templates for adding class to td

Here should go questions about transforming XML with XSLT and FOP.
michelvandenburg
Posts: 1
Joined: Fri May 15, 2020 3:43 pm

Docbook XSL overrules templates for adding class to td

Post by michelvandenburg » Fri May 15, 2020 4:15 pm

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

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

Re: Docbook XSL overrules templates for adding class to td

Post by Radu » Mon May 18, 2020 7:38 am

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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply