mindmapping_to_hdoc.ant 3.43 KB
Newer Older
1
<?xml version="1.0" encoding="UTF-8"?>
2 3
<project basedir="." default="default">
	<property name="in" location="${basedir}/input"/>
4
	<property name="out" value="${basedir}/output"/>
5
	<property name="module" value="default"/>
6
	<property name="resultFile" value="${basedir}/output"/>
7 8 9 10 11 12 13 14 15 16 17
	<taskdef resource="net/sf/antcontrib/antlib.xml">
		<classpath>
			<pathelement location="${basedir}/lib/ant-contrib.jar"/>
		</classpath>
	</taskdef>
	<taskdef resource="net/sf/antcontrib/antcontrib.properties">
		<classpath>
			<pathelement location="${basedir}/lib/ant-contrib.jar"/>
		</classpath>
	</taskdef>

18
	<target name="default" depends="preparation">
19 20 21 22 23 24 25
		<echo>----------------------------Begin of
			conversion----------------------------------</echo>

		<antcall target="hdoc_conversion"/>

		<echo>----------------------------End of conversion----------------------------------</echo>
	</target>
26 27 28 29 30

	<target name="preparation">
		<echo>Setting up the conversion</echo>
		<delete dir="${basedir}/temp"/>
		<mkdir dir="${basedir}/temp"/>
31 32
		<delete dir="${basedir}/output"/>
		<mkdir dir="${basedir}/output"/>
33 34 35
		<echo>--- End ----</echo>
	</target>

36
	<target name="hdoc_conversion">
37
		<echo>InputPath : ${inputPath}</echo>
38
		<if>
39
			<isset property="inputPath"/>
40 41 42 43 44 45 46 47 48 49
			<then>
				<antcall target="hdoc_conversion.input-path"/>
			</then>
			<else>
				<antcall target="hdoc_conversion.no-input-path"/>
			</else>
		</if>
	</target>

	<target name="hdoc_conversion.input-path">
50 51 52
		<echo>There is an input path in parameter : conversion of the file ${inputPath}</echo>
		<basename property="filename" file="${inputPath}" suffix=".mm"/>
		<echo>filename ${filename}</echo>
53 54
		<antcall target="Makehdoc">
			<param name="myXSLT" value="sect.xsl"/>
55 56
			<param name="hdocName" value="${filename}"/>
			<param name="InputPath" value="${inputPath}"/>
57 58
		</antcall>
	</target>
59 60 61 62 63 64 65 66 67 68

	<target name="hdoc_conversion.no-input-path">
		<echo>There is no input path in parameter : conversion of all the files in ./input</echo>

		<for param="inputFile">
			<path>
				<fileset dir="${in}" includes="**/*.mm"/>
			</path>
			<sequential>
				<local name="filename"/>
69
				<basename property="filename" file="@{inputFile}" suffix=".mm"/>
70 71 72
				<antcall target="Makehdoc">
					<param name="myXSLT" value="sect.xsl"/>
					<param name="hdocName" value="${filename}"/>
73
					<param name="inputPath" value="input/${filename}.mm"/>
74 75 76 77 78 79 80
				</antcall>
				<property name="filename" value="${filename}"/>
			</sequential>
		</for>
	</target>


81
	<!-- Convert a mindMap file into a hdoc, with a xsl schema specified in the parameter -->
82
	<target name="Makehdoc">
83 84 85 86 87
		<echo>Begin data conversion</echo>
		<mkdir dir="${basedir}/temp/${hdocName}"/>
		<mkdir dir="${basedir}/temp/${hdocName}/META-INF"/>
		<copy file="${basedir}/mimetype" tofile="${basedir}/temp/${hdocName}/mimetype"/>
		<!-- create the container file with an XSLT transformation -->
88 89 90
		<xslt classpath="lib/saxon9he.jar" in="${basedir}/${inputPath}"
			out="${basedir}/temp/${hdocName}/META-INF/container.xml"
			xslresource="${basedir}/xslt/makeContainer.xsl"/>
91
		<!-- create the file which contains the freemind data converted-->
92 93 94
		<xslt classpath="lib/saxon9he.jar" in="${basedir}/${inputPath}"
			out="${basedir}/temp/${hdocName}/content.xml" xslresource="${basedir}/xslt/${myXSLT}"/>

95
		<!-- zipping files as the hdoc format -->
96
		<zip destfile="${resultFile}/${hdocName}.hdoc" basedir="${basedir}/temp/${hdocName}"/>
97
		<!-- </condition> -->
98

99 100
		<echo>end data conversion</echo>
	</target>
101

102
</project>