-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
279 lines (237 loc) · 12 KB
/
build.xml
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." name="ise3_contentBuild" default="all">
<description>
Builds an ISE3-based website from a TEI dataset.
</description>
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
<taskdef name="schematron"
classpath="lib/ant-schematron-2010-04-14.jar"
classname="com.schematron.ant.SchematronTask"/>
<import file="anttask/overridable.xml"/>
<property name="echo.separator" value="******************************************************"/>
<property name="line.separator" value="
"/>
<property name="source.dir" value="${basedir}/svn"/>
<property name="source.data.dir" value="${source.dir}/data"/>
<property name="utilities.dir" value="${basedir}/lib"/>
<property name="site.dir" value="${basedir}/site"/>
<property name="siteXml.dir" value="${site.dir}/xml"/>
<property name="originalXml.dir" value="${siteXml.dir}/original"/>
<property name="standardXml.dir" value="${siteXml.dir}/standard"/>
<property name="standardXml.temp.dir" value="${siteXml.dir}/standard_temp"/>
<property name="apparatus.temp.dir" value="${standardXml.temp.dir}/apparatus_temp"/>
<property name="standaloneXml.dir" value="${siteXml.dir}/standalone"/>
<property name="xsl.dir" value="${basedir}/xsl"/>
<property name="build.modules.dir" value="${basedir}/build_modules"/>
<property name="lib.dir" value="${basedir}/lib"/>
<property name="saxon" value="${lib.dir}/saxon9he.jar"/>
<property name="tei.dir" value="${basedir}/tei-stylesheets"/>
<property name="tei.zip" value="${basedir}/tei-stylesheets.zip"/>
<property name="source.schema.dir" value="${source.dir}/sch"/>
<property name="site.schema.dir" value="${site.dir}/sch"/>
<fileset id="sourceXml" dir="${source.data.dir}">
<include name="**/**.xml"/>
</fileset>
<fileset id="originalXml" dir="${originalXml.dir}">
<include name="**/**.xml"/>
</fileset>
<!--These are the files we want to move over-->
<fileset id="tempApparatusFiles" dir="${apparatus.temp.dir}">
<include name="**_final.xml"/>
</fileset>
<fileset id="standardXml" dir="${standardXml.dir}">
<include name="**.xml"/>
</fileset>
<fileset id="standardXml.temp" dir="${standardXml.temp.dir}">
<include name="**.xml"/>
</fileset>
<fileset id="standaloneXml" dir="${standaloneXml.dir}">
<include name="**/**.xml"/>
</fileset>
<fileset id="siteXhtml" dir="${site.dir}">
<include name="**.html"/>
</fileset>
<!-- DIR STRUCTURES OF THE SITE
site [site.dir]/
xml [siteXml.dir]/
original [originalXml.dir]/
standalone [standaloneXml.dir]/
HTML FILES-->
<fileset id="schemaFiles" dir="${source.schema.dir}">
<include name="**"/>
</fileset>
<!--We don't need schemas right away, because all of our data should be validated before hand-->
<target name="init">
<echo message="${echo.separator}"/>
<echo message="Cleaning up directories from old build..."/>
<echo message="${echo.separator}"/>
<delete dir="${source.dir}"/>
<delete dir="${site.dir}"/>
<!--We now make the site dir, but the SVN dir is made for us-->
<mkdir dir="${site.dir}"/>
<echo message="${echo.separator}"/>
<echo message="Exporting the SVN data into a data/dir"/>
<exec executable="svn">
<arg line="export https://revision.hcmc.uvic.ca/svn/ise3/ ${source.dir} --ignore-externals"/>
</exec>
<echo message="Importing the TEI stylesheets so we can create temporary documentation..."/>
<get src="https://github.com/TEIC/Stylesheets/archive/dev.zip" dest="${tei.zip}"/>
<unzip src="${tei.zip}" dest="${tei.dir}">
<cutdirsmapper dirs="1"/>
</unzip>
</target>
<target name="copyAuxFiles">
<echo message="${echo.separator}"/>
<echo message="Copying over auxillary files (schema, etc)..."/>
<copy todir="${site.schema.dir}">
<fileset refid="schemaFiles"/>
</copy>
</target>
<target name="createOriginalXml">
<echo message="${echo.separator}"/>
<echo message="Creating (i.e. just flattening, for now) the original XML from the source XML..."/>
<mkdir dir="${originalXml.dir}"/>
<copy todir="${originalXml.dir}" flatten="true">
<fileset refid="sourceXml"/>
</copy>
</target>
<target name="preprocessStandardXml">
<echo message="${echo.separator}"/>
<echo message="Setting up for standarding XML generation..."/>
<echo message="${echo.separator}"/>
<mkdir dir="${standardXml.temp.dir}"/>
<echo message="${echo.separator}"/> <echo message="${echo.separator}"/>
<echo message="Creating files with attached apparatus..."/>
<antcall target="createAnchoredXml"/>
<echo message="${echo.separator}"/>
<echo message="First move the original to the standard temp dir..."/>
<copy todir="${standardXml.temp.dir}">
<fileset refid="originalXml"/>
</copy>
<echo message="${echo.separator}"/>
<echo message="Now move the annotation, collations, and fixed texts over to the temporary directory..."/>
<copy todir="${standardXml.temp.dir}" overwrite="true">
<fileset refid="tempApparatusFiles"/>
<regexpmapper from="^(.*)_final.xml" to="\1.xml"/>
</copy>
<echo message="${echo.separator}"/>
<echo message="Deleting temporary directory : ${apparatus.temp.dir}"/>
<delete dir="${apparatus.temp.dir}"/>
</target>
<target name="createAnchoredXml">
<echo message="${echo.separator}"/>
<echo message="Adding anchors to the texts..."/>
<echo message="${echo.separator}"/>
<echo message="Creating list of documents to which we need to add anchors..."/>
<property name="app.list" value="${apparatus.temp.dir}/app_list.txt"/>
<java classname="net.sf.saxon.Transform" classpath="${saxon}" fork="true">
<jvmarg value="-Xmx1024m"/>
<arg value="-s:${xsl.dir}/create_app_list_master.xsl"/>
<arg value="-xsl:${xsl.dir}/create_app_list_master.xsl"/>
<arg value="basedir=${basedir}"/>
<arg value="outDoc=${app.list}"/>
</java>
<loadfile property="appsToBuild" srcfile="${app.list}"/>
<echo message="${echo.separator}"/>
<echo message="Attaching apparatus to documents.."/>
<foreach list="${appsToBuild}" delimiter="${line.separator}" param="doc" target="attachApparatus"/>
</target>
<target name="attachApparatus">
<propertyregex property="doc.name" input="${doc}" regexp="(.+)\|(.+)" replace="\1"/>
<propertyregex property="app.docs" input="${doc}" regexp="(.+)\|(.+)" replace="\2"/>
<echo message="${echo.separator}"/>
<echo message="Attaching apparatus to ${doc.name}"/>
<echo message="${echo.separator}"/>
<property name="source.file" value="${originalXml.dir}/${doc.name}.xml"/>
<property name="tokenized.file" value="${apparatus.temp.dir}/${doc.name}_tokenized.xml"/>
<property name="final.file" value="${apparatus.temp.dir}/${doc.name}_final.xml"/>
<!--First, tokenize-->
<echo message="Tokenizing ${source.file} by characters..."/>
<xslt in="${source.file}" out="${tokenized.file}" style="${xsl.dir}/tokenizeText.xsl">
<classpath path="${saxon}"/>
<factory name="net.sf.saxon.TransformerFactoryImpl"/>
</xslt>
<echo message="${echo.separator}"/>
<echo message="Linking apparatus to tokenized file..."/>
<foreach list="${app.docs}" delimiter="," param="app.name" target="matchLemmas">
<param name="tokenized.file" value="${tokenized.file}"/>
</foreach>
<echo message="${echo.separator}"/>
<echo message="Untokenzing the text and inputing anchors where necessary..."/>
<java classname="net.sf.saxon.Transform" classpath="${saxon}" fork="true">
<jvmarg value="-Xmx1024m"/>
<arg value="-s:${tokenized.file}"/>
<arg value="-xsl:${xsl.dir}/cleanText.xsl"/>
<arg value="-o:${final.file}"/>
<arg value="basedir=${basedir}"/>
<arg value="appDir=${apparatus.temp.dir}"/>
<arg value="appList=${app.docs}"/>
</java>
</target>
<target name="matchLemmas">
<property name="app.doc" value="${originalXml.dir}/${app.name}.xml"/>
<echo message="${echo.separator}"/>
<echo message="Matching ${app.doc} to ${tokenized.file}"/>
<java classname="net.sf.saxon.Transform" classpath="${saxon}" fork="true">
<jvmarg value="-Xmx1024m"/>
<arg value="-s:${app.doc}"/>
<arg value="-o:${apparatus.temp.dir}/${app.name}_final.xml"/>
<arg value="-xsl:xsl/matchLemmas.xsl"/>
<arg value="basedir=${basedir}"/>
<arg value="tokenizedXml=${tokenized.file}"/>
</java>
</target>
<target name="createStandardXml">
<echo message="${echo.separator}"/>
<echo message="Creating standard XML...."/>
<echo message="${echo.separator}"/>
<mkdir dir="${standardXml.dir}"/>
<!--For now, just copy everything...-->
<copy todir="${standardXml.dir}">
<fileset refid="standardXml.temp"/>
</copy>
<!--XSLT to resolve pointers and add sic/corr-->
<!--Then delete the temporary standard stuff-->
</target>
<target name="createStandaloneXml">
<echo message="Creating Standalone XML from standard files..."/>
<echo message="THIS IS JUST COPYING THE XML FOR NOW..."/>
<mkdir dir="${standaloneXml.dir}"/>
<copy todir="${standaloneXml.dir}">
<fileset refid="standardXml"/>
</copy>
</target>
<target name="createXhtml">
<property name="documentation.list" value="${site.dir}/documentation_list.txt"/>
<java classname="net.sf.saxon.Transform" classpath="${saxon}" fork="true">
<jvmarg value="-Xmx1024m"/>
<arg value="-s:${xsl.dir}/create_documentation_list_master.xsl"/>
<arg value="-xsl:${xsl.dir}/create_documentation_list_master.xsl"/>
<arg value="basedir=${basedir}"/>
<arg value="outDoc=${documentation.list}"/>
</java>
<loadfile property="documentationToBuild" srcfile="${documentation.list}"/>
<foreach param="doc" target="transformWithTei" list="${documentationToBuild}" delimiter="${line.separator}"/>
<delete file="${documentation.list}"/>
<java classname="net.sf.saxon.Transform" classpath="${saxon}" fork="true">
<jvmarg value="-Xmx1024m"/>
<arg value="-s:${xsl.dir}/create_proofing_xhtml.xsl"/>
<arg value="-xsl:${xsl.dir}/create_proofing_xhtml.xsl"/>
<arg value="--suppressXsltNamespaceCheck:on"/>
<arg value="basedir=${basedir}"/>
</java>
</target>
<target name="transformWithTei">
<echo message="${echo.separator}"/>
<echo message="Now creating temporary documentation with TEI stylesheets..."/>
<echo message="Building ${doc}"/>
<property name="docToBuild" value="${standaloneXml.dir}/${doc}.xml"/>
<property name="outputDoc" value="${site.dir}/${doc}.html"/>
<java classname="net.sf.saxon.Transform" classpath="${saxon}" fork="true">
<jvmarg value="-Xmx1024m"/>
<arg value="-s:${docToBuild}"/>
<arg value="-o:${outputDoc}"/>
<arg value="-xsl:${tei.dir}/html5/html5.xsl"/>
</java>
</target>
<target name="all" depends="init, copyAuxFiles, createOriginalXml, preprocessStandardXml, createStandardXml, createStandaloneXml, createXhtml"/>
</project>