blob: 1a853fe3d5923cc4b87027434d2e5445c6e10e6f [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8" ?>
<!-- (c) Copyright IBM Corp. 2005, 2006 All Rights Reserved. -->
<project name="html2dita" basedir="." default="html2dita">
<property name="args.input" value="." />
<property name="args.include.subdirs" value="no" />
<property name="args.output" value="." />
<property name="args.dita.ext" value=".dita" />
<property name="args.xsl" value="h2d.xsl" />
<property name="temp.dir" value="temp"/>
<!-- - - - - - - - - - - - - - - - - -
private target: init
- - - - - - - - - - - - - - - - - -->
<target name="init"
depends="checkinputs"
description="-->Init properties base on input parameters">
<available file="${args.input}" type="file" property="isInputFile" />
<available file="${args.input}" type="dir" property="isInputDir" />
<mkdir dir="${args.output}" />
<condition property="includes.pattern" value="**/*.html,**/*.htm,**/*.xhtml,**/*.xml">
<equals arg1="${args.include.subdirs}"
arg2="yes"
casesensitive="false" />
</condition>
<condition property="includes.pattern" value="**/*.html,**/*.htm,**/*.xhtml,**/*.xml">
<not>
<isset property="includes.pattern" />
</not>
</condition>
</target>
<!-- - - - - - - - - - - - - - - - - -
private target: checkinputs
- - - - - - - - - - - - - - - - - -->
<target name="checkinputs" description="-->Check input parameters">
<fail message="Input parameter 'args.input=${args.input}' does not exist.">
<condition>
<not>
<available file="${args.input}" />
</not>
</condition>
</fail>
<fail message="Input parameter 'args.xsl=${args.xsl}' does not exist">
<condition>
<not>
<available file="${args.xsl}" />
</not>
</condition>
</fail>
</target>
<!-- - - - - - - - - - - - - - - - - -
private target: clean-temp
- - - - - - - - - - - - - - - - - -->
<target name="clean-temp" description="-->Clean temp directory">
<delete dir="${temp.dir}"/>
</target>
<!-- =================================
public target: html2dita
================================= -->
<target name="html2dita"
depends="html2dita-single, html2dita-batch, clean-temp"
description="-->Migrate one or more HTML files to DITA files">
</target>
<!-- - - - - - - - - - - - - - - - - -
private target: preprocess-batch
- - - - - - - - - - - - - - - - - -->
<target name="preprocess-batch"
if="isInputDir"
description="-->Remove xmlns from HTML files">
<xslt
basedir="${args.input}"
destdir="${temp.dir}"
includes="${includes.pattern}"
style="preprocess.xsl"
force="true">
<mapper type="identity"/>
</xslt>
</target>
<!-- - - - - - - - - - - - - - - - - -
private target: html2dita-batch
- - - - - - - - - - - - - - - - - -->
<target name="html2dita-batch"
depends="init, preprocess-batch"
if="isInputDir"
description="-->Migrate HTML files to DITA files in batches">
<xslt
basedir="${temp.dir}"
destdir="${args.output}"
includes="${includes.pattern}"
extension="${args.dita.ext}"
style="${args.xsl}"
force="true">
<param name="infotype"
expression="${args.infotype}"
if="args.infotype" />
<param name="dita-extension"
expression="${args.dita.ext}"
if="args.dita.ext" />
<param name="default-lang"
expression="${args.lang}"
if="args.lang" />
</xslt>
</target>
<!-- - - - - - - - - - - - - - - - - -
private target: preprocess-single
- - - - - - - - - - - - - - - - - -->
<target name="preprocess-single"
if="isInputFile"
description="-->Remove xmlns from HTML file">
<basename file="${args.input}" property="filename" />
<dirname file="${args.input}" property="args.input.dir"/>
<xslt
basedir="${args.input.dir}"
destdir="${temp.dir}"
includes="${filename}"
style="preprocess.xsl"
force="true">
<mapper type="identity"/>
</xslt>
</target>
<!-- - - - - - - - - - - - - - - - - -
private target: html2dita-batch
- - - - - - - - - - - - - - - - - -->
<target name="html2dita-single"
depends="init, preprocess-single"
if="isInputFile"
description="-->Migrate single HTML file to DITA file">
<xslt
basedir="${temp.dir}"
includes="${filename}"
destdir="${args.output}"
extension="${args.dita.ext}"
style="${args.xsl}"
force="true">
<param name="infotype"
expression="${args.infotype}"
if="args.infotype" />
<param name="dita-extension"
expression="${args.dita.ext}"
if="args.dita.ext" />
<param name="default-lang"
expression="${args.lang}"
if="args.lang" />
<param name="FILENAME" expression="${filename}" if="filename" />
</xslt>
</target>
</project>