WebHelp Responsive XSLT Extension Points

Post here questions and problems related to editing and publishing DITA content.
gszabo
Posts: 10
Joined: Wed Jan 25, 2023 1:15 am

WebHelp Responsive XSLT Extension Points

Post by gszabo »

Hello,
I'm not able to get the XSLT extension points working. I'm new to WebHelp Responsive, so I'm probably misunderstanding the online help.
My .opt file has the following:
<xslt>
<extension file="xsl/custom_MainPage.xsl" id="com.oxygenxml.webhelp.xsl.createMainPage"/>
</xslt>
The project is attached.
The 'default' createMainPage.xsl file only contains xsl:import elements, one of which is for createMainPageImpl.xsl. I'm assuming that any template in createMainPageImpl.xsl, or a stylesheet imported by createMainPageImpl.xsl , can be overridden by the com.oxygenxml.webhelp.xsl.createMainPage extension point.

To troubleshoot, I overrode the createMainPageImpl.xsl template that, according to the comments, creates index.html, as follows. I expected that changing the template to the following would cause index.html to not be rendered:

<xsl:template match="/"/>

However, index.html was rendered.
What am I doing wrong?
DITA Map WebHelp Responsive - Curtis.zip
(23.12 KiB) Downloaded 153 times
chrispitude
Posts: 907
Joined: Thu May 02, 2019 2:32 pm

Re: WebHelp Responsive XSLT Extension Points

Post by chrispitude »

Hi gszabo,

Can you add mode="copy_template" to your templates to see if they work as expected?

Code: Select all

<xsl:template match="..." mode="copy_template">
  <!-- ... -->
</xsl:template>
gszabo
Posts: 10
Joined: Wed Jan 25, 2023 1:15 am

Re: WebHelp Responsive XSLT Extension Points

Post by gszabo »

chrispitude, thank you for the response.
I added the mode as below. However, the index.html was still generated.
<xsl:template match="/" mode="copy_template"/>
chrispitude
Posts: 907
Joined: Thu May 02, 2019 2:32 pm

Re: WebHelp Responsive XSLT Extension Points

Post by chrispitude »

You might need to match "/*" (the root element) instead of "/" (the document root).
gszabo
Posts: 10
Joined: Wed Jan 25, 2023 1:15 am

Re: WebHelp Responsive XSLT Extension Points

Post by gszabo »

Thank you. Unfortunately that did not work. So, to further troubleshoot, I copied the following template from createMainPageImpl.xsl (which is imported by createMainPage.xsl) to my extension point stylesheet (custom_MainPage.xsl). I added only the <xsl:message> below, which i expected to terminate processing and output a message to the Oxygen console. However, processing did not terminate and the message was not in the console, as though the extension point is being ignored:

Code: Select all

<xsl:template match="/">
    <xsl:variable name="template_base_uri" select="base-uri()"/>
    
    <xsl:variable name="mainPageTemplate">
      <xsl:apply-templates select="." mode="fixup_XHTML_NS"/>
    </xsl:variable>
    <xsl:message terminate="yes">testing 123</xsl:message>
    
    <xsl:apply-templates select="$mainPageTemplate" mode="copy_template">
      <!-- EXM-36737 - Context node used for messages localization -->
      <xsl:with-param name="i18n_context" select="$i18n_context/*" tunnel="yes" as="element()"/>
      <xsl:with-param name="template_base_uri" select="$template_base_uri" tunnel="yes"/>
    </xsl:apply-templates>
  </xsl:template>
I watched Oxygen's Techniques for Customizing the WebHelp Responsive Output webinar, and I think I'm doing what the presenter showed, but I must be missing some detail.
gszabo
Posts: 10
Joined: Wed Jan 25, 2023 1:15 am

Re: WebHelp Responsive XSLT Extension Points

Post by gszabo »

I fiddled around a bit, and got this to work, though unfortunately I didn't track changes and thus am not positive what worked. It might be because I rearranged the project folder structure so that there's a templates directory in the directory that contains the project file. The templates directory contains the directory for the publishing project.

I attached a screen shot for reference, in case this helps anyone who encounters this issue in the future.
project-publishing-template.png
project-publishing-template.png (14.25 KiB) Viewed 751 times
Last edited by gszabo on Wed Jan 25, 2023 11:08 pm, edited 1 time in total.
chrispitude
Posts: 907
Joined: Thu May 02, 2019 2:32 pm

Re: WebHelp Responsive XSLT Extension Points

Post by chrispitude »

Try the following testcase:

webhelp_example_curtis.zip
(30.03 KiB) Downloaded 148 times

It adds text to the top of each different page type (home page, topic pages, search page, index terms page). To run it, just open the DITA-OT project file named project.xml, then publish that deliverable. I recommend Oxygen v25+ because it has a nice play button in the editing window when you open a DITA-OT project file.

Note that our extension points point to a set of xsl/all-*.xsl files that are include-only files of other files. This setup allows different mixes of other stylesheets to be included for each page type, depending on what is relevant to that page type and what is not.

You can look at the template page files at

Code: Select all

${OXYGEN_HOME}/frameworks/dita/DITA-OT3.x/plugins/com.oxygenxml.webhelp.responsive/oxygen-webhelp/page-templates/wt_index.html
${OXYGEN_HOME}/frameworks/dita/DITA-OT3.x/plugins/com.oxygenxml.webhelp.responsive/oxygen-webhelp/page-templates/wt_search.html
${OXYGEN_HOME}/frameworks/dita/DITA-OT3.x/plugins/com.oxygenxml.webhelp.responsive/oxygen-webhelp/page-templates/wt_terms.html
${OXYGEN_HOME}/frameworks/dita/DITA-OT3.x/plugins/com.oxygenxml.webhelp.responsive/oxygen-webhelp/page-templates/wt_topic.html
to see what @class-qualified pieces can be customized, or you can use your favorite browser to inspect the structures in the published HTML output.

You can find some XSLT customization ideas in the templates/ directory here:

https://github.com/oxygenxml/oxygen-pub ... te-samples

If you have any questions, feel free to ask!
gszabo
Posts: 10
Joined: Wed Jan 25, 2023 1:15 am

Re: WebHelp Responsive XSLT Extension Points

Post by gszabo »

chrispitude, thank you very much for the example! I just looked it over, and the example makes it crystal clear.
Post Reply