#456 refactor content param in inline.* stylesheets

output: all formats
open
nobody
XSL (399)
5
2012-10-17
2012-10-17
No

I have implemented a mechanism, whereby the content of technical inline elements are drawn in from an external source based on the attribute "role" (the source code of the project I am documenting) instead of being explicitly repeated in the docbook document. This makes sure the documentation uses the same terminologie used in the application.
This mechanism overwrites the part of the inline.* templates that calculate the content:

<xsl:param name="content">
<xsl:variable name="id" select="@role"/>
<xsl:choose>
<xsl:when test="normalize-space(.)">
<xsl:call-template name="simple.xlink">
<xsl:with-param name="content">
<xsl:apply-templates/>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="getString">
<xsl:with-param name="id" select="$id"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:param>

This has to be repeated for all the templates (charseq, monoseq, boldseq, etc), and creates a lot of redundant code to maintain.
If the docbook stylesheet would factor out this part into its own template, which would in itself be an improvement, according to the DRY principle, this customization would be much easier:

<xsl:template name="inline.content">
<xsl:call-template name="anchor"/>
<xsl:call-template name="simple.xlink">
<xsl:with-param name="content">
<xsl:apply-templates/>
</xsl:with-param>
</xsl:call-template>
</xsl:template>

I can provide a patch, if you consider the idea acceptable for inclusion into the docbook xsl distribution.

Discussion