Page 1 of 1
Controlling <topichead> behaviour in the HTML output
Posted: Thu May 25, 2023 4:16 pm
by Bas10R
In a HTML output, when you click on a <topichead> entry in the side TOC, the TOC node with the <topichead> expands and the content/output for the first nested child topic is shown.
This is a welcome and expected behaviour, I would just love to know which exact setting/configuration controls that.
Re: Controlling <topichead> behaviour in the HTML output
Posted: Mon May 29, 2023 9:37 am
by cosmin_andrei
Hi Bas10R,
Indeed, this is the intended behavior and it is not configurable.
Re: Controlling <topichead> behaviour in the HTML output
Posted: Mon May 29, 2023 4:48 pm
by Bas10R
Thank you, Andrei!
If it's not configurable, could you please let me know what controls this behaviour (DITA OT, Oxygen's transformation scenario, or something different)?
I'm looking to implement a similar user experience in a non-DITA format, so I'm grasping for tips here!
Re: Controlling <topichead> behaviour in the HTML output
Posted: Tue May 30, 2023 5:44 pm
by cosmin_andrei
Hi,
This is implemented in the internal XSLT stylesheets of the WebHelp Responsive plugin where a link to the first descendant is added.
Re: Controlling <topichead> behaviour in the HTML output
Posted: Thu Jun 01, 2023 11:43 am
by Bas10R
Andrei,
Would you be able to point me to the exact file and lines which handle that?
If it helps, I'm on Oxygen XML Editor version 25.
Re: Controlling <topichead> behaviour in the HTML output
Posted: Fri Jun 09, 2023 10:09 am
by alin
Hello,
In the Publication TOC, the value for the
href attribute of the nodes corresponding to <topichead> elements is computed in the
computeHrefAttr XSL template (line 415) in
{DITA_OT_DIR}\plugins\com.oxygenxml.webhelp.responsive\xsl\navLinks\sidetoc.xsl:
Code: Select all
<xsl:template name="computeHrefAttr">
<xsl:choose>
<xsl:when test="@href and @href != $VOID_HREF">
<xsl:value-of select="@href"/>
</xsl:when>
<xsl:otherwise>
<!-- EXM-38925 Select the href of the first descendant topic ref -->
<xsl:value-of select="descendant::toc:topic[@href and @href != $VOID_HREF][1]/@href"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
The DITA-OT bundled in Oxygen XML Editor is located in:
{OXYGEN_INSTALL_DIR}\frameworks\dita\DITA-OT3.x\
Note that the above XSL file is applied over the
toc.xml file generated in the temporary directory of the WebHelp Responsive transformation.
We use the
$VOID_HREF value to mark the nodes that do not have a value set for the
@href attribute in the DITA map. The assignment of the
$VOID_HREF value is performed in the
{DITA_OT_DIR}\plugins\com.oxygenxml.webhelp.responsive\xsl\navLinks\tocDitaImpl.xsl at line 172:
Code: Select all
<xsl:attribute name="href">
<xsl:choose>
<xsl:when
test="@copy-to and not(ancestor-or-self::*[contains(@chunk, 'to-content')])">
<xsl:call-template name="replace-extension">
<xsl:with-param name="filename" select="@copy-to"/>
<xsl:with-param name="extension" select="$OUT_EXT"/>
<xsl:with-param name="forceReplace"
select="not(@format) or @format = 'dita'"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="@href">
<xsl:call-template name="replace-extension">
<xsl:with-param name="filename" select="@href"/>
<xsl:with-param name="extension" select="$OUT_EXT"/>
<xsl:with-param name="forceReplace"
select="not(@format) or @format = 'dita'"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$VOID_HREF"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
Note, that the above stylesheet is applied over the DITA map file (
.ditamap) from the temporary directory of the WebHelp transformation.
Regards,
Alin
Re: Controlling <topichead> behaviour in the HTML output
Posted: Mon Jun 12, 2023 4:24 pm
by Bas10R
Alin,
Thank you so much, this is super helpful!