optim_to_hdoc.ant 3.43 KB
Newer Older
1
<?xml version="1.0" encoding="UTF-8"?>
Ivan D'halluin's avatar
Ivan D'halluin committed
2
<project basedir="." name="optim_to_hdoc">
3 4
  
  <taskdef resource="net/sf/antcontrib/antlib.xml"/>
5 6 7 8 9
  <taskdef name="jing" classname="com.thaiopensource.relaxng.util.JingTask">
		<classpath>
			<pathelement location="lib/jing.jar"/>
		</classpath>
	</taskdef>
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
  
  <property name="in" location="${basedir}/input"/>
  <property name="out" location="${basedir}/output"/>
  <property name="tmp" location="${basedir}/tmp"/>
  <property name="xsl" location="${basedir}/xsl"/>
  <property name="lib" location="${basedir}/lib"/>
  <property name="log" location="${basedir}/log"/>
  
  <delete dir="${tmp}" failonerror="false"/>
  <mkdir dir="${tmp}"/>
  <delete dir="${out}" failonerror="false"/>
  <mkdir dir="${out}"/>
  <delete dir="${log}" failonerror="false"/>
  <mkdir dir="${log}"/>
  <mkdir dir="${tmp}/extract"/>
  <mkdir dir="${tmp}/internationalisation"/>
  
  <echo message="Extract files..."/>
  
  <for param="archive">
    <path>
      <fileset dir="${in}" includes="*"/>
    </path>
    <sequential>
      <local name="archive_name"/>
35
      <basename property="archive_name" file="@{archive}" suffix=".scar"/>
36 37 38 39 40
      <unzip src="@{archive}" dest="${tmp}/extract/${archive_name}"></unzip>
    </sequential>
  </for>
  
  <echo message="Internationalize files..."/>
41

42 43 44 45 46 47 48 49 50 51 52
  <xslt useImplicitFileset="false" destdir="${tmp}/internationalisation" style="${xsl}/internalisation.xsl">
    <param name="currentDir" expression="."/>
    <fileset dir="${tmp}/extract">
      <!-- only converting the root files -->
      <include name="*/*.paper"/>
      <include name="*/*.section"/>
      <include name="*/*.website"/>
      <include name="*/*.slideshow"/>
      <include name="*/*.webpage"/>
    </fileset>
  </xslt>
53

54 55 56
  <echo message="Convert to hdoc..."/>
  
  <xslt basedir="${tmp}/internationalisation" destdir="${out}" style="${xsl}/optim_to_hdoc.xsl"/>
57

58 59 60 61 62 63 64 65 66 67 68 69 70
  <echo message="Copy ressources files..."/>

  <copy todir="${out}">
    <fileset dir="${tmp}/extract">
      <!-- only copying resources files -->
      <exclude name="*/*.paper"/>
      <exclude name="*/*.section"/>
      <exclude name="*/*.website"/>
      <exclude name="*/*.slideshow"/>
      <exclude name="*/*.webpage"/>
    </fileset>
  </copy>
  
Ivan D'halluin's avatar
Ivan D'halluin committed
71 72 73
  <echo message="Build hdoc format..."/>
  
  <for param="folder">
Ivan D'halluin's avatar
Ivan D'halluin committed
74 75 76 77 78 79
    <path>
      <dirset dir="${out}" includes="*"/>
    </path>
    <sequential>
      <local name="folder_name"/>
      <basename property="folder_name" file="@{folder}"/>
Ivan D'halluin's avatar
Ivan D'halluin committed
80 81 82 83 84
      <copy file="${lib}/container.xml" todir="@{folder}/META-INF/"/>
      <first id="first">
        <fileset dir="@{folder}" includes="*.html" />
      </first>
      <move file="${toString:first}" tofile="@{folder}/content.xml"/>
85 86 87 88 89 90 91 92 93 94
      <trycatch property="foo" reference="bar">
        <try>
          <jing file="@{folder}/META-INF/container.xml" rngfile="../schemas/container/hdoc1-container.rng"></jing>
          <jing file="@{folder}/content.xml" rngfile="../schemas/xhtml/hdoc1-xhtml.rng"></jing>
        </try>
        <catch>
          <echo>Validation error of hdoc output</echo>
        </catch>
      </trycatch>
      
Ivan D'halluin's avatar
Ivan D'halluin committed
95
    </sequential>
Ivan D'halluin's avatar
Ivan D'halluin committed
96
  </for>
Ivan D'halluin's avatar
Ivan D'halluin committed
97
  
98 99 100 101 102 103 104 105 106
  <echo message="Zip result..."/>
 
  <for param="folder">
    <path>
      <dirset dir="${out}" includes="*"/>
    </path>
    <sequential>
      <local name="folder_name"/>
      <basename property="folder_name" file="@{folder}"/>
Ivan D'halluin's avatar
Ivan D'halluin committed
107
      <zip destfile="${out}/${folder_name}.hdoc" basedir="@{folder}" ></zip>
108 109
    </sequential>
  </for>
110 111
    
</project>