optim_to_hdoc.ant 5.82 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
<?xml version="1.0" encoding="UTF-8"?>

<project default="convert_to_hdoc">
    
    <taskdef resource="net/sf/antcontrib/antcontrib.properties">
        <classpath>
            <pathelement location="${basedir}/lib/ant-contrib-0.6.jar"/>
        </classpath>
    </taskdef>
    
    <target name="convert_to_hdoc" depends="preparation">

        <unzip src="${InputPath}" dest="${InputPath}_FILES"/> 
        
        <fileset id="rootFiles" dir="${InputPath}_FILES" includes="*.paper | *.section | *.website | *.slideshow | *.webpage"/>  
        <property name="prop.rootFiles" refid="rootFiles"/>
        <property name="currentdir" value="${InputPath}_FILES"/> 
        
        <echo message="  "/>
        <echo message="        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"/>
        <echo message="        ! CHECKING FOR ITEM FILE IN ROOT DIRECTORY !"/>
        <echo message="        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"/>
        <echo message="  "/>
        <antcall target="direct_conversion"/>
        <antcall target="finde_file"/>
        
    </target>
    
    
    <target name="preparation">
        <echo message="  "/>
        <echo message="        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"/>
        <echo message="        !!!!!!! DEBUT PREPARATION !!!!!!!"/>
        <echo message="        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"/>
        <echo message="  "/>
        
        <delete dir="${InputPath}_HDOC"></delete>
        <delete dir="${InputPath}_FILES"></delete>
        
        <echo message="  "/>
        <echo message="        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"/>
        <echo message="        !!!!!!!! FIN PREPARATION !!!!!!!!"/>
        <echo message="        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"/>
        <echo message="  "/>
    </target>
    
    <target name="file_null">
        <condition property="file.null" else="false">
            <equals arg1="${prop.rootFiles}" arg2=""/>
        </condition>
        <echo message="Root file missing ? ${file.null}"/>
    </target>
    
    <target name="finde_file" if="${file.null}" depends="file_null">
        
        <echo message="  "/>
        <echo message="        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"/>
        <echo message="        ! NO ITEM FILE FOUND IN ROOT DIRECTORY !"/>
        <echo message="        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"/>
        <echo message="  "/>
        
        <echo message="  "/>
        <echo message="        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"/>
        <echo message="        ! CHECKING FOR ITEM FILE IN SUB DIRECTORIES !"/>
        <echo message="        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"/>
        <echo message="  "/>
        
        <foreach target="finde_file_subdir" param="worksheet" inheritall="true">
            <path>
                <dirset dir="${InputPath}_FILES">
                    <include name="*"/>
                </dirset>
            </path>
        </foreach>
        
    </target>
    
    <target name="finde_file_subdir">
        <echo message="finde_file_subdir called with dir : ${worksheet}"/>
        <fileset id="file" dir="${worksheet}" includes="*.paper | *.section | *.website | *.slideshow | *.webpage"/>  
        <property name="testfile" refid="file"/>
        <basename property="dir.name" file="${worksheet}"/>  
        
        <if>
            <equals arg1="${testfile}" arg2="" />
            <then>

            </then>
            <else>
                <antcall target="conversion">
                    <param name="rootfile" value="${worksheet}/${testfile}"/>
                    <param name="currentDir" value="${dir.name}"/>
                </antcall>
            </else>
        </if>

    </target>
    
    <target name="direct_conversion" unless="${file.null}" depends="file_null">
        <antcall target="conversion">
            <param name="rootfile" value="${InputPath}_FILES/${prop.rootFiles}"/>
            <param name="currentDir" value=""/>
        </antcall>
    </target>
    
    <target name="conversion">
        
        <echo message="conversion called with rootfile : ${rootfile} and currentDir : ${currentDir}"/>
        
        <copy todir="${InputPath}_HDOC">
            <fileset dir="hdoc"/>
        </copy>
        
        <echo message="  "/>
        <echo message="        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"/>
        <echo message="        !!!!! DEBUT INTERNALISATION !!!!!"/>
        <echo message="        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"/>
        <echo message="  "/>
        <xslt in="${rootfile}" out="${InputPath}_FILES/content1.xml" style="xsl/internalisation.xsl">
            <param name="currentDir" expression="${currentDir}"/>
        </xslt>
        <echo message="  "/>
        <echo message="        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"/>
        <echo message="        !!!!!! FIN INTERNALISATION !!!!!!"/>
        <echo message="        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"/>
        <echo message="  "/>
        <echo message="  "/>
        <echo message="        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"/>
        <echo message="        !!!!!!!! DEBUT CONVERSION !!!!!!!"/>
        <echo message="        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"/>
        <echo message="  "/>
        <xslt in="${InputPath}_FILES/content1.xml" out="${InputPath}_HDOC/content.xml" style="xsl/optim_to_hdoc.xsl"/>
        <echo message="  "/>
        <echo message="        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"/>
        <echo message="        !!!!!!!!! FIN CONVERSION !!!!!!!!"/>
        <echo message="        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"/>
        <echo message="  "/>
        
        <copy todir="${InputPath}_HDOC/optim">
            <fileset dir="${InputPath}_FILES"/>
        </copy>
        
        <zip basedir="${InputPath}_HDOC" destfile="${OutputPath}"></zip>
        
        <delete dir="${InputPath}_HDOC"></delete>
        <delete dir="${InputPath}_FILES"></delete>
    </target>
    
</project>