apply-imports / next-match missing in org.dita-community.dita3html

jcb_mgc
Posts: 2
Joined: Thu Sep 10, 2020 7:03 pm

apply-imports / next-match missing in org.dita-community.dita3html

Post by jcb_mgc » Thu Sep 10, 2020 7:15 pm

Hi,
We have a custom DITA-OT plugin that overrides several templates in the base xhtml plugin. One of these is gen-user-scripts.

In testing, our plugin in the oXygen environment, I found that our gen-user-scripts override is not being called at all. The problem seems to be that the gen-user-scripts override in the org.dita-community-dita3html plugin is not chaining template calls with xsl:apply-templates or xsl:next-match.

This is the template from the org.dita-commity-dita3html plugin. I inserted a comment where the call should go:

Code: Select all

<xsl:template mode="gen-user-scripts" match="*[contains(@class, ' topic/topic ')]">
    <xsl:choose>
      <xsl:when test="$mathJaxUseCDNLinkBoolean">
        <!-- Reference to MathMax script as served over the public Web: -->
        <script type="text/javascript"
          src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?{$mathJaxConfigParam}">
        </script>    
      </xsl:when>
      <xsl:when test="$mathJaxUseLocalLinkBoolean">
        <xsl:if test="$mathJaxLocalJavascriptUri = ''">
          <xsl:message> - [WARN] Runtime parameter $mathJaxUseLocalLinkBoolean is true but $mathJaxLocalJavascriptUri is not set. </xsl:message>
        </xsl:if>
        <script type="text/javascript"
          src="{$mathJaxLocalJavascriptUri}?{$mathJaxConfigParam}">
        </script>    
      </xsl:when>
      <xsl:otherwise>
        <!-- Do not use MathJax Javascript library -->
      </xsl:otherwise>
    </xsl:choose>
    <!-- TEMPLATE CHAINING...CALL xsl:apply-imports SHOULD BE HERE -->
  </xsl:template>
I found that if I add a call to xsl:apply-imports at the point where the "TEMPLATE CHAINING" comment is, then our own gen-user-scripts template is called.

I can fix this locally for now, but I wonder if a change request should be filed against the org.dita-community.dita2html plugin. I did not investigate whether there are other places where apply-imports should be called.

Thanks,
JCB

Radu
Posts: 7154
Joined: Fri Jul 09, 2004 5:18 pm

Re: apply-imports / next-match missing in org.dita-community.dita3html

Post by Radu » Fri Sep 11, 2020 7:02 am

Hi,

Thanks for the report, I added an issue on the plugin's project:

https://github.com/dita-community/dita1 ... t/issues/8

and I also added an internal issue to look into fixing this on our side. These plugins are quite old but they still contain some functionality related to mathml and svg handling which is not in the DITA OT code.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

jcb_mgc
Posts: 2
Joined: Thu Sep 10, 2020 7:03 pm

Re: apply-imports / next-match missing in org.dita-community.dita3html

Post by jcb_mgc » Fri Sep 11, 2020 6:11 pm

Hi Radu thanks for looking into that issue.

This is actually something we've been wondering about for a long time. So far, we have been using DITA-OT with our own plugin, and we have been the only fish in the pond. Now we are migrating to oXygen and that's not the case anymore.

We don't have calls to apply-imports or next-match in our own plugin - we haven't had to worry about it. As I add them, I know it's quite likely I will find cases where calling the next plugin will produce incorrect content for us. It's also possible that a plugin that executes before us could cause problems.

Do you have a general strategy for handling this? It seems wrong to not call the next plugin. It seems like it breaks the whole system. Our plugin will never be released into the wild, but we still have to coexist. It could become quite a job to have to address this with each oXygen and/or DITA-OT update.

Would it be considered as a design flaw in our DITA customizations if we find such cases -- where we have to interrupt and stop the stream of processing in order to produce the desired content with DITA-OT?

Thanks again!
John

Radu
Posts: 7154
Joined: Fri Jul 09, 2004 5:18 pm

Re: apply-imports / next-match missing in org.dita-community.dita3html

Post by Radu » Mon Sep 14, 2020 8:12 am

Hi John,

Indeed DITA OT plugins which override the same extension points and add XSLTs may interfere with each other.
Well one option would be to continue to use your custom DITA OT distribution with Oxygen, in the Oxygen Preferences->DITA page you can add a reference to your custom DITA OT folder.
Another option might be to create your own transformation type, copy the entire XHTML plugin and make your own version of it. But you would need to maintain your plugin and maybe update it with the latest changes when new DITA OT versions come up.
Another option would be that when you add your plugins to Oxygen's bundled DITA-OT/plugins folder to remove the dita-community ones (if you are not using embedded MathML and SVG content), then run the DITA OT integrator.
As on Windows Oxygen is usually installed in the Program Files folder, usually you need administrator rights to add and delete plugins to the DITA-OT/plugins folder, then run the DITA OT integrator. So we usually recommend copying the entire DITA-OT folder from Oxygen to an outside location and then go to the Preferences->DITA page and refer to that custom DITA OT installation.
Maybe you could also perform some automated tests, on an integration server which would handle the publishing using a custom company specific DITA OT version after publishing you could run some scripts through the produced HTML content, see if it retains your XSLT customizations. In this way when you update to newer DITA OT versions your tests would start failing on the integration server if your XSLT templates no longer matches anything.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply