Statistics
| Revision:

root / tmp / org.txm.core / res / org / txm / xml / xsl / tei / docx / build-to.xml @ 187

History | View | Annotate | Download (6.5 kB)

1
<?xml version="1.0" encoding="utf-8"?>
2
<project basedir="." default="dist" name="teidocx">
3
<!--
4
        This library is free software; you can redistribute it and/or
5
        modify it under the terms of the GNU Lesser General Public
6
        License as published by the Free Software Foundation; either
7
        version 2.1 of the License, or (at your option) any later version.
8
        
9
        This library is distributed in the hope that it will be useful,
10
        but WITHOUT ANY WARRANTY; without even the implied warranty of
11
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
        Lesser General Public License for more details.
13
        
14
        You should have received a copy of the GNU Lesser General Public
15
        License along with this library; if not, write to the Free Software
16
        Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
        
18
        Id: $Id: build-to.xml 9875 2011-12-04 18:27:43Z rahtz $
19
        Copyright: 2011, TEI Consortium<
20
-->
21
  <!--
22
 Convert TEI documents into docx files.
23
 -->
24
  <!-- Path to TEI XML file. -->
25
  <property name="inputFile" value=""/>
26
  <!-- Path where the output docx file will be saved. -->
27
  <property name="outputFile" value=""/>
28
  <!-- which profile directory-->
29
  <property name="profileDir" value="../profiles"/>
30
  <!-- which profile -->
31
  <property name="profile" value="default"/>
32
  <!-- which language -->
33
  <property name="lang" value="en"/>
34
  <!-- where does oxygen keep stuff -->
35
  <property name="oxygenlib" value=""/>
36
  <!-- Stylesheet for transformation -->
37
  <property name="teitoDocx"       value="${profileDir}/${profile}/docx/to.xsl"/>
38
  <property name="listgraphics"    value="../tools/makegraphicsanttask.xsl"/>
39
  <dirname property="xslDir"       file="${teitoDocx}"/>
40
  <dirname property="inputFileDir" file="${inputFile}"/>
41
  <dirname property="outputDir"    file="${outputFile}"/>
42
  <property name="outputTempDir"   value="${outputDir}/temp-dir-for-ant"/>
43

    
44
  <path id="classpath">
45
    <pathelement path="${java.class.path}"/>
46
  </path>
47

    
48
  <condition property="makecoverpages">
49
    <available file="${profileDir}/${profile}/docx/makecoverpages.xsl"/>
50
  </condition>
51
  <import file="../odds2/build-to.xml"/>
52
  <target name="setup">
53
    <!-- Recreate temporary output directory -->
54
    <taskdef name="images" classname="ImageTask" classpath="../tools/ImageInfo/ImageInfo.jar"/>
55
    <delete dir="${outputTempDir}"/>
56
    <mkdir  dir="${outputTempDir}"/>
57
  </target>
58

    
59
  <target name="nocoverpages" unless="makecoverpages">
60
    <move file="${outputTempDir}/newdocument.xml" tofile="${outputTempDir}/word/document.xml" overwrite="true"/>
61
  </target>
62

    
63
  <target name="coverpages" if="makecoverpages">
64
    <echo>Make cover pages</echo>
65
    <xslt
66
          style="${profileDir}/${profile}/docx/makecoverpages.xsl" 
67
          in="${outputTempDir}/word/document.xml" 
68
          out="${outputTempDir}/tmp3.xml" 
69
          classpath="classpath">
70
      <xmlcatalog>
71
        <catalogpath>
72
          <pathelement location="../../../../catalog.xml"/>
73
          <pathelement location="../../../../../xhtml11/dtd/xhtmlcatalog.xml"/>
74
        </catalogpath>
75
      </xmlcatalog>
76
      <factory name="net.sf.saxon.TransformerFactoryImpl"/>
77
      <classpath location="${oxygenlib}/saxon9he.jar"/>
78
      <param name="headerFile"   expression="file:///${outputTempDir}/tmp2.xml"/>
79
      <param name="documentFile" expression="file:///${outputTempDir}/newdocument.xml"/>
80
    </xslt>
81
    <move file="${outputTempDir}/tmp3.xml" tofile="${outputTempDir}/word/document.xml" overwrite="true"/>
82
    <delete file="${outputTempDir}/newdocument.xml"/>
83
  </target>
84

    
85

    
86

    
87
  <target name="transform">
88
    <!-- The transformation for DOCX output. -->
89
    <echo level="info">unzip Word template</echo>
90
    <unzip src="${xslDir}/template.docx" dest="${outputTempDir}"/>
91
    <echo level="info">Get names of graphics files and write an ant task</echo>
92
    <xslt force="yes" style="${listgraphics}" classpath="classpath" in="${outputTempDir}/tmp2.xml" out="${outputTempDir}/copy.xml">
93
      <xmlcatalog>
94
        <catalogpath>
95
          <pathelement location="../../../../catalog.xml"/>
96
          <pathelement location="../../../../../xhtml11/dtd/xhtmlcatalog.xml"/>
97
        </catalogpath>
98
      </xmlcatalog>
99
      <factory name="net.sf.saxon.TransformerFactoryImpl"/>
100
      <classpath location="${oxygenlib}/saxon9ee.jar"/>
101
      <param name="inputDir" expression="${inputFileDir}"/>
102
      <param name="mediaDir" expression="word/media"/>
103
    </xslt>
104
    <echo level="info">Copy image files by running ant task</echo>
105
    <ant antfile="${outputTempDir}/copy.xml"/>
106
    <echo level="info">Read dimensions of image files and write info file</echo>
107
    <images outputFile="${outputTempDir}/image-size-info.xml">
108
      <fileset dir="${outputTempDir}/word" includes="media/*.*"/>
109
    </images>
110
    <echo level="info">XSLT generate files for docx </echo>
111
    <xslt force="yes" style="${teitoDocx}" in="${outputTempDir}/tmp2.xml" out="${outputTempDir}/newdocument.xml" classpath="classpath">
112
      <xmlcatalog>
113
        <catalogpath>
114
          <pathelement location="../../../../catalog.xml"/>
115
          <pathelement location="../../../../../xhtml11/dtd/xhtmlcatalog.xml"/>
116
        </catalogpath>
117
      </xmlcatalog>
118
      <factory name="net.sf.saxon.TransformerFactoryImpl"/>
119
      <classpath location="${oxygenlib}/saxon9ee.jar"/>
120
      <param name="word-directory" expression="file:///${outputTempDir}"/>
121
      <param name="inputDir" expression="${inputFileDir}"/>
122
      <!-- supply name of language-->
123
      <param name="lang" expression="${lang}" if="lang"/>
124
      <!-- emit some diagnostics"-->
125
      <param name="debug" expression="${debug}" if="debug"/>
126
      <!-- be verbose-->
127
      <param name="verbose" expression="${verbose}" if="verbose"/>
128
    </xslt>
129
    <move file="${outputTempDir}/docProps/newcore.xml" tofile="${outputTempDir}/docProps/core.xml" overwrite="true"/>
130
    <move file="${outputTempDir}/docProps/newcustom.xml" tofile="${outputTempDir}/docProps/custom.xml" overwrite="true"/>
131
  </target>
132

    
133
  <target name="zip">
134
    <echo level="info">ZIP: put files from ${outputTempDir} together into ${outputFile}</echo>
135
    <zip destfile="${outputDir}/temp-for-ant.zip" basedir="${outputTempDir}" compress="true" excludes="tmp1.xml,tmp2.xml,image-size-info.xml,copy.xml"/>
136
    <move file="${outputDir}/temp-for-ant.zip" tofile="${outputFile}" overwrite="true"/>
137
  </target>
138

    
139
  <target name="cleanup" unless="debug">
140
    <delete dir="${outputTempDir}"/>
141
  </target>
142

    
143
  <target name="dist"
144
          depends="setup,odd,notodd,transform,nocoverpages,coverpages,zip,cleanup"/>
145

    
146

    
147
</project>