自定义 HTML 插件创建 index.html 不影响
Custom XHTML plugin creation index.html not effecting
我创建了这样的自定义 xhtml 插件
我的plugin.xml代码是
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file is part of the DITA Open Toolkit project.
See the accompanying license.txt file for applicable licenses.
-->
<plugin id="com.custom.xhtml">
<!-- extensions -->
<feature extension="dita.xsl.xhtml" file="xslhtml/dita2xhtml.xsl"/>
<feature extension="dita.conductor.transtype.check" value="xhtml-custom" type="txt"/>
<feature extension="dita.conductor.target.relative" file="build.xml"/>
<!-- change value to match your custom transtype -->
</plugin>
build.xml代码为
<?xml version="1.0" encoding="UTF-8"?>
<project name="com.custom.xhtml">
<import file="build_transtype-custom.xml"/>
</project>
build_transtype-custom.xml是
<project name="xhtml-custom" default="dita2xhtml-custom">
<property name="transtype" value="xhtml-custom"/>
<target name="dita2xhtml-custom">
<echo>custom HTML transform</echo>
<!-- Set properties here -->
<antcall target="dita2xhtml"/>
</target>
</project>
然后我将基本插件 xsl 文件夹粘贴到自定义插件,我更改了名为 dita2xhtml.xsl
的 xsl
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="dita2html-base.xsl"/>
<xsl:output method="xml" encoding="UTF-8" indent="no"/>
<xsl:variable name="source-chars" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ .'"/>
<xsl:variable name="target-chars" select="'abcdefghijklmnopqrstuvwxyz__'"/>
<xsl:template match="task">
<div class="topic">
<xsl:attribute name="id">
<xsl:value-of select="attribute::id"/>
</xsl:attribute>
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="task/title">
<h1>Chapter <xsl:number count="task"/>. <xsl:apply-templates/><xsl:text> </xsl:text><script type="text/javascript" language="JavaScript" src="find5.js"><xsl:text>​</xsl:text></script></h1>
</xsl:template>
<xsl:template match="section">
<div class="section" id="{translate(title, $source-chars, $target-chars )}">
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="taskbody">
<div>
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="title">
<h2 class="sectiontitle">
<xsl:apply-templates/>
</h2>
</xsl:template>
<xsl:template match="p">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
<xsl:template match="steps">
<ol>
<xsl:apply-templates/>
</ol>
</xsl:template>
<xsl:template match="step">
<li>
<xsl:apply-templates/>
</li>
</xsl:template>
<xsl:template match="cmd">
<span>
<xsl:apply-templates/>
</span>
</xsl:template>
<xsl:template match="b">
<strong>
<xsl:apply-templates/>
<xsl:text>​</xsl:text>
</strong>
</xsl:template>
<xsl:template match="menucascade">
<span class="menucascade">
<xsl:apply-templates/>
</span>
</xsl:template>
<xsl:template match="uicontrol">
<span class="uicontrol">
<xsl:apply-templates/>
</span>
</xsl:template>
<xsl:template match="filepath">
<span class="filepath">
<xsl:apply-templates/>
</span>
</xsl:template>
<xsl:template match="xref">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="info">
<div>
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="i">
<em>
<xsl:apply-templates/>
</em>
</xsl:template>
<!-- Add both lang and xml:lang attributes -->
<xsl:template match="@xml:lang" name="generate-lang">
<xsl:param name="lang" select="."/>
<xsl:attribute name="xml:lang">
<xsl:value-of select="$lang"/>
</xsl:attribute>
<xsl:attribute name="lang">
<xsl:value-of select="$lang"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
然后在 xslhtml\map2htmtoc 文件夹中将名为 map2htmtocImpl.xsl 的 xsl 模板更改为 generate-toc,如下所示
模板更改仅完成
<xsl:template name="generate-toc">
<html style="overflow-y:auto"><xsl:value-of select="$newline"/>
<head><xsl:value-of select="$newline"/><title>Configuring Workflow</title><xsl:value-of select="$newline"/>
<xsl:value-of select="$newline"/>
<xsl:call-template name="generateDefaultCopyright"/>
<xsl:call-template name="generateCharset"/>
<xsl:if test="string-length($contenttarget)>0 and
$contenttarget!='NONE'">
<base target="{$contenttarget}"/>
<xsl:value-of select="$newline"/>
</xsl:if>
<!-- initial meta information -->
<!-- Set the character set to UTF-8 -->
<!-- Generate a default copyright, if needed -->
<xsl:call-template name="generateDefaultMeta"/> <!-- Standard meta for security, robots, etc -->
<xsl:call-template name="copyright"/> <!-- Generate copyright, if specified manually -->
<xsl:call-template name="generateCssLinks"/> <!-- Generate links to CSS files -->
<xsl:call-template name="generateMapTitle"/> <!-- Generate the <title> element -->
<xsl:call-template name="gen-user-head" /> <!-- include user's XSL HEAD processing here -->
<xsl:call-template name="gen-user-scripts" /> <!-- include user's XSL javascripts here -->
<xsl:call-template name="gen-user-styles" /> <!-- include user's XSL style element and content here -->
</head><xsl:value-of select="$newline"/>
<body>
<xsl:if test="string-length($OUTPUTCLASS) > 0">
<xsl:attribute name="class">
<xsl:value-of select="$OUTPUTCLASS"/>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="$newline"/>
<nav><xsl:value-of select="$newline"/>
<div xmlns:glossdata="http://dita4publishers.org/glossdata" xmlns:mapdriven="http://dita4publishers.org/mapdriven" xmlns:enum="http://dita4publishers.org/enumerables" class="dynamic-toc"><xsl:value-of select="$newline"/>
<div id="container" ><xsl:value-of select="$newline"/>
<div id="containerTop"><xsl:value-of select="$newline"/>
<div id="main"><xsl:value-of select="$newline"/>
<div id="content"><xsl:value-of select="$newline"/>
<form name="mainForm" action="javscript:;"><xsl:value-of select="$newline"/>
<div class="newsItem"><xsl:value-of select="$newline"/>
<div id="expandcontractdiv"><xsl:value-of select="$newline"/>
<a href="javascript:tree.expandAll()" class="treetools">Expand all</a><xsl:value-of select="$newline"/>
<a href="javascript:tree.collapseAll()" class="treetools">Collapse all</a><xsl:value-of select="$newline"/>
</div><xsl:value-of select="$newline"/>
<div id="treeDiv1"> </div><xsl:value-of select="$newline"/>
</div><xsl:value-of select="$newline"/>
</form><xsl:value-of select="$newline"/>
</div><xsl:value-of select="$newline"/>
</div><xsl:value-of select="$newline"/>
</div><xsl:value-of select="$newline"/>
</div><xsl:value-of select="$newline"/>
</div><xsl:value-of select="$newline"/>
<xsl:apply-templates/>
</nav><xsl:value-of select="$newline"/>
<iframe class="contentwin" id="contentwin" name="contentwin" src="test.html">
</iframe><xsl:value-of select="$newline"/>
<div id="footer" class="footer"></div><xsl:value-of select="$newline"/>
<script xmlns:glossdata="http://dita4publishers.org/glossdata" xmlns:mapdriven="http://dita4publishers.org/mapdriven" xmlns:enum="http://dita4publishers.org/enumerables" type="text/javascript" src="yahoo.js"> </script><xsl:value-of select="$newline"/>
<script xmlns:glossdata="http://dita4publishers.org/glossdata" xmlns:mapdriven="http://dita4publishers.org/mapdriven" xmlns:enum="http://dita4publishers.org/enumerables" type="text/javascript" src="event.js"> </script><xsl:value-of select="$newline"/>
<script xmlns:glossdata="http://dita4publishers.org/glossdata" xmlns:mapdriven="http://dita4publishers.org/mapdriven" xmlns:enum="http://dita4publishers.org/enumerables" type="text/javascript" src="treeview.js"> </script><xsl:value-of select="$newline"/>
</body><xsl:value-of select="$newline"/>
</html>
</xsl:template>
然后我在命令提示符下 运行 integrator.xml 命令 ant -f integrator.xml 然后我在氧气中 运行 转换名为 xhtml-custom 然后我是转换成功但氧气显示一些错误,如下所示
System ID: E:\task\Test.ditamap
Scenario: Test (xhtml-common)
Input file: E:\task\Test.ditamap
Engine name: DITA-OT
Severity: error
Description: Ambiguous rule match for /task/taskbody[1]/steps[1]/step[3]/cmd[1]/image[1]
System ID: E:\task\Test.ditamap
Scenario: Test (xhtml-common)
Input file: E:\task\Test.ditamap
Engine name: DITA-OT
Severity: error
Description: Ambiguous rule match for /task/taskbody[1]/steps[1]/step[6]/info[1]/image[1]
System ID: E:\task\Test.ditamap
Scenario: Test (xhtml-common)
Input file: E:\task\Test.ditamap
Engine name: DITA-OT
Severity: error
Description: Ambiguous rule match for /task/taskbody[1]/steps[1]/step[7]/stepresult[1]/image[1]
System ID: E:\task\Test.ditamap
Scenario: Test (xhtml-common)
Input file: E:\task\Test.ditamap
Engine name: DITA-OT
Severity: error
Description: Ambiguous rule match for /task/taskbody[1]/steps[1]/step[9]/info[1]/image[1]
System ID: E:\task\Test.ditamap
Scenario: Test (xhtml-common)
Input file: E:\task\Test.ditamap
Engine name: DITA-OT
Severity: error
Description: Ambiguous rule match for /task/taskbody[1]/steps[1]/step[8]/info[1]/image[1]
System ID: E:\task\Test.ditamap
Scenario: Test (xhtml-common)
Input file: E:\task\Test.ditamap
Engine name: DITA-OT
Severity: error
Description: Ambiguous rule match for /task/taskbody[1]/steps[1]/step[12]/cmd[1]/image[1]
并且由转换模板创建的 index.html 更改未应用
请协助我解决这个问题
您似乎有两个用例:
1) 自定义为每个主题生成的 HTML 输出。
2) 自定义为 index.html table 内容生成的 HTML 输出。
答案主要是关于 (1)。
在您的 plugin.xml 中添加此扩展名:
<feature extension="dita.xsl.xhtml" file="xslhtml/dita2xhtml.xsl"/>
您的自定义 "dita2xhtml.xsl" 将作为 XSLT 自定义样式表提供给所有基于 XHTML 的输出。因此扩展将不限于您的自定义转换类型,即使是基本 XHTML 输出也将使用您的 XSLT 更改。
您的自定义 "dita2xhtml.xsl" 不会成为转换中的主要 XSLT 样式表,但您在其中编写的 xsl:templates 将优先于基本 XSLT 样式表中的样式表。所以你的自定义 "dita2xhtml.xsl" 不应该包含对其他 XSLT 样式表的导入,比如你可能从基本 XHTML 插件复制的 "dita2html-base.xsl",它应该只包含 xsl:templates 覆盖基础处理。当 DITA 主题转换为等效的 HTML 文件时,将应用您的自定义 XSLT 处理。
如果您还想影响 index.html(内容的 table)的生成方式,还有另一个名为 "dita.xsl.htmltoc" 的插件扩展,您可以在 plugin.xml 并让它指向另一个自定义 XSLT 样式表,它将覆盖在基本 XHTML 插件中指定的用于 TOC 处理的模板。
但是正如我提到的,"dita.xsl.xhtml" 和 "dita.xsl.htmltoc" 扩展都将应用于所有基于 XHTML 的输出,包括默认的 XHTML 输出。
如果您希望 XSLT 自定义仅适用于您的自定义转换类型,事情会变得更难,您不再在 plugin.xml 中声明扩展,而是在 "build_transtype-custom.xml" 中声明扩展,而不是添加简单的 antcall到主要的 xhtml 目标:
<antcall target="dita2xhtml"/>
你会做这样的事情:
<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>
完成后,您的自定义 "dita2xhtml.xsl" 将成为在为每个 DITA 主题生成 HTML 文件时应用的主要 XSLT 样式表。因此您的自定义 "dita2xhtml.xsl" 将需要导入到基础 XHTML XSLT 处理:
<xsl:import href="plugin:org.dita.xhtml:xsl/dita2xhtml.xsl"/>
我创建了这样的自定义 xhtml 插件
我的plugin.xml代码是
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file is part of the DITA Open Toolkit project.
See the accompanying license.txt file for applicable licenses.
-->
<plugin id="com.custom.xhtml">
<!-- extensions -->
<feature extension="dita.xsl.xhtml" file="xslhtml/dita2xhtml.xsl"/>
<feature extension="dita.conductor.transtype.check" value="xhtml-custom" type="txt"/>
<feature extension="dita.conductor.target.relative" file="build.xml"/>
<!-- change value to match your custom transtype -->
</plugin>
build.xml代码为
<?xml version="1.0" encoding="UTF-8"?>
<project name="com.custom.xhtml">
<import file="build_transtype-custom.xml"/>
</project>
build_transtype-custom.xml是
<project name="xhtml-custom" default="dita2xhtml-custom">
<property name="transtype" value="xhtml-custom"/>
<target name="dita2xhtml-custom">
<echo>custom HTML transform</echo>
<!-- Set properties here -->
<antcall target="dita2xhtml"/>
</target>
</project>
然后我将基本插件 xsl 文件夹粘贴到自定义插件,我更改了名为 dita2xhtml.xsl
的 xsl<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="dita2html-base.xsl"/>
<xsl:output method="xml" encoding="UTF-8" indent="no"/>
<xsl:variable name="source-chars" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ .'"/>
<xsl:variable name="target-chars" select="'abcdefghijklmnopqrstuvwxyz__'"/>
<xsl:template match="task">
<div class="topic">
<xsl:attribute name="id">
<xsl:value-of select="attribute::id"/>
</xsl:attribute>
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="task/title">
<h1>Chapter <xsl:number count="task"/>. <xsl:apply-templates/><xsl:text> </xsl:text><script type="text/javascript" language="JavaScript" src="find5.js"><xsl:text>​</xsl:text></script></h1>
</xsl:template>
<xsl:template match="section">
<div class="section" id="{translate(title, $source-chars, $target-chars )}">
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="taskbody">
<div>
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="title">
<h2 class="sectiontitle">
<xsl:apply-templates/>
</h2>
</xsl:template>
<xsl:template match="p">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
<xsl:template match="steps">
<ol>
<xsl:apply-templates/>
</ol>
</xsl:template>
<xsl:template match="step">
<li>
<xsl:apply-templates/>
</li>
</xsl:template>
<xsl:template match="cmd">
<span>
<xsl:apply-templates/>
</span>
</xsl:template>
<xsl:template match="b">
<strong>
<xsl:apply-templates/>
<xsl:text>​</xsl:text>
</strong>
</xsl:template>
<xsl:template match="menucascade">
<span class="menucascade">
<xsl:apply-templates/>
</span>
</xsl:template>
<xsl:template match="uicontrol">
<span class="uicontrol">
<xsl:apply-templates/>
</span>
</xsl:template>
<xsl:template match="filepath">
<span class="filepath">
<xsl:apply-templates/>
</span>
</xsl:template>
<xsl:template match="xref">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="info">
<div>
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="i">
<em>
<xsl:apply-templates/>
</em>
</xsl:template>
<!-- Add both lang and xml:lang attributes -->
<xsl:template match="@xml:lang" name="generate-lang">
<xsl:param name="lang" select="."/>
<xsl:attribute name="xml:lang">
<xsl:value-of select="$lang"/>
</xsl:attribute>
<xsl:attribute name="lang">
<xsl:value-of select="$lang"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
然后在 xslhtml\map2htmtoc 文件夹中将名为 map2htmtocImpl.xsl 的 xsl 模板更改为 generate-toc,如下所示
模板更改仅完成
<xsl:template name="generate-toc">
<html style="overflow-y:auto"><xsl:value-of select="$newline"/>
<head><xsl:value-of select="$newline"/><title>Configuring Workflow</title><xsl:value-of select="$newline"/>
<xsl:value-of select="$newline"/>
<xsl:call-template name="generateDefaultCopyright"/>
<xsl:call-template name="generateCharset"/>
<xsl:if test="string-length($contenttarget)>0 and
$contenttarget!='NONE'">
<base target="{$contenttarget}"/>
<xsl:value-of select="$newline"/>
</xsl:if>
<!-- initial meta information -->
<!-- Set the character set to UTF-8 -->
<!-- Generate a default copyright, if needed -->
<xsl:call-template name="generateDefaultMeta"/> <!-- Standard meta for security, robots, etc -->
<xsl:call-template name="copyright"/> <!-- Generate copyright, if specified manually -->
<xsl:call-template name="generateCssLinks"/> <!-- Generate links to CSS files -->
<xsl:call-template name="generateMapTitle"/> <!-- Generate the <title> element -->
<xsl:call-template name="gen-user-head" /> <!-- include user's XSL HEAD processing here -->
<xsl:call-template name="gen-user-scripts" /> <!-- include user's XSL javascripts here -->
<xsl:call-template name="gen-user-styles" /> <!-- include user's XSL style element and content here -->
</head><xsl:value-of select="$newline"/>
<body>
<xsl:if test="string-length($OUTPUTCLASS) > 0">
<xsl:attribute name="class">
<xsl:value-of select="$OUTPUTCLASS"/>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="$newline"/>
<nav><xsl:value-of select="$newline"/>
<div xmlns:glossdata="http://dita4publishers.org/glossdata" xmlns:mapdriven="http://dita4publishers.org/mapdriven" xmlns:enum="http://dita4publishers.org/enumerables" class="dynamic-toc"><xsl:value-of select="$newline"/>
<div id="container" ><xsl:value-of select="$newline"/>
<div id="containerTop"><xsl:value-of select="$newline"/>
<div id="main"><xsl:value-of select="$newline"/>
<div id="content"><xsl:value-of select="$newline"/>
<form name="mainForm" action="javscript:;"><xsl:value-of select="$newline"/>
<div class="newsItem"><xsl:value-of select="$newline"/>
<div id="expandcontractdiv"><xsl:value-of select="$newline"/>
<a href="javascript:tree.expandAll()" class="treetools">Expand all</a><xsl:value-of select="$newline"/>
<a href="javascript:tree.collapseAll()" class="treetools">Collapse all</a><xsl:value-of select="$newline"/>
</div><xsl:value-of select="$newline"/>
<div id="treeDiv1"> </div><xsl:value-of select="$newline"/>
</div><xsl:value-of select="$newline"/>
</form><xsl:value-of select="$newline"/>
</div><xsl:value-of select="$newline"/>
</div><xsl:value-of select="$newline"/>
</div><xsl:value-of select="$newline"/>
</div><xsl:value-of select="$newline"/>
</div><xsl:value-of select="$newline"/>
<xsl:apply-templates/>
</nav><xsl:value-of select="$newline"/>
<iframe class="contentwin" id="contentwin" name="contentwin" src="test.html">
</iframe><xsl:value-of select="$newline"/>
<div id="footer" class="footer"></div><xsl:value-of select="$newline"/>
<script xmlns:glossdata="http://dita4publishers.org/glossdata" xmlns:mapdriven="http://dita4publishers.org/mapdriven" xmlns:enum="http://dita4publishers.org/enumerables" type="text/javascript" src="yahoo.js"> </script><xsl:value-of select="$newline"/>
<script xmlns:glossdata="http://dita4publishers.org/glossdata" xmlns:mapdriven="http://dita4publishers.org/mapdriven" xmlns:enum="http://dita4publishers.org/enumerables" type="text/javascript" src="event.js"> </script><xsl:value-of select="$newline"/>
<script xmlns:glossdata="http://dita4publishers.org/glossdata" xmlns:mapdriven="http://dita4publishers.org/mapdriven" xmlns:enum="http://dita4publishers.org/enumerables" type="text/javascript" src="treeview.js"> </script><xsl:value-of select="$newline"/>
</body><xsl:value-of select="$newline"/>
</html>
</xsl:template>
然后我在命令提示符下 运行 integrator.xml 命令 ant -f integrator.xml 然后我在氧气中 运行 转换名为 xhtml-custom 然后我是转换成功但氧气显示一些错误,如下所示
System ID: E:\task\Test.ditamap
Scenario: Test (xhtml-common)
Input file: E:\task\Test.ditamap
Engine name: DITA-OT
Severity: error
Description: Ambiguous rule match for /task/taskbody[1]/steps[1]/step[3]/cmd[1]/image[1]
System ID: E:\task\Test.ditamap
Scenario: Test (xhtml-common)
Input file: E:\task\Test.ditamap
Engine name: DITA-OT
Severity: error
Description: Ambiguous rule match for /task/taskbody[1]/steps[1]/step[6]/info[1]/image[1]
System ID: E:\task\Test.ditamap
Scenario: Test (xhtml-common)
Input file: E:\task\Test.ditamap
Engine name: DITA-OT
Severity: error
Description: Ambiguous rule match for /task/taskbody[1]/steps[1]/step[7]/stepresult[1]/image[1]
System ID: E:\task\Test.ditamap
Scenario: Test (xhtml-common)
Input file: E:\task\Test.ditamap
Engine name: DITA-OT
Severity: error
Description: Ambiguous rule match for /task/taskbody[1]/steps[1]/step[9]/info[1]/image[1]
System ID: E:\task\Test.ditamap
Scenario: Test (xhtml-common)
Input file: E:\task\Test.ditamap
Engine name: DITA-OT
Severity: error
Description: Ambiguous rule match for /task/taskbody[1]/steps[1]/step[8]/info[1]/image[1]
System ID: E:\task\Test.ditamap
Scenario: Test (xhtml-common)
Input file: E:\task\Test.ditamap
Engine name: DITA-OT
Severity: error
Description: Ambiguous rule match for /task/taskbody[1]/steps[1]/step[12]/cmd[1]/image[1]
并且由转换模板创建的 index.html 更改未应用
请协助我解决这个问题
您似乎有两个用例: 1) 自定义为每个主题生成的 HTML 输出。 2) 自定义为 index.html table 内容生成的 HTML 输出。
答案主要是关于 (1)。 在您的 plugin.xml 中添加此扩展名:
<feature extension="dita.xsl.xhtml" file="xslhtml/dita2xhtml.xsl"/>
您的自定义 "dita2xhtml.xsl" 将作为 XSLT 自定义样式表提供给所有基于 XHTML 的输出。因此扩展将不限于您的自定义转换类型,即使是基本 XHTML 输出也将使用您的 XSLT 更改。 您的自定义 "dita2xhtml.xsl" 不会成为转换中的主要 XSLT 样式表,但您在其中编写的 xsl:templates 将优先于基本 XSLT 样式表中的样式表。所以你的自定义 "dita2xhtml.xsl" 不应该包含对其他 XSLT 样式表的导入,比如你可能从基本 XHTML 插件复制的 "dita2html-base.xsl",它应该只包含 xsl:templates 覆盖基础处理。当 DITA 主题转换为等效的 HTML 文件时,将应用您的自定义 XSLT 处理。
如果您还想影响 index.html(内容的 table)的生成方式,还有另一个名为 "dita.xsl.htmltoc" 的插件扩展,您可以在 plugin.xml 并让它指向另一个自定义 XSLT 样式表,它将覆盖在基本 XHTML 插件中指定的用于 TOC 处理的模板。
但是正如我提到的,"dita.xsl.xhtml" 和 "dita.xsl.htmltoc" 扩展都将应用于所有基于 XHTML 的输出,包括默认的 XHTML 输出。
如果您希望 XSLT 自定义仅适用于您的自定义转换类型,事情会变得更难,您不再在 plugin.xml 中声明扩展,而是在 "build_transtype-custom.xml" 中声明扩展,而不是添加简单的 antcall到主要的 xhtml 目标:
<antcall target="dita2xhtml"/>
你会做这样的事情:
<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>
完成后,您的自定义 "dita2xhtml.xsl" 将成为在为每个 DITA 主题生成 HTML 文件时应用的主要 XSLT 样式表。因此您的自定义 "dita2xhtml.xsl" 将需要导入到基础 XHTML XSLT 处理:
<xsl:import href="plugin:org.dita.xhtml:xsl/dita2xhtml.xsl"/>