hdoc_to_optim.ant 3.18 KB
Newer Older
1
<project name="hdoc_to_optim" default="convert">
2

3
4
5
6
7
8
	<taskdef resource="net/sf/antcontrib/antcontrib.properties">
		<classpath>
			<pathelement location="lib/ant-contrib.jar" />
		</classpath>
	</taskdef>
	
9
	<!-- Arguments properties -->
10
	<property name="DocType" 			value="paper" />
11
	<property name="InputFile" 			value="none" />
12
13
	<property name="InputPath" 			value="input" />
	<property name="OutputPath" 		value="output" />
14
	<property name="OutputScarPath" 	value="${OutputPath}/result.scar" />
15
	
16
17
18
19
20
21
22
23
    <target name="convert">
		<!--Check wether there is an input using command line or not-->
	    <if>
		  <equals arg1="${InputFile}" arg2="none" />
		  <then>
			<!--There is no input, check the input folder-->
			
			<echo message="The value of property InputFile is ${InputFile} ... Checking the input folder" />
24
			<echo message="The value of property DocType is ${DocType}" />
25
26
27
28
29
30
31
			<!-- get input hdoc file path -->
			<fileset id="fileset_hdoc" dir="${InputPath}" casesensitive="yes">
				<include name="*.hdoc"/>
			</fileset>
			<pathconvert property="HdocFile" pathsep="" refid="fileset_hdoc" />
			
			<echo message="Executing conversion..." />
32
		
33
34
35
36
37
38
39
			<!--unzips the hdoc to be converted-->
			<unzip dest="hdoc" src ="${HdocFile}"/>
			
			<!--gives all rights to avoid bugs-->
			<chmod dir="hdoc" perm="777"/>
			
			<!--launches the XSLT find_content to retrieve the content path-->
40
41
42
			<xslt in="hdoc/META-INF/container.xml" out="get_content.ant" style="xsl/find_content.xsl">
				<param name="DocumentType" expression="${DocType}"/>
			</xslt>
43
			<chmod file="get_content.ant" perm="777"/>
44

45
46
47
48
49
50
			<!--launches the ANT get_content resulting from the previous XSLT in order to launch the conversion-->
			<ant antfile="get_content.ant"/>
			<!--once the conversion is complete, the result is zipped-->
			<zip basedir="result" destfile="${OutputScarPath}" encoding="UTF-8"/>
			
			<!--temporary files and folders are deleted-->
51
52
			<delete dir="hdoc"/>
			<delete dir="result"/>
53
54
55
56
57
58
59
60
			<delete file="get_content.ant"/>
			<delete file="get_ressources.ant"/>
			
		  </then>
		  <else>
			<!--There is an input-->
			
			<echo message="The value of property InputFile is ${InputFile}" />
61
			<echo message="The value of property DocType is ${DocType}" />
62
			<echo message="Executing conversion..." />
63
		
64
65
66
67
68
69
70
			<!--unzips the hdoc to be converted-->
			<unzip dest="hdoc" src ="${InputFile}"/>
			
			<!--gives all rights to avoid bugs-->
			<chmod dir="hdoc" perm="777"/>
			
			<!--launches the XSLT find_content to retrieve the content path-->
71
72
73
			<xslt in="hdoc/META-INF/container.xml" out="get_content.ant" style="xsl/find_content.xsl">
				<param name="DocumentType" expression="${DocType}"/>
			</xslt>
74
			<chmod file="get_content.ant" perm="777"/>
75

76
77
78
79
80
81
			<!--launches the ANT get_content resulting from the previous XSLT in order to launch the conversion-->
			<ant antfile="get_content.ant"/>
			<!--once the conversion is complete, the result is zipped-->
			<zip basedir="result" destfile="${OutputScarPath}" encoding="UTF-8"/>
			
			<!--temporary files and folders are deleted-->
82
83
			<delete dir="hdoc"/>
			<delete dir="result"/>
84
85
86
87
88
89
			<delete file="get_content.ant"/>
			<delete file="get_ressources.ant"/>
		  </else>
		</if>   

	</target>
90

Drain's avatar
Drain committed
91
</project>