是否可以使用DITA-OT将自定义ANT参数传递到自定义插件中?

时间:2014-03-28 14:22:14

标签: ant parameters customization dita dita-ot

我已经创建了DITA-OT PDF插件,它运行良好且应该如此。下一步是将ANT参数传递给我的自定义插件的重写XSLT文件。正如您所看到的,这扩展了pdf2插件处理,我有自定义样式表正在工作。

以下是有关如何执行此操作的文档。这适用于默认插件(pdf2,xhtml等) http://dita-ot.github.io/1.8/dev_ref/plugin-xsltparams.html

但是当我尝试为自己的插件做同样的技巧时,我永远无法进行集成。我已将以下行添加到“plugin.xml”

<?xml version='1.0' encoding='UTF-8'?>
<plugin id="com.mymods.pdf">
  <require plugin="org.dita.pdf2" />
  <feature extension="dita.conductor.transtype.check" value="com.mymods.pdf" />
  <feature extension="dita.transtype.print" value="com.mymods.pdf" />
  <feature extension="dita.conductor.target.relative" file="integrator.xml" />
  <feature extension="dita.conductor.com.mymods.pdf.param" file="insertParameters.xml"/>
<template file="build_mymods_pdf_template.xml"/>
</plugin>

我的“insertParameters.xml”看起来像这样:

<?xml version='1.0' encoding='UTF-8'?>
<dummy>
  <!-- EXAMPLE: <param name="paramNameinXSLT" expression="${antProperty}" if="antProperty"/> -->
  <param name="custom.data1" expression="${custom.data1}" if="custom.data1"/>
  <param name="custom.data2" expression="${custom.data2}" if="custom.data2"/>
</dummy>

然后,当我尝试将更改集成到DITA-OT中时,我得到了这个:

BUILD FAILED
DITA-OT1.8.4\integrator.xml:59: The following error occurred while executing this line:
DITA-OT1.8.4\integrator.xml:49: Integration failed: Plug-in com.mymods.pdf uses an undefined extension point dita.conductor.com.mymods.pdf.param

另外一个信息:我试图在“plugin.xml”中更改一行指向原始pdf2插件而不是我自己的插件:

<feature extension="dita.conductor.pdf2.param" file="insertParameters.xsl"/>

然后集成是成功的,但是当我尝试用我的插件处理pdf输出时,我得到导致BUILD FAILED的错误:

mycustom.xsl Fatal Error! Variable custom.data1 has not been declared (or its declaration is not in scope)
mycustom.xsl Fatal Error! Variable custom.data2 has not been declared (or its declaration is not in scope)

是否有可能将ANT参数传递给自定义插件XSLT处理,或者只能默认DITA-OT转换方案(例如pdf2,xhtml)?我做错了什么?

1 个答案:

答案 0 :(得分:0)

您需要为dita.conductor.com.mymods.pdf.param添加extension point

<extension-point id="dita.conductor.com.mymods.pdf.param"
                 name="Custom parameters"/>

如果您想传递使用自定义扩展点定义的参数,则需要将这些参数添加到mycustom.xsl

<xsl:param name="custom.data1"/>
<xsl:param name="custom.data2"/>