hdoc_to_basex.ant 2.18 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 10 11 12 13 14 15 16 17 18 19 20 21 22
  <property file="build.properties"/>
		
	<target name="convert">
		<!-- Preparation for the file transformation : delete old folders and create new folders -->
		<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
23

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

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

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

    <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" >
53

54 55 56 57 58 59 60
		<!-- 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
61 62 63 64

    </target> 
    
</project>