code-srv-test/dita-ot-3.6/plugins/org.dita.base/build_preprocess.xml
2021-03-23 22:38:58 +00:00

393 lines
No EOL
18 KiB
XML

<?xml version="1.0" encoding="UTF-8"?><!--
This file is part of the DITA Open Toolkit project.
Copyright 2006 IBM Corporation
See the accompanying LICENSE file for applicable license.
--><project xmlns:dita="http://dita-ot.sourceforge.net" xmlns:if="ant:if" xmlns:unless="ant:unless" name="ditaot-preprocess">
<!-- Set to "true" if you get out-of-memory errors during preprocess
while processing very large (thousands of files) document sets. -->
<condition property="dita.preprocess.reloadstylesheet" value="${conserve-memory}">
<and>
<not><isset property="dita.preprocess.reloadstylesheet"/></not>
<isset property="conserve-memory"/>
</and>
</condition>
<target name="preprocess" depends="preprocess.init,ditaval-merge,gen-list,debug-filter,mapref,branch-filter,keyref,copy-to,conrefpush,conref,profile,topic-fragment,chunk,move-meta-entries,maplink,topicpull,clean-map,clean-preprocess,copy-files" description="Preprocessing ended"/>
<target name="preprocess.init">
<dita-ot-fail id="DOTA002F">
<condition>
<not><isset property="args.input"/></not>
</condition>
</dita-ot-fail>
<condition property="clean-preprocess.use-result-filename" value="true">
<or>
<isset property="result.rewrite-rule.class"/>
<isset property="result.rewrite-rule.xsl"/>
</or>
</condition>
<basename property="dita.input.filename" file="${args.input}"/>
<pathconvert property="dita.map.filename.root">
<path path="${dita.input.filename}"/>
<chainedmapper>
<mapper type="flatten"/>
<mapper type="regexp" from="^(.+)(\..+?)$$" to="\1"/>
</chainedmapper>
</pathconvert>
<property name="dita.topic.filename.root" value="${dita.map.filename.root}"/>
<echo level="info">*****************************************************************</echo>
<echo level="info">* input = ${args.input}</echo>
<echo level="info">* resources = ${args.resources}</echo>
<echo level="info">*****************************************************************</echo>
</target>
<!-- clean-temp
Remove anything in the ${dita.temp.dir} directory before starting. -->
<target name="clean-temp" unless="clean-temp.skip" depends="" description="Clean temp directory">
<delete includeemptydirs="true" failonerror="no">
<fileset dir="${dita.temp.dir}"/>
</delete>
</target>
<target name="ditaval-merge" depends="" description="Merge DITAVAL files into temporary file">
<pipeline message="Preprocess and merge ditavals" taskname="ditaval-merge" if:set="args.filter">
<module class="org.dita.dost.module.MergeDitavalModule">
<param name="ditaval" value="${args.filter}"/>
<param name="ditadir" location="${dita.dir}"/>
</module>
</pipeline>
</target>
<!-- gen-list
Create the manifest files listing which files are referenced by the input file (even indirectly). -->
<target name="gen-list" depends="" unless="preprocess.gen-list.skip" description="Generate file list">
<pipeline message="Generate list." taskname="gen-list" inputmap="${args.input}">
<module class="org.dita.dost.module.GenMapAndTopicListModule">
<param name="resources" value="${args.resources}" if:set="args.resources"/>
<param name="inputdir" location="${args.input.dir}" if:set="args.input.dir"/>
<param name="ditadir" location="${dita.dir}"/>
<param name="validate" value="${validate}"/>
<param name="generatecopyouter" value="${generate.copy.outer}"/>
<param name="outercontrol" value="${outer.control}"/>
<param name="onlytopicinmap" value="${onlytopic.in.map}"/>
<param name="crawl" value="${link-crawl}" if:set="link-crawl"/>
<param name="outputdir" location="${dita.output.dir}"/>
<param name="transtype" value="${transtype}"/>
<param name="gramcache" value="${args.grammar.cache}"/>
<param name="setsystemid" value="${args.xml.systemid.set}"/>
<param name="profiling.enable" value="${filter-on-parse}" unless:set="filter-on-parse"/>
<param name="generate-debug-attributes" value="${generate-debug-attributes}" if:set="generate-debug-attributes"/>
<param name="processing-mode" value="${processing-mode}" if:set="processing-mode"/>
</module>
</pipeline>
</target>
<!-- debug-filter
Copy input files to ${dita.temp.dir} tree.
While copying, populate default attributes like @class,
add @xtrf and @xtrc and filter out elements according to valfile, if any. -->
<target name="debug-filter" depends="" unless="preprocess.debug-filter.skip" description="Debug and filter input files">
<pipeline message="Debug and filtering." taskname="filter">
<module class="org.dita.dost.module.DebugAndFilterModule">
<param name="ditadir" location="${dita.dir}"/>
<param name="validate" value="${validate}"/>
<param name="transtype" value="${transtype}"/>
<param name="gramcache" value="${args.grammar.cache}"/>
<param name="setsystemid" value="${args.xml.systemid.set}"/>
<param name="profiling.enable" value="${filter-on-parse}" unless:set="filter-on-parse"/>
<param name="generate-debug-attributes" value="${generate-debug-attributes}" if:set="generate-debug-attributes"/>
<param name="processing-mode" value="${processing-mode}" if:set="processing-mode"/>
</module>
</pipeline>
<job-property dir="${dita.temp.dir}"/>
<dirname property="_dita.map.output.dir" file="${dita.output.dir}/${user.input.file}"/>
<dirname property="_dita.map.temp.dir" file="${dita.temp.dir}/${user.input.file}"/>
<property name="dita.map.output.dir" location="${_dita.map.output.dir}/${uplevels}"/>
<local name="inputMapPath"/>
<pathconvert property="inputMapPath">
<ditafileset format="ditamap" input="true"/>
</pathconvert>
<condition property="noMap">
<equals arg1="${inputMapPath}" arg2=""/>
</condition>
</target>
<!-- profile -->
<target name="profile" depends="profile-check" unless="preprocess.profile.skip" description="Profile input files">
<pipeline message="Profile filtering." taskname="profile" inputmap="${args.input}">
<module class="org.dita.dost.module.FilterModule">
<ditafileset format="dita"/>
<ditafileset format="ditamap" input="true"/>
<param name="ditaval" location="${dita.input.valfile}" if:set="dita.input.valfile"/>
<param name="transtype" value="${transtype}"/>
</module>
</pipeline>
<local name="inputTopicPath"/>
<pathconvert property="inputTopicPath">
<ditafileset format="dita"/>
</pathconvert>
<condition property="noTopic">
<equals arg1="${inputTopicPath}" arg2=""/>
</condition>
</target>
<target name="profile-check">
<condition property="preprocess.profile.skip">
<istrue value="${filter-on-parse}"/>
</condition>
</target>
<target name="branch-filter">
<pipeline taskname="branch-filter" message="Filter branches">
<module class="org.dita.dost.module.BranchFilterModule"/>
</pipeline>
</target>
<!-- conref push
Push information to the specified target -->
<target name="conrefpush" depends="" unless="preprocess.conrefpush.skip" description="Resolve conref push">
<pipeline message="Resolve conref push." taskname="conref-push">
<module class="org.dita.dost.module.ConrefPushModule">
<ditafileset format="dita"/>
<ditafileset format="ditamap" input="true"/>
</module>
</pipeline>
</target>
<!-- move-meta-entries
Push information from <topicmeta> in the map into the corresponding topics and
pull metadata (such as navtitle) into the map from the referenced topics. -->
<target name="move-meta-entries" depends="" unless="preprocess.move-meta-entries.skip" description="Move metadata entries">
<pipeline message="Move metadata entries." taskname="move-meta" inputmap="${user.input.file}">
<module class="org.dita.dost.module.MoveMetaModule">
<param name="style" location="${dita.plugin.org.dita.base.dir}/xsl/preprocess/mappull.xsl"/>
<param name="conserve-memory" expression="${conserve-memory}" if:set="conserve-memory"/>
</module>
</pipeline>
</target>
<!-- conref
Pull elements referenced by conref into their correct place. -->
<target name="conref" depends="" unless="preprocess.conref.skip" description="Resolve conref in input files">
<property name="dita.preprocess.reloadstylesheet.conref" value="${dita.preprocess.reloadstylesheet}"/>
<makeurl property="exportfile.url" file="${dita.temp.dir}/export.xml" validate="false"/>
<pipeline message="Resolve conref in input files" taskname="conref">
<xslt basedir="${dita.temp.dir}" reloadstylesheet="${dita.preprocess.reloadstylesheet.conref}" style="${dita.plugin.org.dita.base.dir}/xsl/preprocess/conref.xsl" filenameparameter="file-being-processed" parallel="${parallel}">
<ditafileset conref="true"/>
<param name="EXPORTFILE" expression="${exportfile.url}"/>
<param name="TRANSTYPE" expression="${transtype}"/>
</xslt>
</pipeline>
</target>
<target name="topic-fragment" depends="" description="Normalize same topic fragment identifiers and table column names, and resolve coderef">
<pipeline message="Resolve topic fragment." taskname="topic-fragment">
<sax format="dita" parallel="${parallel}">
<filter class="org.dita.dost.writer.TopicFragmentFilter">
<param name="attributes" value="href"/>
</filter>
<filter class="org.dita.dost.writer.NormalizeTableFilter">
<param name="processing-mode" value="${processing-mode}" if:set="processing-mode"/>
</filter>
<filter class="org.dita.dost.writer.NormalizeSimpleTableFilter"/>
<filter class="org.dita.dost.writer.CoderefResolver" unless:set="preprocess.coderef.skip"/>
<filter class="org.dita.dost.writer.NormalizeCodeblock" unless:set="preprocess.normalize-codeblock.skip"/>
</sax>
</pipeline>
</target>
<!-- mapref
Produce a logical super-map from the map references
(topicref with format="ditamap") in the input map. -->
<target name="mapref" depends="mapref-check" unless="preprocess.mapref.skip" description="Resolve mapref in ditamap">
<property name="dita.preprocess.reloadstylesheet.mapref" value="${dita.preprocess.reloadstylesheet}"/>
<dirname property="mapref.workdir" file="${dita.temp.dir}/${user.input.file}"/>
<pipeline message="Resolve mapref in ditamap" taskname="mapref">
<module class="org.dita.dost.module.MaprefModule" parallel="false">
<param name="style" location="${dita.plugin.org.dita.base.dir}/xsl/preprocess/mapref.xsl"/>
<ditafileset format="ditamap"/>
</module>
</pipeline>
</target>
<target name="mapref-check">
</target>
<!-- keyref
Resolve keyref using key definition in ditamap-->
<target name="keyref" depends="" unless="preprocess.keyref.skip" description="Resolve keyref">
<pipeline message="Resolve keyref." taskname="keyref">
<module class="org.dita.dost.module.KeyrefModule" parallel="${parallel}">
<param name="transtype" value="${transtype}"/>
</module>
</pipeline>
<pipeline message="Resolve mapref in ditamap" taskname="mapref">
<xslt basedir="${dita.temp.dir}" reloadstylesheet="${dita.preprocess.reloadstylesheet.mapref}" style="${dita.plugin.org.dita.base.dir}/xsl/preprocess/mapref.xsl" filenameparameter="file-being-processed">
<ditafileset format="ditamap" input="true"/>
<param name="TRANSTYPE" expression="${transtype}"/>
<param name="child-topicref-warning" expression="false"/>
<param name="keep-submap-href" expression="false"/>
<xmlcatalog refid="dita.catalog"/>
</xslt>
</pipeline>
</target>
<target name="copy-to">
<pipeline message="Resolve copy-to." taskname="copy-to">
<module class="org.dita.dost.module.CopyToModule">
<param name="force-unique" value="${force-unique}" if:set="force-unique"/>
</module>
</pipeline>
</target>
<!-- chunk
Assemble virtual supertopics based on chunk attribute in map. -->
<target name="chunk" depends="chunk-check" unless="preprocess.chunk.skip" description="Process chunks">
<pipeline message="Process chunks." taskname="chunk" inputmap="${user.input.file}">
<module class="org.dita.dost.module.ChunkModule" parallel="false">
<param name="transtype" value="${transtype}"/>
<param name="root-chunk-override" value="${root-chunk-override}" if:set="root-chunk-override"/>
</module>
</pipeline>
<local name="inputTopicPath"/>
<pathconvert property="inputTopicPath">
<ditafileset format="dita"/>
</pathconvert>
<condition property="noTopic">
<equals arg1="${inputTopicPath}" arg2=""/>
</condition>
</target>
<target name="chunk-check">
<condition property="preprocess.chunk.skip">
<isset property="noMap"/>
</condition>
</target>
<!-- maplink
Collect all links from maps and push them into topics. -->
<target name="maplink" depends="maplink-check" unless="preprocess.maplink.skip" description="Find and generate related link information">
<property name="dita.preprocess.reloadstylesheet.maplink" value="${dita.preprocess.reloadstylesheet}"/>
<pipeline message="Move related links" taskname="maplink" inputmap="${user.input.file}">
<module class="org.dita.dost.module.MoveLinksModule">
<param name="style" location="${dita.plugin.org.dita.base.dir}/xsl/preprocess/maplink.xsl"/>
<param name="include.rellinks" expression="${include.rellinks}" if:set="include.rellinks"/>
</module>
</pipeline>
</target>
<target name="maplink-check">
<condition property="preprocess.maplink.skip">
<isset property="noMap"/>
</condition>
</target>
<!-- topicpull
Populate link text for links within topics (xref, link). -->
<target name="topicpull" depends="topicpull-check" unless="preprocess.topicpull.skip" description="Pull metadata for link and xref element">
<property name="dita.preprocess.reloadstylesheet.topicpull" value="${dita.preprocess.reloadstylesheet}"/>
<pipeline message="Pull metadata for link and xref element" taskname="topicpull">
<xslt basedir="${dita.temp.dir}" reloadstylesheet="${dita.preprocess.reloadstylesheet.topicpull}" style="${dita.plugin.org.dita.base.dir}/xsl/preprocess/topicpull.xsl" parallel="${parallel}">
<ditafileset format="dita" processingRole="normal"/>
<param name="TABLELINK" expression="${args.tablelink.style}" if:set="args.tablelink.style"/>
<param name="FIGURELINK" expression="${args.figurelink.style}" if:set="args.figurelink.style"/>
<param name="ONLYTOPICINMAP" expression="${onlytopic.in.map}" if:set="onlytopic.in.map"/>
<!-- Deprecated since 2.5 -->
<param name="defaultLanguage" expression="${default.language}"/>
<param name="remove-broken-links" expression="${remove-broken-links}" if:set="remove-broken-links"/>
</xslt>
</pipeline>
</target>
<target name="topicpull-check">
<condition property="preprocess.topicpull.skip">
<isset property="noTopic"/>
</condition>
</target>
<!-- Clean maps from processing time -->
<target name="clean-map" depends="clean-map-check" unless="preprocess.clean-map-check.skip" description="Clean ditamap">
<property name="dita.preprocess.reloadstylesheet.clean-map" value="${dita.preprocess.reloadstylesheet}"/>
<pipeline message="Clean ditamap" taskname="clean-map">
<xslt basedir="${dita.temp.dir}" reloadstylesheet="${dita.preprocess.reloadstylesheet.clean-map}" style="${dita.plugin.org.dita.base.dir}/xsl/preprocess/clean-map.xsl">
<ditafileset format="ditamap" input="true"/>
<xmlcatalog refid="dita.catalog"/>
</xslt>
</pipeline>
</target>
<target name="clean-map-check">
<condition property="preprocess.clean-map-check.skip">
<isset property="noMap"/>
</condition>
</target>
<!-- Clean tempory files at the end of preprocess -->
<target name="clean-preprocess" unless="preprocess.clean-preprocess.skip" description="Clean preprocess">
<pipeline message="Clean preprocess" taskname="clean-preprocess">
<param name="use-result-filename" value="${clean-preprocess.use-result-filename}" if:set="clean-preprocess.use-result-filename"/>
<module class="org.dita.dost.module.CleanPreprocessModule" parallel="${parallel}">
<param name="result.rewrite-rule.xsl" value="${result.rewrite-rule.xsl}" if:set="result.rewrite-rule.xsl"/>
<param name="result.rewrite-rule.class" value="${result.rewrite-rule.class}" if:set="result.rewrite-rule.class"/>
</module>
</pipeline>
</target>
<!-- copy-files
Copy files to the output directory. -->
<target name="copy-files" depends="copy-image,copy-html,copy-flag" unless="preprocess.copy-files.skip"/>
<target name="copy-image" unless="preprocess.copy-image.skip" depends="" description="Copy image files">
<condition property="copy-image.todir" value="${_dita.map.output.dir}/${uplevels}" else="${dita.output.dir}">
<equals arg1="${generate.copy.outer}" arg2="1"/>
</condition>
<copy todir="${copy-image.todir}" failonerror="false" overwrite="true">
<ditafileset format="image"/>
<jobmapper/>
</copy>
</target>
<target name="copy-html" depends="" unless="preprocess.copy-html.skip" description="Copy html files">
<condition property="copy-html.todir" value="${_dita.map.output.dir}/${uplevels}" else="${dita.output.dir}">
<equals arg1="${generate.copy.outer}" arg2="1"/>
</condition>
<copy todir="${copy-html.todir}" failonerror="false" overwrite="true">
<ditafileset>
<excludes format="dita"/>
<excludes format="ditamap"/>
<excludes format="ditaval"/>
<excludes format="image"/>
<excludes format="coderef"/>
</ditafileset>
<jobmapper/>
</copy>
</target>
<target name="copy-flag" depends="copy-flag-check" unless="preprocess.copy-flag.skip" description="Copy flag files">
<dita-ot-copy todir="${dita.output.dir}" relativepaths="${relflagimagelist}"/>
</target>
<target name="copy-flag-check">
<job-property dir="${dita.temp.dir}"/>
<condition property="preprocess.copy-flag.skip">
<or>
<isset property="preprocess.copy-files.skip"/>
<not><isset property="dita.input.valfile"/></not>
</or>
</condition>
</target>
</project>