-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild.xml
executable file
·281 lines (259 loc) · 8.79 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
280
281
<?xml version="1.0" encoding="UTF-8"?>
<project name="stf" default="run.schematron" basedir=".">
<description>Tasks for running both Schematron and tests of
Schematron.</description>
<dirname property="stf.basedir" file="${ant.file.stf}"/>
<pathconvert property="stf.basedir.converted" dirsep="/">
<path location="${stf.basedir}" />
<!-- Ant under cygwin uses a lowercase drive letter, which Java
programs don't always recognise as a drive letter, so
translate. -->
<map from="c:" to="/C:"/>
<map from="d:" to="/D:"/>
<map from="e:" to="/E:"/>
</pathconvert>
<!-- Current project folder as file path. -->
<property name="pd" value="."/>
<!-- Current file folder as file path. -->
<property name="pwd" value="${user.dir}"/>
<property name="oxygen.frameworks.dir"
value="${oxygenInstallDir}/frameworks"/>
<!-- XML file of properties determining or describing local
configuration. -->
<property
name="properties.xml"
location="${pwd}/properties.xml"/>
<property
file="${properties.xml}"/>
<!-- File of properties determining or describing 'stf' system
configuration. -->
<property name="stf.properties.xml"
value="${stf.basedir.converted}/properties.xml"/>
<property file="${stf.properties.xml}"/>
<!-- Schematron properties. -->
<!-- Top-level Schematron schema file. -->
<property name="schematron" value="${pwd}/schematron/testing.sch"/>
<!-- Directory containing Schematron test files. -->
<!-- Should be absolute path for sake of XProc testing of Schematron. -->
<property name="tests.dir" value="${pwd}/tests"/>
<!-- Binding with which to run Schematron. -->
<property
name="schematron.binding"
value="xslt2" />
<!-- Location of ISO Schematron XSLT implementation -->
<property
name="iso.schematron.dir"
value="${stf.basedir.converted}/iso-schematron-${schematron.binding}"/>
<!-- Location of Calabash jar. -->
<property name="calabash.jar"
value="${oxygenInstallDir}/lib/xproc/calabash/calabash.jar"/>
<!-- Location of XML catalog resolver library. -->
<property name="resolver.jar"
value="${oxygenInstallDir}/lib/resolver.jar"/>
<!-- Class name of XML catalog resolver. -->
<property name="resolver.class"
value="org.apache.xml.resolver.tools.CatalogResolver"/>
<!-- Location of Saxon 9.2 (or later) jar. -->
<!--<property name="saxon.jar"
value="${oxygenInstallDir}/lib/saxon9ee.jar"/>-->
<!-- If not already set, saxon.jar location depends on OS. -->
<condition property="saxon.jar" value="${saxon.jar.windows}">
<os family="windows" />
</condition>
<condition property="saxon.jar" value="${saxon.jar.mac}">
<os family="mac" />
</condition>
<property name="saxon.jar" value="${saxon.jar.unix}" />
<macrodef name="test.schematron"
description="Tests Schematron using Calabash and Saxon">
<attribute name="schematron"
default="${schematron}"
description="Schematron file to use." />
<attribute name="tests.dir"
default="${tests.dir}"
description="Directory containing test files." />
<attribute name="basedir"
default="${pwd}"
description="Base directory." />
<attribute name="catalog.xml"
default=""
description="XML catalog file." />
<sequential>
<java classname="com.xmlcalabash.drivers.Main"
dir="@{basedir}"
fork="true">
<classpath>
<pathelement location="${calabash.jar}"/>
<pathelement location="${saxon.jar}"/>
<pathelement location="${resolver.jar}"/>
</classpath>
<sysproperty key="xml.catalog.files"
value="@{catalog.xml}"/>
<sysproperty key="java.util.logging.ConsoleHandler.level"
value="ERROR" />
<arg value="-U"/>
<arg value="${resolver.class}"/>
<arg value="-E"/>
<arg value="${resolver.class}"/>
<arg value="${stf.basedir.converted}/xproc/test-schematron.xpl"/>
<arg value="path=@{tests.dir}"/>
<arg value="schematron=@{schematron}"/>
</java>
</sequential>
</macrodef>
<target name="test.schematron"
description="Run Schematron on the test files.">
<test.schematron />
</target>
<property name="deleteonexit" value="false" />
<macrodef name="schematron"
description="Runs Schematron using Saxon">
<attribute name="schematron"
default="${schematron}"
description="Schematron file to use." />
<attribute name="includes"
default="**/*.xml"
description="Files on which to run Schematron." />
<attribute name="basedir"
default="${pwd}"
description="Base directory from which to run Schematron." />
<attribute name="saxon.jar"
default="${saxon.jar}"
description="Location of Saxon jar." />
<attribute name="deleteonexit"
default="${deleteonexit}"
description="Whether to delete intermediate XSLT files on exit." />
<sequential>
<echo message="Running '@{schematron}' Schematron on XML files in '${tests.dir}'. SVRL in 'out'."/>
<mkdir dir="${pwd}/tmp"/>
<mkdir dir="${pwd}/out"/>
<tempfile property="expanded.sch"
prefix="expanded"
suffix=".sch"
destdir="tmp"
deleteonexit="@{deleteonexit}"/>
<tempfile property="unabstract.sch"
prefix="unabstract"
suffix=".sch"
destdir="tmp"
deleteonexit="@{deleteonexit}"/>
<tempfile property="schematron.xsl"
prefix="schematron"
suffix=".xsl"
destdir="tmp"
deleteonexit="@{deleteonexit}"/>
<tempfile property="check-schematron.xsl"
prefix="check-schematron"
suffix=".xsl"
destdir="${pwd}/tmp"
deleteonexit="@{deleteonexit}"/>
<!-- expand inclusions -->
<xslt basedir="@{basedir}"
style="${iso.schematron.dir}/iso_dsdl_include.xsl"
in="@{schematron}"
out="${expanded.sch}"
classpath="@{saxon.jar}">
<factory name="net.sf.saxon.TransformerFactoryImpl">
<attribute
name="http://saxon.sf.net/feature/allow-external-functions"
value="true"/>
<attribute
name="http://saxon.sf.net/feature/linenumbering"
value="true"/>
</factory>
</xslt>
<!-- expand abstract patterns -->
<xslt basedir="@{basedir}"
style="${iso.schematron.dir}/iso_abstract_expand.xsl"
in="${expanded.sch}"
out="${unabstract.sch}"
classpath="@{saxon.jar}">
<factory name="net.sf.saxon.TransformerFactoryImpl">
<attribute
name="http://saxon.sf.net/feature/allow-external-functions"
value="true"/>
<attribute
name="http://saxon.sf.net/feature/linenumbering"
value="true"/>
</factory>
</xslt>
<!-- compile it -->
<xslt basedir="@{basedir}"
style="${iso.schematron.dir}/iso_svrl_for_${schematron.binding}.xsl"
in="${unabstract.sch}"
out="${schematron.xsl}"
classpath="@{saxon.jar}">
<factory name="net.sf.saxon.TransformerFactoryImpl">
<attribute
name="http://saxon.sf.net/feature/allow-external-functions"
value="true"/>
<attribute
name="http://saxon.sf.net/feature/linenumbering"
value="true"/>
</factory>
</xslt>
<echo message="Validate" />
<!-- validate -->
<xslt basedir="@{basedir}"
destdir="${pwd}/out"
includes="@{includes}"
style="${schematron.xsl}"
classpath="@{saxon.jar}">
<factory name="net.sf.saxon.TransformerFactoryImpl">
<attribute
name="http://saxon.sf.net/feature/allow-external-functions"
value="true"/>
<attribute
name="http://saxon.sf.net/feature/linenumbering"
value="true"/>
</factory>
<identitymapper />
</xslt>
<!-- compile check schematron -->
<xslt basedir="@{basedir}"
style="${iso.schematron.dir}/iso_schematron_message_${schematron.binding}.xsl"
in="${stf.basedir.converted}/schematron/check.sch"
out="${check-schematron.xsl}"
classpath="${saxon.jar}">
<factory name="net.sf.saxon.TransformerFactoryImpl">
<attribute
name="http://saxon.sf.net/feature/allow-external-functions"
value="true"/>
<attribute
name="http://saxon.sf.net/feature/linenumbering"
value="true"/>
</factory>
<identitymapper />
</xslt>
<!-- check -->
<xslt basedir="${pwd}/out"
destdir="${pwd}/check"
includes="@{includes}"
style="${check-schematron.xsl}"
classpath="${saxon.jar}">
<identitymapper />
<factory name="net.sf.saxon.TransformerFactoryImpl">
<attribute
name="http://saxon.sf.net/feature/validation-warnings"
value="false"/>
<attribute
name="http://saxon.sf.net/feature/linenumbering"
value="true"/>
</factory>
</xslt>
</sequential>
</macrodef>
<target name="run.schematron">
<schematron />
</target>
<!-- Utility targets. -->
<target name="echoproperties">
<echoproperties />
</target>
<target name="markdown">
<exec executable="markdown"
output="README.html">
<arg value="README.md" />
</exec>
</target>
</project>