Your topics might contain multiple references to the same <term>.
These terms can further be explained in the glossary. In this case, you may want to only keep
the first occurrence of this term to be a link to the glossary and display the other terms as
text.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="3.0">
<xsl:template match="*[contains(@class, ' topic/term ')]" name="topic.term">
<!-- Save the current @href value -->
<xsl:variable name="current-href" select="@href"/>
<!-- Get the closest parent topic -->
<xsl:variable name="closest-parent"
select="ancestor::*[contains(@class, ' topic/topic ')][1]"/>
<!-- Get the first <term> having the same href -->
<xsl:variable name="first-term-with-same-href" select="($closest-parent//
*[contains(@class, ' topic/term ')][@href=$current-href])[1]"/>
<!-- Call the HTML5 default template -->
<xsl:variable name="result">
<xsl:next-match/>
</xsl:variable>
<!-- Call the copy template that will remove the links -->
<xsl:apply-templates select="$result" mode="remove-extra-links">
<xsl:with-param name="is-first-term-with-same-href"
select="generate-id(.) = generate-id($first-term-with-same-href)" tunnel="yes"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="node() | @*" mode="remove-extra-links">
<xsl:copy>
<xsl:apply-templates select="node() | @*" mode="#current"/>
</xsl:copy>
</xsl:template>
<xsl:template match="a" mode="remove-extra-links">
<xsl:param name="is-first-term-with-same-href" tunnel="yes"/>
<xsl:choose>
<!-- Process the first term as a link -->
<xsl:when test="$is-first-term-with-same-href">
<xsl:next-match/>
</xsl:when>
<xsl:otherwise>
<!-- Process the other terms as text -->
<xsl:copy-of select="child::*"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>com.oxygenxml.pdf.css.xsl.merged2html5 XSLT extension
point:<publishing-template>
...
<pdf>
...
<xslt>
<extension
id="com.oxygenxml.pdf.css.xsl.merged2html5"
file="xslt/merged2html5Extension.xsl"/>
</xslt>