【问题】
docbook中,已经按照教程,成功的实现了用ant编译默认的webhelp了,现在打算去把此编译环境,加入到我原先自己的一套docbook编译环境中。
当前已经存在了之前可以正常通过xsltproc编译的docbook的xml源码。
其中主文件中xinclude了其他子文件:
<xi:include href="glossary.xml"/> <xi:include href="ch01_reduced_instruction_set.xml"/> <xi:include href="reference.xml"/>
接下来,就是去想办法使得此处的ant webhelp得以成功编译:
然后先是去把三个jar:saxon-6.5.5.jar,xercesImpl.jar,xml-apis.jar,都移到对应的文件夹
E:\Dev_Root\docbook\tools\webhelp\extensions
中了,然后修改了原先的build.properties中配置为:
xslt-processor-classpath=E:/Dev_Root/docbook/tools/webhelp/extensions/saxon-6.5.5.jar xercesImpl.jar=E:/Dev_Root/docbook/tools/webhelp/extensions/xercesImpl.jar xml-apis.jar=E:/Dev_Root/docbook/tools/webhelp/extensions/xml-apis.jar
然后去按照教程,建立一个build.xml
文件,其中内容为:
<project> <property name="input-xml" value="arm_vs_mips.xml"/> <property name="input-images-dirs" value="images/** figures/** graphics/**"/> <property name="output-dir" value="../output/webhelp"/> <import file="E:/Dev_Root/docbook/tools/docbook-xsl-ns-1.77.0/webhelp/build.xml"/> </project>
放到对应的arm_vs_mips的book的src目录:
E:\Dev_Root\docbook\dev\books\arm_vs_mips\src
下,然后在cygwin中,该文件夹下,执行对应的
ant webhelp
结果显示profiling\profile.xsl找不到,然后通过暂时性地,把原build.xml中的:
style="../profiling/profile.xsl">
改为:
style="E:/Dev_Root/docbook/tools/docbook-xsl-ns-1.77.0/profiling/profile.xsl">
而得以继续编译,接着,编译出现错误:
Administrator@K470 /cygdrive/e/Dev_Root/docbook/dev/books/arm_vs_mips/src $ ant webhelp --execdebug exec "/cygdrive/d/Program Files/Java/jre7/bin/java" -classpath "E:/dev_install_root/apache_ant/apache-ant-1.8.4/lib/ant-launcher.jar" -Dant.home="E:/dev_install_root/apache_ant/apache-ant-1.8.4" -Dant.library.dir="E:/dev_install_root/apache_ant/apache-ant-1.8.4/lib" -Dcygwin.user.home="E:/dev_install_root/cygwin/home/Administrator" org.apache.tools.ant.launch.Launcher -cp ".;D:/Program Files/Java/jre7/lib" "webhelp" Unable to locate tools.jar. Expected to find it in D:\Program Files\Java\jre7\lib\tools.jar Buildfile: E:\Dev_Root\docbook\dev\books\arm_vs_mips\src\build.xml validate: clean: [delete] Deleting directory E:\Dev_Root\docbook\dev\books\arm_vs_mips\output\webhelp chunk: [mkdir] Created dir: E:\Dev_Root\docbook\dev\books\arm_vs_mips\output\webhelp [xslt] Processing E:\Dev_Root\docbook\dev\books\arm_vs_mips\src\arm_vs_mips.xml to E:\Dev_Root\docbook\dev\books\arm_vs_mips\output\webhelp\null2135779454 [xslt] Loading stylesheet E:\Dev_Root\docbook\tools\docbook-xsl-ns-1.77.0\profiling\profile.xsl [xslt] Processing E:\Dev_Root\docbook\dev\books\arm_vs_mips\output\webhelp\null2135779454 to E:\Dev_Root\docbook\dev\books\arm_vs_mips\output\webhelp\null35563522 [xslt] Loading stylesheet E:\Dev_Root\docbook\tools\docbook-xsl-ns-1.77.0\webhelp\xsl\webhelp.xsl [xslt] language: zh [xslt] Element include in namespace 'http://www.w3.org/2001/XInclude' encountered in book, but no template matches. [xslt] Element include in namespace 'http://www.w3.org/2001/XInclude' encountered in book, but no template matches. [xslt] Element include in namespace 'http://www.w3.org/2001/XInclude' encountered in book, but no template matches. [xslt] Writing ../output/webhelp/content/index.html for book [xslt] Writing ../output/webhelp/index.html [xslt] Writing ../output/webhelp/content/search/l10n.js [copy] Copying 92 files to E:\Dev_Root\docbook\dev\books\arm_vs_mips\output\webhelp [copy] Copying 1 file to E:\Dev_Root\docbook\dev\books\arm_vs_mips\output\webhelp\content index: [copy] Copying 1 file to E:\Dev_Root\docbook\dev\books\arm_vs_mips\output\webhelp [copy] Copied 1 empty directory to 1 empty directory under E:\Dev_Root\docbook\dev\books\arm_vs_mips\output\webhelp [copy] Copying 2 files to E:\Dev_Root\docbook\dev\books\arm_vs_mips\output\webhelp [echo] Indexing html files in ../output/webhelp/content [java] Stemming enabled [java] The created index files are located in ..\output\webhelp\content\search\.js [java] Delay = 226 milliseconds webhelp: BUILD SUCCESSFUL Total time: 4 seconds
对应的,倒是可以生成最开始,xinclude之前的那部分内容的,截图如下:
接下来,就是去解决,用ant编译webhelp但是出现:
[xslt] Element include in namespace ‘http://www.w3.org/2001/XInclude’ encountered in book, but no template matches.
的错误的问题了。
【解决过程】
1.参考:[docbook-apps] Missing Xerces Classpath definition in DocBook XSL 1.77.0 Webhelp Sample
去把
classpath="${xercesImpl.jar}
加入到profile.xsl过程中,即把:
style="E:/Dev_Root/docbook/tools/docbook-xsl-ns-1.77.0/profiling/profile.xsl">
变为:
style="E:/Dev_Root/docbook/tools/docbook-xsl-ns-1.77.0/profiling/profile.xsl" classpath="${xercesImpl.jar}">
然后在去编译看看,结果好像就解决了上述的xinclude的问题了。
2.不过,后来又看到上面那个帖子的回复:
Re: [docbook-apps] Missing Xerces Classpath definition in DocBook XSL 1.77.0 Webhelp Sample
又说这个设置不需要在此处加,而只需要在build.properties添加即可,但是我此处的确是已经在build.properties中添加了xercesImpl.jar的配置的。
而且也是其所说的1.8.x,即1.8.4版本的ant啊,但是此处编译的确会出错的。
而通过上述手动加在xslt中,至少是可以避免该问题的,所以,事实证明,还是需要添加classpath="${xercesImpl.jar}到xslt处理过程中的。
【总结】
对于docbook中用
ant webhelp
编译webhelp出现:
[xslt] Element include in namespace ‘http://www.w3.org/2001/XInclude’ encountered in book, but no template matches.
的错误的原因为,使用ant中调用xslt时,classpath中没有包含用于处理xinclude的xercesImpl.jar,所以:
解决办法为,把xercesImpl.jar的classpath添加到xslt处理过程中即可。
即,把build.xml中的target name="chunk"中的
<xslt in="${input-xml}" out="${xincluded-profiled.xml}"
部分的:
style="E:/Dev_Root/docbook/tools/docbook-xsl-ns-1.77.0/profiling/profile.xsl">
改为:
style="E:/Dev_Root/docbook/tools/docbook-xsl-ns-1.77.0/profiling/profile.xsl" classpath="${xercesImpl.jar}">
就可以使得xercesImpl能够正常处理xinclude的xml文件了。
【相关内容】
不过,其后又出现别的"null WrappedRuntimeException 系统找不到指定的文件"方面的错误,关于该错误的折腾结果如下:
转载请注明:在路上 » 【已解决】docbook中,用ant编译webhelp出错:[xslt] Element include in namespace ‘http://www.w3.org/2001/XInclude’ encountered in book, but no template matches.