我正在尝试使用fn:doc()函数从XSLT StylesHeet处理中读取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 filesoxygen xml editor 19jre/bin/java" -Xmx256m -classpath "C:Program FilesOxygen XML Editor 19toolsant/lib/ant-launcher.jar" "-Dant.home=C:Program FilesOxygen XML Editor 19toolsant" org.apache.tools.ant.launch.Launcher -lib "D:My_DocumentsJavaSaxonPE9-8-0-3Jsaxon9pe.jar" -lib "D:My_DocumentsJavaxml-commons-resolver-1.2resolver.jar" -lib "D:My_DocumentsJavaxml-commons-external-1.4.01xml-apis.jar" -lib "D:My_DocumentsJavaxml-commons-external-1.4.01xml-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:SVNacmekeyuicontrol-convbuild.xml
Adding reference: ant.PropertyHelper
Detected Java version: 1.8 in: c:program filesoxygen xml editor 19jre
Detected OS: Windows 8.1
...
uicontrol.conv.impl:
Setting project property: dummy.input -> D:SVNacmekeyuicontrol-conv/dummy-in.xml
Setting project property: dummy.output -> D:SVNacmekeyuicontrol-conv/dummy-out.xml
Setting project property: xsl.file -> D:SVNacmekeyuicontrol-conv/xsl/convUicontrol.xsl
[xslt] Using class org.apache.tools.ant.taskdefs.optional.TraXLiaison
[xslt] In file D:SVNacmekeyuicontrol-convdummy-in.xml time: 1504138459522
[xslt] Out file D:SVNacmekeyuicontrol-convdummy-out.xml time: 0
[xslt] Style file D:SVNacmekeyuicontrol-conv/xsl/convUicontrol.xsl time: 1504138455268
[xslt] Processing D:SVNacmekeyuicontrol-convdummy-in.xml to D:SVNacmekeyuicontrol-convdummy-out.xml
[xslt] Loading stylesheet D:SVNacmekeyuicontrol-convxslconvUicontrol.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-OTdita-ot-2.5.2catalog-dita.xml'
Parsing D:DITA-OTdita-ot-2.5.2catalog-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:SVNacmekeyuicontrol-convxslconvUicontrol.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:SVNacme-devVisualWorksja-JPkeydef-mapmap.dtd (Specified file does not found.) Cause: java.io.FileNotFoundException: D:SVNacme-devVisualWorksja-JPkeydef-mapmap.dtd (Specified file does not found.)
[xslt] Failed to process D:SVNacmekeyuicontrol-convdummy-in.xml
[antcall] Exiting D:SVNacmekeyuicontrol-convbuild.xml.
BUILD FAILED
D:SVNacmekeyuicontrol-convbuild.xml:20: The following error occurred while executing this line:
D:SVNacmekeyuicontrol-convbuild.xml:32: Fatal error during transformation using D:SVNacmekeyuicontrol-convxslconvUicontrol.xsl: I/O error reported by XML parser processing file:/D:/SVN/acme-dev/VisualWorks/ja-JP/keydef-map/mKeyDefUi.ditamap: D:SVNacme-devVisualWorksja-JPkeydef-mapmap.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怎么了?
您还应该尝试在Xerces库" xercesimpl.jar"中添加类Path的引用。另外,您的控制台输出中的此错误行:
java.lang.NoSuchFieldException: _isNotSecureProcessing
似乎表明正在尝试使用Xalan TransformerFactoryImpl。