Hi.
We added a new "Preprocess" plugin to our DITA-OT process and this has (so far) fixed the problem of <abbreviated-form> and <term> elements not appearing in related-links.
- Override to add abbreviated-form processing.
- Set the linktext from a topic, unless specified within the topicref.
Code: Select all
<xsl:template match="*" mode="mappull:getmetadata_linktext">
<xsl:param name="type"/>
<xsl:param name="scope">#none#</xsl:param>
<xsl:param name="format">#none#</xsl:param>
<xsl:param name="file"/>
<xsl:param name="topicpos"/>
<xsl:param name="topicid"/>
<xsl:param name="classval"/>
<xsl:variable name="doc" select="document($file,/)"/>
<xsl:choose>
<!-- If linktext is already specified, use that -->
<xsl:when test="*[contains(@class, ' map/topicmeta ')]/*[contains(@class, ' map/linktext ')]">
<xsl:apply-templates select="." mode="mappull:add-usertext-PI"/>
<xsl:apply-templates select="*[contains(@class, ' map/topicmeta ')]/*[contains(@class, ' map/linktext ')]"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="linktext">
<xsl:choose>
<!--if it's external and not dita, use the href as fallback-->
<xsl:when test="($scope='external' and not($format='dita' or $format='DITA')) or $type='external'">
<xsl:apply-templates select="." mode="mappull:get-linktext_external-and-non-dita"/>
</xsl:when>
<!--if it's external and dita, leave empty as fallback, so that the final output process can handle file extension-->
<xsl:when test="$scope='external'">
<xsl:apply-templates select="." mode="mappull:get-linktext_external-dita"/>
</xsl:when>
<xsl:when test="$scope='peer'">
<xsl:apply-templates select="." mode="mappull:get-linktext_peer-dita"/>
</xsl:when>
<!-- skip resource-only image files -->
<xsl:when test="($format='jpg' or $format='jpeg' or $format='tiff' or $format='gif'
or $format='eps' or $format='svg' or $format='tif') and @processing-role='resource-only'"/>
<xsl:when test="not($format='#none#' or $format='dita' or $format='DITA')">
<xsl:apply-templates select="." mode="mappull:get-linktext-for-non-dita"/>
</xsl:when>
<xsl:when test="@href=''">#none#</xsl:when>
<!--xsl:when test="not(contains($file,$DITAEXT))">
<xsl:text>#none#</xsl:text>
<xsl:apply-templates select="." mode="ditamsg:unknown-extension"/>
</xsl:when-->
<!--grabbing text from a particular topic in another file-->
<xsl:when test="$topicpos='otherfile'">
<xsl:variable name="target" select="$doc//*[@id=$topicid]"/>
<xsl:choose>
<xsl:when test="$target[contains(@class, $classval)]/*[contains(@class, ' topic/title ')]">
<xsl:variable name="grabbed-value">
<xsl:apply-templates select="($target[contains(@class, $classval)])[1]/*[contains(@class, ' topic/title ')]" mode="text-only"/>
</xsl:variable>
<xsl:value-of select="normalize-space($grabbed-value)"/>
</xsl:when>
<xsl:when test="$target[contains(@class, ' topic/topic ')]/*[contains(@class, ' topic/title ')]">
<xsl:variable name="grabbed-value">
<xsl:apply-templates select="($target[contains(@class, ' topic/topic ')])[1]/*[contains(@class, ' topic/title ')]" mode="text-only"/>
</xsl:variable>
<xsl:value-of select="normalize-space($grabbed-value)"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="linktext-fallback"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!--grabbing text from the first topic in another file-->
<xsl:when test="$topicpos='firstinfile'">
<xsl:choose>
<xsl:when test="$doc//*[contains(@class, ' topic/topic ')][1]/*[contains(@class, ' topic/title ')]">
<xsl:variable name="abbreviated">
<xsl:apply-templates select="($doc//*[contains(@class, ' topic/topic ')])[1]/*[contains(@class, ' topic/title ')]" mode="handle-abbreviated"/>
</xsl:variable>
<!-- <xsl:apply-templates select="($doc//*[contains(@class, ' topic/topic ')])[1]/*[contains(@class, ' topic/title ')]" mode="tree2stream"/>-->
<xsl:variable name="grabbed-value">
<xsl:apply-templates select="$abbreviated" mode="text-only"/>
<!-- <xsl:apply-templates select="($doc//*[contains(@class, ' topic/topic ')])[1]/*[contains(@class, ' topic/title ')]" mode="text-only"/>-->
</xsl:variable>
<xsl:value-of select="normalize-space($grabbed-value)"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="linktext-fallback"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>#none#<!--never happens - both possible values for topicpos are tested--></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="not($linktext='#none#')">
<xsl:apply-templates select="." mode="mappull:add-gentext-PI"/>
<linktext class="- map/linktext ">
<xsl:copy-of select="$linktext"/>
</linktext>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
and this:
- More or less an identity transform, but replaces abbreviated-form with text.
- The next step after this is to emit text only, so attributes don't matter.
Code: Select all
<xsl:template match="*|text()|processing-instruction()" mode="handle-abbreviated">
<xsl:choose>
<xsl:when test="name() = 'abbreviated-form'">
<!-- Tomorrow: Open the file, find the abbreviated form insert it. DONE! -->
<!-- Oh and move the overrides into a preprocessor file. -->
<xsl:variable name="gloss-entry" select="document(@href)/*"/>
<xsl:choose>
<xsl:when test="$gloss-entry/glossBody/glossAlt/glossAcronym">
<xsl:value-of select="$gloss-entry/glossBody/glossAlt/glossAcronym"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$gloss-entry/glossterm"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!-- [2016Apr2] When statement copied from above for term handling -->
<xsl:when test="name() = 'term'">
<xsl:variable name="gloss-entry" select="document(@href)/*"/>
<xsl:value-of select="$gloss-entry/glossterm"/>
</xsl:when>
<!-- [2016Apr2] When statement copied from above for keyword handling -->
<!--<xsl:when test="name() = 'keyword'">
<xsl:variable name="gloss-entry" select="document(@href)/*"/>
<xsl:value-of select="$gloss-entry/glossterm"/>
</xsl:when>-->
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates mode="handle-abbreviated"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
I hope that you can add similar default logic to the Oxygen Webhelp.
Take care,
- Nick