Controlling <topichead> behaviour in the HTML output

Post here questions and problems related to editing and publishing DITA content.
Bas10R
Posts: 34
Joined: Thu May 25, 2023 4:08 pm

Controlling <topichead> behaviour in the HTML output

Post 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.
cosmin_andrei
Posts: 138
Joined: Mon Jun 12, 2017 10:50 am

Re: Controlling <topichead> behaviour in the HTML output

Post by cosmin_andrei »

Hi Bas10R,
Indeed, this is the intended behavior and it is not configurable.
Regards,
Cosmin
--
Cosmin Andrei
oXygen XML Editor and Author Support
Bas10R
Posts: 34
Joined: Thu May 25, 2023 4:08 pm

Re: Controlling <topichead> behaviour in the HTML output

Post 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!
cosmin_andrei
Posts: 138
Joined: Mon Jun 12, 2017 10:50 am

Re: Controlling <topichead> behaviour in the HTML output

Post 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.
Regards,
Cosmin
--
Cosmin Andrei
oXygen XML Editor and Author Support
Bas10R
Posts: 34
Joined: Thu May 25, 2023 4:08 pm

Re: Controlling <topichead> behaviour in the HTML output

Post 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.
alin
Site Admin
Posts: 268
Joined: Thu Dec 24, 2009 11:21 am

Re: Controlling <topichead> behaviour in the HTML output

Post 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
Alin Balasa
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
Bas10R
Posts: 34
Joined: Thu May 25, 2023 4:08 pm

Re: Controlling <topichead> behaviour in the HTML output

Post by Bas10R »

Alin,

Thank you so much, this is super helpful!
Post Reply