hdoc_to_basex.ant 2.23 KB
Newer Older
simei.yin's avatar
simei.yin committed
1
2
3
4
5
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." name="myantce" default="convert">
  
  <taskdef resource="net/sf/antcontrib/antlib.xml"/>
  
6
7
8
9
  <property file="build.properties"/>
		
	<target name="convert">
		<!-- Preparation for the file transformation : delete old folders and create new folders -->
Baptiste Montange's avatar
Baptiste Montange committed
10
		<delete dir="${tmp}" failonerror="false"/>
11
12
13
14
15
16
17
18
19
20
21
22
23
		<mkdir dir="${tmp}"/>
		<delete dir="${out}" failonerror="false"/>
		<mkdir dir="${out}"/>
		<delete dir="${log}" failonerror="false"/>
		<mkdir dir="${log}"/>
		<echo message="DEBUT"/>
		
		<!-- Convert all the hdoc files in the directory ${in} to data xml files that will be imported to basex later.
		Fonctions "UnzipHdocFile" and "content" will be called. -->
		<for param="inputFile">
			<path>
			  <fileset dir="${in}" includes="**/*.hdoc"/>
			</path>
simei.yin's avatar
simei.yin committed
24

25
26
27
			<sequential>
			  <local name="filename"/>
			  <basename property="filename" file="@{inputFile}"/>
28

29
30
31
32
33
34
35
36
37
38
39
40
				<antcall target="UnzipHdocFile">
				<param name="filename" value="${filename}"/>
			  </antcall>
			  
			  <antcall target="content">
				<param name="filename" value="${filename}"/>
			  </antcall>
			  <echo message="FIN"/>
			</sequential>
		</for>
		
		<!-- Clean-->
Baptiste Montange's avatar
Baptiste Montange committed
41
		<delete dir="${tmp}" failonerror="false"/>
42
	</target>
43

simei.yin's avatar
simei.yin committed
44
45
46
47
48
49
50
51
52
53

    <target name="UnzipHdocFile">
        <!-- Unzip the input hdoc file. Decompressed folder is named "decompressedHdoc" : this name is the only one which
        refers to the hdoc file furthermore in this project. -->
      <unzip src="${in}/${filename}" dest="${tmp}/${filename}/decompressedHdoc"/>
      <chmod dir="${tmp}/${filename}/decompressedHdoc" perm="777"/>
      <echo message="${tmp}/${filename}/decompressedHdoc"/>
    </target>

     <target name="content" >
54

55
56
57
58
59
60
61
		<!-- Transformation of a xml file decompressed from hdoc file to data xml file to be imported to basex.
		The transformation will be done in terms of the xsl file in ${xsl}.-->
		<xslt in="${tmp}/${filename}/decompressedHdoc/content.xml" out="${out}/${filename}_data.xml" style="${xsl}/transformation.xsl" processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison">
			<param name="filename" expression="${filename}"/>
			<param name="lib" expression="${lib}"/>
		</xslt>
		<echo message="${filename}" />
simei.yin's avatar
simei.yin committed
62
63
64
65

    </target> 
    
</project>