blob: 2ea77af8cbbc8bddc1d90137f3abb6a3b1ccc2b8 [file] [log] [blame]
Akron9a8ee3e2022-01-31 13:51:49 +01001<?xml version="1.0" encoding="UTF-8"?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
bansp5e2d1c02022-03-10 04:51:40 +01003 xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:nkjp="http://www.nkjp.pl/ns/1.0"
4 xmlns:tei="http://www.tei-c.org/ns/1.0" xmlns:f="func"
Piotr Banskif8af3a92022-05-23 03:20:10 +02005 xmlns:fn="http://www.w3.org/2005/xpath-functions"
Piotr Banski763b41f2022-06-02 01:13:23 +02006 xmlns:xi="http://www.w3.org/2001/XInclude"
7 xmlns:map="http://www.w3.org/2005/xpath-functions/map" exclude-result-prefixes="xs f fn map nkjp tei xi"
bansp5e2d1c02022-03-10 04:51:40 +01008 version="3.0" expand-text="yes">
Akron9a8ee3e2022-01-31 13:51:49 +01009
banspe726b4a2022-03-28 05:47:45 +020010
11<!-- PARAMETERS -->
bansp5e2d1c02022-03-10 04:51:40 +010012
bansp8f6700b2022-03-27 05:27:09 +020013 <xsl:param name="sourceDir" select="'test/resources/nkjp2korap_sample2'" as="xs:string"/>
banspd1bf1db2022-04-04 02:16:24 +020014 <!-- the directory containing NKJP files, in the form of a collection of text-level dirs
15 (that is how we know both the $corpusID and the $docID) -->
Akron9a8ee3e2022-01-31 13:51:49 +010016
bansp8f6700b2022-03-27 05:27:09 +020017 <xsl:param name="targetDir" select="'test/output'" as="xs:string"/>
banspd1bf1db2022-04-04 02:16:24 +020018 <!-- where the corpus/document/text/annotations hierarchy is going to be created -->
banspf2b24e62022-03-28 18:12:08 +020019
20 <xsl:param name="skip_docID" as="xs:string">
Piotr Banskic5950ce2022-05-27 15:07:08 +020021 <!--<xsl:value-of select="''"/>-->
22 <xsl:value-of select="'HellerPodgladanie,IsakowiczZaleskiMoje,KolakowskiOco,MysliwskiKamien,WilkWilczy,ZycieWarszawy_Zycie'"/>
banspb5992532022-03-29 15:55:44 +020023 </xsl:param>
24 <!-- comma-separated list of document IDs to be skipped from processing
banspf2b24e62022-03-28 18:12:08 +020025 example: HellerPodgladanie,KOT
banspd1bf1db2022-04-04 02:16:24 +020026 no functionality beyond string identity is supported
27 (this is just for testing) -->
banspb5992532022-03-29 15:55:44 +020028
Piotr Banski1ae16bd2022-05-25 15:59:40 +020029 <xsl:param name="SHOW_ORTH_IN_STRUCT" as="xs:boolean" select="true()"/>
Piotr Banski09096ee2022-05-25 13:41:03 +020030 <!-- for debugging structure.xml production -->
31
bansp8f6700b2022-03-27 05:27:09 +020032
bansp9dc10002022-05-17 22:33:34 +020033<!-- VARIABLES (= constants...) -->
banspe726b4a2022-03-28 05:47:45 +020034
35 <xsl:variable name="corpusID" as="xs:string" select="'NKJP'" static="yes"/>
36 <xsl:variable name="docID" as="xs:string" select="'NKJP'" static="yes"/>
bansp8f6700b2022-03-27 05:27:09 +020037
38 <xsl:variable name="targetCorpusDir_slashed" select="$targetDir || '/' || $corpusID || '/'" as="xs:string"/>
bansp5e2d1c02022-03-10 04:51:40 +010039
banspd1bf1db2022-04-04 02:16:24 +020040 <xsl:variable name="systemDoctypeI5" as="xs:string"
41 select="'http://corpora.ids-mannheim.de/I5/DTD/i5.dtd'" static="true"/>
bansp5e2d1c02022-03-10 04:51:40 +010042
banspd1bf1db2022-04-04 02:16:24 +020043 <xsl:variable name="publicDoctypeI5" as="xs:string" static="true"
44 select="'-//IDS//DTD I5 1.0//EN'"/>
bansp5e2d1c02022-03-10 04:51:40 +010045
banspd1bf1db2022-04-04 02:16:24 +020046 <xsl:variable name="KorAP_namespace" static="true" as="xs:string"
47 select="'http://ids-mannheim.de/ns/KorAP'"/>
bansp5e2d1c02022-03-10 04:51:40 +010048
bansp5f841732022-03-16 06:27:31 +010049 <xsl:variable name="KorAP-XML_version" select="'KorAP-0.4'" as="xs:string" static="true"/>
50 <!-- this is only a bit funny -->
51
banspe726b4a2022-03-28 05:47:45 +020052 <xsl:variable name="collection_params" as="xs:string" static="yes"
53 select="'recurse=yes;validation=strip;select=text.xml;content-type=application/xml;on-error=warning;xinclude=yes'"
54 />
55 <!-- see https://www.saxonica.com/documentation11/index.html#!sourcedocs/collections/collection-directories -->
56
57 <xsl:variable name="collection_of_text" select="collection($sourceDir || '?' || $collection_params)" as="document-node()+"/>
banspd1bf1db2022-04-04 02:16:24 +020058
banspe726b4a2022-03-28 05:47:45 +020059<!-- MODES -->
bansp5e2d1c02022-03-10 04:51:40 +010060
Piotr Banski43b9db02022-06-03 02:38:42 +020061 <xsl:mode name="struct" on-no-match="deep-skip"/>
Piotr Banskifaa910f2022-06-03 00:46:29 +020062 <xsl:mode name="corpus-header" on-no-match="deep-skip"/>
Piotr Banskia0a9fc02022-06-03 01:20:18 +020063 <xsl:mode name="text-header" on-no-match="deep-skip"/>
64 <xsl:mode name="text_inside_header" on-no-match="text-only-copy"/>
Piotr Banski763b41f2022-06-02 01:13:23 +020065 <xsl:mode name="copy" on-no-match="shallow-copy"/>
Piotr Banski6a4a2522022-05-24 01:16:47 +020066 <xsl:mode use-accumulators="#all"/>
Piotr Banski09096ee2022-05-25 13:41:03 +020067
Piotr Banskie1ac5202022-05-30 21:25:21 +020068 <xsl:accumulator name="element-index" as="xs:integer" initial-value="0">
69 <xsl:accumulator-rule match="tei:*[ancestor-or-self::tei:text]" select="$value + 1" phase="start"/>
Piotr Banski09096ee2022-05-25 13:41:03 +020070 </xsl:accumulator>
Piotr Banskifdc858a2022-05-25 02:40:32 +020071
Piotr Banski65a6d0b2022-05-31 17:23:08 +020072
73
74 <!--I think I may be able to actually merge the two accumulators, but let's see-->
75 <xsl:accumulator name="morpho-offsets" as="map(xs:string, item()+)+" initial-value="(map{'null':(0,0)})">
Piotr Banskifdc858a2022-05-25 02:40:32 +020076
77 <xsl:accumulator-rule match="tei:body/tei:p" phase="start">
78 <xsl:variable name="preceding_index" as="xs:integer">
79 <xsl:variable name="the_tail" as="map(*)" select="head(reverse($value))"/>
80 <xsl:sequence select="map:get($the_tail,map:keys($the_tail)[1])[2]"/>
Piotr Banski6a4a2522022-05-24 01:16:47 +020081 </xsl:variable>
82
Piotr Banskifdc858a2022-05-25 02:40:32 +020083 <xsl:variable name="our_base" as="xs:integer" select="if($preceding_index eq 0) then $preceding_index else $preceding_index + 1"/>
84 <!-- for paragraphs, it's in either being initial or not -->
Piotr Banski09096ee2022-05-25 13:41:03 +020085
Piotr Banskifdc858a2022-05-25 02:40:32 +020086 <xsl:sequence select="
87 $value,
88 map {
89 string(@xml:id): ($preceding_index,$our_base)
90 }"/>
91 </xsl:accumulator-rule>
Piotr Banski65a6d0b2022-05-31 17:23:08 +020092 <!-- this is morpho-offsets -->
Piotr Banskifdc858a2022-05-25 02:40:32 +020093 <xsl:accumulator-rule match="tei:s" phase="start">
94 <xsl:variable name="preceding_index" as="xs:integer">
95 <xsl:variable name="the_tail" as="map(*)" select="head(reverse($value))"/>
96 <xsl:sequence select="map:get($the_tail,map:keys($the_tail)[1])[2]"/>
Piotr Banskifdc858a2022-05-25 02:40:32 +020097 </xsl:variable>
Piotr Banski92791a22022-05-26 01:41:10 +020098 <xsl:variable name="our_base" as="xs:integer" select="if($preceding_index eq 0) then $preceding_index else $preceding_index + xs:integer(f:is_preceded_by_ws(.,true()))"/>
Piotr Banski09096ee2022-05-25 13:41:03 +020099
Piotr Banskifdc858a2022-05-25 02:40:32 +0200100 <xsl:sequence select="
101 $value,
102 map {
103 string(@xml:id): ($preceding_index,$our_base)
104 }"/>
105 </xsl:accumulator-rule>
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200106 <!-- this is morpho-offsets -->
107
108<!-- I want something that won't be matched in other layers, for efficiency - that
109 may allow me to merge the accumulators, eventually;
110 but I also want to filter out the rejected tokenization alternatives already here -->
111 <xsl:accumulator-rule match="tei:seg[tei:fs[@type eq 'morph' and tei:f[@name eq 'disamb']]]" phase="end">
112
Piotr Banskifdc858a2022-05-25 02:40:32 +0200113 <xsl:variable name="preceding_index" as="xs:integer">
114 <xsl:variable name="the_tail" as="map(*)" select="head(reverse($value))"/>
115 <xsl:sequence select="map:get($the_tail,map:keys($the_tail)[1])[2]"/>
Piotr Banskifdc858a2022-05-25 02:40:32 +0200116 </xsl:variable>
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200117 <xsl:variable name="our_base" as="xs:integer" select="$preceding_index + xs:integer(f:is_preceded_by_ws(.,true()))"/>
Piotr Banski09096ee2022-05-25 13:41:03 +0200118
Piotr Banski6a4a2522022-05-24 01:16:47 +0200119 <xsl:sequence select="
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200120 $value,
121 map {
122 string(@xml:id): ($our_base,$our_base + string-length(tei:fs/tei:f[@name eq 'orth']/tei:string))
123 }"/>
124
Piotr Banski6a4a2522022-05-24 01:16:47 +0200125 </xsl:accumulator-rule>
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200126 <!-- this is morpho-offsets -->
Piotr Banskifdc858a2022-05-25 02:40:32 +0200127 <xsl:accumulator-rule match="tei:s" phase="end">
128 <xsl:variable name="preceding_index" as="xs:integer">
129 <xsl:variable name="the_tail" as="map(*)" select="head(reverse($value))"/>
130 <xsl:sequence select="map:get($the_tail,map:keys($the_tail)[1])[2]"/>
Piotr Banski09096ee2022-05-25 13:41:03 +0200131
Piotr Banskifdc858a2022-05-25 02:40:32 +0200132 </xsl:variable>
133 <xsl:variable name="our_base" as="xs:integer">
134 <xsl:variable name="incomplete" select="map:find($value,string(@xml:id))(1)" as="xs:integer+"/>
135 <xsl:sequence select="$incomplete[2]"/>
136 </xsl:variable>
Piotr Banski09096ee2022-05-25 13:41:03 +0200137
Piotr Banskifdc858a2022-05-25 02:40:32 +0200138 <xsl:sequence select="
139 $value,
140 map {
141 string(@xml:id): ($our_base,$preceding_index)
142 }"/>
143 </xsl:accumulator-rule>
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200144 <!-- this is morpho-offsets -->
Piotr Banskifdc858a2022-05-25 02:40:32 +0200145 <xsl:accumulator-rule match="tei:body/tei:p" phase="end">
146 <xsl:variable name="preceding_index" as="xs:integer">
147 <xsl:variable name="the_tail" as="map(*)" select="head(reverse($value))"/>
148 <xsl:sequence select="map:get($the_tail,map:keys($the_tail)[1])[2]"/>
149
Piotr Banskifdc858a2022-05-25 02:40:32 +0200150 </xsl:variable>
151 <xsl:variable name="our_base" as="xs:integer">
152 <xsl:variable name="incomplete" select="map:find($value,string(@xml:id))(1)" as="xs:integer+"/>
153 <xsl:sequence select="$incomplete[2]"/>
154 </xsl:variable>
Piotr Banski09096ee2022-05-25 13:41:03 +0200155
Piotr Banskifdc858a2022-05-25 02:40:32 +0200156 <xsl:sequence select="
157 $value,
158 map {
159 string(@xml:id): ($our_base,$preceding_index)
160 }"/>
161 </xsl:accumulator-rule>
Piotr Banski43b9db02022-06-03 02:38:42 +0200162
163 <xsl:accumulator-rule match="tei:body" phase="end">
164 <xsl:variable name="preceding_index" as="xs:integer">
165 <xsl:variable name="the_tail" as="map(*)" select="head(reverse($value))"/>
166 <xsl:sequence select="map:get($the_tail, map:keys($the_tail)[1])[2]"/>
167 </xsl:variable>
168
169 <xsl:sequence select="
170 $value,
171 map {
172 string(@xml:id): (0, $preceding_index)
173 }"/>
174 </xsl:accumulator-rule>
175
176 <xsl:accumulator-rule match="tei:text" phase="end">
177 <xsl:variable name="preceding_index" as="xs:integer">
178 <xsl:variable name="the_tail" as="map(*)" select="head(reverse($value))"/>
179 <xsl:sequence select="map:get($the_tail, map:keys($the_tail)[1])[2]"/>
180 </xsl:variable>
181
182 <xsl:sequence select="
183 $value,
184 map {
185 string(@xml:id): (0, $preceding_index)
186 }"/>
187 </xsl:accumulator-rule>
188
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200189 </xsl:accumulator>
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200190
191 <xsl:accumulator name="segmentation-offsets" as="map(xs:string, item()+)+" initial-value="(map{'null':(0,0)})">
192
193 <xsl:accumulator-rule match="tei:body/tei:p" phase="start">
194 <xsl:variable name="preceding_index" as="xs:integer">
195 <xsl:variable name="the_tail" as="map(*)" select="head(reverse($value))"/>
196 <xsl:sequence select="map:get($the_tail,map:keys($the_tail)[1])[2]"/>
197 </xsl:variable>
198
199 <xsl:variable name="our_base" as="xs:integer" select="if($preceding_index eq 0) then $preceding_index else $preceding_index + 1"/>
200 <!-- for paragraphs, it's in either being initial or not -->
201
202 <xsl:sequence select="
203 $value,
204 map {
205 string(@xml:id): ($preceding_index,$our_base)
206 }"/>
207 </xsl:accumulator-rule>
208
209 <xsl:accumulator-rule match="tei:s" phase="start">
210 <xsl:variable name="preceding_index" as="xs:integer">
211 <xsl:variable name="the_tail" as="map(*)" select="head(reverse($value))"/>
212 <xsl:sequence select="map:get($the_tail,map:keys($the_tail)[1])[2]"/>
213 </xsl:variable>
214 <xsl:variable name="our_base" as="xs:integer" select="if($preceding_index eq 0) then $preceding_index else $preceding_index + xs:integer(f:is_preceded_by_ws(.,true()))"/>
215
216 <xsl:sequence select="
217 $value,
218 map {
219 string(@xml:id): ($preceding_index,$our_base)
220 }"/>
221 </xsl:accumulator-rule>
222
223 <xsl:accumulator-rule match="tei:w[parent::tei:seg[count(@nkjp:rejected) eq 0]]" phase="end">
224 <xsl:variable name="preceding_index" as="xs:integer">
225 <xsl:variable name="the_tail" as="map(*)" select="head(reverse($value))"/>
226 <xsl:sequence select="map:get($the_tail,map:keys($the_tail)[1])[2]"/>
227 </xsl:variable>
228 <xsl:variable name="our_base" as="xs:integer" select="$preceding_index + xs:integer(f:is_preceded_by_ws(parent::tei:seg,true()))"/>
229
230 <xsl:sequence select="
231 $value,
232 map {
233 string(parent::tei:seg/@xml:id): ($our_base,$our_base + string-length())
234 }"/>
235 </xsl:accumulator-rule>
236
237 <xsl:accumulator-rule match="tei:s" phase="end">
238 <xsl:variable name="preceding_index" as="xs:integer">
239 <xsl:variable name="the_tail" as="map(*)" select="head(reverse($value))"/>
240 <xsl:sequence select="map:get($the_tail,map:keys($the_tail)[1])[2]"/>
241
242 </xsl:variable>
243 <xsl:variable name="our_base" as="xs:integer">
244 <xsl:variable name="incomplete" select="map:find($value,string(@xml:id))(1)" as="xs:integer+"/>
245 <xsl:sequence select="$incomplete[2]"/>
246 </xsl:variable>
247
248 <xsl:sequence select="
249 $value,
250 map {
251 string(@xml:id): ($our_base,$preceding_index)
252 }"/>
253 </xsl:accumulator-rule>
254
255 <xsl:accumulator-rule match="tei:body/tei:p" phase="end">
256 <xsl:variable name="preceding_index" as="xs:integer">
257 <xsl:variable name="the_tail" as="map(*)" select="head(reverse($value))"/>
258 <xsl:sequence select="map:get($the_tail,map:keys($the_tail)[1])[2]"/>
259
260 </xsl:variable>
261 <xsl:variable name="our_base" as="xs:integer">
262 <xsl:variable name="incomplete" select="map:find($value,string(@xml:id))(1)" as="xs:integer+"/>
263 <xsl:sequence select="$incomplete[2]"/>
264 </xsl:variable>
265
266 <xsl:sequence select="
267 $value,
268 map {
269 string(@xml:id): ($our_base,$preceding_index)
270 }"/>
271 </xsl:accumulator-rule>
Piotr Banskifdc858a2022-05-25 02:40:32 +0200272
273 <xsl:accumulator-rule match="tei:body" phase="end">
274 <xsl:variable name="preceding_index" as="xs:integer">
275 <xsl:variable name="the_tail" as="map(*)" select="head(reverse($value))"/>
276 <xsl:sequence select="map:get($the_tail, map:keys($the_tail)[1])[2]"/>
277 </xsl:variable>
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200278
Piotr Banskifdc858a2022-05-25 02:40:32 +0200279 <xsl:sequence select="
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200280 $value,
281 map {
282 string(@xml:id): (0, $preceding_index)
283 }"/>
Piotr Banskifdc858a2022-05-25 02:40:32 +0200284 </xsl:accumulator-rule>
285
286 <xsl:accumulator-rule match="tei:text" phase="end">
287 <xsl:variable name="preceding_index" as="xs:integer">
288 <xsl:variable name="the_tail" as="map(*)" select="head(reverse($value))"/>
289 <xsl:sequence select="map:get($the_tail, map:keys($the_tail)[1])[2]"/>
290 </xsl:variable>
291
292 <xsl:sequence select="
293 $value,
294 map {
295 string(@xml:id): (0, $preceding_index)
296 }"/>
297 </xsl:accumulator-rule>
Piotr Banski6a4a2522022-05-24 01:16:47 +0200298 </xsl:accumulator>
bansp5e2d1c02022-03-10 04:51:40 +0100299
banspe726b4a2022-03-28 05:47:45 +0200300 <!-- FUNCTIONS -->
301
bansp5f841732022-03-16 06:27:31 +0100302 <xsl:function name="f:compute_nesting" as="xs:integer">
banspd1bf1db2022-04-04 02:16:24 +0200303 <xsl:param name="node" as="element()"/>
bansp5f841732022-03-16 06:27:31 +0100304 <xsl:variable name="rel_depth"
305 select="count($node/ancestor-or-self::*[local-name(.) ne 'TEI'][local-name(.) ne 'teiCorpus'])"
306 as="xs:integer"/>
bansp5f841732022-03-16 06:27:31 +0100307 <xsl:sequence select="$rel_depth"/>
308 </xsl:function>
309
Piotr Banski92791a22022-05-26 01:41:10 +0200310 <xsl:function name="f:is_preceded_by_ws" as="xs:boolean">
bansp9dc10002022-05-17 22:33:34 +0200311 <xsl:param name="node" as="element()"/>
Piotr Banskifdc858a2022-05-25 02:40:32 +0200312 <xsl:param name="suppress_initial" as="xs:boolean"/>
Piotr Banski4f4c2d22022-05-19 01:44:32 +0200313
Piotr Banski92791a22022-05-26 01:41:10 +0200314 <xsl:choose>
315 <xsl:when test="local-name($node) eq 'seg'">
316 <xsl:choose>
317 <xsl:when test="$node/@nkjp:nps">
318 <xsl:sequence select="fn:false()"/>
319 </xsl:when>
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200320 <xsl:when test="$node/tei:fs/tei:f[@name eq 'nps']">
321 <!--added for traversing ann_morphosyntax-->
322 <xsl:sequence select="fn:false()"/>
323 </xsl:when>
Piotr Banski92791a22022-05-26 01:41:10 +0200324 <xsl:when
325 test="$node/ancestor::tei:s[count(preceding-sibling::tei:s) eq 0] and $node/ancestor::tei:p[count(preceding-sibling::tei:p) eq 0] and not($node/preceding::tei:seg[count(@nkjp:rejected) eq 0])">
326 <xsl:sequence select="fn:false()"/>
327 <!-- the otherwise very costly check for preceding segs fires only if the first two are true, so it will have minimal search space -->
328 </xsl:when>
329 <xsl:when
330 test="$suppress_initial and $node/ancestor::tei:s/descendant::tei:seg[count(@nkjp:rejected) eq 0][1]/@xml:id eq $node/@xml:id">
331 <!-- I forget how node identity works now, so let me just compare the IDs -->
332 <xsl:sequence select="fn:false()"/>
333 </xsl:when>
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200334 <xsl:when
335 test="$suppress_initial and $node/ancestor::tei:s/descendant::tei:seg[tei:fs/tei:f[@name eq 'disamb']][1]/@xml:id eq $node/@xml:id">
336 <!--added for traversing ann_morphosyntax-->
337 <xsl:sequence select="fn:false()"/>
338 </xsl:when>
Piotr Banski92791a22022-05-26 01:41:10 +0200339 <xsl:otherwise>
340 <xsl:sequence select="fn:true()"/>
341 </xsl:otherwise>
342 </xsl:choose>
343 </xsl:when>
344 <xsl:when test="local-name($node) eq 's'">
345 <xsl:choose>
346 <xsl:when test="exists($node/preceding-sibling::tei:s)">
347 <xsl:sequence select="fn:true()"/>
348 </xsl:when>
349 <xsl:otherwise>
350 <xsl:sequence
351 select="not($suppress_initial) and exists($node/ancestor::tei:p[1]/preceding-sibling::tei:p)"
352 />
353 </xsl:otherwise>
354 </xsl:choose>
355
356 </xsl:when>
357 <xsl:when test="local-name($node) eq 'p'">
358 <xsl:sequence select="exists($node/preceding-sibling::tei:p)"/>
359 </xsl:when>
360 <xsl:otherwise>
361 <xsl:message terminate="yes"
362 select="'Wrong argument passed to f:is_preceded_by_ws(): ' || local-name($node) || ' Only p, s, seg are allowed.'"
363 />
364 </xsl:otherwise>
365 </xsl:choose>
366 </xsl:function>
banspd1bf1db2022-04-04 02:16:24 +0200367
banspb5992532022-03-29 15:55:44 +0200368<!-- UTILITY TEMPLATES -->
369
bansp9103aab2022-03-19 05:10:21 +0100370 <xsl:template match="@default" mode="#all"/>
bansp97ba7ce2022-03-26 05:14:06 +0100371 <!-- this is to delete some auto-inserted attribute throughout -->
bansp9103aab2022-03-19 05:10:21 +0100372
Piotr Banski6a4a2522022-05-24 01:16:47 +0200373 <xsl:template match="tei:w" mode="#all"/>
banspe726b4a2022-03-28 05:47:45 +0200374<!-- NKJP-SGJP has apparently resigned from standoff representations by adding <w> everywhere;
Piotr Banskifdc858a2022-05-25 02:40:32 +0200375 we reach for them, but from the level of <seg>, so we don't need to process <w> separately -->
bansp8f6700b2022-03-27 05:27:09 +0200376
Piotr Banski09096ee2022-05-25 13:41:03 +0200377 <!-- fall-thru, skipping the potential <paren> element and filtering out the bad guys -->
Piotr Banski6a4a2522022-05-24 01:16:47 +0200378 <xsl:template match="tei:choice" mode="struct">
Piotr Banski09096ee2022-05-25 13:41:03 +0200379 <xsl:apply-templates select="descendant::tei:seg[count(@nkjp:rejected) eq 0]" mode="struct"/>
Piotr Banski6a4a2522022-05-24 01:16:47 +0200380 </xsl:template>
Piotr Banskia51907c2022-05-25 15:09:41 +0200381 <xsl:template match="tei:choice" mode="morpho">
382 <xsl:apply-templates select="descendant::tei:seg[count(@nkjp:rejected) eq 0]" mode="morpho"/>
383 </xsl:template>
banspb5992532022-03-29 15:55:44 +0200384
385 <!-- MAIN PROCESSING -->
386
bansp5e2d1c02022-03-10 04:51:40 +0100387 <xsl:template name="xsl:initial-template">
banspf2b24e62022-03-28 18:12:08 +0200388 <xsl:variable name="IDs_to_skip" select="tokenize($skip_docID,',')" as="xs:string*"/>
banspd1bf1db2022-04-04 02:16:24 +0200389
banspe726b4a2022-03-28 05:47:45 +0200390 <!-- we only want to call the template below once, and we process a random NKJP corpus file for that purpose,
bansp8f6700b2022-03-27 05:27:09 +0200391 because all we need is the main corpus header, and we can (should) get to that from any NKJP corpus document -->
392 <xsl:call-template name="create_corpus_header">
Piotr Banskifaa910f2022-06-03 00:46:29 +0200393 <xsl:with-param name="text.doc" select="$collection_of_text[1]" as="document-node()"/>
bansp8f6700b2022-03-27 05:27:09 +0200394 <xsl:with-param name="target" select="$targetCorpusDir_slashed || 'header.xml'" as="xs:string"/>
395 </xsl:call-template>
396
banspe726b4a2022-03-28 05:47:45 +0200397 <xsl:for-each select="$collection_of_text">
398 <xsl:variable name="my_dir" as="xs:string" select="replace(base-uri(),'/text\.xml','')"/>
399 <xsl:variable name="my_textID" as="xs:string" select="tokenize($my_dir,'/')[last()]"/>
400 <xsl:variable name="ann_morphosyntax.uri" select="$my_dir || '/ann_morphosyntax.xml'" as="xs:string"/>
Piotr Banski081c5de2022-06-03 01:57:13 +0200401 <!--<xsl:variable name="ann_segmentation.uri" select="$my_dir || '/ann_segmentation.xml'" as="xs:string"/>-->
Piotr Banskic5950ce2022-05-27 15:07:08 +0200402 <xsl:variable name="ann_named.uri" select="$my_dir || '/ann_named.xml'" as="xs:string"/>
403 <xsl:variable name="ann_groups.uri" select="$my_dir || '/ann_groups.xml'" as="xs:string"/>
404 <xsl:variable name="ann_words.uri" select="$my_dir || '/ann_words.xml'" as="xs:string"/>
banspe726b4a2022-03-28 05:47:45 +0200405
banspf2b24e62022-03-28 18:12:08 +0200406 <xsl:choose>
407 <xsl:when test="$my_textID = $IDs_to_skip"/>
bansp9dc10002022-05-17 22:33:34 +0200408 <!-- this is a utility step, for when we want to ignore some texts for any reason (debugging, selective update) -->
banspf2b24e62022-03-28 18:12:08 +0200409 <xsl:otherwise>
banspd1bf1db2022-04-04 02:16:24 +0200410
bansp9dc10002022-05-17 22:33:34 +0200411 <xsl:call-template name="process_single_sample">
Piotr Banskif9590692022-06-02 15:39:48 +0200412 <xsl:with-param name="text.doc" as="document-node()" select="."/>
413 <xsl:with-param name="ann_morphosyntax.doc" as="document-node()"
banspf2b24e62022-03-28 18:12:08 +0200414 select="doc($ann_morphosyntax.uri)"/>
Piotr Banski081c5de2022-06-03 01:57:13 +0200415<!-- <xsl:with-param name="ann_segmentation.xml" as="document-node()"
416 select="doc($ann_segmentation.uri)"/>-->
banspf2b24e62022-03-28 18:12:08 +0200417 <xsl:with-param name="my_textID" select="$my_textID" as="xs:string"/>
Piotr Banskic5950ce2022-05-27 15:07:08 +0200418 <!-- the following parameters may happen to be null -->
Piotr Banskif9590692022-06-02 15:39:48 +0200419 <xsl:with-param name="ann_named.doc" as="document-node()*"
Piotr Banskic5950ce2022-05-27 15:07:08 +0200420 select="if(fn:doc-available($ann_named.uri)) then doc($ann_named.uri) else ()"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200421 <xsl:with-param name="ann_groups.doc" as="document-node()*"
Piotr Banskic5950ce2022-05-27 15:07:08 +0200422 select="if(fn:doc-available($ann_groups.uri)) then doc($ann_groups.uri) else ()"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200423 <xsl:with-param name="ann_words.doc" as="document-node()*"
Piotr Banskic5950ce2022-05-27 15:07:08 +0200424 select="if(fn:doc-available($ann_words.uri)) then doc($ann_words.uri) else ()"/>
425
bansp9dc10002022-05-17 22:33:34 +0200426 </xsl:call-template>
banspf2b24e62022-03-28 18:12:08 +0200427 </xsl:otherwise>
428 </xsl:choose>
banspe726b4a2022-03-28 05:47:45 +0200429 </xsl:for-each>
bansp8f6700b2022-03-27 05:27:09 +0200430 </xsl:template>
431
432 <xsl:template name="process_single_sample">
Piotr Banskif9590692022-06-02 15:39:48 +0200433 <xsl:param name="text.doc" as="document-node()"/>
434 <xsl:param name="ann_morphosyntax.doc" as="document-node()"/>
Piotr Banski081c5de2022-06-03 01:57:13 +0200435<!-- <xsl:param name="ann_segmentation.xml" as="document-node()"/>-->
banspd1bf1db2022-04-04 02:16:24 +0200436 <xsl:param name="my_textID" as="xs:string" select="'0-BAD_textID'"/>
bansp9dc10002022-05-17 22:33:34 +0200437 <!-- empty textID should never happen, but if it does, it will be signalled at the top of the output -->
Piotr Banskif9590692022-06-02 15:39:48 +0200438 <xsl:param name="ann_named.doc" as="document-node()*"/>
439 <xsl:param name="ann_groups.doc" as="document-node()*"/>
440 <xsl:param name="ann_words.doc" as="document-node()*"/>
banspe726b4a2022-03-28 05:47:45 +0200441
442 <xsl:variable name="targetBaseDir" as="xs:string" select="$targetCorpusDir_slashed || $docID || '/' || $my_textID"/>
443
444 <xsl:variable name="compoundID" as="xs:string"
445 select="$corpusID || '_' || $docID || '.' || $my_textID"/>
446 <!-- this is what occurs in the text and data layers as @docid -->
447
bansp5e2d1c02022-03-10 04:51:40 +0100448 <xsl:call-template name="create_data">
Piotr Banski081c5de2022-06-03 01:57:13 +0200449 <xsl:with-param name="ann_morphosyntax.doc" select="$ann_morphosyntax.doc" as="document-node()"/>
banspe726b4a2022-03-28 05:47:45 +0200450 <xsl:with-param name="compoundID" select="$compoundID" as="xs:string"/>
451 <xsl:with-param name="target" select="$targetBaseDir || '/data.xml'" as="xs:string"/>
bansp5f841732022-03-16 06:27:31 +0100452 </xsl:call-template>
453
Piotr Banski43b9db02022-06-03 02:38:42 +0200454 <xsl:call-template name="create_struct">
banspe726b4a2022-03-28 05:47:45 +0200455 <xsl:with-param name="compoundID" select="$compoundID" as="xs:string"/>
Piotr Banski43b9db02022-06-03 02:38:42 +0200456 <xsl:with-param name="ann_morphosyntax.doc" select="$ann_morphosyntax.doc"
bansp5f841732022-03-16 06:27:31 +0100457 as="document-node()"/>
banspe726b4a2022-03-28 05:47:45 +0200458 <xsl:with-param name="target" select="$targetBaseDir || '/struct/structure.xml'" as="xs:string"
bansp5f841732022-03-16 06:27:31 +0100459 />
Piotr Banski43b9db02022-06-03 02:38:42 +0200460 </xsl:call-template>
Piotr Banski92791a22022-05-26 01:41:10 +0200461
Piotr Banski081c5de2022-06-03 01:57:13 +0200462<!-- <xsl:call-template name="create_morpho">
banspe726b4a2022-03-28 05:47:45 +0200463 <xsl:with-param name="compoundID" select="$compoundID" as="xs:string"/>
bansp3e5b20c2022-03-18 20:22:31 +0100464 <xsl:with-param name="ann_segmentation.xml" select="$ann_segmentation.xml"
465 as="document-node()"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200466 <xsl:with-param name="ann_morphosyntax.doc" select="$ann_morphosyntax.doc"
bansp5f841732022-03-16 06:27:31 +0100467 as="document-node()"/>
banspe726b4a2022-03-28 05:47:45 +0200468 <xsl:with-param name="target" select="$targetBaseDir || '/nkjp/morpho.xml'" as="xs:string"/>
Piotr Banski081c5de2022-06-03 01:57:13 +0200469 </xsl:call-template>-->
Piotr Banskia51907c2022-05-25 15:09:41 +0200470
Piotr Banski081c5de2022-06-03 01:57:13 +0200471<!--
472
473 THESE ARE SAFE
474
475
476 <xsl:call-template name="create_text_header">
Piotr Banskif9590692022-06-02 15:39:48 +0200477 <xsl:with-param name="text.doc" select="$text.doc" as="document-node()"/>
banspe726b4a2022-03-28 05:47:45 +0200478 <xsl:with-param name="compoundID" select="$compoundID" as="xs:string"/>
479 <xsl:with-param name="target" select="$targetBaseDir || '/header.xml'" as="xs:string"/>
Piotr Banski09096ee2022-05-25 13:41:03 +0200480 </xsl:call-template>
Piotr Banski6a4a2522022-05-24 01:16:47 +0200481
Piotr Banskif9590692022-06-02 15:39:48 +0200482 <xsl:if test="$ann_named.doc">
Piotr Banski763b41f2022-06-02 01:13:23 +0200483 <xsl:variable name="rev_lookup-seq" as="map(*)+">
484 <xsl:for-each
Piotr Banskif9590692022-06-02 15:39:48 +0200485 select="$ann_named.doc//tei:seg/tei:ptr">
Piotr Banski763b41f2022-06-02 01:13:23 +0200486 <xsl:variable name="trg" as="xs:string" select="fn:substring-before(@target, '#')"/>
Piotr Banski081c5de2022-06-03 01:57:13 +0200487 <!-\- caution: as of 01-June-2022, some of the pointers are malformed (missing '#' when referencing locally).
488 so we need to act around it but also sustainably - in case that error gets corrected -\->
Piotr Banski763b41f2022-06-02 01:13:23 +0200489
490 <xsl:if test="fn:string-length($trg) and $trg eq 'ann_morphosyntax.xml'">
491 <xsl:sequence>
492 <xsl:map-entry key="fn:substring-after(fn:string(@target), '#')" select="fn:current()"
493 />
494 </xsl:sequence>
495 </xsl:if>
496 </xsl:for-each>
497 </xsl:variable>
498 <xsl:variable name="rev_lookup" as="map(*)" select="map:merge($rev_lookup-seq,map{'duplicates':'combine'})"/>
499
Piotr Banskic5950ce2022-05-27 15:07:08 +0200500 <xsl:call-template name="create_named">
501 <xsl:with-param name="compoundID" select="$compoundID" as="xs:string"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200502 <xsl:with-param name="ann_morphosyntax.doc" select="$ann_morphosyntax.doc"
Piotr Banskic5950ce2022-05-27 15:07:08 +0200503 as="document-node()"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200504 <xsl:with-param name="ann_named.doc" select="$ann_named.doc"
Piotr Banskic5950ce2022-05-27 15:07:08 +0200505 as="document-node()"/>
506 <xsl:with-param name="target" select="$targetBaseDir || '/nkjp/named.xml'" as="xs:string"/>
Piotr Banski763b41f2022-06-02 01:13:23 +0200507 <xsl:with-param name="rev_lookup" select="$rev_lookup" as="map(*)"/>
Piotr Banskic5950ce2022-05-27 15:07:08 +0200508 </xsl:call-template>
509 </xsl:if>
Piotr Banski081c5de2022-06-03 01:57:13 +0200510-->
Piotr Banskif9590692022-06-02 15:39:48 +0200511 <xsl:if test="$ann_words.doc and $ann_groups.doc">
Piotr Banskic5950ce2022-05-27 15:07:08 +0200512 <xsl:call-template name="create_groups">
513 <xsl:with-param name="compoundID" select="$compoundID" as="xs:string"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200514 <xsl:with-param name="ann_morphosyntax.doc" select="$ann_morphosyntax.doc"
Piotr Banskic5950ce2022-05-27 15:07:08 +0200515 as="document-node()"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200516 <xsl:with-param name="ann_words.doc" select="$ann_words.doc"
Piotr Banskic5950ce2022-05-27 15:07:08 +0200517 as="document-node()"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200518 <xsl:with-param name="ann_groups.doc" select="$ann_groups.doc"
Piotr Banskic5950ce2022-05-27 15:07:08 +0200519 as="document-node()"/>
520 <xsl:with-param name="target" select="$targetBaseDir || '/nkjp/groups.xml'" as="xs:string"/>
521 </xsl:call-template>
522 </xsl:if>
523
bansp5e2d1c02022-03-10 04:51:40 +0100524 </xsl:template>
525
526 <!-- ************************** data.xml ******************* -->
527
528 <xsl:template name="create_data">
Piotr Banski081c5de2022-06-03 01:57:13 +0200529 <xsl:param name="ann_morphosyntax.doc" as="document-node()"/>
banspe726b4a2022-03-28 05:47:45 +0200530 <xsl:param name="compoundID" as="xs:string"/>
bansp5f841732022-03-16 06:27:31 +0100531 <xsl:param name="target" as="xs:string"/>
bansp5e2d1c02022-03-10 04:51:40 +0100532 <!-- create the data.xml file -->
533 <xsl:result-document encoding="UTF-8" method="xml" indent="yes"
bansp5f841732022-03-16 06:27:31 +0100534 xpath-default-namespace="{$KorAP_namespace}" href="{$target}">
bansp5e2d1c02022-03-10 04:51:40 +0100535
Akron9a8ee3e2022-01-31 13:51:49 +0100536 <xsl:processing-instruction name="xml-model">href=&quot;text.rng&quot; type=&quot;application/xml&quot; schematypens=&quot;http://relaxng.org/ns/structure/1.0&quot;</xsl:processing-instruction>
bansp5e2d1c02022-03-10 04:51:40 +0100537 <xsl:element name="raw_text" namespace="{$KorAP_namespace}">
bansp5f841732022-03-16 06:27:31 +0100538 <xsl:attribute name="docid" select="$compoundID"/>
bansp5e2d1c02022-03-10 04:51:40 +0100539 <xsl:element name="metadata" namespace="{$KorAP_namespace}">
540 <xsl:attribute name="file" select="'metadata.xml'"/>
541 </xsl:element>
542
543 <xsl:element name="text" namespace="{$KorAP_namespace}">
bansp9dc10002022-05-17 22:33:34 +0200544 <xsl:variable name="content" as="xs:string+">
Piotr Banski081c5de2022-06-03 01:57:13 +0200545 <!--<xsl:for-each select="$ann_morphosyntax.doc/tei:teiCorpus/tei:TEI/tei:text/tei:body/tei:p/tei:s//tei:seg[count(@nkjp:rejected) eq 0]">-->
546 <xsl:for-each select="$ann_morphosyntax.doc/tei:teiCorpus/tei:TEI/tei:text/tei:body/tei:p/tei:s/tei:seg[tei:fs/tei:f[@name eq 'disamb']]">
bansp9dc10002022-05-17 22:33:34 +0200547 <xsl:sequence select="
Piotr Banskifdc858a2022-05-25 02:40:32 +0200548 if (f:is_preceded_by_ws(.,false())) then
bansp9dc10002022-05-17 22:33:34 +0200549 ' '
550 else
Piotr Banski081c5de2022-06-03 01:57:13 +0200551 '', ./tei:fs/tei:f[@name eq 'orth']/tei:string"/>
bansp9dc10002022-05-17 22:33:34 +0200552 </xsl:for-each>
553 </xsl:variable>
554 <xsl:value-of select="string-join($content)"/>
bansp5e2d1c02022-03-10 04:51:40 +0100555 </xsl:element>
Akron9a8ee3e2022-01-31 13:51:49 +0100556 </xsl:element>
banspf79443e2022-02-25 14:25:33 +0100557 </xsl:result-document>
Akron9a8ee3e2022-01-31 13:51:49 +0100558 </xsl:template>
559
bansp5f841732022-03-16 06:27:31 +0100560 <!-- ************************** struct ******************* -->
561
562 <xsl:template name="create_struct">
banspe726b4a2022-03-28 05:47:45 +0200563 <xsl:param name="compoundID" as="xs:string"/>
Piotr Banski43b9db02022-06-03 02:38:42 +0200564 <xsl:param name="ann_morphosyntax.doc" as="document-node()"/>
bansp5f841732022-03-16 06:27:31 +0100565 <xsl:param name="target" as="xs:string"/>
Piotr Banski4f4c2d22022-05-19 01:44:32 +0200566
bansp5f841732022-03-16 06:27:31 +0100567 <xsl:result-document encoding="UTF-8" method="xml" indent="yes"
568 xpath-default-namespace="http://ids-mannheim.de/ns/KorAP" href="{$target}">
569 <xsl:processing-instruction name="xml-model">href=&quot;span.rng&quot; type=&quot;application/xml&quot; schematypens=&quot;http://relaxng.org/ns/structure/1.0&quot;</xsl:processing-instruction>
570 <xsl:element name="layer" namespace="{$KorAP_namespace}">
571 <xsl:attribute name="docid" select="$compoundID"/>
572 <xsl:attribute name="version" select="$KorAP-XML_version"/>
573
574 <xsl:element name="spanList" namespace="{$KorAP_namespace}">
Piotr Banski43b9db02022-06-03 02:38:42 +0200575 <xsl:apply-templates select="$ann_morphosyntax.doc/tei:teiCorpus/tei:TEI/tei:text" mode="struct"/>
bansp5f841732022-03-16 06:27:31 +0100576 </xsl:element>
577 </xsl:element>
578 </xsl:result-document>
579 </xsl:template>
580
Piotr Banski43b9db02022-06-03 02:38:42 +0200581 <xsl:template match="tei:text | tei:body | tei:p | tei:s | tei:seg[tei:fs/tei:f[@name eq 'disamb']]" mode="struct">
Piotr Banski09096ee2022-05-25 13:41:03 +0200582 <xsl:variable name="offsets" as="xs:integer+">
Piotr Banski43b9db02022-06-03 02:38:42 +0200583 <xsl:sequence select="map:get(fn:accumulator-after('morpho-offsets')[last()], string(@xml:id))"/>
Piotr Banski09096ee2022-05-25 13:41:03 +0200584 </xsl:variable>
Piotr Banski6a4a2522022-05-24 01:16:47 +0200585
bansp5f841732022-03-16 06:27:31 +0100586 <xsl:variable name="my_name" select="local-name()" as="xs:string"/>
Piotr Banskie1ac5202022-05-30 21:25:21 +0200587 <xsl:variable name="my_index" select="fn:accumulator-before('element-index')" as="xs:integer"/>
bansp3e5b20c2022-03-18 20:22:31 +0100588
bansp5f841732022-03-16 06:27:31 +0100589 <xsl:element name="span" namespace="{$KorAP_namespace}">
590 <xsl:attribute name="id" select="'s' || $my_index"/>
Piotr Banski09096ee2022-05-25 13:41:03 +0200591 <xsl:attribute name="from" select="$offsets[1]"/>
592 <xsl:attribute name="to" select="$offsets[2]"/>
bansp5f841732022-03-16 06:27:31 +0100593 <xsl:attribute name="l" select="f:compute_nesting(.)"/>
Piotr Banski09096ee2022-05-25 13:41:03 +0200594 <xsl:if test="local-name() eq 'seg' and $SHOW_ORTH_IN_STRUCT">
595 <xsl:comment><xsl:value-of select="fn:normalize-space(.)"/></xsl:comment>
596 </xsl:if>
bansp5f841732022-03-16 06:27:31 +0100597 <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0">
Piotr Banskifdc858a2022-05-25 02:40:32 +0200598 <xsl:attribute name="type" select="'struct'"></xsl:attribute> <!-- STRUCT vs. LEX for morpho -->
bansp5f841732022-03-16 06:27:31 +0100599 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
bansp3e5b20c2022-03-18 20:22:31 +0100600 <xsl:attribute name="name" select="'name'"/>
601 <xsl:value-of select="local-name()"/>
bansp5f841732022-03-16 06:27:31 +0100602 </xsl:element>
603 <xsl:if test="count(@*)">
604 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
605 <xsl:attribute name="name" select="'attr'"/>
606 <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0">
607 <xsl:attribute name="type" select="'attr'"/>
608 <xsl:for-each select="@*">
609 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
610 <xsl:attribute name="name" select="local-name(.)"/>
611 <xsl:value-of select="."/>
612 </xsl:element>
613 </xsl:for-each>
614 </xsl:element>
615 </xsl:element>
616 </xsl:if>
617 </xsl:element>
618 </xsl:element>
Piotr Banskia51907c2022-05-25 15:09:41 +0200619 <xsl:apply-templates mode="struct"/>
bansp5f841732022-03-16 06:27:31 +0100620 </xsl:template>
621
622 <!-- ************************** morpho ******************* -->
623
624 <xsl:template name="create_morpho">
banspe726b4a2022-03-28 05:47:45 +0200625 <xsl:param name="compoundID" as="xs:string"/>
bansp3e5b20c2022-03-18 20:22:31 +0100626 <xsl:param name="ann_segmentation.xml" as="document-node()"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200627 <xsl:param name="ann_morphosyntax.doc" as="document-node()"/>
bansp5f841732022-03-16 06:27:31 +0100628 <xsl:param name="target" as="xs:string"/>
629
630 <xsl:result-document encoding="UTF-8" method="xml" indent="yes"
631 xpath-default-namespace="http://ids-mannheim.de/ns/KorAP" href="{$target}">
632 <xsl:processing-instruction name="xml-model">href=&quot;span.rng&quot; type=&quot;application/xml&quot; schematypens=&quot;http://relaxng.org/ns/structure/1.0&quot;</xsl:processing-instruction>
bansp3e5b20c2022-03-18 20:22:31 +0100633 <xsl:element name="layer" namespace="{$KorAP_namespace}">
634 <xsl:attribute name="docid" select="$compoundID"/>
635 <xsl:attribute name="version" select="$KorAP-XML_version"/>
636
637 <xsl:element name="spanList" namespace="{$KorAP_namespace}">
638 <xsl:apply-templates select="$ann_segmentation.xml//tei:text" mode="morpho">
Piotr Banskif9590692022-06-02 15:39:48 +0200639 <xsl:with-param name="ann_morphosyntax.doc" select="$ann_morphosyntax.doc" as="document-node()" tunnel="yes"/>
bansp3e5b20c2022-03-18 20:22:31 +0100640 </xsl:apply-templates>
641 </xsl:element>
642 </xsl:element>
bansp5f841732022-03-16 06:27:31 +0100643 </xsl:result-document>
644 </xsl:template>
645
bansp3e5b20c2022-03-18 20:22:31 +0100646 <xsl:template match="tei:seg" mode="morpho">
Piotr Banskif9590692022-06-02 15:39:48 +0200647 <xsl:param name="ann_morphosyntax.doc" as="document-node()" tunnel="yes"/>
Piotr Banskia51907c2022-05-25 15:09:41 +0200648 <!-- it's so spread out because I wanted to make sure to be able to look up the individual
649 constituent values, should anything go wrong; it might get compacted at some point, but
650 the increase in efficiency will probably be minimal, compared to the decrease of readability -->
651 <xsl:variable name="offsets" as="xs:integer+">
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200652 <xsl:sequence select="map:get(fn:accumulator-after('segmentation-offsets')[last()], string(@xml:id))"/>
Piotr Banskia51907c2022-05-25 15:09:41 +0200653 </xsl:variable>
bansp3e5b20c2022-03-18 20:22:31 +0100654 <xsl:variable name="my_name" select="local-name()" as="xs:string"/>
655 <xsl:variable name="my_id" select="@xml:id" as="xs:string"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200656 <xsl:variable name="my_morph-seg" as="node()" select="$ann_morphosyntax.doc//tei:seg[substring-after(@corresp,'#') eq $my_id]"/>
bansp3e5b20c2022-03-18 20:22:31 +0100657 <xsl:variable name="my_disamb" select="$my_morph-seg//tei:fs/tei:f[@name eq 'disamb']" as="node()"/>
658 <xsl:variable name="my_choice-id" select="substring-after($my_disamb//tei:f[@name eq 'choice']/@fVal,'#')" as="xs:string"/>
659 <xsl:variable name="my_choice-lex" select="$my_morph-seg//tei:f[@name eq 'interps']/tei:fs[@type eq 'lex'][descendant::tei:symbol[@xml:id eq $my_choice-id]]" as="node()"/>
660 <xsl:variable name="chosen-msd" as="xs:string" select="$my_choice-lex/descendant::tei:symbol[@xml:id eq $my_choice-id]/@value"/>
Piotr Banskie1ac5202022-05-30 21:25:21 +0200661 <xsl:variable name="my_index" select="fn:accumulator-before('element-index')" as="xs:integer"/>
bansp3e5b20c2022-03-18 20:22:31 +0100662
bansp3e5b20c2022-03-18 20:22:31 +0100663 <xsl:element name="span" namespace="{$KorAP_namespace}">
Piotr Banskia51907c2022-05-25 15:09:41 +0200664 <xsl:attribute name="id" select="'m' || $my_index"/>
665 <xsl:attribute name="from" select="$offsets[1]"/>
666 <xsl:attribute name="to" select="$offsets[2]"/>
bansp3e5b20c2022-03-18 20:22:31 +0100667 <xsl:attribute name="l" select="f:compute_nesting(.)"/>
668 <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0">
669 <xsl:attribute name="type" select="'lex'"/>
670 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
671 <xsl:attribute name="name" select="'lex'"/>
Piotr Banski763b41f2022-06-02 01:13:23 +0200672 <xsl:comment select="(if(@nkjp:nps) then ' ' else '_') || $my_morph-seg//tei:fs/tei:f[@name eq 'orth']/tei:string"/>
bansp3e5b20c2022-03-18 20:22:31 +0100673 <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0">
bansp3e5b20c2022-03-18 20:22:31 +0100674 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
675 <xsl:attribute name="name" select="'lemma'"/>
676 <xsl:value-of select="$my_choice-lex/tei:f[@name eq 'base']/tei:string"/>
677 </xsl:element>
678 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
679 <xsl:attribute name="name" select="'pos'"/>
680 <xsl:value-of select="$my_choice-lex/tei:f[@name eq 'ctag']/tei:symbol/@value"/>
681 </xsl:element>
682 <xsl:if test="string-length($chosen-msd)">
683 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
684 <xsl:attribute name="name" select="'msd'"/>
685 <xsl:value-of select="$chosen-msd"/>
686 </xsl:element>
687 </xsl:if>
688 <xsl:if test="$my_morph-seg//tei:fs/tei:f[@name eq 'nps']">
689 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
690 <xsl:attribute name="name" select="'join'"/>
691 <xsl:value-of select="'left'"/>
692 </xsl:element>
693 </xsl:if>
694 </xsl:element>
695 </xsl:element>
696 </xsl:element>
697 </xsl:element>
bansp3e5b20c2022-03-18 20:22:31 +0100698 </xsl:template>
banspe726b4a2022-03-28 05:47:45 +0200699
Piotr Banskic5950ce2022-05-27 15:07:08 +0200700 <!-- ************************** named entities ******************* -->
701
702 <xsl:template name="create_named">
703 <xsl:param name="compoundID" as="xs:string"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200704 <xsl:param name="ann_morphosyntax.doc" as="document-node()"/>
705 <xsl:param name="ann_named.doc" as="document-node()"/>
Piotr Banskic5950ce2022-05-27 15:07:08 +0200706 <xsl:param name="target" as="xs:string"/>
Piotr Banski763b41f2022-06-02 01:13:23 +0200707 <xsl:param name="rev_lookup" as="map(*)"/>
708
Piotr Banskic5950ce2022-05-27 15:07:08 +0200709 <xsl:result-document encoding="UTF-8" method="xml" indent="yes"
710 xpath-default-namespace="http://ids-mannheim.de/ns/KorAP" href="{$target}">
711 <xsl:processing-instruction name="xml-model">href=&quot;span.rng&quot; type=&quot;application/xml&quot; schematypens=&quot;http://relaxng.org/ns/structure/1.0&quot;</xsl:processing-instruction>
712 <xsl:element name="layer" namespace="{$KorAP_namespace}">
713 <xsl:attribute name="docid" select="$compoundID"/>
714 <xsl:attribute name="version" select="$KorAP-XML_version"/>
715
716 <xsl:element name="spanList" namespace="{$KorAP_namespace}">
Piotr Banskif9590692022-06-02 15:39:48 +0200717 <xsl:apply-templates select="$ann_morphosyntax.doc//tei:text" mode="named">
718 <xsl:with-param name="ann_named.doc" select="$ann_named.doc" as="document-node()" tunnel="yes"/>
Piotr Banski763b41f2022-06-02 01:13:23 +0200719 <xsl:with-param name="rev_lookup" select="$rev_lookup" as="map(*)" tunnel="yes"/>
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200720 </xsl:apply-templates>
Piotr Banskic5950ce2022-05-27 15:07:08 +0200721 </xsl:element>
722 </xsl:element>
723 </xsl:result-document>
724 </xsl:template>
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200725
726 <xsl:template match="tei:seg" mode="named"/>
727
728 <xsl:template match="tei:seg[tei:fs[tei:f[@name eq 'disamb']]]" mode="named">
Piotr Banskif9590692022-06-02 15:39:48 +0200729 <xsl:param name="ann_named.doc" as="document-node()" tunnel="yes"/>
Piotr Banski763b41f2022-06-02 01:13:23 +0200730 <xsl:param name="rev_lookup" as="map(*)" tunnel="yes"/>
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200731
732 <xsl:variable name="offsets" as="xs:integer+">
733 <xsl:sequence select="map:get(fn:accumulator-after('morpho-offsets')[last()], string(@xml:id))"/>
734 </xsl:variable>
735
Piotr Banski763b41f2022-06-02 01:13:23 +0200736 <xsl:variable name="ptr" select="map:get($rev_lookup,fn:string(@xml:id))" as="element(tei:ptr)*"/>
737 <!-- it's an element, because we need to see where it stands in a sequence... -->
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200738
Piotr Banski763b41f2022-06-02 01:13:23 +0200739 <xsl:if test="$ptr">
740 <xsl:variable name="my_id" select="@xml:id" as="xs:string"/>
741 <xsl:variable name="my_index" select="fn:accumulator-before('element-index')" as="xs:integer"/>
742
743 <xsl:element name="span" namespace="{$KorAP_namespace}">
744 <xsl:attribute name="id" select="'n' || $my_index"/>
745 <xsl:attribute name="from" select="$offsets[1]"/>
746 <xsl:attribute name="to" select="$offsets[2]"/>
747 <xsl:attribute name="l" select="f:compute_nesting(.)"/>
748 <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0">
749 <xsl:attribute name="type" select="'ne'"/>
750 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
751 <xsl:attribute name="name" select="'ne'"/>
752 <xsl:comment select="
753 (if (tei:fs/tei:f[@name eq 'nps']) then
754 ' '
755 else
756 '_') || tei:fs/tei:f[@name eq 'orth']/tei:string"/>
757 <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0">
758 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
759 <xsl:attribute name="name" select="'complex-ent'"/>
760 <xsl:for-each select="$ptr">
761 <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0">
762 <xsl:attribute name="type" select="'complex-ent'"/>
763 <xsl:for-each select="parent::tei:seg/tei:fs[1]/tei:f">
764 <xsl:if test="@name eq 'type' or @name eq 'subtype'">
765 <xsl:copy-of select="." copy-namespaces="no"/>
766 </xsl:if>
767 </xsl:for-each>
768 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
769 <xsl:attribute name="name" select="'nkjp-named'"/>
770 <xsl:copy-of select="parent::tei:seg/tei:fs[1]" copy-namespaces="no"/>
771 </xsl:element>
772 </xsl:element>
773 </xsl:for-each>
774
775 </xsl:element>
776
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200777 </xsl:element>
778 </xsl:element>
779 </xsl:element>
780 </xsl:element>
Piotr Banski763b41f2022-06-02 01:13:23 +0200781 </xsl:if>
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200782 </xsl:template>
783
Piotr Banskic5950ce2022-05-27 15:07:08 +0200784
785 <!-- ************************** syntactic chunks ******************* -->
786
787 <xsl:template name="create_groups">
788 <xsl:param name="compoundID" as="xs:string"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200789 <xsl:param name="ann_morphosyntax.doc" as="document-node()"/>
790 <xsl:param name="ann_words.doc" as="document-node()"/>
791 <xsl:param name="ann_groups.doc" as="document-node()"/>
Piotr Banskic5950ce2022-05-27 15:07:08 +0200792 <xsl:param name="target" as="xs:string"/>
793
794 <xsl:result-document encoding="UTF-8" method="xml" indent="yes"
795 xpath-default-namespace="http://ids-mannheim.de/ns/KorAP" href="{$target}">
796 <xsl:processing-instruction name="xml-model">href=&quot;span.rng&quot; type=&quot;application/xml&quot; schematypens=&quot;http://relaxng.org/ns/structure/1.0&quot;</xsl:processing-instruction>
797 <xsl:element name="layer" namespace="{$KorAP_namespace}">
798 <xsl:attribute name="docid" select="$compoundID"/>
799 <xsl:attribute name="version" select="$KorAP-XML_version"/>
800
801 <xsl:element name="spanList" namespace="{$KorAP_namespace}">
802 <!--<xsl:apply-templates select="$ann_segmentation.xml//tei:text" mode="groups">
Piotr Banskif9590692022-06-02 15:39:48 +0200803 <xsl:with-param name="ann_morphosyntax.doc" select="$ann_morphosyntax.doc" as="document-node()" tunnel="yes"/>
804 <xsl:with-param name="ann_words.doc" select="$ann_words.doc" as="document-node()" tunnel="yes"/>
805 <xsl:with-param name="ann_groups.doc" select="$ann_groups.doc" as="document-node()" tunnel="yes"/>
Piotr Banskic5950ce2022-05-27 15:07:08 +0200806 </xsl:apply-templates>-->
807 </xsl:element>
808 </xsl:element>
809 </xsl:result-document>
810 </xsl:template>
811
bansp5f841732022-03-16 06:27:31 +0100812 <!-- ************************** TEXT header ******************* -->
813
814 <xsl:template name="create_text_header">
Piotr Banskif9590692022-06-02 15:39:48 +0200815 <xsl:param name="text.doc" as="document-node()"/>
banspe726b4a2022-03-28 05:47:45 +0200816 <xsl:param name="compoundID" as="xs:string"/>
bansp5f841732022-03-16 06:27:31 +0100817 <xsl:param name="target" as="xs:string"/>
818
819 <!-- create the local header.xml file -->
820 <xsl:result-document encoding="UTF-8" method="xml" indent="yes"
821 xpath-default-namespace="http://ids-mannheim.de/ns/KorAP" href="{$target}">
822
823 <idsHeader type="document" pattern="text" status="new" version="1.1" TEIform="teiHeader">
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200824 <xsl:apply-templates select="$text.doc//tei:TEI/tei:teiHeader/tei:*" mode="text-header">
banspe726b4a2022-03-28 05:47:45 +0200825 <xsl:with-param name="compoundID" as="xs:string" select="$compoundID" tunnel="yes"/>
826 </xsl:apply-templates>
bansp5f841732022-03-16 06:27:31 +0100827 </idsHeader>
828 </xsl:result-document>
829 </xsl:template>
830
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200831 <xsl:template match="tei:fileDesc" mode="text-header">
bansp9103aab2022-03-19 05:10:21 +0100832 <xsl:element name="{local-name()}">
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200833 <xsl:apply-templates mode="text-header"/>
bansp9103aab2022-03-19 05:10:21 +0100834 </xsl:element>
bansp5f841732022-03-16 06:27:31 +0100835 </xsl:template>
836
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200837 <xsl:template match="tei:title" mode="text-header">
bansp5f841732022-03-16 06:27:31 +0100838 <t.title>
839 <xsl:apply-templates/>
840 </t.title>
841 </xsl:template>
842
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200843 <xsl:template match="tei:titleStmt" mode="text-header">
banspe726b4a2022-03-28 05:47:45 +0200844 <xsl:param name="compoundID" as="xs:string" tunnel="yes"/>
bansp5f841732022-03-16 06:27:31 +0100845 <titleStmt>
846 <textSigle>
banspe726b4a2022-03-28 05:47:45 +0200847 <xsl:value-of select="$compoundID"/>
bansp5f841732022-03-16 06:27:31 +0100848 </textSigle>
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200849 <xsl:apply-templates mode="text-header"/>
bansp5f841732022-03-16 06:27:31 +0100850 </titleStmt>
851 </xsl:template>
852
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200853 <xsl:template match="tei:publicationStmt" mode="text-header">
bansp9103aab2022-03-19 05:10:21 +0100854 <xsl:element name="{local-name()}">
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200855 <xsl:apply-templates mode="text-header"/>
bansp9103aab2022-03-19 05:10:21 +0100856 </xsl:element>
857 </xsl:template>
858
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200859 <xsl:template match="tei:availability" mode="text-header">
bansp9103aab2022-03-19 05:10:21 +0100860 <xsl:element name="{local-name()}">
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200861 <xsl:apply-templates mode="text-header" select="@* | *"/>
bansp9103aab2022-03-19 05:10:21 +0100862 </xsl:element>
863 </xsl:template>
864
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200865 <xsl:template match="tei:profileDesc" mode="text-header">
bansp9103aab2022-03-19 05:10:21 +0100866 <xsl:element name="{local-name()}">
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200867 <xsl:apply-templates mode="text-header"/>
bansp9103aab2022-03-19 05:10:21 +0100868 </xsl:element>
869 </xsl:template>
bansp5f841732022-03-16 06:27:31 +0100870
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200871 <xsl:template match="tei:textClass" mode="text-header">
bansp9103aab2022-03-19 05:10:21 +0100872 <xsl:element name="{local-name()}">
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200873 <xsl:apply-templates mode="text-header" select="@* | *"/>
bansp9103aab2022-03-19 05:10:21 +0100874 </xsl:element>
875 </xsl:template>
876
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200877 <xsl:template match="tei:catRef" mode="text-header corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100878 <xsl:element name="{local-name()}">
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200879 <xsl:apply-templates mode="text-header" select="@* | *"/>
bansp9103aab2022-03-19 05:10:21 +0100880 </xsl:element>
881 </xsl:template>
882
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200883 <xsl:template match="@status | @scheme | @target | @type | @xml:id[ancestor::tei:classDecl] | @xml:lang" mode="text-header corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100884 <xsl:copy-of select="."/>
885 </xsl:template>
886
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200887 <xsl:template match="tei:p" mode="text-header corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100888 <xsl:element name="{local-name()}">
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200889 <xsl:apply-templates mode="text_inside_header"/>
bansp9103aab2022-03-19 05:10:21 +0100890 </xsl:element>
891 </xsl:template>
892
893
894 <!-- OPTIMIZATION has to take modes into account -->
bansp5e2d1c02022-03-10 04:51:40 +0100895 <!-- ************************** CORPUS header ******************* -->
896 <xsl:template name="create_corpus_header">
Piotr Banskifaa910f2022-06-03 00:46:29 +0200897 <xsl:param name="text.doc" as="document-node()"/>
bansp5f841732022-03-16 06:27:31 +0100898 <xsl:param name="target" as="xs:string"/>
bansp5e2d1c02022-03-10 04:51:40 +0100899
900 <!-- create the corpus-level header.xml file -->
bansp5f841732022-03-16 06:27:31 +0100901 <xsl:result-document encoding="UTF-8" method="xml" indent="yes" href="{$target}">
bansp5e2d1c02022-03-10 04:51:40 +0100902
903 <!--doctype-public="{$publicDoctypeI5}"
904 doctype-system="{$systemDoctypeI5}">
905 these are, sadly, useless
906 -->
907
908 <idsHeader type="corpus" pattern="text" status="new" version="1.1" TEIform="teiHeader">
Piotr Banskifaa910f2022-06-03 00:46:29 +0200909 <xsl:apply-templates select="$text.doc/tei:teiCorpus/tei:teiHeader/tei:*" mode="corpus-header"/>
bansp5e2d1c02022-03-10 04:51:40 +0100910 </idsHeader>
911 </xsl:result-document>
912 </xsl:template>
913
Piotr Banskifaa910f2022-06-03 00:46:29 +0200914 <xsl:template match="tei:fileDesc" mode="corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100915 <xsl:element name="{local-name()}">
Piotr Banskifaa910f2022-06-03 00:46:29 +0200916 <xsl:apply-templates mode="corpus-header"/>
bansp9103aab2022-03-19 05:10:21 +0100917 </xsl:element>
bansp5e2d1c02022-03-10 04:51:40 +0100918 </xsl:template>
bansp9103aab2022-03-19 05:10:21 +0100919
bansp5e2d1c02022-03-10 04:51:40 +0100920
Piotr Banskifaa910f2022-06-03 00:46:29 +0200921 <xsl:template match="tei:title" mode="corpus-header">
bansp5e2d1c02022-03-10 04:51:40 +0100922 <c.title>
Piotr Banskifaa910f2022-06-03 00:46:29 +0200923 <xsl:apply-templates mode="corpus-header" select="@*"/>
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200924 <xsl:apply-templates mode="text_inside_header"/>
bansp5e2d1c02022-03-10 04:51:40 +0100925 </c.title>
926 </xsl:template>
927
Piotr Banskifaa910f2022-06-03 00:46:29 +0200928 <xsl:template match="tei:titleStmt" mode="corpus-header">
bansp5e2d1c02022-03-10 04:51:40 +0100929 <titleStmt>
930 <korpusSigle>
931 <xsl:value-of select="$corpusID"/>
932 </korpusSigle>
Piotr Banskifaa910f2022-06-03 00:46:29 +0200933 <xsl:apply-templates mode="corpus-header"/>
bansp5e2d1c02022-03-10 04:51:40 +0100934 </titleStmt>
935 </xsl:template>
936
Piotr Banskifaa910f2022-06-03 00:46:29 +0200937 <xsl:template match="tei:publicationStmt" mode="corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100938 <xsl:element name="{local-name()}">
Piotr Banskifaa910f2022-06-03 00:46:29 +0200939 <xsl:apply-templates mode="corpus-header"/>
bansp9103aab2022-03-19 05:10:21 +0100940 </xsl:element>
941 </xsl:template>
942
Piotr Banskifaa910f2022-06-03 00:46:29 +0200943 <xsl:template match="tei:availability" mode="corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100944 <xsl:element name="{local-name()}">
Piotr Banskifaa910f2022-06-03 00:46:29 +0200945 <xsl:apply-templates mode="corpus-header" select="@* | *"/>
bansp9103aab2022-03-19 05:10:21 +0100946 </xsl:element>
947 </xsl:template>
948
Piotr Banskifaa910f2022-06-03 00:46:29 +0200949 <xsl:template match="tei:encodingDesc" mode="corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100950 <xsl:element name="{local-name()}">
Piotr Banskifaa910f2022-06-03 00:46:29 +0200951 <xsl:apply-templates mode="corpus-header"/>
bansp9103aab2022-03-19 05:10:21 +0100952 </xsl:element>
953 </xsl:template>
954
Piotr Banskifaa910f2022-06-03 00:46:29 +0200955 <xsl:template match="tei:classDecl | tei:taxonomy | tei:category | tei:taxonomy/tei:bibl" mode="corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100956 <xsl:element name="{local-name()}">
Piotr Banskifaa910f2022-06-03 00:46:29 +0200957 <xsl:apply-templates mode="corpus-header" select="@* | *"/>
bansp9103aab2022-03-19 05:10:21 +0100958 </xsl:element>
959 </xsl:template>
960
Piotr Banskifaa910f2022-06-03 00:46:29 +0200961 <xsl:template match="tei:bibl/tei:title | tei:edition | tei:desc" mode="corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100962 <xsl:element name="{local-name()}">
Piotr Banskifaa910f2022-06-03 00:46:29 +0200963 <xsl:apply-templates mode="corpus-header" select="@*"/>
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200964 <xsl:apply-templates mode="text_inside_header"/>
bansp9103aab2022-03-19 05:10:21 +0100965 </xsl:element>
966 </xsl:template>
967<!--
Piotr Banskifaa910f2022-06-03 00:46:29 +0200968 <xsl:template match="tei:textClass" mode="corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100969 <xsl:element name="{local-name()}">
970 <xsl:apply-templates mode="corpus" select="@* | *"/>
971 </xsl:element>
972 </xsl:template>
973
Piotr Banskifaa910f2022-06-03 00:46:29 +0200974 <xsl:template match="tei:catRef" mode="corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100975 <xsl:element name="{local-name()}">
976 <xsl:apply-templates mode="corpus" select="@* | *"/>
977 </xsl:element>
978 </xsl:template>
979-->
bansp5e2d1c02022-03-10 04:51:40 +0100980
981
982
983 <!-- this template can be called by the XSPEC test; TODO: find a way to call the main() template directly -->
984 <!-- I have not fully handled the param transmission, which would have to be kludged in just for the sake of XSPec,
985 because I'm disabling this for now, due to XSpec design issues; relevant links, a.o.:
986
987 https://stackoverflow.com/questions/64933277/what-is-the-cause-of-error-cannot-execute-xslresult-document-while-evaluating
988 https://www.balisage.net/Proceedings/vol25/html/Galtman01/BalisageVol25-Galtman01.html
989
990 In short: the internal design of XSpec forces kludges when one wants to use xsl:result-document in their stylesheets. But I don't
991 want to be strangled by kludges at the beginning of work, I've already lost quite a bit of time on this investigation,
992 I will therefore "just code" and then can think of externalizing bits of templates if we want to play with tests. For now,
993 I don't want to have to handle context items is a special way inside variables, etc., because I'm not sure it's worth it.
994
995 -->
996 <!--<xsl:template name="test_full">
997 <xsl:param name="corpusID"/>
998 <xsl:param name="docID"/>
999 <xsl:param name="textID"/>
1000 <xsl:call-template name="xsl:initial-template"/>
1001 </xsl:template>-->
1002
Akron9a8ee3e2022-01-31 13:51:49 +01001003</xsl:stylesheet>
Piotr Banski6a4a2522022-05-24 01:16:47 +02001004
Piotr Banskifdc858a2022-05-25 02:40:32 +02001005<!-- template for serializing maps in messages <xsl:message select="('map:',serialize($map, map{'method':'adaptive'}))"/> -->