dita-ot

In dita-ot is it possible to integrate into a feature extension for a specific transtype only?


Specifically, I have a custom dita-ot xhtml plugin which uses the <feature extension="dita.xsl.xhtml" file="xsl/header.xsl"/> to integrate into the xhtml pipeline. But this extension is used by the default xhtml output as well. I don't want this. Is there a way to run my extensions only for my own plugin?

A small example (brandheader example from the dita-ot documentation) which demonstrates the described behavior:

plugin.xml:

<?xml version="1.0" encoding="UTF-8"?>
<plugin id="com.example.brandheader">
    <feature extension="ant.import" file="build.xml" />
    <feature extension="dita.xsl.xhtml" file="xsl/header.xsl"/>
    <transtype name="xhtml-extension" />
</plugin>

build.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project name="com.example.xhtml.extension" basedir=".">
    <target name="dita2xhtml-extension" depends="dita2xhtml"/>
</project>

header.xsl:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template name="gen-user-header">
        <div>
            <img src="https://www.dita-ot.org/images/dita-ot-logo.svg" alt="Example Company Banner"/>
        </div>
    </xsl:template>
</xsl:stylesheet>

The customized header appears for the xhtml transtype as well as for the xhtml-extension transtype.

I searched on stackoverflow for a similar question and I read the dita-ot developer documentation. But I couldn't find an option to enable the extension only for my plugin.

I am happy about any input.


Solution

  • Another option is to override the main XSLT used for processing in your custom XHTML plugin's build file:

    <target name="dita2xhtml-custom"
          depends="dita2xhtml-custom.init,
                   dita2xhtml"/>
    <target name="dita2xhtml-custom.init">
      <property name="args.xsl"
            location="${dita.plugin.com.example.xhtml-custom.dir}/custom-main.xsl"/>
    </target>
    

    and your custom-main.xsl would import the xhtml XSLT stylesheet like:

    <xsl:import href="plugin:org.dita.xhtml:xsl/dita2xhtml.xsl"/>
    

    and add your own templates to the custom-main.xsl to override templates in the dita2xhtml.xsl.