Page 1 of 1

Need a refactoring to make navtitle match the topic title - Version 17.1

Posted: Mon Mar 18, 2019 8:46 am
by Sathya
Hi team,
Would like to know if we have a method to update navtitle with the topic title.

Re: Need a refactoring to make navtitle match the topic title - Version 17.1

Posted: Mon Mar 18, 2019 11:46 am
by Radu
Hi Sathya,

Newer versions of Oxygen (for example Oxygen 18.1 and newer) have in the Preferences->"DITA" page a special section where you can choose to automatically set the navtitle to the topic title when using our actions to insert topic references.

With Oxygen 17.1 you could create a custom XML Refactoring action based on XSLT which would be applied on the DITA Map, for each topicref it would extract the title from the reference and set the @navtitle attribute to that value:

https://www.oxygenxml.com/doc/versions/ ... tions.html

A refactoring XSLT stylesheet for this would look something like:

Code: Select all

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>

<!-- Get topic title and use it to set navtitle on topicref -->
<xsl:template match="topicref[@href]">
<xsl:copy>
<xsl:apply-templates select="@* except @navtitle"/>
<xsl:attribute name="navtitle"><xsl:value-of select="document(@href)/*/title"/></xsl:attribute>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Regards,
Radu

Re: Need a refactoring to make navtitle match the topic title - Version 17.1

Posted: Thu Mar 28, 2019 8:44 am
by Sathya
Thanks so much Radu. I created an operation description file. The refactoring operation works fine.