hdoc_to_epub.ant 1.8 KB
Newer Older
1
<?xml version="1.0" encoding="UTF-8"?>
cliclac's avatar
cliclac committed
2 3 4 5 6 7 8
<project name="hdoc_to_epub" basedir="." default="convert">

  <taskdef resource="net/sf/antcontrib/antlib.xml"/>

  <property name="in" location="${basedir}/input"/>
  <property name="out" location="${basedir}/output"/>
  <property name="tmp" location="${basedir}/tmp"/>
cliclac's avatar
test  
cliclac committed
9
  <property name="schema" location="${basedir}/schema"/>
cliclac's avatar
cliclac committed
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

  <target name="convert">
    <delete dir="${tmp}" failonerror="false"/>
    <sleep seconds="1"/>
    <mkdir dir="${tmp}"/>

    <delete dir="${out}" failonerror="false"/>
    <sleep seconds="1"/>
    <mkdir dir="${out}"/>

    <for param="inputFile">
      <path>
        <fileset dir="${in}" includes="**/*.hdoc"/>
      </path>

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

        <antcall target="UnzipHdocFile">
          <param name="filename" value="${filename}"/>
        </antcall>

        <antcall target="ValidateInput">
          <param name="filename" value="${filename}"/>
        </antcall>
      </sequential>
    </for>
  </target>

  <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"/>
  </target>

  <!-- Validating the XML container file -->
	<target name="ValidateInput">
    <trycatch property="foo" reference="bar">
      <try>
        <jing file="${tmp}/${filename}/decompressedHdoc/META-INF/container.xml" rngfile="${schema}/hdoc1-container.rng"></jing>
      </try>
      <catch>
        <echo>Validation failed</echo>
      </catch>
    </trycatch>
	</target>

59
</project>