forked from itplr-kosit/xrechnung-schematron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
183 lines (180 loc) · 9.18 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
<project name="xrechnung-schematron" default="compile-schematron-rules"
basedir=".">
<description>Build the XRechnung Schematron for ITPLR-KoSIT</description>
<!-- set global properties for this build -->
<!-- main build directories -->
<property name="src.dir" location="${basedir}/validation" />
<property name="lib.dir" location="${basedir}/lib" />
<property name="build.dir" location="${basedir}/build" />
<property name="download.dir" location="${build.dir}/download" />
<property name="dist.dir" location="${basedir}/dist" />
<property name="test.src.dir" location="${basedir}/test" />
<property name="test.build.dir" location="${build.dir}/test" />
<property name="bis.build.dir" location="${basedir}/build/bis" />
<!-- Naming -->
<property name="xr-schematron.version.full" value="1.2.0" />
<property name="xrechnung.version" value="1.2.0" />
<property name="dist.name"
value="xrechnung-${xrechnung.version}-schematron-${xr-schematron.version.full}" />
<property name="saxon.jar" value="saxon9he.jar" />
<property name="xr-schematron.zip" value="${dist.name}.zip" />
<macrodef name="schematron-compile"
description="Compiles Schematron to XSLT using Saxon">
<attribute name="schematron" description="Schematron file to compile." />
<attribute name="workdir"
description="Base directory in which to download Schematron Skeleton and keep intermediaries." />
<attribute name="outdir" />
<attribute name="insuffix" default="sch" />
<attribute name="saxon.jar" default="${lib.dir}/${saxon.jar}"
description="Location of Saxon jar." />
<attribute name="deleteonexit" default="true"
description="Whether to delete intermediate XSLT files on exit. Note if not deleting, then subsequent runs of macro produce wrong results!" />
<attribute name="schematronbinding" default="xslt2"
description="Which XSLT version to build for." />
<sequential>
<local name="schematron.basename" />
<basename file="@{schematron}" suffix="@{insuffix}"
property="schematron.basename" />
<echo
message="Compiling '@{schematron}' Schematron with basename='${schematron.basename}'" />
<mkdir dir="@{workdir}" />
<tempfile property="expanded.sch" prefix="expanded" suffix=".sch"
destdir="@{workdir}" deleteonexit="@{deleteonexit}" />
<tempfile property="unabstract.sch" prefix="unabstract"
suffix=".sch" destdir="@{workdir}"
deleteonexit="@{deleteonexit}" />
<tempfile property="schematron.xsl" prefix="schematron"
suffix=".xsl" destdir="@{workdir}"
deleteonexit="@{deleteonexit}" />
<tempfile property="check-schematron.xsl" prefix="check-schematron"
suffix=".xsl" destdir="@{workdir}"
deleteonexit="@{deleteonexit}" />
<!-- Download schematron skeletons -->
<property name="schematron.skeleton.url"
value="https://raw.githubusercontent.com/Schematron/schematron/master/trunk/schematron/code" />
<get src="${schematron.skeleton.url}/iso_dsdl_include.xsl"
dest="@{workdir}" verbose="true" skipexisting="true"
usetimestamp="true" httpusecaches="true" />
<get src="${schematron.skeleton.url}/iso_abstract_expand.xsl"
dest="@{workdir}" verbose="true" skipexisting="true"
usetimestamp="true" httpusecaches="true" />
<get
src="${schematron.skeleton.url}/iso_svrl_for_@{schematronbinding}.xsl"
dest="@{workdir}" verbose="true" skipexisting="true"
usetimestamp="true" httpusecaches="true" />
<get
src="${schematron.skeleton.url}/iso_schematron_skeleton_for_saxon.xsl"
dest="@{workdir}" verbose="true" skipexisting="true"
usetimestamp="true" httpusecaches="true" />
<!-- expand inclusions -->
<xslt style="@{workdir}/iso_dsdl_include.xsl" in="@{schematron}"
out="@{workdir}/${schematron.basename}-expanded.sch"
classpath="@{saxon.jar}">
<factory name="net.sf.saxon.TransformerFactoryImpl" />
</xslt>
<!-- expand abstract patterns -->
<xslt style="@{workdir}/iso_abstract_expand.xsl"
in="@{workdir}/${schematron.basename}-expanded.sch"
out="@{workdir}/${schematron.basename}-unabstract.sch"
classpath="@{saxon.jar}">
<factory name="net.sf.saxon.TransformerFactoryImpl" />
</xslt>
<!-- svrl it -->
<xslt style="@{workdir}/iso_svrl_for_@{schematronbinding}.xsl"
in="@{workdir}/${schematron.basename}-unabstract.sch"
out="@{outdir}/${schematron.basename}.xsl"
classpath="@{saxon.jar}">
<factory name="net.sf.saxon.TransformerFactoryImpl" />
<param name="generate-fired-rule" expression="false" />
<param name="full-path-notation" expression="3" />
</xslt>
<echo
message="finished schematron compile output to @{outdir}/${schematron.basename}.xslt"
/>
</sequential>
</macrodef>
<target name="init"
description="Initializes build directory structure and ISO timestamp">
<!-- Create timestamps -->
<tstamp>
<format property="build.date" pattern="yyyy-MM-dd" />
</tstamp>
<echo>Build date: ${build.date}</echo>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build.dir}" />
<mkdir dir="${download.dir}" />
<mkdir dir="${lib.dir}" />
<mkdir dir="${dist.dir}" />
</target>
<target name="prepare-saxon" depends="init"
description="Download Saxon-HE and add jar to library directory">
<get
src="https://sourceforge.net/projects/saxon/files/Saxon-HE/9.8/SaxonHE9-8-0-8J.zip/download"
dest="${download.dir}/SaxonHE9-8-0-8J.zip" verbose="true"
skipexisting="true" usetimestamp="true" />
<unzip src="${download.dir}/SaxonHE9-8-0-8J.zip" dest="${lib.dir}">
<patternset>
<include name="**/${saxon.jar}" />
</patternset>
<flattenmapper />
</unzip>
</target>
<target name="prepare-build-dir" depends="init"
description="Works for zip from master and release zips">
<copy todir="${build.dir}">
<fileset dir="${src.dir}">
<include name="**/*.sch" />
<exclude name="**/*.xsl" />
<exclude name="**/XRechnung-UBL-validation.sch" />
</fileset>
<fileset dir="${basedir}">
<include name="README.md" />
<include name="CHANGELOG.md" />
</fileset>
</copy>
</target>
<target name="compile-schematron-rules"
depends="prepare-saxon, prepare-build-dir"
description="Works for zip from master and release zips">
<schematron-compile
schematron="${build.dir}/schematron/cii/XRechnung-CII-validation.sch"
insuffix="sch" workdir="${download.dir}"
outdir="${build.dir}/schematron/cii" deleteonexit="false" />
<schematron-compile
schematron="${build.dir}/schematron/ubl-cn/XRechnung-UBL-validation-CreditNote.sch"
insuffix="sch" workdir="${download.dir}"
outdir="${build.dir}/schematron/ubl-cn" />
<schematron-compile
schematron="${build.dir}/schematron/ubl-inv/XRechnung-UBL-validation-Invoice.sch"
insuffix="sch" workdir="${download.dir}"
outdir="${build.dir}/schematron/ubl-inv" deleteonexit="false" />
</target>
<target name="compile-schematron-rules-bis"
depends="compile-schematron-rules"
description="Compiles schematron rules for OpenPeppol
BIS">
<mkdir dir="${bis.build.dir}" />
<copy todir="${bis.build.dir}">
<fileset dir="${test.src.dir}">
<include name="instances/bis/**/*.xml" />
</fileset>
<cutdirsmapper dirs="2"/>
</copy>
<copy file="src/bis/DE-PeppolBis3.0-UBL.sch" todir="${bis.build.dir}/UBL"
/>
<copy file="src/bis/DE-PeppolBis3.0-CII.sch"
todir="${bis.build.dir}/CII"/>
</target>
<target name="dist" depends="compile-schematron-rules"
description="Generate the distribution">
<zip destfile="${dist.dir}/${xr-schematron.zip}" basedir="${build.dir}"
excludes="download/**,schematron/QS*2017/**" />
<zip destfile="${dist.dir}/German_Rules_BISBilling.zip" basedir="${build.dir}/bis"
excludes="download/**,schematron/QS*2017/**" />
</target>
<target name="clean" description="clean up">
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build.dir}" verbose="true" includeEmptyDirs="true" />
<delete dir="${dist.dir}" />
</target>
</project>