<?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="dita2eclipsecontent" default="dita2eclipsecontent">
  <property name="transtype" value="eclipsecontent"/>
    
  <import file="build_init.xml" />
  <import file="build_preprocess.xml" />
  <import file="build_general.xml" />

  <target name="dita2eclipsecontent" unless="noMap"
    depends="build-init, preprocess, dita.topics.eclipse.content, 
                     dita.map.eclipse.content">
  </target>

  <target name="dita.map.eclipse.content"
    depends="dita.map.eclipsecontent.init, dita.map.eclipsecontent.toc,
                     dita.map.eclipsecontent.index, 
                     dita.map.eclipsecontent.plugin" />

  <target name="dita.map.eclipsecontent.init"
    description="Init properties for EclipseContent">
    <basename property="dita.map.toc.root" file="${dita.input.filename}"
      suffix=".ditamap" />
    <condition property="args.eclipsecontent.toc"
      value="${dita.map.toc.root}">
      <not>
        <isset property="args.eclipsecontent.toc" />
      </not>
    </condition>
    <condition property="content.link.ext" value=".html?srcext=dita">
      <equals arg1="${dita.ext}" arg2=".dita"></equals>
    </condition>
    <condition property="content.link.ext" value=".html?srcext=xml">
      <equals arg1="${dita.ext}" arg2=".xml"></equals>
    </condition>
  </target>

  <target name="dita.map.eclipsecontent.toc"
    depends="dita.map.eclipsecontent.init"
    description="Build EclipseContent TOC file">
    <xslt processor="trax" basedir="${dita.temp.dir}"
      destdir="${output.dir}" includesfile="${dita.temp.dir}${file.separator}${user.input.file.listfile}"
      classpathref="dost.class.path"
      style="${dita.script.dir}${file.separator}map2eclipse.xsl">
    	<excludesfile name="${dita.temp.dir}${file.separator}${resourceonlyfile}" if="resourceonlyfile"/>
      <param name="DITAEXT" expression="${dita.ext}" if="dita.ext" />
      <param name="OUTEXT" expression="${content.link.ext}" />
      <mapper type="glob" from="*${dita.input.filename}"
        to="*${args.eclipsecontent.toc}.xml" />
    </xslt>
  </target>
  
  <target name="dita.map.eclipsecontent.index" unless="noMap"
    depends="dita.map.eclipsecontent.init"
    description="Build Eclipse Help index file">
    <pipeline message="Extract index term."
      module="IndexTermExtract"
      basedir="${basedir}"
      tempdir="${dita.temp.dir}"
      inputmap="${user.input.file}">
      <param name="output" location="${output.dir}${file.separator}${user.input.file}"/>
      <param name="targetext" value="${content.link.ext}"/>
      <param name="indextype" value="eclipsehelp"/>
      <param name="encoding" value="${args.dita.locale}" if="args.dita.locale"/>
    </pipeline>
  </target>

  <target name="dita.map.eclipsecontent.plugin"
    depends="dita.map.eclipsecontent.init"
    description="Build EclipseContent plugin file">
    <xslt processor="trax"
      in="${dita.temp.dir}${file.separator}${user.input.file}"
      out="${dita.map.output.dir}${file.separator}plugin.xml"
      classpathref="dost.class.path"
      style="${dita.script.dir}${file.separator}map2plugin-cp.xsl">
      <param name="TOCROOT" expression="${args.eclipsecontent.toc}" />
      <param name="version" expression="${args.eclipse.version}"
        if="args.eclipse.version" />
      <param name="provider" expression="${args.eclipse.provider}"
        if="args.eclipse.provider" />
    </xslt>
  </target>

  <target name="dita.topics.eclipse.content" unless="noTopic">
    <!--<copy todir="${output.dir}">
      <fileset dir="${dita.temp.dir}" includes="${fullditatopiclist} ${chunkedtopiclist}">
      </fileset>
    </copy>-->

  	<xslt processor="trax" 
          basedir="${dita.temp.dir}" 
          destdir="${output.dir}"
          includesfile="${dita.temp.dir}${file.separator}${fullditatopicfile}"
          classpathref="dost.class.path"
          extension="${dita.ext}" 
          style="${dita.script.dir}${file.separator}dita2dynamicdita.xsl"
          filenameparameter="FILENAME"
          filedirparameter="FILEDIR">
      <excludesfile name="${dita.temp.dir}${file.separator}${resourceonlyfile}" if="resourceonlyfile"></excludesfile>
      <includesfile name="${dita.temp.dir}${file.separator}${chunkedtopicfile}" if="chunkedtopicfile"></includesfile>
      <param name="OUTEXT" expression="${dita.ext}" if="dita.ext"></param>
      <param name="DRAFT" expression="${args.draft}" if="args.draft"></param>
      <param name="DBG" expression="${args.debug}" if="args.debug"></param>
    </xslt>

  </target>

</project>
