我想使用ANT脚本向我的DITA主题模型添加自定义CSS样式表(请参阅以下代码):
我的ANT脚本:
<?xml version="1.0" encoding="UTF-8" ?>
<!-- ==================
Web Output Custom CSS
==================-->
<project name="grid_web_css"default="grids.grid_web_css" basedir=".">
<property name="dita.dir" location="${basedir}${file.separator}..${file.separator}..${file.separator}.."/>
<property name="css.output.dir" value="${dita.dir}${file.separator}projects${file.separator}css-projects${file.separator}ant-scripts${file.separator}out${file.separator}ex-ant-understanding-css"/>
<property name="the.input.dir" value="${dita.dir}${file.separator}projects${file.separator}css-projects"/>
<property name="css.source.dir" location="${dita.dir}${file.separator}projects${file.separator}css-projects${file.separator}shared-assets"/>
<target name="grids.grid_web_css" depends="clean.grids.grid_web_css">
<ant antfile="${dita.dir}/build.xml">
<property name="args.input" location="${dita.dir}${file.separator}projects${file.separator}css-projects${file.separator}understanding_css.ditamap"/>
<property name="input.dir" location="${the.input.dir}"/>
<property name="output.dir" location="${css.output.dir}"/>
<property name="transtype" value="html5"/>
<property name="args.cssroot" location="${css.source.dir}"/>
<property name="args.css" value="${css.source.dir}${file.separator}web-css-grids.css"/>
<property name="args.csspath" value="${css.output.dir}/css"/>
<property name="args.copycss" value="yes"/>
<property name="processor" value="saxon"/>
<property name="classpath" value="${dita.dir}${file.separator}lib${file.separator}saxon.jar"/>
</ant>
<copy todir="${css.output.dir}/css">
<fileset dir="${css.source.dir}"/>
</copy>
</target>
<target name="clean.grids.grid_web_css" description="remove the sample web output">
<delete dir="${css.output.dir}"/>
</target>
</project>
根据下面的终端输出,建立目录并找到并执行build.xml文件。然而,目录中实际上没有生成任何内容,我无法隔离问题。
lingeringcode@Linger:~/dita-ot-2.1.1$ ant -f '/home/lingeringcode/dita-ot-2.1.1/projects/css-projects/ant-scripts/ant_grid_web_css.xml'
Buildfile: /home/lingeringcode/dita-ot-2.1.1/projects/css-projects/ant-scripts/ant_grid_web_css.xml
clean.grids.grid_web_css:
[delete] Deleting directory /home/lingeringcode/dita-ot-2.1.1/projects/css-projects/ant-scripts/out/ex-ant-understanding-css
grids.grid_web_css:
init:
dita2html5.init:
check-arg:
[mkdir] Created dir: /home/lingeringcode/dita-ot-2.1.1/projects/css-projects/ant-scripts/out/ex-ant-understanding-css
[mkdir] Created dir: /home/lingeringcode/dita-ot-2.1.1/projects/css-projects/ant-scripts/temp/temp20151020094428144
log-arg:
[echo] *****************************************************************
[echo] * basedir = /home/lingeringcode/dita-ot-2.1.1/projects/css-projects/ant-scripts
[echo] * dita.dir = /home/lingeringcode/dita-ot-2.1.1
[echo] * transtype = html5
[echo] * tempdir = /home/lingeringcode/dita-ot-2.1.1/projects/css-projects/ant-scripts/temp/temp20151020094428144
[echo] * outputdir = /home/lingeringcode/dita-ot-2.1.1/projects/css-projects/ant-scripts/out/ex-ant-understanding-css
[echo] * clean.temp = true
[echo] * DITA-OT version = 2.1.1
[echo] * XML parser = Xerces
[echo] * XSLT processor = Saxon
[echo] * collator = JDL
[echo] *****************************************************************
[echo] #Ant properties
[echo] #Tue Oct 20 09:44:29 CDT 2015
[echo] args.copycss=yes
[echo] args.css=/home/lingeringcode/dita-ot-2.1.1/projects/css-projects/shared-assets/web-css-grids.css
[echo] args.csspath=/home/lingeringcode/dita-ot-2.1.1/projects/css-projects/ant-scripts/out/ex-ant-understanding-css/css
[echo] args.cssroot=/home/lingeringcode/dita-ot-2.1.1/projects/css-projects/shared-assets
[echo] args.grammar.cache=yes
[echo] args.input=/home/lingeringcode/dita-ot-2.1.1/projects/css-projects/understanding_css.ditamap
[echo] args.logdir=/home/lingeringcode/dita-ot-2.1.1/projects/css-projects/ant-scripts/out/ex-ant-understanding-css
[echo] args.xml.systemid.set=yes
[echo] dita.dir=/home/lingeringcode/dita-ot-2.1.1
[echo] dita.plugin.com.sophos.tocjs.dir=/home/lingeringcode/dita-ot-2.1.1/plugins/com.sophos.tocjs
[echo] dita.plugin.org.dita.base.dir=/home/lingeringcode/dita-ot-2.1.1
[echo] dita.plugin.org.dita.docbook.dir=/home/lingeringcode/dita-ot-2.1.1/plugins/org.dita.docbook
[echo] dita.plugin.org.dita.eclipsecontent.dir=/home/lingeringcode/dita-ot-2.1.1/plugins/org.dita.eclipsecontent
[echo] dita.plugin.org.dita.eclipsehelp.dir=/home/lingeringcode/dita-ot-2.1.1/plugins/org.dita.eclipsehelp
[echo] dita.plugin.org.dita.htmlhelp.dir=/home/lingeringcode/dita-ot-2.1.1/plugins/org.dita.htmlhelp
[echo] dita.plugin.org.dita.javahelp.dir=/home/lingeringcode/dita-ot-2.1.1/plugins/org.dita.javahelp
[echo] dita.plugin.org.dita.odt.dir=/home/lingeringcode/dita-ot-2.1.1/plugins/org.dita.odt
[echo] dita.plugin.org.dita.pdf2.dir=/home/lingeringcode/dita-ot-2.1.1/plugins/org.dita.pdf2
[echo] dita.plugin.org.dita.specialization.dita11.dir=/home/lingeringcode/dita-ot-2.1.1/plugins/org.dita.specialization.dita11
[echo] dita.plugin.org.dita.specialization.eclipsemap.dir=/home/lingeringcode/dita-ot-2.1.1/plugins/org.dita.specialization.eclipsemap
[echo] dita.plugin.org.dita.troff.dir=/home/lingeringcode/dita-ot-2.1.1/plugins/org.dita.troff
[echo] dita.plugin.org.dita.wordrtf.dir=/home/lingeringcode/dita-ot-2.1.1/plugins/org.dita.wordrtf
[echo] dita.plugin.org.dita.xhtml.dir=/home/lingeringcode/dita-ot-2.1.1/plugins/org.dita.xhtml
[echo] dita.plugin.org.oasis-open.dita.v1_2.dir=/home/lingeringcode/dita-ot-2.1.1/plugins/org.oasis-open.dita.v1_2
[echo] dita.temp.dir=/home/lingeringcode/dita-ot-2.1.1/projects/css-projects/ant-scripts/temp/temp20151020094428144
[echo] *****************************************************************
build-init:
preprocess.init:
[echo] *****************************************************************
[echo] * input = /home/lingeringcode/dita-ot-2.1.1/projects/css-projects/understanding_css.ditamap
[echo] *****************************************************************
gen-list:
BUILD FAILED
/home/lingeringcode/dita-ot-2.1.1/projects/css-projects/ant-scripts/ant_grid_web_css.xml:18: The following error occurred while executing this line:
/home/lingeringcode/dita-ot-2.1.1/build.xml:42: The following error occurred while executing this line:
/home/lingeringcode/dita-ot-2.1.1/plugins/org.dita.base/build_preprocess.xml:78: java.lang.ClassNotFoundException: org.dita.dost.module.GenMapAndTopicListModule
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:191)
at org.apache.tools.ant.IntrospectionHelper$6.set(IntrospectionHelper.java:1095)
at org.apache.tools.ant.IntrospectionHelper$AttributeSetter.setObject(IntrospectionHelper.java:1493)
at org.apache.tools.ant.IntrospectionHelper.setAttribute(IntrospectionHelper.java:411)
at org.apache.tools.ant.RuntimeConfigurable.maybeConfigure(RuntimeConfigurable.java:528)
at org.apache.tools.ant.RuntimeConfigurable.maybeConfigure(RuntimeConfigurable.java:464)
at org.apache.tools.ant.UnknownElement.handleChild(UnknownElement.java:592)
at org.apache.tools.ant.UnknownElement.handleChildren(UnknownElement.java:358)
at org.apache.tools.ant.UnknownElement.configure(UnknownElement.java:204)
at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:163)
at org.apache.tools.ant.Task.perform(Task.java:347)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:440)
at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:440)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.Main.runBuild(Main.java:851)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
正如您可以从上面的输出中读到的,错误输出在“BUILD FAILED”行之后开始。
我想我要么错误地设置我的环境变量,要么就是我甚至无法想象导致这个问题;因此,我需要额外关注这个问题。
因此,也许有人可以帮助我了解我应该如何设置我的java + ant + saxon + xalan-我还没有找到关于这个过程的好文档。另外,如何验证我拥有使其工作所需的一切。或者,我很乐意帮助看看它是不是别的。
仅供参考,我正在使用DITA-OT 2.1.1。这是我在Github上的主题模型的链接:https://github.com/lingeringcode/css-projects。
任何帮助表示赞赏! : - )
FTR,dita
命令与-D
args一起使用,如下所示:
:~/dita-ot-2.1.1$ dita -f html5 -i 'projects/css-projects/understanding_css.ditamap' \ -o 'projects/css-projects/ex-understanding-css' \ -Dargs.cssroot='projects/css-projects/shared-assets' \ -Dargs.css='${cssroot}/web-css-grids.css' \ -Dargs.csspath='css' \ -Dargs.copycss='yes'
我还重置了我的CLASSPATH变量,确保确实找到了dost.jar。再次运行ant脚本后,我收到一条新的BUILD FAILED
错误消息(yay,progress?!),如下所示:
lingeringcode@Linger:~/dita-ot-2.1.1/projects/css-projects$ ant -f '/home/lingeringcode/dita-ot-2.1.1/projects/css-projects/ant-scripts/ant_grid_web_css.xml' Buildfile: /home/lingeringcode/dita-ot-2.1.1/projects/css-projects/ant-scripts/ant_grid_web_css.xml clean.grids.grid_web_css: [delete] Deleting directory /home/lingeringcode/dita-ot-2.1.1/projects/css-projects/ex-ant-understanding-css grids.grid_web_css: init: dita2html5.init: check-arg: [mkdir] Created dir: /home/lingeringcode/dita-ot-2.1.1/projects/css-projects/ex-ant-understanding-css [mkdir] Created dir: /home/lingeringcode/dita-ot-2.1.1/projects/css-projects/ant-scripts/temp/temp20151022130204394 log-arg: [echo] ***************************************************************** [echo] * basedir = /home/lingeringcode/dita-ot-2.1.1/projects/css-projects/ant-scripts [echo] * dita.dir = /home/lingeringcode/dita-ot-2.1.1 [echo] * transtype = html5 [echo] * tempdir = /home/lingeringcode/dita-ot-2.1.1/projects/css-projects/ant-scripts/temp/temp20151022130204394 [echo] * outputdir = /home/lingeringcode/dita-ot-2.1.1/projects/css-projects/ex-ant-understanding-css [echo] * clean.temp = true [echo] * DITA-OT version = 2.1.1 [echo] * XML parser = Xerces [echo] * XSLT processor = Saxon [echo] * collator = JDL [echo] ***************************************************************** [echo] #Ant properties [echo] #Thu Oct 22 13:02:05 CDT 2015 [echo] args.copycss=yes [echo] args.css=/home/lingeringcode/dita-ot-2.1.1/projects/css-projects/shared-assets/web-css-grids.css [echo] args.csspath=/home/lingeringcode/dita-ot-2.1.1/projects/css-projects/ex-ant-understanding-css/css [echo] args.cssroot=/home/lingeringcode/dita-ot-2.1.1/projects/css-projects/shared-assets [echo] args.grammar.cache=yes [echo] args.input=/home/lingeringcode/dita-ot-2.1.1/projects/css-projects/understanding_css.ditamap [echo] args.logdir=/home/lingeringcode/dita-ot-2.1.1/projects/css-projects/ex-ant-understanding-css [echo] args.xml.systemid.set=yes [echo] dita.dir=/home/lingeringcode/dita-ot-2.1.1 [echo] dita.plugin.com.sophos.tocjs.dir=/home/lingeringcode/dita-ot-2.1.1/plugins/com.sophos.tocjs [echo] dita.plugin.org.dita.base.dir=/home/lingeringcode/dita-ot-2.1.1 [echo] dita.plugin.org.dita.docbook.dir=/home/lingeringcode/dita-ot-2.1.1/plugins/org.dita.docbook [echo] dita.plugin.org.dita.eclipsecontent.dir=/home/lingeringcode/dita-ot-2.1.1/plugins/org.dita.eclipsecontent [echo] dita.plugin.org.dita.eclipsehelp.dir=/home/lingeringcode/dita-ot-2.1.1/plugins/org.dita.eclipsehelp [echo] dita.plugin.org.dita.htmlhelp.dir=/home/lingeringcode/dita-ot-2.1.1/plugins/org.dita.htmlhelp [echo] dita.plugin.org.dita.javahelp.dir=/home/lingeringcode/dita-ot-2.1.1/plugins/org.dita.javahelp [echo] dita.plugin.org.dita.odt.dir=/home/lingeringcode/dita-ot-2.1.1/plugins/org.dita.odt [echo] dita.plugin.org.dita.pdf2.dir=/home/lingeringcode/dita-ot-2.1.1/plugins/org.dita.pdf2 [echo] dita.plugin.org.dita.specialization.dita11.dir=/home/lingeringcode/dita-ot-2.1.1/plugins/org.dita.specialization.dita11 [echo] dita.plugin.org.dita.specialization.eclipsemap.dir=/home/lingeringcode/dita-ot-2.1.1/plugins/org.dita.specialization.eclipsemap [echo] dita.plugin.org.dita.troff.dir=/home/lingeringcode/dita-ot-2.1.1/plugins/org.dita.troff [echo] dita.plugin.org.dita.wordrtf.dir=/home/lingeringcode/dita-ot-2.1.1/plugins/org.dita.wordrtf [echo] dita.plugin.org.dita.xhtml.dir=/home/lingeringcode/dita-ot-2.1.1/plugins/org.dita.xhtml [echo] dita.plugin.org.oasis-open.dita.v1_2.dir=/home/lingeringcode/dita-ot-2.1.1/plugins/org.oasis-open.dita.v1_2 [echo] dita.temp.dir=/home/lingeringcode/dita-ot-2.1.1/projects/css-projects/ant-scripts/temp/temp20151022130204394 [echo] ***************************************************************** build-init: preprocess.init: [echo] ***************************************************************** [echo] * input = /home/lingeringcode/dita-ot-2.1.1/projects/css-projects/understanding_css.ditamap [echo] ***************************************************************** gen-list: [gen-list] Failed to read print transtypes from configuration, using defaults. [gen-list] Using Xerces grammar pool for DTD and schema caching. [gen-list] Processing file:/home/lingeringcode/dita-ot-2.1.1/projects/css-projects/understanding_css.ditamap BUILD FAILED /home/lingeringcode/dita-ot-2.1.1/projects/css-projects/ant-scripts/ant_grid_web_css.xml:24: The following error occurred while executing this line: /home/lingeringcode/dita-ot-2.1.1/build.xml:42: The following error occurred while executing this line: /home/lingeringcode/dita-ot-2.1.1/plugins/org.dita.base/build_preprocess.xml:78: Failed to run pipeline: Failed to load messages configuration file: Message configuration file not found
现在,它正在报告“失败的管道”+无法加载某些配置文件。有什么想法吗?
答案 0 :(得分:1)
这是重要的信息:
java.lang.ClassNotFoundException: org.dita.dost.module.GenMapAndTopicListModule
这表示缺少dost.jar。您必须将DITA库传递给Ant,否则脚本不起作用。
您可以在文档Building output using Ant中阅读如何调用Ant。
也许您根本不需要使用Ant调用转换。 dita
命令具有args.css
参数,可能会执行您要实现的操作。请查看Ant parameters: Common HTML-based transformations。