blob: 1a853fe3d5923cc4b87027434d2e5445c6e10e6f [file] [log] [blame]
Marc Kupietzaa7524b2024-09-22 12:00:48 +02001<?xml version="1.0" encoding="UTF-8" ?>
2<!-- (c) Copyright IBM Corp. 2005, 2006 All Rights Reserved. -->
3
4<project name="html2dita" basedir="." default="html2dita">
5
6 <property name="args.input" value="." />
7 <property name="args.include.subdirs" value="no" />
8 <property name="args.output" value="." />
9 <property name="args.dita.ext" value=".dita" />
10 <property name="args.xsl" value="h2d.xsl" />
11 <property name="temp.dir" value="temp"/>
12
13 <!-- - - - - - - - - - - - - - - - - -
14 private target: init
15 - - - - - - - - - - - - - - - - - -->
16 <target name="init"
17 depends="checkinputs"
18 description="-->Init properties base on input parameters">
19 <available file="${args.input}" type="file" property="isInputFile" />
20 <available file="${args.input}" type="dir" property="isInputDir" />
21 <mkdir dir="${args.output}" />
22 <condition property="includes.pattern" value="**/*.html,**/*.htm,**/*.xhtml,**/*.xml">
23 <equals arg1="${args.include.subdirs}"
24 arg2="yes"
25 casesensitive="false" />
26 </condition>
27 <condition property="includes.pattern" value="**/*.html,**/*.htm,**/*.xhtml,**/*.xml">
28 <not>
29 <isset property="includes.pattern" />
30 </not>
31 </condition>
32 </target>
33
34
35 <!-- - - - - - - - - - - - - - - - - -
36 private target: checkinputs
37 - - - - - - - - - - - - - - - - - -->
38 <target name="checkinputs" description="-->Check input parameters">
39 <fail message="Input parameter 'args.input=${args.input}' does not exist.">
40 <condition>
41 <not>
42 <available file="${args.input}" />
43 </not>
44 </condition>
45 </fail>
46 <fail message="Input parameter 'args.xsl=${args.xsl}' does not exist">
47 <condition>
48 <not>
49 <available file="${args.xsl}" />
50 </not>
51 </condition>
52 </fail>
53 </target>
54
55 <!-- - - - - - - - - - - - - - - - - -
56 private target: clean-temp
57 - - - - - - - - - - - - - - - - - -->
58 <target name="clean-temp" description="-->Clean temp directory">
59 <delete dir="${temp.dir}"/>
60 </target>
61
62 <!-- =================================
63 public target: html2dita
64 ================================= -->
65 <target name="html2dita"
66 depends="html2dita-single, html2dita-batch, clean-temp"
67 description="-->Migrate one or more HTML files to DITA files">
68 </target>
69
70
71 <!-- - - - - - - - - - - - - - - - - -
72 private target: preprocess-batch
73 - - - - - - - - - - - - - - - - - -->
74 <target name="preprocess-batch"
75 if="isInputDir"
76 description="-->Remove xmlns from HTML files">
77 <xslt
78 basedir="${args.input}"
79 destdir="${temp.dir}"
80 includes="${includes.pattern}"
81 style="preprocess.xsl"
82 force="true">
83 <mapper type="identity"/>
84 </xslt>
85 </target>
86
87 <!-- - - - - - - - - - - - - - - - - -
88 private target: html2dita-batch
89 - - - - - - - - - - - - - - - - - -->
90 <target name="html2dita-batch"
91 depends="init, preprocess-batch"
92 if="isInputDir"
93 description="-->Migrate HTML files to DITA files in batches">
94
95 <xslt
96 basedir="${temp.dir}"
97 destdir="${args.output}"
98 includes="${includes.pattern}"
99 extension="${args.dita.ext}"
100 style="${args.xsl}"
101 force="true">
102 <param name="infotype"
103 expression="${args.infotype}"
104 if="args.infotype" />
105 <param name="dita-extension"
106 expression="${args.dita.ext}"
107 if="args.dita.ext" />
108 <param name="default-lang"
109 expression="${args.lang}"
110 if="args.lang" />
111 </xslt>
112 </target>
113
114 <!-- - - - - - - - - - - - - - - - - -
115 private target: preprocess-single
116 - - - - - - - - - - - - - - - - - -->
117 <target name="preprocess-single"
118 if="isInputFile"
119 description="-->Remove xmlns from HTML file">
120 <basename file="${args.input}" property="filename" />
121 <dirname file="${args.input}" property="args.input.dir"/>
122 <xslt
123 basedir="${args.input.dir}"
124 destdir="${temp.dir}"
125 includes="${filename}"
126 style="preprocess.xsl"
127 force="true">
128 <mapper type="identity"/>
129 </xslt>
130 </target>
131
132 <!-- - - - - - - - - - - - - - - - - -
133 private target: html2dita-batch
134 - - - - - - - - - - - - - - - - - -->
135 <target name="html2dita-single"
136 depends="init, preprocess-single"
137 if="isInputFile"
138 description="-->Migrate single HTML file to DITA file">
139 <xslt
140 basedir="${temp.dir}"
141 includes="${filename}"
142 destdir="${args.output}"
143 extension="${args.dita.ext}"
144 style="${args.xsl}"
145 force="true">
146 <param name="infotype"
147 expression="${args.infotype}"
148 if="args.infotype" />
149 <param name="dita-extension"
150 expression="${args.dita.ext}"
151 if="args.dita.ext" />
152 <param name="default-lang"
153 expression="${args.lang}"
154 if="args.lang" />
155 <param name="FILENAME" expression="${filename}" if="filename" />
156 </xslt>
157 </target>
158
159
160</project>