<?xml version="1.0" encoding="utf-8"?><!-- This file is part of the DITA Open Toolkit project hosted on 
     Sourceforge.net. See the accompanying license.txt file for 
     applicable licenses.--><!-- (c) Copyright IBM Corp. 2006 All Rights Reserved. --><project name="ditaot-preprocess" basedir=".">

  <!-- 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="false">
    <not><isset property="dita.preprocess.reloadstylesheet"></isset></not>
  </condition>

  <target name="preprocess" depends="start-preprocess,gen-list,debug-filter,copy-files,conrefpush,conref,move-meta-entries,keyref,coderef,mapref,mappull,chunk,maplink,move-links,topicpull" description="Preprocessing ended"></target>

  <!-- preprocess modules begin -->
  <target name="start-preprocess" description="Preprocessing started"></target>

  <!-- clean-temp
      Remove anything in the ${dita.temp.dir} directory before starting. -->
  <target name="clean-temp" unless="clean_temp" description="Clean temp directory">
    <delete includeemptydirs="true" failonerror="no">
      <fileset dir="${dita.temp.dir}"></fileset>
    </delete>
  </target>

  <!-- gen-list
      Create the manifest files listing which files are referenced by the input file (even indirectly). -->
  <target name="gen-list" depends="gen-list-without-flagging,gen-list-with-flagging" unless="preprocess.gen-list.skip" description="Generate file list">
  </target>

  <target name="gen-list-without-flagging" depends="gen-list-flag-check" unless="preprocess.gen-list-without-flagging.skip">
    <pipeline message="Generate list." module="GenMapAndTopicList" basedir="${basedir}" inputmap="${args.input}" tempdir="${dita.temp.dir}">
      <param name="ditadir" location="${dita.dir}"></param>
      <param name="validate" value="${validate}"></param>
      <param name="generatecopyouter" value="${generate.copy.outer}"></param>
      <param name="outercontrol" value="${outer.control}"></param>
      <param name="onlytopicinmap" value="${onlytopic.in.map}"></param>
      <param name="outputdir" location="${output.dir}"></param>
      <param name="transtype" value="${transtype}"></param>
      <param name="gramcache" value="${args.grammar.cache}"></param>
      <param name="setsystemid" value="${args.xml.systemid.set}"></param>
    </pipeline>
  </target>

  <target name="gen-list-with-flagging" depends="gen-list-flag-check" unless="preprocess.gen-list-with-flagging.skip">
    <pipeline message="Generate list." module="GenMapAndTopicList" basedir="${basedir}" inputmap="${args.input}" tempdir="${dita.temp.dir}">
      <param name="ditadir" location="${dita.dir}"></param>
      <param name="ditaval" value="${dita.input.valfile}"></param>
      <param name="validate" value="${validate}"></param>
      <param name="generatecopyouter" value="${generate.copy.outer}"></param>
      <param name="outercontrol" value="${outer.control}"></param>
      <param name="onlytopicinmap" value="${onlytopic.in.map}"></param>
      <param name="outputdir" location="${output.dir}"></param>
      <param name="transtype" value="${transtype}"></param>
      <param name="gramcache" value="${args.grammar.cache}"></param>
      <param name="setsystemid" value="${args.xml.systemid.set}"></param>
    </pipeline>
  </target>

  <target name="gen-list-flag-check">
    <!-- The apparent double-negative logic of "unless skipped"
        is so that plugins extending depend.preprocess.gen-list.pre
        can skip all gen-list processing if they choose to re-implement it themselves. -->
    <condition property="preprocess.gen-list-without-flagging.skip">
      <or>
        <isset property="preprocess.gen-list.skip"></isset>
        <isset property="dita.input.valfile"></isset>
      </or>
    </condition>
    <condition property="preprocess.gen-list-with-flagging.skip">
      <or>
        <isset property="preprocess.gen-list.skip"></isset>
        <not><isset property="dita.input.valfile"></isset></not>
      </or>
    </condition>
  </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="gen-list,debug,debug-and-filter" unless="preprocess.debug-filter.skip" description="Debug and filter input files">
    <!--<property file="${dita.temp.dir}${file.separator}dita.list" />-->
    <xmlpropertyreader file="${dita.temp.dir}${file.separator}dita.xml.properties"></xmlpropertyreader>
    <dirname property="dita.map.output.dir" file="${output.dir}${file.separator}${user.input.file}"></dirname>
    <condition property="noConref">
      <equals arg1="${conreflist}" arg2=""></equals>
    </condition>
    <condition property="noMap">
      <equals arg1="${fullditamaplist}" arg2=""></equals>
    </condition>
  	<!--
    <condition property="noTopic">
      <equals arg1="${fullditatopiclist}" arg2="" />
    </condition>
    -->
    <condition property="noImagelist">
      <equals arg1="${imagelist}" arg2=""></equals>
    </condition>
    <condition property="noHtmllist">
      <equals arg1="${htmllist}" arg2=""></equals>
    </condition>
    <condition property="noSublist">
      <equals arg1="${subtargetslist}" arg2=""></equals>
    </condition>
    <condition property="noConrefPush">
      <equals arg1="${conrefpushlist}" arg2=""></equals>
    </condition>
    <condition property="noKeyref">
      <equals arg1="${keyreflist}" arg2=""></equals>
    </condition>
  </target>

  <target name="debug" depends="debug-filter-flag-check" unless="preprocess.debug.skip" description="Debug input files">
    <pipeline message="Debug and filtering." module="DebugAndFilter" basedir="${basedir}" tempdir="${dita.temp.dir}">
      <param name="ditaext" value="${dita.extname}"></param>
      <param name="ditadir" location="${dita.dir}"></param>
      <param name="validate" value="${validate}"></param>
      <param name="transtype" value="${transtype}"></param>
      <param name="setsystemid" value="${args.xml.systemid.set}"></param>
    </pipeline>
  </target>

  <target name="debug-and-filter" depends="debug-filter-flag-check" unless="preprocess.debug-and-filter.skip" description="Debug and filter input files">
    <pipeline message="Debug and filtering." module="DebugAndFilter" basedir="${basedir}" tempdir="${dita.temp.dir}">
      <param name="ditaval" value="${dita.input.valfile}"></param>
      <param name="ditaext" value="${dita.extname}"></param>
      <param name="ditadir" location="${dita.dir}"></param>
      <param name="validate" value="${validate}"></param>
      <param name="transtype" value="${transtype}"></param>
      <param name="setsystemid" value="${args.xml.systemid.set}"></param>
    </pipeline>
  </target>

  <target name="debug-filter-flag-check">
    <!-- The apparent double-negative logic of "unless skipped"
      is so that plugins extending depend.preprocess.debug-filter.pre
      can skip all debug-filter processing if they choose to re-implement it themselves. -->
    <condition property="preprocess.debug.skip">
      <or>
        <isset property="preprocess.debug-filter.skip"></isset>
        <isset property="dita.input.valfile"></isset>
      </or>
    </condition>
    <condition property="preprocess.debug-and-filter.skip">
      <or>
        <isset property="preprocess.debug-filter.skip"></isset>
        <not><isset property="dita.input.valfile"></isset></not>
      </or>
    </condition>
  </target>
  
  <!-- conref push
      Push information to the specified target -->
  <target name="conrefpush" depends="debug-filter,conrefpush-check" unless="preprocess.conrefpush.skip" description="Resolve conref push">
    <pipeline message="Resolve conref push." module="ConrefPush" basedir="${basedir}" tempdir="${dita.temp.dir}"></pipeline>     
  </target>
  
  <target name="conrefpush-check">
    <condition property="preprocess.conrefpush.skip">
      <isset property="noConrefPush"></isset>
    </condition>
  </target>
  
  <!-- move-meta-entries
      Push information from <topicmeta> in the map into the corresponding topics. -->
  <target name="move-meta-entries" depends="debug-filter,move-meta-entries-check" unless="preprocess.move-meta-entries.skip" description="Move metadata entries">
    <pipeline message="Move metadata entries." module="MoveMeta" basedir="${basedir}" inputmap="${user.input.file}" tempdir="${dita.temp.dir}"></pipeline>
  </target>

  <target name="move-meta-entries-check">
    <condition property="preprocess.move-meta-entries.skip">
      <isset property="noMap"></isset>
    </condition>
  </target>
  
  <!-- conref
      Pull elements referenced by conref into their correct place. -->
  <target name="conref" depends="debug-filter,conrefpush,conref-check" unless="preprocess.conref.skip" description="Resolve conref in input files">
    <condition property="dita.preprocess.reloadstylesheet.conref" value="${dita.preprocess.reloadstylesheet}">
      <not><isset property="dita.preprocess.reloadstylesheet.conref"></isset></not>
    </condition>
    <xslt processor="trax" basedir="${dita.temp.dir}" destdir="${dita.temp.dir}" includesfile="${dita.temp.dir}${file.separator}${conreffile}" classpathref="dost.class.path" reloadstylesheet="${dita.preprocess.reloadstylesheet.conref}" style="${dita.script.dir}${file.separator}preprocess${file.separator}conref.xsl" filenameparameter="file-being-processed">
      <mapper type="glob" from="*" to="*.cnrf"></mapper>
      <param name="DITAEXT" expression="${dita.ext}"></param>
      <!-- added by William on 2009-06-26 for req #12014 start -->
      <param name="BASEDIR" expression="${basedir}"></param>
      <param name="TEMPDIR" expression="${dita.temp.dir}"></param>
      <param name="TRANSTYPE" expression="${transtype}"></param>
      <!-- added by William on 2009-06-26 for req #12014 end -->
      
    </xslt>
    <move todir="${dita.temp.dir}">
      <fileset dir="${dita.temp.dir}" includes="**/*.cnrf"></fileset>
      <mapper type="glob" from="*.cnrf" to="*"></mapper>
    </move>
  </target>
  
  <target name="conref-check">
    <condition property="preprocess.conref.skip">
      <isset property="noConref"></isset>
    </condition>
  </target>
  
  <!-- coderef -->
  <target name="coderef" depends="debug-filter,keyref,coderef-check" unless="preprocess.coderef.skip" description="Resolve coderef in input files">
    
    <pipeline message="Resolve coderef." module="Coderef" basedir="${basedir}" tempdir="${dita.temp.dir}"></pipeline>
      
  </target>
  
  <target name="coderef-check">
    <condition property="preprocess.coderef.skip">
      <isset property="noCoderef"></isset>
    </condition>
  </target>
  
  <!-- mapref
      Produce a logical super-map from the map references
      (topicref with format="ditamap") in the input map. -->
  <target name="mapref" depends="coderef,mapref-check" unless="preprocess.mapref.skip" description="Resolve mapref in ditamap">
    <condition property="dita.preprocess.reloadstylesheet.mapref" value="${dita.preprocess.reloadstylesheet}">
      <not><isset property="dita.preprocess.reloadstylesheet.mapref"></isset></not>
    </condition>
    <dirname property="mapref.workdir" file="${dita.temp.dir}${file.separator}${user.input.file}"></dirname>
    <xslt processor="trax" basedir="${dita.temp.dir}" destdir="${dita.temp.dir}" includesfile="${dita.temp.dir}${file.separator}${fullditamapfile}" extension=".ditamap.ref" classpathref="dost.class.path" reloadstylesheet="${dita.preprocess.reloadstylesheet.mapref}" style="${dita.script.dir}${file.separator}preprocess${file.separator}mapref.xsl">
      <param name="DITAEXT" expression="${dita.ext}" if="dita.ext"></param>
      <param name="TRANSTYPE" expression="${transtype}"></param>
      <!--Added by William on 2010-04-14 for bug:2982485 start -->
      <param name="FILEREF" expression="file:"></param>
      <!--Added by William on 2010-04-14 for bug:2982485 end -->
      
    </xslt>
    <move overwrite="true" todir="${dita.temp.dir}">
      <fileset dir="${dita.temp.dir}" includes="**/*.ditamap.ref"></fileset>
      <mapper type="glob" from="*.ditamap.ref" to="*.ditamap"></mapper>
    </move>
  </target>

  <target name="mapref-check">
    <condition property="preprocess.mapref.skip">
      <isset property="noMap"></isset>
    </condition>
  </target>
  
  <!-- keyref
       Resolve keyref using key definition in ditamap-->
  <target name="keyref" depends="move-meta-entries,keyref-check" unless="preprocess.keyref.skip" description="Resolve keyref">
    <pipeline message="Resolve keyref." module="Keyref" basedir="${basedir}" tempdir="${dita.temp.dir}">
      <param name="ditaext" value="${dita.extname}"></param>
    </pipeline>
  </target>
  
  <target name="keyref-check">
    <condition property="preprocess.keyref.skip">
      <isset property="noKeyref"></isset>
    </condition>
  </target>
    
  <!-- mappull
      Pull metadata (such as navtitle) into the map from the referenced topics. -->
  <target name="mappull" depends="mapref,mappull-check" unless="preprocess.mappull.skip" description="Pull the navtitle and topicmeta from topics to ditamap">
    <dirname property="mappull.workdir" file="${dita.temp.dir}${file.separator}${user.input.file}"></dirname>
    <condition property="dita.preprocess.reloadstylesheet.mappull" value="${dita.preprocess.reloadstylesheet}">
      <not><isset property="dita.preprocess.reloadstylesheet.mappull"></isset></not>
    </condition>
    <xslt processor="trax" basedir="${dita.temp.dir}" destdir="${dita.temp.dir}" includesfile="${dita.temp.dir}${file.separator}${fullditamapfile}" extension=".ditamap.pull" classpathref="dost.class.path" reloadstylesheet="${dita.preprocess.reloadstylesheet.mappull}" style="${dita.script.dir}${file.separator}preprocess${file.separator}mappull.xsl">
      <param name="DITAEXT" expression="${dita.ext}" if="dita.ext"></param>
      <param name="TRANSTYPE" expression="${transtype}"></param>
      
    </xslt>
    <move overwrite="true" todir="${dita.temp.dir}">
      <fileset dir="${dita.temp.dir}" includes="**/*.ditamap.pull"></fileset>
      <mapper type="glob" from="*.ditamap.pull" to="*.ditamap"></mapper>
    </move>
  </target>
  
  <target name="mappull-check">
    <condition property="preprocess.mappull.skip">
      <isset property="noMap"></isset>
    </condition>
  </target>
  
  <!-- chunk
      Assemble virtual supertopics based on chunk attribute in map. -->
  <target name="chunk" depends="mappull,chunk-check" unless="preprocess.chunk.skip" description="Process chunks">
    <pipeline message="Process chunks." module="Chunk" basedir="${basedir}" inputmap="${user.input.file}" tempdir="${dita.temp.dir}">
      <param name="ditaext" value="${dita.ext}"></param>
      <param name="transtype" value="${transtype}"></param>
    </pipeline>
  	
  	<xmlpropertyreader file="${dita.temp.dir}${file.separator}dita.xml.properties"></xmlpropertyreader>
  	<condition property="noTopic">
  	  	<equals arg1="${fullditatopiclist}" arg2=""></equals>
  	</condition>
  </target>

  <target name="chunk-check">
    <condition property="preprocess.chunk.skip">
      <isset property="noMap"></isset>
    </condition>
  </target>
  
  <!-- maplink
    Produce maplinks.unordered file, containing all related links
    implied by the map (family and reltables). -->
  <target name="maplink" depends="chunk,maplink-check" unless="preprocess.maplink.skip" description="Find and generate related link information">
    <dirname property="maplink.workdir" file="${dita.temp.dir}/${user.input.file}"></dirname>
    <condition property="dita.preprocess.reloadstylesheet.maplink" value="${dita.preprocess.reloadstylesheet}">
      <not><isset property="dita.preprocess.reloadstylesheet.maplink"></isset></not>
    </condition>
    <xslt processor="trax" in="${dita.temp.dir}${file.separator}${user.input.file}" out="${maplink.workdir}${file.separator}maplinks.unordered" classpathref="dost.class.path" reloadstylesheet="${dita.preprocess.reloadstylesheet.maplink}" style="${dita.script.dir}${file.separator}preprocess${file.separator}maplink.xsl">
      <param name="DITAEXT" expression="${dita.ext}" if="dita.ext"></param>
      <param name="INPUTMAP" expression="${user.input.file}"></param>
      
    </xslt>
  </target>

  <target name="maplink-check">
    <condition property="preprocess.maplink.skip">
      <isset property="noMap"></isset>
    </condition>
  </target>
  
  <!-- move-links
      Push links from maplinks.unordered file into
      <related-links> sections of the corresponding topics. -->
  <target name="move-links" depends="maplink,move-links-check" unless="preprocess.move-links.skip" description="Move the related link information to topics">
    <pipeline message="Move links." module="MoveLinks" inputmap="${user.input.file}" tempdir="${dita.temp.dir}">
      <param name="maplinks" location="${maplink.workdir}${file.separator}maplinks.unordered"></param>
    </pipeline>
  </target>

  <target name="move-links-check">
    <condition property="preprocess.move-links.skip">
      <isset property="noMap"></isset>
    </condition>
  </target>
  
  <!-- topicpull
      Populate link text for links within topics (xref, link). -->
  <target name="topicpull" depends="debug-filter,topicpull-check" unless="preprocess.topicpull.skip" description="Pull metadata for link and xref element">
    <condition property="dita.preprocess.reloadstylesheet.topicpull" value="${dita.preprocess.reloadstylesheet}">
      <not><isset property="dita.preprocess.reloadstylesheet.topicpull"></isset></not>
    </condition>
    <xslt processor="trax" basedir="${dita.temp.dir}" destdir="${dita.temp.dir}" includesfile="${dita.temp.dir}${file.separator}${fullditatopicfile}" classpathref="dost.class.path" reloadstylesheet="${dita.preprocess.reloadstylesheet.topicpull}" style="${dita.script.dir}${file.separator}preprocess${file.separator}topicpull.xsl">
      <includesfile name="${dita.temp.dir}${file.separator}${chunkedtopicfile}" if="chunkedtopicfile"></includesfile>
      <param name="DITAEXT" expression="${dita.ext}" if="dita.ext"></param>
      <param name="TABLELINK" expression="${args.tablelink.style}" if="args.tablelink.style"></param>
      <param name="FIGURELINK" expression="${args.figurelink.style}" if="args.figurelink.style"></param>
      <param name="ONLYTOPICINMAP" expression="${onlytopic.in.map}" if="onlytopic.in.map"></param>
      
      <mapper type="glob" from="*" to="*.pull"></mapper>
    </xslt>
    <move todir="${dita.temp.dir}">
      <fileset dir="${dita.temp.dir}" includes="**/*.pull"></fileset>
      <mapper type="glob" from="*.pull" to="*"></mapper>
    </move>
  </target>

  <target name="topicpull-check">
    <condition property="preprocess.topicpull.skip">
      <isset property="noTopic"></isset>
    </condition>
  </target>
  
  <!-- copy-files
      Copy files to the output directory. -->
  <target name="copy-files" depends="debug-filter,copy-image,copy-html,copy-flag,copy-subsidiary,copy-generated-files" unless="preprocess.copy-files.skip"></target>

  <target name="copy-image" depends="copy-image-check" unless="preprocess.copy-image.skip" description="Copy image files">
    <copy todir="${output.dir}">
      <fileset dir="${user.input.dir}" includesfile="${dita.temp.dir}${file.separator}${imagefile}"></fileset>
    </copy>
  </target>
  
  <target name="copy-image-check">
    <condition property="preprocess.copy-image.skip">
      <or>
        <isset property="preprocess.copy-files.skip"></isset>
        <isset property="noImagelist"></isset>
      </or>
    </condition>
  </target>

  <target name="copy-html" depends="copy-html-check" unless="preprocess.copy-html.skip" description="Copy html files">
    <copy todir="${output.dir}">
      <fileset dir="${user.input.dir}" includesfile="${dita.temp.dir}${file.separator}${htmlfile}"></fileset>
    </copy>
  </target>

  <target name="copy-html-check">
    <condition property="preprocess.copy-html.skip">
      <or>
        <isset property="preprocess.copy-files.skip"></isset>
        <isset property="noHtmllist"></isset>
      </or>
    </condition>
  </target>
  
  <target name="copy-flag" depends="copy-flag-check" unless="preprocess.copy-flag.skip" description="Copy flag files">
    <copy todir="${dita.map.output.dir}">
      <fileset dir="${dita.resource.dir}" includes="delta.gif,deltaend.gif"></fileset>
    </copy>
    <dita-ot-copy todir="${output.dir}" includes="${flagimagelist}" relativepaths="${relflagimagelist}"></dita-ot-copy>
  </target>
  
  <target name="copy-flag-check">
    <condition property="preprocess.copy-flag.skip">
      <or>
        <isset property="preprocess.copy-files.skip"></isset>
        <not><isset property="dita.input.valfile"></isset></not>
      </or>
    </condition>
  </target>
  
  <target name="copy-subsidiary" depends="copy-subsidiary-check" unless="preprocess.copy-subsidiary.skip" description="Copy subsidiary files">
    <copy todir="${dita.temp.dir}">
      <fileset dir="${user.input.dir}" includesfile="${dita.temp.dir}${file.separator}${subtargetsfile}"></fileset>
    </copy>
  </target>


  <target name="copy-subsidiary-check">
    <condition property="preprocess.copy-subsidiary.skip">
      <or>
        <isset property="preprocess.copy-files.skip"></isset>
        <isset property="noSublist"></isset>
      </or>
    </condition>
  </target>
  
  <target name="copy-generated-files" unless="preprocess.copy-generated-files.skip" description="Copy generated files">
    <copy todir="${args.logdir}">
      <fileset dir="${dita.temp.dir}" includes="dita.list,property.temp,dita.xml.properties"></fileset>
    </copy>
  </target>

  <!-- The following targets are not really part of the preprocess pipeline. -->
  
  <target name="copy-revflag" if="dita.input.valfile">
    <copy todir="${output.dir}">
      <fileset dir="${dita.resource.dir}" includes="*.gif"></fileset>
    </copy>
  </target>
    
  <target name="copy-css" unless="user.csspath.url" description="Copy CSS files">    
    <condition property="user.copycss.yes">
      <and>
        <equals arg1="${args.copycss}" arg2="yes"></equals>
        <isset property="args.css.present"></isset>
      </and>
    </condition>
    <property name="user.csspath.real" value="${output.dir}${file.separator}${user.csspath}"></property>
    <mkdir dir="${user.csspath.real}"></mkdir>    
    <!-- Always copy system default css files -->
    <copy todir="${user.csspath.real}">
      <fileset dir="${dita.resource.dir}" includes="*.css"></fileset>
    </copy>    
    <!-- Copy user specify css file when required -->
    <antcall target="copy-css-user"></antcall>
  </target>

  <target name="copy-css-user" if="user.copycss.yes">
    <copy file="${args.css.real}" todir="${user.csspath.real}"></copy>
  </target>
  
  <!-- depecrated: keep for back-compatibility -->
  <target name="move-index-entries" depends="move-meta-entries"></target>  
  
</project>