Page 1 of 1

Resolve abbreviated-form and term in Webhelp related-links

Posted: Fri Apr 01, 2016 9:26 am
by urbanrobots
Hello.

I believe that this is a DITA-OT bug. We thought that the Webhelp 17.1 plugin solved this, but <abbreviated-form> and <term> used for glossary entries still do not correctly resolve in HTML output.

For example, this input file's title:

Code: Select all

<title>Keyword (<keyword keyref="g_etsi"/>) Term
(<term keyref="g_etsi"/>) Abbreviated-Form(<abbreviated-form keyref="g_etsi"/>)</title>
Renders link this the output related links section of other topics:

Code: Select all

Related concepts
Keyword () Term () Abbreviated-Form()
Thanks,
- Nick

Re: Resolve abbreviated-form and term in Webhelp related-links

Posted: Fri Apr 01, 2016 9:46 am
by Radu
Hi Nick,

Indeed the WebHelp plugin depends on the XHTML output plugin so it also inherits part of its problems.
Have you tried producing the output with both DITA OT 1.8 and 2.x? You can configure the default used DITA OT in the Preferences->DITA page.
If you can still reproduce the issue with DITA OT 2.x maybe you could put together a very small sample DITA project and either send it to us (support@oxygenxml.com) or add an issue directly on the DITA OT issues list:

https://github.com/dita-ot/dita-ot

Regards,
Radu

Re: Resolve abbreviated-form and term in Webhelp related-links

Posted: Fri Apr 01, 2016 12:12 pm
by xephon
There is a known processing error of abbreviated-form and term in the DITA-OT 2.x, see #2173. Maybe this is related to your issue.

Re: Resolve abbreviated-form and term in Webhelp related-links

Posted: Wed Apr 13, 2016 7:42 am
by urbanrobots
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

Re: Resolve abbreviated-form and term in Webhelp related-links

Posted: Wed Apr 13, 2016 12:12 pm
by Radu
Hi Nick,

I created a sample project on my side and indeed I reproduced the problem.
It seems that at some point one of my colleagues opened a DITA Open Toolkit issue about this:

https://github.com/dita-ot/dita-ot/issues/2067

I added a comment on the issue + link to this forum post.

Regards,
Radu