build_template.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Copyright © 2005 by Idiom Technologies, Inc. All rights reserved.
  4. IDIOM is a registered trademark of Idiom Technologies, Inc. and WORLDSERVER
  5. and WORLDSTART are trademarks of Idiom Technologies, Inc. All other
  6. trademarks are the property of their respective owners.
  7. IDIOM TECHNOLOGIES, INC. IS DELIVERING THE SOFTWARE "AS IS," WITH
  8. ABSOLUTELY NO WARRANTIES WHATSOEVER, WHETHER EXPRESS OR IMPLIED, AND IDIOM
  9. TECHNOLOGIES, INC. DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
  10. BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  11. PURPOSE AND WARRANTY OF NON-INFRINGEMENT. IDIOM TECHNOLOGIES, INC. SHALL NOT
  12. BE LIABLE FOR INDIRECT, INCIDENTAL, SPECIAL, COVER, PUNITIVE, EXEMPLARY,
  13. RELIANCE, OR CONSEQUENTIAL DAMAGES (INCLUDING BUT NOT LIMITED TO LOSS OF
  14. ANTICIPATED PROFIT), ARISING FROM ANY CAUSE UNDER OR RELATED TO OR ARISING
  15. OUT OF THE USE OF OR INABILITY TO USE THE SOFTWARE, EVEN IF IDIOM
  16. TECHNOLOGIES, INC. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  17. Idiom Technologies, Inc. and its licensors shall not be liable for any
  18. damages suffered by any person as a result of using and/or modifying the
  19. Software or its derivatives. In no event shall Idiom Technologies, Inc.'s
  20. liability for any damages hereunder exceed the amounts received by Idiom
  21. Technologies, Inc. as a result of this transaction.
  22. These terms and conditions supersede the terms and conditions in any
  23. licensing agreement to the extent that such terms and conditions conflict
  24. with those set forth herein.
  25. -->
  26. <project xmlns:dita="http://dita-ot.sourceforge.net" name="dita.build" basedir=".">
  27. <target name="dita2pdf2.init">
  28. <dita-ot-fail id="PDFX012F">
  29. <condition>
  30. <and>
  31. <isset property="pdf.formatter"/>
  32. <dita:extension id="dita.conductor.pdf2.formatter.check" behavior="org.dita.dost.platform.CheckTranstypeAction"
  33. property="pdf.formatter"/>
  34. </and>
  35. </condition>
  36. <param name="1" value="${pdf.formatter}"/>
  37. </dita-ot-fail>
  38. <dita-ot-fail id="DOTA066F">
  39. <condition>
  40. <and>
  41. <isset property="args.xsl.pdf" />
  42. <not>
  43. <available file="${args.xsl.pdf}" type="file" />
  44. </not>
  45. </and>
  46. </condition>
  47. <param name="1" location="${args.xsl.pdf}"/>
  48. </dita-ot-fail>
  49. <property name="preprocess.copy-image.skip" value="true"/>
  50. <condition property="args.rellinks" value="nofamily">
  51. <not><isset property="args.rellinks"/></not>
  52. </condition>
  53. </target>
  54. <target name="dita2pdf" depends="dita2pdf2"/>
  55. <target name="dita2pdf2" depends="dita2pdf2.init, build-init, preprocess, map2pdf2, topic2pdf2"/>
  56. <target name="transform.topic2pdf.init">
  57. <property name="pdf2.temp.dir" value="${dita.temp.dir}"/>
  58. <property name="customization.dir" value="${dita.plugin.org.dita.pdf2.dir}/Customization"/>
  59. <property file="${customization.dir}/build.properties"/>
  60. <condition property="pdf2.i18n.skip" value="true">
  61. <and>
  62. <isset property="org.dita.pdf2.i18n.enabled"/>
  63. <isfalse value="${org.dita.pdf2.i18n.enabled}"/>
  64. </and>
  65. </condition>
  66. <loadfile property="default.locale">
  67. <string>${default.language}</string>
  68. <filterchain>
  69. <tokenfilter>
  70. <replaceregex pattern="-" replace="_" flags="gi"/>
  71. </tokenfilter>
  72. </filterchain>
  73. </loadfile>
  74. <property name="lib.dir" value="${dita.dir}/lib"/>
  75. <property name="fo.lib.dir" value="${dita.plugin.org.dita.pdf2.dir}/lib"/>
  76. <property name="merged.file" value="${dita.map.filename.root}_MERGED.xml"/>
  77. <!-- configure FO engines -->
  78. <!-- default is FOP. Can be changed here, or with pdf.formatter property. -->
  79. <property name="pdf.formatter" value="fop"/>
  80. <property name="artwork.dir" value="${pdf2.temp.dir}"/>
  81. <condition property="file.protocol.prefix" value="file://">
  82. <os family="unix"/>
  83. </condition>
  84. <condition property="file.protocol.prefix" value="file:/">
  85. <not><isset property="file.protocol.prefix"/></not>
  86. </condition>
  87. <property name="xml.catalog.files" value="${customization.dir}/catalog.xml;${dita.plugin.org.dita.pdf2.dir}/cfg/catalog.xml;${dita.dir}/catalog-dita.xml"/>
  88. <property name="xsl.dir" value="${dita.plugin.org.dita.pdf2.dir}/xsl"/>
  89. <property name="xsl.fo.dir" value="${dita.plugin.org.dita.pdf2.dir}/xsl/fo"/>
  90. <property name="xsl.common.dir" value="${dita.plugin.org.dita.pdf2.dir}/xsl/common"/>
  91. <property name="cfg.dir" value="${dita.plugin.org.dita.pdf2.dir}/cfg"/>
  92. <property name="cfg.fo.dir" value="${dita.plugin.org.dita.pdf2.dir}/cfg/fo"/>
  93. <property name="cfg.common.dir" value="${dita.plugin.org.dita.pdf2.dir}/cfg/common"/>
  94. <path id="project.class.path">
  95. <pathelement path="${java.class.path}"/>
  96. <pathelement location="${lib.dir}/saxon.jar"/>
  97. <pathelement location="${lib.dir}/saxon-dom.jar"/>
  98. <pathelement location="${lib.dir}/resolver.jar"/>
  99. <pathelement location="${lib.dir}/icu4j.jar"/>
  100. <pathelement location="${fo.lib.dir}/fo.jar"/>
  101. </path>
  102. </target>
  103. <target name="topic2pdf2" if="noMap">
  104. <antcall target="preview.topic.pdf"/>
  105. </target>
  106. <target name="preview.topic.pdf"
  107. depends="transform.topic2pdf.init,
  108. preview.topic.pdf.init,
  109. transform.topic2pdf"/>
  110. <target name="preview.topic.pdf.init">
  111. <property name="inputFile" location="${dita.temp.dir}/${user.input.file}"/>
  112. <!--property name="outputFile" location="${dita.map.output.dir}/${dita.topic.filename.root}.pdf"/-->
  113. <property name="outputFile.base" value="${dita.topic.filename.root}"/>
  114. <property name="artworkPrefix" value="${artwork.dir}"/>
  115. </target>
  116. <target name="map2pdf2" unless="noMap">
  117. <dirname property="dita.temp.dir.fullpath" file="${dita.temp.dir}${file.separator}dummy.file"/>
  118. <pipeline message="topicmerge" taskname="topic-merge"
  119. inputmap="${dita.temp.dir.fullpath}${file.separator}${user.input.file}"
  120. tempdir="${dita.temp.dir.fullpath}">
  121. <module class="org.dita.dost.module.TopicMergeModule">
  122. <param name="output" location="${dita.temp.dir.fullpath}${file.separator}${dita.map.filename.root}_MERGED.xml"/>
  123. <param name="style" location="${dita.plugin.org.dita.pdf2.dir}/xsl/common/topicmerge.xsl"/>
  124. </module>
  125. </pipeline>
  126. <antcall target="publish.map.pdf"/>
  127. </target>
  128. <target name="publish.map.pdf"
  129. depends="transform.topic2pdf.init,
  130. publish.map.pdf.init,
  131. transform.topic2pdf"/>
  132. <target name="publish.map.pdf.init">
  133. <property name="inputFile" location="${dita.temp.dir}/${merged.file}"/>
  134. <!--property name="outputFile" location="${dita.map.output.dir}/${dita.map.filename.root}.pdf"/-->
  135. <property name="outputFile.base" value="${dita.map.filename.root}"/>
  136. <property name="artworkPrefix" value="${artwork.dir}"/>
  137. </target>
  138. <target name="transform.topic2fo"
  139. depends="transform.topic2fo.init,
  140. transform.topic2fo.index,
  141. transform.topic2fo.main,
  142. transform.topic2fo.i18n"/>
  143. <target name="transform.topic2fo.init"
  144. dita:extension="depends org.dita.dost.platform.InsertDependsAction"
  145. dita:depends="{depend.org.dita.pdf2.init.pre}">
  146. <taskdef name="detect-lang" classname="com.suite.sol.ditaot.DetectLang"
  147. classpathref="project.class.path"/>
  148. <taskdef name="gen-variable" classname="org.dita.dost.pdf2.VariableFileTask"
  149. classpathref="project.class.path"/>
  150. <makeurl file="${inputFile}" property="inputFile.url" validate="true"/>
  151. <!-- Set document.locale from xml:lang -->
  152. <!-- The map takes precedence, followed by the first topic -->
  153. <detect-lang documentPath="${inputFile.url}"/>
  154. <tempfile property="variable.file" destdir="${dita.temp.dir}" prefix="strings." suffix=".xml"/>
  155. <gen-variable file="${variable.file}">
  156. <fileset dir="${customization.dir}/common/vars" erroronmissingdir="false">
  157. <include name="*.xml"/>
  158. </fileset>
  159. </gen-variable>
  160. <condition property="variable.file.exists">
  161. <available file="${variable.file}" />
  162. </condition>
  163. <condition property="document.locale" value="${default.locale}">
  164. <not><isset property="document.locale"/></not>
  165. </condition>
  166. <!-- WS runtime properties -->
  167. <property file="${cfg.common.dir}/properties/${document.locale}.properties"/>
  168. <condition property="document.language" value="${default.language}">
  169. <not><isset property="document.language"/></not>
  170. </condition>
  171. <echo level="info">Using document.locale=${document.locale}</echo>
  172. <condition property="args.bookmark.style" value="">
  173. <not><isset property="args.bookmark.style"/></not>
  174. </condition>
  175. <condition property="args.chapter.layout" value="">
  176. <not><isset property="args.chapter.layout"/></not>
  177. </condition>
  178. <condition property="args.draft" value="no">
  179. <not><isset property="args.draft"/></not>
  180. </condition>
  181. <condition property="publish.required.cleanup" value="${args.draft}">
  182. <and>
  183. <not><isset property="publish.required.cleanup"/></not>
  184. <isset property="args.draft"/>
  185. </and>
  186. </condition>
  187. <condition property="args.gen.task.lbl" value="">
  188. <not><isset property="args.gen.task.lbl"/></not>
  189. </condition>
  190. <!-- use customized xsl file for pdf transform.-->
  191. <condition property="temp.transformation.file" value="${args.xsl.pdf}">
  192. <and>
  193. <isset property="args.xsl.pdf"/>
  194. <available file="${args.xsl.pdf}" type="file"/>
  195. </and>
  196. </condition>
  197. <condition property="temp.transformation.file" value="${dita.plugin.org.dita.pdf2.dir}/${args.xsl.pdf}">
  198. <and>
  199. <not><isset property="temp.transformation.file"/></not>
  200. <isset property="args.xsl.pdf"/>
  201. </and>
  202. </condition>
  203. <condition property="args.bookmap-order" value="discard">
  204. <not><isset property="args.bookmap-order"/></not>
  205. </condition>
  206. <condition property="args.figurelink.style" value="NUMTITLE">
  207. <not><isset property="args.figurelink.style"/></not>
  208. </condition>
  209. <condition property="args.tablelink.style" value="NUMTITLE">
  210. <not><isset property="args.tablelink.style"/></not>
  211. </condition>
  212. </target>
  213. <target name="transform.topic2fo.index">
  214. <taskdef classname="com.idiominc.ws.opentopic.fo.index2.IndexPreprocessorTask"
  215. name="index-preprocess" classpathref="project.class.path"/>
  216. <condition property="index.config.file" value="${customization.dir}/common/index/${document.locale}.xml">
  217. <and>
  218. <not><isset property="index.config.file"/></not>
  219. <available file="${customization.dir}/common/index/${document.locale}.xml"/>
  220. </and>
  221. </condition>
  222. <condition property="index.config.file" value="${cfg.dir}/common/index/${document.locale}.xml">
  223. <and>
  224. <not><isset property="index.config.file"/></not>
  225. <available file="${cfg.dir}/common/index/${document.locale}.xml"/>
  226. </and>
  227. </condition>
  228. <condition property="index.config.file" value="${customization.dir}/common/index/${document.language}.xml">
  229. <and>
  230. <not><isset property="index.config.file"/></not>
  231. <available file="${customization.dir}/common/index/${document.language}.xml"/>
  232. </and>
  233. </condition>
  234. <condition property="index.config.file" value="${cfg.dir}/common/index/${document.language}.xml">
  235. <and>
  236. <not><isset property="index.config.file"/></not>
  237. <available file="${cfg.dir}/common/index/${document.language}.xml"/>
  238. </and>
  239. </condition>
  240. <condition property="index.config.file" value="${cfg.dir}/common/index/${default.language}.xml">
  241. <not><isset property="index.config.file"/></not>
  242. </condition>
  243. <index-preprocess input="${inputFile.url}" output="${dita.temp.dir}/stage1.xml"
  244. indexConfig="${index.config.file}" locale="${document.locale}"
  245. catalogs="${xml.catalog.files}"/>
  246. </target>
  247. <target name="transform.topic2fo.main">
  248. <!--makeurl seems to output file:/C: style instead of file:///C:, but xep, fop, and ah all accept it.-->
  249. <makeurl property="artworkPrefixUrl" file="${artworkPrefix}"/>
  250. <makeurl property="dita.map.output.dir.url" file="${pdf2.temp.dir}" validate="no"/>
  251. <makeurl property="work.dir.url" file="${dita.temp.dir}" validate="no"/>
  252. <makeurl property="customization.dir.url" file="${customization.dir}" validate="no"/>
  253. <makeurl property="user.input.dir.url" file="${user.input.dir}"/>
  254. <makeurl property="variable.file.url" file="${variable.file}" validate="no"/>
  255. <xslt style="${temp.transformation.file}"
  256. in="${dita.temp.dir}/stage1.xml"
  257. out="${dita.temp.dir}/stage2.fo">
  258. <param name="locale" expression="${document.locale}"/>
  259. <param name="customizationDir.url" expression="${customization.dir.url}" if="customization.dir"/>
  260. <param name="input.dir.url" expression="${user.input.dir.url}"/>
  261. <param name="DRAFT" expression="${args.draft}"/>
  262. <param name="output.dir.url" expression="${dita.map.output.dir.url}"/>
  263. <param name="work.dir.url" expression="${work.dir.url}"/>
  264. <param name="artworkPrefix" expression="${artworkPrefixUrl}"/>
  265. <param name="publishRequiredCleanup" expression="${publish.required.cleanup}"/>
  266. <param name="artLabel" expression="${args.artlbl}" if="args.artlbl"/>
  267. <param name="antArgsBookmarkStyle" expression="${args.bookmark.style}"/>
  268. <param name="antArgsChapterLayout" expression="${args.chapter.layout}"/>
  269. <param name="include.rellinks" expression="${include.rellinks}"/>
  270. <param name="antArgsGenerateTaskLabels" expression="${args.gen.task.lbl}"/>
  271. <param name="pdfFormatter" expression="${pdf.formatter}"/>
  272. <param name="bookmap-order" expression="${args.bookmap-order}"/>
  273. <param name="figurelink.style" expression="${args.figurelink.style}"/>
  274. <param name="tablelink.style" expression="${args.tablelink.style}"/>
  275. <param name="variableFiles.url" expression="${variable.file.url}" if="variable.file.exists"/>
  276. <param name="defaultLanguage" expression="${default.language}"/>
  277. <dita:extension id="dita.conductor.pdf2.param" behavior="org.dita.dost.platform.InsertAction"/>
  278. <xmlcatalog>
  279. <catalogpath path="${xml.catalog.files}"/>
  280. </xmlcatalog>
  281. </xslt>
  282. </target>
  283. <target name="transform.topic2fo.i18n"
  284. depends="transform.topic2fo.i18n.filter,
  285. transform.topic2fo.i18n.no-filter"/>
  286. <target name="transform.topic2fo.i18n.filter" unless="pdf2.i18n.skip">
  287. <taskdef classname="com.idiominc.ws.opentopic.fo.i18n.PreprocessorTask" name="i18n-preprocess"
  288. classpathref="project.class.path"/>
  289. <condition property="i18n.config.file" value="${customization.dir}/fo/i18n/${document.locale}.xml">
  290. <and>
  291. <not><isset property="i18n.config.file"/></not>
  292. <available file="${customization.dir}/fo/i18n/${document.locale}.xml"/>
  293. </and>
  294. </condition>
  295. <condition property="i18n.config.file" value="${cfg.fo.dir}/i18n/${document.locale}.xml">
  296. <and>
  297. <not><isset property="i18n.config.file"/></not>
  298. <available file="${cfg.fo.dir}/i18n/${document.locale}.xml"/>
  299. </and>
  300. </condition>
  301. <condition property="i18n.config.file" value="${customization.dir}/fo/i18n/${document.language}.xml">
  302. <and>
  303. <not><isset property="i18n.config.file"/></not>
  304. <available file="${customization.dir}/fo/i18n/${document.language}.xml"/>
  305. </and>
  306. </condition>
  307. <condition property="i18n.config.file" value="${cfg.fo.dir}/i18n/${document.language}.xml">
  308. <and>
  309. <not><isset property="i18n.config.file"/></not>
  310. <available file="${cfg.fo.dir}/i18n/${document.language}.xml"/>
  311. </and>
  312. </condition>
  313. <condition property="i18n.config.file" value="${cfg.fo.dir}/i18n/${default.language}.xml">
  314. <not><isset property="i18n.config.file"/></not>
  315. </condition>
  316. <i18n-preprocess input="${dita.temp.dir}/stage2.fo" output="${pdf2.temp.dir}/topic.fo"
  317. config="${i18n.config.file}"
  318. style="${xsl.fo.dir}/i18n-postprocess.xsl">
  319. <xmlcatalog>
  320. <catalogpath path="${xml.catalog.files}"/>
  321. </xmlcatalog>
  322. </i18n-preprocess>
  323. </target>
  324. <target name="transform.topic2fo.i18n.no-filter" if="pdf2.i18n.skip">
  325. <echo level="info">Skip I18N font processing.</echo>
  326. <move file="${dita.temp.dir}/stage2.fo" tofile="${pdf2.temp.dir}/topic.fo"/>
  327. </target>
  328. <target name="transform.topic2pdf"
  329. dita:extension="depends org.dita.dost.platform.InsertDependsAction"
  330. dita:depends="copyCoreArtwork,
  331. transform.topic2fo,
  332. {depend.org.dita.pdf2.format.pre},
  333. transform.fo2pdf,
  334. {depend.org.dita.pdf2.format.post}"/>
  335. <target name="transform.fo2pdf"
  336. dita:extension="depends org.dita.dost.platform.InsertDependsAction"
  337. dita:depends="{depend.org.dita.pdf2.format}"/>
  338. <target name="copyCoreArtwork">
  339. <copy todir="${artwork.dir}/Configuration/OpenTopic" failonerror="false">
  340. <fileset dir="${dita.plugin.org.dita.pdf2.dir}" includes="cfg/common/artwork/**/*.*"/>
  341. </copy>
  342. <copy todir="${artwork.dir}/Customization/OpenTopic" failonerror="false">
  343. <fileset dir="${customization.dir}" includes="common/artwork/**/*.*"/>
  344. </copy>
  345. </target>
  346. </project>