Skip to content

Commit

Permalink
Add glossseealso template rule and support @linkend
Browse files Browse the repository at this point in the history
I run into the problem of useing <glossseealso linkend="..."/>
instead of <glossseealso otherterm="..."/>.

As we are so get used to linkend in xref, I think it is
natural to support this in <glossseealso> too.

Although the commit contains several lines, the only change
in comparison to the original template rule is this:

  <xsl:variable name="otherterm" select="(@otherterm|@linkend)[1]"/>

The rest is like the original template rule.
  • Loading branch information
tomschr committed Nov 24, 2022
1 parent e7af36d commit b7b3c7c
Showing 1 changed file with 52 additions and 1 deletion.
53 changes: 52 additions & 1 deletion suse2013/xhtml/glossary.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
xmlns="http://www.w3.org/1999/xhtml"
xmlns:t="http://nwalsh.com/docbook/xsl/template/1.0"
xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0"
exclude-result-prefixes="exsl l t">
xmlns:xlink="http://www.w3.org/1999/xlink"
exclude-result-prefixes="exsl l t xlink">

<xsl:template match="glossary">
<xsl:variable name="language">
Expand Down Expand Up @@ -143,4 +144,54 @@
<xsl:apply-templates select="indexterm|revhistory|glosssee|glossdef"/>
</xsl:template>


<xsl:template match="glossseealso">
<xsl:variable name="otherterm" select="(@otherterm|@linkend)[1]"/><!-- SUSE -->
<xsl:variable name="targets" select="key('id', $otherterm)"/>
<xsl:variable name="target" select="$targets[1]"/>
<xsl:variable name="xlink" select="@xlink:href"/>

<xsl:choose>
<xsl:when test="$target">
<a>
<xsl:apply-templates select="." mode="common.html.attributes"/>
<xsl:call-template name="id.attribute"/>
<xsl:attribute name="href">
<xsl:call-template name="href.target">
<xsl:with-param name="object" select="$target"/>
</xsl:call-template>
</xsl:attribute>
<xsl:apply-templates select="$target" mode="xref-to"/>
</a>
</xsl:when>
<xsl:when test="$xlink">
<xsl:call-template name="simple.xlink">
<xsl:with-param name="content">
<xsl:apply-templates/>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$otherterm != '' and not($target)">
<xsl:message>
<xsl:text>Warning: glossseealso @otherterm reference not found: </xsl:text>
<xsl:value-of select="$otherterm"/>
</xsl:message>
<xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>

<xsl:choose>
<xsl:when test="position() = last()"/>
<xsl:otherwise>
<xsl:call-template name="gentext.template">
<xsl:with-param name="context" select="'glossary'"/>
<xsl:with-param name="name" select="'seealso-separator'"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

</xsl:stylesheet>

0 comments on commit b7b3c7c

Please sign in to comment.