Custom XHTML plugin creation index.html not effecting

蹲街弑〆低调 提交于 2019-12-02 09:30:00

You seem to have two use cases: 1) Customize the HTML output produced for each topic. 2) Customize the HTML output produced for the index.html table of contents.

By answer will be mostly about (1). Once in your plugin.xml you add this extension:

<feature extension="dita.xsl.xhtml" file="xslhtml/dita2xhtml.xsl"/>

your custom "dita2xhtml.xsl" will be contributed as an XSLT customization stylesheet to all the XHTML-based outputs. So the extension will not be limited to your custom transtype, even the base XHTML output will use your XSLT changes. Your custom "dita2xhtml.xsl" will not be the main XSLT stylesheet in the transformation, but the xsl:templates you write in it will take precedence over the ones in the base XSLT stylesheets. So your custom "dita2xhtml.xsl" should not contain imports to other XSLT stylesheets like "dita2html-base.xsl" which you probably copied from the base XHTML plugin, it should just contain the xsl:templates which override the base processing. Your custom XSLT processing will be applied when DITA topics are converted to equivalent HTML files.

If you also want to influence how the index.html (table of contents) is generated there is another plugin extension called "dita.xsl.htmltoc" which you can declare in the plugin.xml and have it point to another custom XSLT stylesheet which will override templates specified in the base XHTML plugin for the TOC processing.

But as I mentioned both the "dita.xsl.xhtml" and "dita.xsl.htmltoc" extensions will be applied to all XHTML-based outputs, including to the default XHTML output.

If you want your XSLT customizations to apply only for you custom transformation type things get harder, you no longer declare the extensions in the plugin.xml but in your "build_transtype-custom.xml" instead of adding a simple antcall to the main xhtml target:

  <antcall target="dita2xhtml"/>

you would do something like:

<target name="dita2xhtml-custom">
    <echo>custom HTML transform</echo>
    <property name="args.xsl" value="${dita.plugin.com.custom.xhtml.dir}/xslhtml/dita2xhtml.xsl"/>
    <antcall target="dita2xhtml"/>
</target>

After you do that, your custom "dita2xhtml.xsl" will become the main XSLT stylesheet applied when producing the HTML file for each DITA topic. So your custom "dita2xhtml.xsl" will need to have an import to the base XHTML XSLT processing:

 <xsl:import href="plugin:org.dita.xhtml:xsl/dita2xhtml.xsl"/>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!