4.8.1. Customizing the transformation to DocBook

The transformation from XHTML to DocBook is done by the docma/html2docbook.xsl script located in the web application folder of Docmenta. If a plug-in adds files with one of the prefixes listed in the following table, then the content of these files is included in the html2docbook.xsl file. The resulting XSL code is used to transform the XHTML content to DocBook. The files have to be located in the same folder as the html2docbook.xsl script.
Table 4.8.1. Filename prefixes for DocBook transformation files
File PrefixDescription
html2db- Files with this prefix are included for all DocBook-based exports (DocBook, PDF, static HTML, WebHelp V1 and EPUB).
html2db_print- Files with this prefix are included for print output (for example PDF), but not for HTML-based output formats.
html2db_pdf- Files with this prefix are only included for PDF output.
html2db_html- Files with this prefix are only included for HTML-based output formats that utilize the DocBook stylesheets (static HTML, WebHelp V1 and EPUB).
Note: WebHelp V2
The WebHelp V2 format is not based on DocBook. Therefore, none of these transformation files have impact on the WebHelp V2 output. To adapt the output of WebHelp V2, AutoFormat styles can be used (see Chapter 4.6, AutoFormat plug-ins).
As an example, we add support for side floats in print output. A side float shall be defined by a paragraph or div block, which has a style with ID aside assigned. In DocBook an element named sidebar exists for creating side floats. That means, all that needs to be achieved in the export process, is to transform p and div elements, which have the CSS class "aside" assigned, into DocBook sidebar elements. Therefore, we add a file named html2db_print-aside.xsl to the docma folder of Docmenta. Following the content of the file:
<xsl:template match="div[@class='aside']">
<sidebar><xsl:apply-templates /></sidebar>
</xsl:template>
 
<xsl:template match="p[@class='aside']">
<sidebar><xsl:apply-templates /></sidebar>
</xsl:template>

Listing 4.8.1. html2db_print-aside.xsl

Note that Docmenta also defines XSL templates for handling p and div elements. In our example, the templates defined in 4.8.1: html2db_print-aside.xsl automatically replace the Docmenta templates due to the priorization rules of XSLT. However, in some cases it may be necessary to explicitely increase the priority of an added template by using the XSLT priority attribute.
For the sidebar element to be rendered as side float, we also have to set the DocBook XSL parameter "sidebar.float.type". To achieve this, we have to extend the customization layer of the DocBook XSL stylesheets. This is described in the following section.