在ant xslt任务

时间:2017-08-31 04:21:57

标签: ant xslt-2.0 saxon dita

我正在尝试使用fn:doc()函数从我的XSLT样式表处理中读取ditamap文件。但是ant失败了,因为即使指定了目录文件,也无法解析DTD公共标识符。

[ditamap:mKeyDefUi.ditamap]

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE map PUBLIC "-//OASIS//DTD DITA Map//EN" "map.dtd">
<map>
   <keydef keys="UI_Action">
      <topicmeta>
         <keywords>
            <keyword>処理</keyword>
         </keywords>
      </topicmeta>
   </keydef>
   <keydef keys="UI_ActionAfterPrinting">
      <topicmeta>
         <keywords>
            <keyword>印刷終了時の設定</keyword>
         </keywords>
      </topicmeta>
   </keydef>
   ...
</map>

[ant buld.xml主要部分]

<property name="key.map.url" value="file:/D:/SVN/acme-dev/VisualWorks/ja-JP/keydef-map/mKeyDefUi.ditamap"/>
<property name="dita.catalog.file" value="/D:/DITA-OT/dita-ot-2.5.2/catalog-dita.xml"/>
...
<!-- Main target -->
<target name="uicontrol.conv">
    <echo message="topic.file.prop=${topic.file.prop}"/>
    <antcall target="uicontrol.conv.impl">
        <param name="prmTopicFileProp" value="${topic.file.prop}"/>
        <param name="prmOutputDirUrl" value="${output.dir.url}"/>
        <param name="prmKeyMapUrl" value="${key.map.url}"/>
        <param name="prmLogFileUrl" value="${log.file.url}"/>
    </antcall>
</target>

<target name="uicontrol.conv.impl">
    <property name="dummy.input" value="${basedir}/dummy-in.xml"/>
    <property name="dummy.output" value="${basedir}/dummy-out.xml"/>
    <property name="xsl.file" value="${basedir}/xsl/convUicontrol.xsl"/>
    <xslt processor="trax" in="${dummy.input}" out="${dummy.output}" style="${xsl.file}" force="true">
        <factory name="net.sf.saxon.TransformerFactoryImpl"/>
        <param name="PRM_TOPIC_FILE_PROP" expression="${prmTopicFileProp}"/>
        <param name="PRM_OUTPUT_DIR_URL" expression="${prmOutputDirUrl}"/>
        <param name="PRM_KEY_MAP_URL" expression="${prmKeyMapUrl}"/>
        <param name="PRM_LOG_FILE_URL" expression="${prmLogFileUrl}"/>
        <xmlcatalog>
            <catalogpath>
                <pathelement location="${dita.catalog.file}"/>
            </catalogpath>
        </xmlcatalog>
    </xslt>
</target>

[蚂蚁日志]

Executing:
"c:\program files\oxygen xml editor 19\jre/bin/java" -Xmx256m -classpath "C:\Program Files\Oxygen XML Editor 19\tools\ant/lib/ant-launcher.jar" "-Dant.home=C:\Program Files\Oxygen XML Editor 19\tools\ant" org.apache.tools.ant.launch.Launcher -lib "D:\My_Documents\Java\SaxonPE9-8-0-3J\saxon9pe.jar" -lib "D:\My_Documents\Java\xml-commons-resolver-1.2\resolver.jar" -lib "D:\My_Documents\Java\xml-commons-external-1.4.01\xml-apis.jar" -lib "D:\My_Documents\Java\xml-commons-external-1.4.01\xml-apis-ext.jar" -f "build.xml" "-Dwebhelp.trial.license=no" -v -d

Apache Ant(TM) version 1.9.8 compiled on December 25 2016
Buildfile: D:\SVN\acme\key\uicontrol-conv\build.xml
Adding reference: ant.PropertyHelper
Detected Java version: 1.8 in: c:\program files\oxygen xml editor 19\jre
Detected OS: Windows 8.1
...

uicontrol.conv.impl:
Setting project property: dummy.input -> D:\SVN\acme\key\uicontrol-conv/dummy-in.xml
Setting project property: dummy.output -> D:\SVN\acme\key\uicontrol-conv/dummy-out.xml
Setting project property: xsl.file -> D:\SVN\acme\key\uicontrol-conv/xsl/convUicontrol.xsl
     [xslt] Using class org.apache.tools.ant.taskdefs.optional.TraXLiaison
     [xslt] In file D:\SVN\acme\key\uicontrol-conv\dummy-in.xml time: 1504138459522
     [xslt] Out file D:\SVN\acme\key\uicontrol-conv\dummy-out.xml time: 0
     [xslt] Style file D:\SVN\acme\key\uicontrol-conv/xsl/convUicontrol.xsl time: 1504138455268
     [xslt] Processing D:\SVN\acme\key\uicontrol-conv\dummy-in.xml to D:\SVN\acme\key\uicontrol-conv\dummy-out.xml
     [xslt] Loading stylesheet D:\SVN\acme\key\uicontrol-conv\xsl\convUicontrol.xsl
java.lang.NoSuchFieldException: _isNotSecureProcessing
resolve: 'util_string.xsl' with base: 'file:/D:/SVN/acme/key/uicontrol-conv/xsl/convUicontrol.xsl'
Class org.apache.tools.ant.types.resolver.ApacheCatalogResolver loaded from parent loader (parentFirst)
Apache resolver library found, xml-commons resolver will be used
Using catalogpath 'D:\DITA-OT\dita-ot-2.5.2\catalog-dita.xml'
Parsing D:\DITA-OT\dita-ot-2.5.2\catalog-dita.xml
resolve: 'file:/D:/SVN/acme-dev/VisualWorks/ja-JP/keydef-map/mKeyDefUi.ditamap' with base: 'file:/D:/SVN/acme/key/uicontrol-conv/xsl/convUicontrol.xsl'
resolveEntity: '-//OASIS//DTD DITA Map//EN': 'file:/D:/SVN/acme-dev/VisualWorks/ja-JP/keydef-map/map.dtd'
No matching catalog entry found, parser will use: 'file:/D:/SVN/acme-dev/VisualWorks/ja-JP/keydef-map/map.dtd'
     [xslt] D:\SVN\acme\key\uicontrol-conv\xsl\convUicontrol.xsl:17:4: Fatal Error! I/O error reported by XML parser processing file:/D:/SVN/acme-dev/VisualWorks/ja-JP/keydef-map/mKeyDefUi.ditamap: D:\SVN\acme-dev\VisualWorks\ja-JP\keydef-map\map.dtd (Specified file does not found.) Cause: java.io.FileNotFoundException: D:\SVN\acme-dev\VisualWorks\ja-JP\keydef-map\map.dtd (Specified file does not found.)
     [xslt] Failed to process D:\SVN\acme\key\uicontrol-conv\dummy-in.xml
  [antcall] Exiting D:\SVN\acme\key\uicontrol-conv\build.xml.

BUILD FAILED
D:\SVN\acme\key\uicontrol-conv\build.xml:20: The following error occurred while executing this line:
D:\SVN\acme\key\uicontrol-conv\build.xml:32: Fatal error during transformation using D:\SVN\acme\key\uicontrol-conv\xsl\convUicontrol.xsl: I/O error reported by XML parser processing file:/D:/SVN/acme-dev/VisualWorks/ja-JP/keydef-map/mKeyDefUi.ditamap: D:\SVN\acme-dev\VisualWorks\ja-JP\keydef-map\map.dtd (Specified file does not found.); SystemID: file:/D:/SVN/acme/key/uicontrol-conv/xsl/convUicontrol.xsl; Line#: 17; Column#: 4

xslt任务加载了最新的DITA-OT目录文件。但公共标识符' - // OASIS // DTD DITA Map // EN'未解析。 我的build.xml出了什么问题?

1 个答案:

答案 0 :(得分:0)

您还应该尝试将类路径引用添加到Xerces库&#34; xercesImpl.jar&#34;。 此控制台输出中的错误行也是:

  java.lang.NoSuchFieldException: _isNotSecureProcessing

似乎表明尝试使用Xalan TransformerFactoryImpl。