Page 1 of 1

Is there an extension point for topicComponentsExpander.xsl or way to override on of its templates

Posted: Fri Jun 14, 2019 8:40 pm
by axhxu
Hi,
Some of our source content is generating empty on this page areas due to the fact we have section elements without titles.

I want to make a chnage to <xsl:template match="whc:webhelp_topic_toc" mode="copy_template"> to detect if the list of items is empty and if so dont output the section.

Current line:
<xsl:if test="count($generate_topic_toc/ul/descendant::li) > 1">

Modified line:
<xsl:if test="count($generate_topic_toc/ul/descendant::li) > 1 and (string($generate_topic_toc) !='')">

I can do this in the original file but would rather not make customizations there.

Can I override this file or the template using an extension point?

Thanks
Arron Varga

Re: Is there an extension point for topicComponentsExpander.xsl or way to override on of its templates

Posted: Fri Jun 21, 2019 8:00 am
by radu_pisoi
Hi,

Yes, you can use the com.oxygenxml.webhelp.xsl.dita2webhelp XSLT-Import Extension Point to override the XSLT stylesheet (dita2webhelp.xsl) that produces an HTML file for each DITA topic.

See more information in our user manual:
* WebHelp Responsive XSLT-Import and XSLT-Parameter Extension Points
* XSLT Extensions for WebHelp Responsive Transformations

Re: Is there an extension point for topicComponentsExpander.xsl or way to override on of its templates

Posted: Tue Jun 25, 2019 3:26 pm
by axhxu
Just to confirm you are saying I can use the com.oxygenxml.webhelp.xsl.dita2webhelp extension point to override a template in the topicComponentsExpander.xsl file?

So I would add to my opt file:

Code: Select all

<xslt>
          
            <extension id="com.oxygenxml.webhelp.xsl.dita2webhelp" file="xsl/mainFiles/customDita2webhelp.xsl"/>

...
</xslt>
then I would add to my customDita2webhelp.xsl:

Code: Select all

<!-- Expand 'webhelp_topic_toc' place holder. -->
    <xsl:template match="whc:webhelp_topic_toc" mode="copy_template">
        <xsl:param name="ditaot_topicContent" tunnel="yes"/>
        
        <xsl:if test="oxy:getParameter('webhelp.show.topic.toc') = 'yes'">
            <xsl:choose>
                <xsl:when test="exists($ditaot_topicContent)">
                    <xsl:variable name="generate_topic_toc">
                        <!-- Copy topic content without the related links section. -->
                        <!-- Try to copy the 'main' element. Generally, it is generated by DITA-OT 2.x  -->
                        <xsl:variable name="topicContent2_0" select="$ditaot_topicContent//body//main"/>
                        
                        <xsl:if test="exists($topicContent2_0)">
                            <xsl:call-template name="generateTopicTOC">
                                <xsl:with-param name="topicContent2_0" select="$topicContent2_0"/>
                            </xsl:call-template>
                        </xsl:if>
                    </xsl:variable>
                    <!-- IPTS-1081 -->
                    <xsl:if test="count($generate_topic_toc/ul/descendant::li) > 1 and (string($generate_topic_toc) !='')">
                        <xsl:variable name="topic_toc_content">
                            <div>
                                <xsl:call-template name="generateComponentClassAttribute">
                                    <xsl:with-param name="compClass">wh_topic_toc</xsl:with-param>
                                </xsl:call-template>
                                <!-- Copy attributes -->
                                <xsl:copy-of select="@* except @class"/>
                                
                                <div class="wh_topic_label"><xsl:call-template name="getWebhelpString"><xsl:with-param name="stringName" select="'on_this_page'"/></xsl:call-template></div>
                                <xsl:copy-of select="$generate_topic_toc"/>
                              
                            </div>    
                        </xsl:variable>
                        <xsl:call-template name="outputComponentContent">
                            <xsl:with-param name="compContent" select="$topic_toc_content"/>
                            <xsl:with-param name="compName" select="local-name()"/>
                        </xsl:call-template>
                    </xsl:if>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:message>Cannot expand the 'webhelp_topic_content' component.</xsl:message>                
                </xsl:otherwise>
            </xsl:choose>
        </xsl:if>
    </xsl:template>

Re: Is there an extension point for topicComponentsExpander.xsl or way to override on of its templates

Posted: Mon Jul 01, 2019 12:11 pm
by radu_pisoi
Hi,

Yes, it seems correct. Have you encountered any problem?

Re: Is there an extension point for topicComponentsExpander.xsl or way to override on of its templates

Posted: Mon Jul 08, 2019 3:25 pm
by axhxu
Hi,
So I tried moving the template <xsl:template match="whc:webhelp_topic_toc" mode="copy_template"> to my customDita2webhelp.xsl file and now we do not get the on this page section at all when we should.

If I make my slight change to the template in the topicComponentExpander.xsl file then everything works as expected the on page area displays when there are section titles and does not display if there are section titles but they are empty.

I would prefer to not have to make chnages to your source files and figure out how to extend it so my code remains separate from the out of the box code.

Re: Is there an extension point for topicComponentsExpander.xsl or way to override on of its templates

Posted: Tue Jul 09, 2019 3:38 pm
by radu_pisoi
Hi,

I cannot find any reason why your extension point is not working, everything seems ok.

Could you send us a sample publishing template together with your XSLT extension on support@oxygenxml.com?