Xref text resolution on elements without title

Post here questions and problems related to editing and publishing DITA content.
NicoAMP
Posts: 97
Joined: Tue Mar 06, 2018 2:07 pm
Contact:

Xref text resolution on elements without title

Post by NicoAMP »

Hi,

In DITA if you use an xref without text, that's the title of linked element that it gets in output (PDF,WebHelp).

For example with following code I will have "Go to How To Make." :

Code: Select all

Go to <xref href="a001" format="dita"/>.
...
<task id="a001">
<title>How To Make</title>
...
But here I will have "Go to."

Code: Select all


Go to <xref href="a001" format="dita"/>.
...
<stepsection id="ONE-ONE">My stepsection</stepsection>
...
I would like to manage this last case (linked element without title).

For PDF, in my plugin, I just have to insert this template (it works) :

Code: Select all

<xsl:template match="*[contains(@class, ' task/stepsection ')]" mode="retrieveReferenceTitle">
<xsl:value-of select="."/>
</xsl:template>
But for HTML I don't know where I have to do modification.
I try to modify this template, but inside it it seems that xref text are already resolved:

Code: Select all

<xsl:template match="*[contains(@class, ' topic/xref ')]" name="topic.xref">...
Any idea where xref text for WebHelp (HTML5) are resolved?

Thanks.
Nicolas Delobel
AmeXio
nicolas.delobel at group.amexio.net
Radu
Posts: 9057
Joined: Fri Jul 09, 2004 5:18 pm

Re: Xref text resolution on elements without title

Post by Radu »

Hi Nico,

I think the link texts are resolved for the HTML output in the same XSLT stylesheet in which I advised you here to make changes:

post51896.html

Maybe you can add some xsl:messages in this template:

Code: Select all

<xsl:template match="*[dita-ot:is-link(.)]">
There is an XSLT extension point called "dita.xsl.topicpull" which may allow you to contribute a DITA OT plugin with a custom XSLT stylesheet to override that:

https://www.dita-ot.org/dev/extension-p ... mport.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
NicoAMP
Posts: 97
Joined: Tue Mar 06, 2018 2:07 pm
Contact:

Re: Xref text resolution on elements without title

Post by NicoAMP »

I add a test on text() content on the following template (in topicpullImpl.xsl) and it works.

Code: Select all

<xsl:template match="*" mode="topicpull:resolvelinktext" priority="-1">
<xsl:variable name="target-text">
<xsl:choose>
<xsl:when test="*[contains(@class,' topic/title ')][1]">
<xsl:apply-templates
select="*[contains(@class,' topic/title ')][1]" mode="text-only"/>
</xsl:when>
<!--If there isn't a title ,then process with spectitle -->
<xsl:when test="@spectitle">
<xsl:value-of select="@spectitle"/>
</xsl:when>
<!--If there is text ,then process text -->
<xsl:when test="text()">
<xsl:value-of select="text()"/>
</xsl:when>
<!-- No title, no text or spectitle; check to see if the element provides generated text -->
<xsl:otherwise>
<xsl:apply-templates select="." mode="topicpull:get_generated_text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="exists($target-text)">
<xsl:value-of select="normalize-space($target-text)"/>
</xsl:if>
</xsl:template>
Thanks Radu for your help.
Nicolas Delobel
AmeXio
nicolas.delobel at group.amexio.net
Post Reply