Search code examples
xsltrenderingdocbookdocbook-5

DocBook 5 rendering without abbrev tag


My DocBook 5 document contains glossentry tags that contain abbrev tags. The abbrev tags do not seem to contribute anything whatsoever to the rendered HTML. I'm new to DocBook and XSLT. Where do I need to start looking to change this? I've been looking through the docs and aside from being surprised by this apparently being the default behaviour, I'm not sure where to look next to troubleshoot.

Setup: My DocBook file starts simply with <book xmlns:xl="http://www.w3.org/1999/xlink">. I point xsltproc only to a single XSL file, which contains exactly this:

<?xml version='1.0'?>
<xsl:stylesheet  
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:import href="/usr/share/sgml/docbook/xsl-stylesheets/html/docbook.xsl"/>

<xsl:output method="html"
            encoding="UTF-8"
            indent="no"/>
<xsl:param name="html.stylesheet" select="'main.css'"/>
<xsl:param name="generate.toc">
  book      toc,title
</xsl:param>
<xsl:param name="glossentry.show.acronym">yes</xsl:param>

</xsl:stylesheet>

Solution

  • There is a parameter named glossentry.show.acronym that you can set to yes to ensure both "acronym and abbrev elements in the glossentry" are displayed. You can also set it to primary to ensure these elements are displayed as the primary text for an entry.

    If you need more customization, you would need to add your own template overriding the one in the Docbook stylesheet, which is

    <xsl:template match="d:glossentry/d:abbrev"> <xsl:apply-templates/> <xsl:if test="following-sibling::d:acronym|following-sibling::d:abbrev">, </xsl:if> </xsl:template>
    

    and outputs the abbrev elements as a comma separated list.