XSL override dita2html5.xsl

Having trouble installing Oxygen XML WebHelp? Got a bug to report? Post it all here.
TopSolid
Posts: 13
Joined: Tue Jun 27, 2023 11:00 am

XSL override dita2html5.xsl

Post by TopSolid »

Hi!
AFAIK, when transforming from DITA to WebHelp, the 2 first steps are:
  • dita2html5 = generic engine DITA-OT
  • dita2webhelp = UI Oxygen
WebHelp proposes official endpoints to override xsl.
https://www.oxygenxml.com/doc/versions/ ... uyr_b1y_bx
I have in my dita source

Code: Select all

<area>
   <xref outputclass="popup-link"/>
</area>
I want final result in HTML5

Code: Select all

<area href="..." shape="rect" class="popup-link">
But the first step dita2html5 that generates <area href="..." shape="rect"> looses my class and next step dita2webhelp is too late.

So, is there a way to override dita2html5 endpoint inside an opt with WebHelp engine? Example:

Code: Select all

 <xslt>
            <extension file="resources/xsl/imagemap-override.xsl" id="com.oxygenxml.webhelp.xsl.dita2webhelp"/>
            <extension file="resources/xsl/imagemap-override.xsl" id="com.oxygenxml.webhelp.xsl.dita2html5"/>
            <extension file="resources/xsl/imagemap-override.xsl" id="org.dita.html5.xsl.dita2html5"/>
</xslt>
Thanks for help
julien_lacour
Posts: 818
Joined: Wed Oct 16, 2019 3:47 pm

Re: XSL override dita2html5.xsl

Post by julien_lacour »

Hello,

Not exactly. As you correctly identified, the main processing step is dita2webhelp, and can be extended using the com.oxygenxml.webhelp.xsl.dita2webhelp extension point.

WebHelp Responsive pipeline leverages parts of the standard DITA-OT HTML5 plugin, and those processing stages can also be customized or overridden through the same extension point, so you can perfectly declare:

Code: Select all

<xslt>
  <extension file="resources/xsl/imagemap-override.xsl" id="com.oxygenxml.webhelp.xsl.dita2webhelp"/>
</xslt>
And add the following template in imagemap-override.xsl:

Code: Select all

<!-- Copied from org.dita.html5/xsl/ut-d.xsl -->
<xsl:template match="*[contains(@class, ' topic/xref ')]" mode="imagemap-xref">
  <xsl:attribute name="href"><xsl:call-template name="href"/></xsl:attribute>
  <xsl:if test="@outputclass">
    <xsl:attribute name="class" select="@outputclass"/>      
  </xsl:if>
  <xsl:if test="@scope='external' or @type='external' or ((@format='PDF' or @format='pdf') and not(@scope='local'))">
    <xsl:apply-templates select="." mode="external-link"/>
  </xsl:if>
</xsl:template>
And you will get <area class="popup-link" href="..." shape="rect"> in the output.

Regards,
Julien
Post Reply