hdoc_to_optim.ant 2.93 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="none" />
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 24 25 26 27 28 29 30
    <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" />
			<!-- 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..." />
31
		
32 33 34 35 36 37 38 39 40
			<!--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-->
			<xslt in="hdoc/META-INF/container.xml" out="get_content.ant" style="xsl/find_content.xsl"/>
			<chmod file="get_content.ant" perm="777"/>
41

42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
			<!--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-->
			<!--<delete dir="hdoc"/>
			<delete dir="result"/>-->
			<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}" />
			<echo message="Executing conversion..." />
59
		
60 61 62 63 64 65 66 67 68
			<!--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-->
			<xslt in="hdoc/META-INF/container.xml" out="get_content.ant" style="xsl/find_content.xsl"/>
			<chmod file="get_content.ant" perm="777"/>
69

70 71 72 73 74 75 76 77 78 79 80 81 82 83
			<!--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-->
			<!--<delete dir="hdoc"/>
			<delete dir="result"/>-->
			<delete file="get_content.ant"/>
			<delete file="get_ressources.ant"/>
		  </else>
		</if>   

	</target>
84

85
</project>