Statistics
| Revision:

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

History | View | Annotate | Download (3.3 kB)

1
<?xml version="1.0" encoding="utf-8"?>
2
<project basedir="." name="fix template styles">
3
        <!-- ANT script to prepare and clean up a template for the DOCX transformation 
4
                to be used for creating a DOCX target file tranformed from a TEI XML document.
5
        -->
6
  
7
  <!-- define the the saxon transformer or place it in the ant lib directory -->
8
  <property name = "saxon.jar" value=".../saxon9he.jar"/>
9
  
10
        <!-- modfiy basedir, if necessary: -Dbasedir=... -->
11
        <echo>     basedir: ${basedir}</echo>
12
        
13
        <!-- profile, may be overwritten by external property: -Dprofile=default -->
14
        <property name="profile" value="default"/>
15
    
16
        <!-- the profiles directory, may be overwritten by: -DprofilesDir=... -->
17
        <property name="profilesDir">../../profiles/</property>
18
        <echo> profilesDir: ${profilesDir}</echo>
19

    
20
        <!-- the source directory, may be overwritten by: -DsourceDir=... -->
21
        <property name="sourceDir">${profilesDir}${profile}/docx/</property>
22

    
23
        <!-- the source file, may be overwritten by: -DsourceFile=... -->
24
        <property name="sourceFile">${sourceDir}template_original.docx</property>
25
        <echo>  sourceFile: ${sourceFile}</echo>
26
  
27
        <!-- the target directory, may be overwritten by: -DtargetDir=... 
28
                        The target directory is also used as a base for a temporary workind directory. -->
29
        <property name="targetDir">${profilesDir}${profile}/docx/</property>
30
  
31
        <!-- the target file, may be overwritten by: -DtargetFile=... -->
32
        <property name="targetFile">${targetDir}template.docx</property>
33
        <echo>  targetFile: ${targetFile}</echo>
34
        
35
        <!-- remove the target file -->
36
        <delete file="${targetFile}" />
37
        
38
        <!-- create the working directory and unzip the source file -->
39
        <property name="temp">${targetDir}temp/</property>
40
        <mkdir dir="${temp}"/>
41
        <unzip src="${sourceFile}" dest="${temp}" failOnEmptyArchive="true" />
42

    
43
        <!-- remove custom document properties -->
44
        <delete includeEmptyDirs="true" verbose="true">
45
                <fileset dir="${temp}">
46
                        <include name="docProps/custom.xml" />
47
                        <include name="word/webSettings.xml" />
48
                        <include name="word/_rels/settings.xml.rels" />
49
                        <include name="word/endnotes.xml" />
50
                        <include name="word/footnotes.xml" />
51
                        <include name="customXml/*" />
52
                        <include name="word/footer*" />
53
                        <include name="word/header*" />
54
                        <include name="word/theme" />
55
                        <include name="word/glossary" />
56
                </fileset>
57
        </delete>
58

    
59
        <!-- fix .rels -->
60
        <xslt style="fixdotrels.xsl"  in="${temp}_rels/.rels"  out="${temp}__rels/.rels" >
61
                <factory name="net.sf.saxon.TransformerFactoryImpl"/>
62
                <classpath location="${saxon.jar}"/>
63
        </xslt>
64
        <move file="${temp}__rels/.rels" tofile="${temp}_rels/.rels" verbose="true" />
65

    
66

    
67
        <!-- fix styles -->
68
        <xslt style="fixstyle.xsl"  in="${temp}word/styles.xml"  out="${temp}word/_styles.xml" >
69
                <factory name="net.sf.saxon.TransformerFactoryImpl"/>
70
                <classpath location="${saxon.jar}"/>
71
        </xslt>
72
        <move file="${temp}word/_styles.xml" tofile="${temp}word/styles.xml" verbose="true" />
73

    
74
        <!-- zip back together -->
75
        <zip destfile="${targetFile}" basedir="${temp}" />
76

    
77
        <!-- delete the working directory whith all its content -->
78
        <echo>remove working directory</echo>
79
        <delete includeEmptyDirs="true" verbose="true">
80
                <fileset dir="${temp}"/>
81
        </delete>
82

    
83
        <echo>  target template stored in ${targetFile}</echo>
84

    
85
</project>