blob: d2d8bc02eb22138645d49318b61391e2181f57b0 [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 Banskiba6cc632022-06-03 14:07:33 +0200462 <xsl:call-template name="create_morpho">
banspe726b4a2022-03-28 05:47:45 +0200463 <xsl:with-param name="compoundID" select="$compoundID" as="xs:string"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200464 <xsl:with-param name="ann_morphosyntax.doc" select="$ann_morphosyntax.doc"
bansp5f841732022-03-16 06:27:31 +0100465 as="document-node()"/>
banspe726b4a2022-03-28 05:47:45 +0200466 <xsl:with-param name="target" select="$targetBaseDir || '/nkjp/morpho.xml'" as="xs:string"/>
Piotr Banskiba6cc632022-06-03 14:07:33 +0200467 </xsl:call-template>
Piotr Banskia51907c2022-05-25 15:09:41 +0200468
Piotr Banski081c5de2022-06-03 01:57:13 +0200469<!--
470
471 THESE ARE SAFE
472
473
474 <xsl:call-template name="create_text_header">
Piotr Banskif9590692022-06-02 15:39:48 +0200475 <xsl:with-param name="text.doc" select="$text.doc" as="document-node()"/>
banspe726b4a2022-03-28 05:47:45 +0200476 <xsl:with-param name="compoundID" select="$compoundID" as="xs:string"/>
477 <xsl:with-param name="target" select="$targetBaseDir || '/header.xml'" as="xs:string"/>
Piotr Banski09096ee2022-05-25 13:41:03 +0200478 </xsl:call-template>
Piotr Banski6a4a2522022-05-24 01:16:47 +0200479
Piotr Banskif9590692022-06-02 15:39:48 +0200480 <xsl:if test="$ann_named.doc">
Piotr Banski763b41f2022-06-02 01:13:23 +0200481 <xsl:variable name="rev_lookup-seq" as="map(*)+">
482 <xsl:for-each
Piotr Banskif9590692022-06-02 15:39:48 +0200483 select="$ann_named.doc//tei:seg/tei:ptr">
Piotr Banski763b41f2022-06-02 01:13:23 +0200484 <xsl:variable name="trg" as="xs:string" select="fn:substring-before(@target, '#')"/>
Piotr Banski081c5de2022-06-03 01:57:13 +0200485 <!-\- caution: as of 01-June-2022, some of the pointers are malformed (missing '#' when referencing locally).
486 so we need to act around it but also sustainably - in case that error gets corrected -\->
Piotr Banski763b41f2022-06-02 01:13:23 +0200487
488 <xsl:if test="fn:string-length($trg) and $trg eq 'ann_morphosyntax.xml'">
489 <xsl:sequence>
490 <xsl:map-entry key="fn:substring-after(fn:string(@target), '#')" select="fn:current()"
491 />
492 </xsl:sequence>
493 </xsl:if>
494 </xsl:for-each>
495 </xsl:variable>
496 <xsl:variable name="rev_lookup" as="map(*)" select="map:merge($rev_lookup-seq,map{'duplicates':'combine'})"/>
497
Piotr Banskic5950ce2022-05-27 15:07:08 +0200498 <xsl:call-template name="create_named">
499 <xsl:with-param name="compoundID" select="$compoundID" as="xs:string"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200500 <xsl:with-param name="ann_morphosyntax.doc" select="$ann_morphosyntax.doc"
Piotr Banskic5950ce2022-05-27 15:07:08 +0200501 as="document-node()"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200502 <xsl:with-param name="ann_named.doc" select="$ann_named.doc"
Piotr Banskic5950ce2022-05-27 15:07:08 +0200503 as="document-node()"/>
504 <xsl:with-param name="target" select="$targetBaseDir || '/nkjp/named.xml'" as="xs:string"/>
Piotr Banski763b41f2022-06-02 01:13:23 +0200505 <xsl:with-param name="rev_lookup" select="$rev_lookup" as="map(*)"/>
Piotr Banskic5950ce2022-05-27 15:07:08 +0200506 </xsl:call-template>
507 </xsl:if>
Piotr Banski081c5de2022-06-03 01:57:13 +0200508-->
Piotr Banskif9590692022-06-02 15:39:48 +0200509 <xsl:if test="$ann_words.doc and $ann_groups.doc">
Piotr Banskic5950ce2022-05-27 15:07:08 +0200510 <xsl:call-template name="create_groups">
511 <xsl:with-param name="compoundID" select="$compoundID" as="xs:string"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200512 <xsl:with-param name="ann_morphosyntax.doc" select="$ann_morphosyntax.doc"
Piotr Banskic5950ce2022-05-27 15:07:08 +0200513 as="document-node()"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200514 <xsl:with-param name="ann_words.doc" select="$ann_words.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_groups.doc" select="$ann_groups.doc"
Piotr Banskic5950ce2022-05-27 15:07:08 +0200517 as="document-node()"/>
518 <xsl:with-param name="target" select="$targetBaseDir || '/nkjp/groups.xml'" as="xs:string"/>
519 </xsl:call-template>
520 </xsl:if>
521
bansp5e2d1c02022-03-10 04:51:40 +0100522 </xsl:template>
523
524 <!-- ************************** data.xml ******************* -->
525
526 <xsl:template name="create_data">
Piotr Banski081c5de2022-06-03 01:57:13 +0200527 <xsl:param name="ann_morphosyntax.doc" as="document-node()"/>
banspe726b4a2022-03-28 05:47:45 +0200528 <xsl:param name="compoundID" as="xs:string"/>
bansp5f841732022-03-16 06:27:31 +0100529 <xsl:param name="target" as="xs:string"/>
bansp5e2d1c02022-03-10 04:51:40 +0100530 <!-- create the data.xml file -->
531 <xsl:result-document encoding="UTF-8" method="xml" indent="yes"
bansp5f841732022-03-16 06:27:31 +0100532 xpath-default-namespace="{$KorAP_namespace}" href="{$target}">
bansp5e2d1c02022-03-10 04:51:40 +0100533
Akron9a8ee3e2022-01-31 13:51:49 +0100534 <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 +0100535 <xsl:element name="raw_text" namespace="{$KorAP_namespace}">
bansp5f841732022-03-16 06:27:31 +0100536 <xsl:attribute name="docid" select="$compoundID"/>
bansp5e2d1c02022-03-10 04:51:40 +0100537 <xsl:element name="metadata" namespace="{$KorAP_namespace}">
538 <xsl:attribute name="file" select="'metadata.xml'"/>
539 </xsl:element>
540
541 <xsl:element name="text" namespace="{$KorAP_namespace}">
bansp9dc10002022-05-17 22:33:34 +0200542 <xsl:variable name="content" as="xs:string+">
Piotr Banski081c5de2022-06-03 01:57:13 +0200543 <!--<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]">-->
544 <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 +0200545 <xsl:sequence select="
Piotr Banskifdc858a2022-05-25 02:40:32 +0200546 if (f:is_preceded_by_ws(.,false())) then
bansp9dc10002022-05-17 22:33:34 +0200547 ' '
548 else
Piotr Banski081c5de2022-06-03 01:57:13 +0200549 '', ./tei:fs/tei:f[@name eq 'orth']/tei:string"/>
bansp9dc10002022-05-17 22:33:34 +0200550 </xsl:for-each>
551 </xsl:variable>
552 <xsl:value-of select="string-join($content)"/>
bansp5e2d1c02022-03-10 04:51:40 +0100553 </xsl:element>
Akron9a8ee3e2022-01-31 13:51:49 +0100554 </xsl:element>
banspf79443e2022-02-25 14:25:33 +0100555 </xsl:result-document>
Akron9a8ee3e2022-01-31 13:51:49 +0100556 </xsl:template>
557
bansp5f841732022-03-16 06:27:31 +0100558 <!-- ************************** struct ******************* -->
559
560 <xsl:template name="create_struct">
banspe726b4a2022-03-28 05:47:45 +0200561 <xsl:param name="compoundID" as="xs:string"/>
Piotr Banski43b9db02022-06-03 02:38:42 +0200562 <xsl:param name="ann_morphosyntax.doc" as="document-node()"/>
bansp5f841732022-03-16 06:27:31 +0100563 <xsl:param name="target" as="xs:string"/>
Piotr Banski4f4c2d22022-05-19 01:44:32 +0200564
bansp5f841732022-03-16 06:27:31 +0100565 <xsl:result-document encoding="UTF-8" method="xml" indent="yes"
566 xpath-default-namespace="http://ids-mannheim.de/ns/KorAP" href="{$target}">
567 <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>
568 <xsl:element name="layer" namespace="{$KorAP_namespace}">
569 <xsl:attribute name="docid" select="$compoundID"/>
570 <xsl:attribute name="version" select="$KorAP-XML_version"/>
571
572 <xsl:element name="spanList" namespace="{$KorAP_namespace}">
Piotr Banski43b9db02022-06-03 02:38:42 +0200573 <xsl:apply-templates select="$ann_morphosyntax.doc/tei:teiCorpus/tei:TEI/tei:text" mode="struct"/>
bansp5f841732022-03-16 06:27:31 +0100574 </xsl:element>
575 </xsl:element>
576 </xsl:result-document>
577 </xsl:template>
578
Piotr Banski43b9db02022-06-03 02:38:42 +0200579 <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 +0200580 <xsl:variable name="offsets" as="xs:integer+">
Piotr Banski43b9db02022-06-03 02:38:42 +0200581 <xsl:sequence select="map:get(fn:accumulator-after('morpho-offsets')[last()], string(@xml:id))"/>
Piotr Banski09096ee2022-05-25 13:41:03 +0200582 </xsl:variable>
Piotr Banski6a4a2522022-05-24 01:16:47 +0200583
bansp5f841732022-03-16 06:27:31 +0100584 <xsl:variable name="my_name" select="local-name()" as="xs:string"/>
Piotr Banskie1ac5202022-05-30 21:25:21 +0200585 <xsl:variable name="my_index" select="fn:accumulator-before('element-index')" as="xs:integer"/>
bansp3e5b20c2022-03-18 20:22:31 +0100586
bansp5f841732022-03-16 06:27:31 +0100587 <xsl:element name="span" namespace="{$KorAP_namespace}">
588 <xsl:attribute name="id" select="'s' || $my_index"/>
Piotr Banski09096ee2022-05-25 13:41:03 +0200589 <xsl:attribute name="from" select="$offsets[1]"/>
590 <xsl:attribute name="to" select="$offsets[2]"/>
bansp5f841732022-03-16 06:27:31 +0100591 <xsl:attribute name="l" select="f:compute_nesting(.)"/>
Piotr Banski09096ee2022-05-25 13:41:03 +0200592 <xsl:if test="local-name() eq 'seg' and $SHOW_ORTH_IN_STRUCT">
593 <xsl:comment><xsl:value-of select="fn:normalize-space(.)"/></xsl:comment>
594 </xsl:if>
bansp5f841732022-03-16 06:27:31 +0100595 <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0">
Piotr Banskifdc858a2022-05-25 02:40:32 +0200596 <xsl:attribute name="type" select="'struct'"></xsl:attribute> <!-- STRUCT vs. LEX for morpho -->
bansp5f841732022-03-16 06:27:31 +0100597 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
bansp3e5b20c2022-03-18 20:22:31 +0100598 <xsl:attribute name="name" select="'name'"/>
599 <xsl:value-of select="local-name()"/>
bansp5f841732022-03-16 06:27:31 +0100600 </xsl:element>
601 <xsl:if test="count(@*)">
602 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
603 <xsl:attribute name="name" select="'attr'"/>
604 <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0">
605 <xsl:attribute name="type" select="'attr'"/>
606 <xsl:for-each select="@*">
607 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
608 <xsl:attribute name="name" select="local-name(.)"/>
609 <xsl:value-of select="."/>
610 </xsl:element>
611 </xsl:for-each>
612 </xsl:element>
613 </xsl:element>
614 </xsl:if>
615 </xsl:element>
616 </xsl:element>
Piotr Banskia51907c2022-05-25 15:09:41 +0200617 <xsl:apply-templates mode="struct"/>
bansp5f841732022-03-16 06:27:31 +0100618 </xsl:template>
619
620 <!-- ************************** morpho ******************* -->
621
622 <xsl:template name="create_morpho">
banspe726b4a2022-03-28 05:47:45 +0200623 <xsl:param name="compoundID" as="xs:string"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200624 <xsl:param name="ann_morphosyntax.doc" as="document-node()"/>
bansp5f841732022-03-16 06:27:31 +0100625 <xsl:param name="target" as="xs:string"/>
626
627 <xsl:result-document encoding="UTF-8" method="xml" indent="yes"
628 xpath-default-namespace="http://ids-mannheim.de/ns/KorAP" href="{$target}">
629 <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 +0100630 <xsl:element name="layer" namespace="{$KorAP_namespace}">
631 <xsl:attribute name="docid" select="$compoundID"/>
632 <xsl:attribute name="version" select="$KorAP-XML_version"/>
633
634 <xsl:element name="spanList" namespace="{$KorAP_namespace}">
Piotr Banskiba6cc632022-06-03 14:07:33 +0200635 <xsl:apply-templates select="$ann_morphosyntax.doc//tei:text" mode="morpho"/>
bansp3e5b20c2022-03-18 20:22:31 +0100636 </xsl:element>
637 </xsl:element>
bansp5f841732022-03-16 06:27:31 +0100638 </xsl:result-document>
639 </xsl:template>
640
Piotr Banskiba6cc632022-06-03 14:07:33 +0200641 <xsl:template match="tei:seg[tei:fs/tei:f[@name eq 'disamb']]" mode="morpho">
642
Piotr Banskia51907c2022-05-25 15:09:41 +0200643 <!-- it's so spread out because I wanted to make sure to be able to look up the individual
644 constituent values, should anything go wrong; it might get compacted at some point, but
645 the increase in efficiency will probably be minimal, compared to the decrease of readability -->
646 <xsl:variable name="offsets" as="xs:integer+">
Piotr Banskiba6cc632022-06-03 14:07:33 +0200647 <xsl:sequence select="map:get(fn:accumulator-after('morpho-offsets')[last()], string(@xml:id))"/>
Piotr Banskia51907c2022-05-25 15:09:41 +0200648 </xsl:variable>
Piotr Banskiba6cc632022-06-03 14:07:33 +0200649
bansp3e5b20c2022-03-18 20:22:31 +0100650 <xsl:variable name="my_id" select="@xml:id" as="xs:string"/>
Piotr Banskiba6cc632022-06-03 14:07:33 +0200651 <!--<xsl:variable name="my_morph-seg" as="node()" select="$ann_morphosyntax.doc//tei:seg[substring-after(@corresp,'#') eq $my_id]"/>-->
652 <xsl:variable name="my_disamb" select="tei:fs/tei:f[@name eq 'disamb']" as="node()"/>
bansp3e5b20c2022-03-18 20:22:31 +0100653 <xsl:variable name="my_choice-id" select="substring-after($my_disamb//tei:f[@name eq 'choice']/@fVal,'#')" as="xs:string"/>
Piotr Banskiba6cc632022-06-03 14:07:33 +0200654 <xsl:variable name="my_choice-lex" select="tei:fs/tei:f[@name eq 'interps']/tei:fs[@type eq 'lex'][descendant::tei:symbol[@xml:id eq $my_choice-id]]" as="node()"/>
bansp3e5b20c2022-03-18 20:22:31 +0100655 <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 +0200656 <xsl:variable name="my_index" select="fn:accumulator-before('element-index')" as="xs:integer"/>
bansp3e5b20c2022-03-18 20:22:31 +0100657
bansp3e5b20c2022-03-18 20:22:31 +0100658 <xsl:element name="span" namespace="{$KorAP_namespace}">
Piotr Banskia51907c2022-05-25 15:09:41 +0200659 <xsl:attribute name="id" select="'m' || $my_index"/>
660 <xsl:attribute name="from" select="$offsets[1]"/>
661 <xsl:attribute name="to" select="$offsets[2]"/>
bansp3e5b20c2022-03-18 20:22:31 +0100662 <xsl:attribute name="l" select="f:compute_nesting(.)"/>
663 <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0">
664 <xsl:attribute name="type" select="'lex'"/>
665 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
666 <xsl:attribute name="name" select="'lex'"/>
Piotr Banskiba6cc632022-06-03 14:07:33 +0200667 <xsl:comment select="
668 (if (tei:fs/tei:f[@name eq 'nps']) then
669 ' '
670 else
671 ' _') || tei:fs/tei:f[@name eq 'orth']/tei:string"/>
bansp3e5b20c2022-03-18 20:22:31 +0100672 <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0">
bansp3e5b20c2022-03-18 20:22:31 +0100673 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
674 <xsl:attribute name="name" select="'lemma'"/>
675 <xsl:value-of select="$my_choice-lex/tei:f[@name eq 'base']/tei:string"/>
676 </xsl:element>
677 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
678 <xsl:attribute name="name" select="'pos'"/>
679 <xsl:value-of select="$my_choice-lex/tei:f[@name eq 'ctag']/tei:symbol/@value"/>
680 </xsl:element>
681 <xsl:if test="string-length($chosen-msd)">
682 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
683 <xsl:attribute name="name" select="'msd'"/>
684 <xsl:value-of select="$chosen-msd"/>
685 </xsl:element>
686 </xsl:if>
Piotr Banskiba6cc632022-06-03 14:07:33 +0200687 <xsl:if test="tei:fs/tei:f[@name eq 'nps']">
bansp3e5b20c2022-03-18 20:22:31 +0100688 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
689 <xsl:attribute name="name" select="'join'"/>
690 <xsl:value-of select="'left'"/>
691 </xsl:element>
692 </xsl:if>
693 </xsl:element>
694 </xsl:element>
695 </xsl:element>
696 </xsl:element>
bansp3e5b20c2022-03-18 20:22:31 +0100697 </xsl:template>
banspe726b4a2022-03-28 05:47:45 +0200698
Piotr Banskic5950ce2022-05-27 15:07:08 +0200699 <!-- ************************** named entities ******************* -->
700
701 <xsl:template name="create_named">
702 <xsl:param name="compoundID" as="xs:string"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200703 <xsl:param name="ann_morphosyntax.doc" as="document-node()"/>
704 <xsl:param name="ann_named.doc" as="document-node()"/>
Piotr Banskic5950ce2022-05-27 15:07:08 +0200705 <xsl:param name="target" as="xs:string"/>
Piotr Banski763b41f2022-06-02 01:13:23 +0200706 <xsl:param name="rev_lookup" as="map(*)"/>
707
Piotr Banskic5950ce2022-05-27 15:07:08 +0200708 <xsl:result-document encoding="UTF-8" method="xml" indent="yes"
709 xpath-default-namespace="http://ids-mannheim.de/ns/KorAP" href="{$target}">
710 <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>
711 <xsl:element name="layer" namespace="{$KorAP_namespace}">
712 <xsl:attribute name="docid" select="$compoundID"/>
713 <xsl:attribute name="version" select="$KorAP-XML_version"/>
714
715 <xsl:element name="spanList" namespace="{$KorAP_namespace}">
Piotr Banskif9590692022-06-02 15:39:48 +0200716 <xsl:apply-templates select="$ann_morphosyntax.doc//tei:text" mode="named">
717 <xsl:with-param name="ann_named.doc" select="$ann_named.doc" as="document-node()" tunnel="yes"/>
Piotr Banski763b41f2022-06-02 01:13:23 +0200718 <xsl:with-param name="rev_lookup" select="$rev_lookup" as="map(*)" tunnel="yes"/>
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200719 </xsl:apply-templates>
Piotr Banskic5950ce2022-05-27 15:07:08 +0200720 </xsl:element>
721 </xsl:element>
722 </xsl:result-document>
723 </xsl:template>
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200724
725 <xsl:template match="tei:seg" mode="named"/>
726
727 <xsl:template match="tei:seg[tei:fs[tei:f[@name eq 'disamb']]]" mode="named">
Piotr Banskif9590692022-06-02 15:39:48 +0200728 <xsl:param name="ann_named.doc" as="document-node()" tunnel="yes"/>
Piotr Banski763b41f2022-06-02 01:13:23 +0200729 <xsl:param name="rev_lookup" as="map(*)" tunnel="yes"/>
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200730
731 <xsl:variable name="offsets" as="xs:integer+">
732 <xsl:sequence select="map:get(fn:accumulator-after('morpho-offsets')[last()], string(@xml:id))"/>
733 </xsl:variable>
734
Piotr Banski763b41f2022-06-02 01:13:23 +0200735 <xsl:variable name="ptr" select="map:get($rev_lookup,fn:string(@xml:id))" as="element(tei:ptr)*"/>
736 <!-- it's an element, because we need to see where it stands in a sequence... -->
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200737
Piotr Banski763b41f2022-06-02 01:13:23 +0200738 <xsl:if test="$ptr">
739 <xsl:variable name="my_id" select="@xml:id" as="xs:string"/>
740 <xsl:variable name="my_index" select="fn:accumulator-before('element-index')" as="xs:integer"/>
741
742 <xsl:element name="span" namespace="{$KorAP_namespace}">
743 <xsl:attribute name="id" select="'n' || $my_index"/>
744 <xsl:attribute name="from" select="$offsets[1]"/>
745 <xsl:attribute name="to" select="$offsets[2]"/>
746 <xsl:attribute name="l" select="f:compute_nesting(.)"/>
747 <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0">
748 <xsl:attribute name="type" select="'ne'"/>
749 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
750 <xsl:attribute name="name" select="'ne'"/>
751 <xsl:comment select="
752 (if (tei:fs/tei:f[@name eq 'nps']) then
753 ' '
754 else
Piotr Banskiba6cc632022-06-03 14:07:33 +0200755 ' _') || tei:fs/tei:f[@name eq 'orth']/tei:string"/>
Piotr Banski763b41f2022-06-02 01:13:23 +0200756 <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0">
757 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
758 <xsl:attribute name="name" select="'complex-ent'"/>
759 <xsl:for-each select="$ptr">
760 <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0">
761 <xsl:attribute name="type" select="'complex-ent'"/>
762 <xsl:for-each select="parent::tei:seg/tei:fs[1]/tei:f">
763 <xsl:if test="@name eq 'type' or @name eq 'subtype'">
764 <xsl:copy-of select="." copy-namespaces="no"/>
765 </xsl:if>
766 </xsl:for-each>
767 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
768 <xsl:attribute name="name" select="'nkjp-named'"/>
769 <xsl:copy-of select="parent::tei:seg/tei:fs[1]" copy-namespaces="no"/>
770 </xsl:element>
771 </xsl:element>
772 </xsl:for-each>
773
774 </xsl:element>
775
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200776 </xsl:element>
777 </xsl:element>
778 </xsl:element>
779 </xsl:element>
Piotr Banski763b41f2022-06-02 01:13:23 +0200780 </xsl:if>
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200781 </xsl:template>
782
Piotr Banskic5950ce2022-05-27 15:07:08 +0200783
784 <!-- ************************** syntactic chunks ******************* -->
785
786 <xsl:template name="create_groups">
787 <xsl:param name="compoundID" as="xs:string"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200788 <xsl:param name="ann_morphosyntax.doc" as="document-node()"/>
789 <xsl:param name="ann_words.doc" as="document-node()"/>
790 <xsl:param name="ann_groups.doc" as="document-node()"/>
Piotr Banskic5950ce2022-05-27 15:07:08 +0200791 <xsl:param name="target" as="xs:string"/>
792
793 <xsl:result-document encoding="UTF-8" method="xml" indent="yes"
794 xpath-default-namespace="http://ids-mannheim.de/ns/KorAP" href="{$target}">
795 <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>
796 <xsl:element name="layer" namespace="{$KorAP_namespace}">
797 <xsl:attribute name="docid" select="$compoundID"/>
798 <xsl:attribute name="version" select="$KorAP-XML_version"/>
799
800 <xsl:element name="spanList" namespace="{$KorAP_namespace}">
801 <!--<xsl:apply-templates select="$ann_segmentation.xml//tei:text" mode="groups">
Piotr Banskif9590692022-06-02 15:39:48 +0200802 <xsl:with-param name="ann_morphosyntax.doc" select="$ann_morphosyntax.doc" as="document-node()" tunnel="yes"/>
803 <xsl:with-param name="ann_words.doc" select="$ann_words.doc" as="document-node()" tunnel="yes"/>
804 <xsl:with-param name="ann_groups.doc" select="$ann_groups.doc" as="document-node()" tunnel="yes"/>
Piotr Banskic5950ce2022-05-27 15:07:08 +0200805 </xsl:apply-templates>-->
806 </xsl:element>
807 </xsl:element>
808 </xsl:result-document>
809 </xsl:template>
810
bansp5f841732022-03-16 06:27:31 +0100811 <!-- ************************** TEXT header ******************* -->
812
813 <xsl:template name="create_text_header">
Piotr Banskif9590692022-06-02 15:39:48 +0200814 <xsl:param name="text.doc" as="document-node()"/>
banspe726b4a2022-03-28 05:47:45 +0200815 <xsl:param name="compoundID" as="xs:string"/>
bansp5f841732022-03-16 06:27:31 +0100816 <xsl:param name="target" as="xs:string"/>
817
818 <!-- create the local header.xml file -->
819 <xsl:result-document encoding="UTF-8" method="xml" indent="yes"
820 xpath-default-namespace="http://ids-mannheim.de/ns/KorAP" href="{$target}">
821
822 <idsHeader type="document" pattern="text" status="new" version="1.1" TEIform="teiHeader">
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200823 <xsl:apply-templates select="$text.doc//tei:TEI/tei:teiHeader/tei:*" mode="text-header">
banspe726b4a2022-03-28 05:47:45 +0200824 <xsl:with-param name="compoundID" as="xs:string" select="$compoundID" tunnel="yes"/>
825 </xsl:apply-templates>
bansp5f841732022-03-16 06:27:31 +0100826 </idsHeader>
827 </xsl:result-document>
828 </xsl:template>
829
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200830 <xsl:template match="tei:fileDesc" mode="text-header">
bansp9103aab2022-03-19 05:10:21 +0100831 <xsl:element name="{local-name()}">
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200832 <xsl:apply-templates mode="text-header"/>
bansp9103aab2022-03-19 05:10:21 +0100833 </xsl:element>
bansp5f841732022-03-16 06:27:31 +0100834 </xsl:template>
835
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200836 <xsl:template match="tei:title" mode="text-header">
bansp5f841732022-03-16 06:27:31 +0100837 <t.title>
838 <xsl:apply-templates/>
839 </t.title>
840 </xsl:template>
841
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200842 <xsl:template match="tei:titleStmt" mode="text-header">
banspe726b4a2022-03-28 05:47:45 +0200843 <xsl:param name="compoundID" as="xs:string" tunnel="yes"/>
bansp5f841732022-03-16 06:27:31 +0100844 <titleStmt>
845 <textSigle>
banspe726b4a2022-03-28 05:47:45 +0200846 <xsl:value-of select="$compoundID"/>
bansp5f841732022-03-16 06:27:31 +0100847 </textSigle>
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200848 <xsl:apply-templates mode="text-header"/>
bansp5f841732022-03-16 06:27:31 +0100849 </titleStmt>
850 </xsl:template>
851
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200852 <xsl:template match="tei:publicationStmt" mode="text-header">
bansp9103aab2022-03-19 05:10:21 +0100853 <xsl:element name="{local-name()}">
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200854 <xsl:apply-templates mode="text-header"/>
bansp9103aab2022-03-19 05:10:21 +0100855 </xsl:element>
856 </xsl:template>
857
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200858 <xsl:template match="tei:availability" mode="text-header">
bansp9103aab2022-03-19 05:10:21 +0100859 <xsl:element name="{local-name()}">
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200860 <xsl:apply-templates mode="text-header" select="@* | *"/>
bansp9103aab2022-03-19 05:10:21 +0100861 </xsl:element>
862 </xsl:template>
863
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200864 <xsl:template match="tei:profileDesc" mode="text-header">
bansp9103aab2022-03-19 05:10:21 +0100865 <xsl:element name="{local-name()}">
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200866 <xsl:apply-templates mode="text-header"/>
bansp9103aab2022-03-19 05:10:21 +0100867 </xsl:element>
868 </xsl:template>
bansp5f841732022-03-16 06:27:31 +0100869
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200870 <xsl:template match="tei:textClass" mode="text-header">
bansp9103aab2022-03-19 05:10:21 +0100871 <xsl:element name="{local-name()}">
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200872 <xsl:apply-templates mode="text-header" select="@* | *"/>
bansp9103aab2022-03-19 05:10:21 +0100873 </xsl:element>
874 </xsl:template>
875
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200876 <xsl:template match="tei:catRef" mode="text-header corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100877 <xsl:element name="{local-name()}">
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200878 <xsl:apply-templates mode="text-header" select="@* | *"/>
bansp9103aab2022-03-19 05:10:21 +0100879 </xsl:element>
880 </xsl:template>
881
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200882 <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 +0100883 <xsl:copy-of select="."/>
884 </xsl:template>
885
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200886 <xsl:template match="tei:p" mode="text-header corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100887 <xsl:element name="{local-name()}">
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200888 <xsl:apply-templates mode="text_inside_header"/>
bansp9103aab2022-03-19 05:10:21 +0100889 </xsl:element>
890 </xsl:template>
891
892
893 <!-- OPTIMIZATION has to take modes into account -->
bansp5e2d1c02022-03-10 04:51:40 +0100894 <!-- ************************** CORPUS header ******************* -->
895 <xsl:template name="create_corpus_header">
Piotr Banskifaa910f2022-06-03 00:46:29 +0200896 <xsl:param name="text.doc" as="document-node()"/>
bansp5f841732022-03-16 06:27:31 +0100897 <xsl:param name="target" as="xs:string"/>
bansp5e2d1c02022-03-10 04:51:40 +0100898
899 <!-- create the corpus-level header.xml file -->
bansp5f841732022-03-16 06:27:31 +0100900 <xsl:result-document encoding="UTF-8" method="xml" indent="yes" href="{$target}">
bansp5e2d1c02022-03-10 04:51:40 +0100901
902 <!--doctype-public="{$publicDoctypeI5}"
903 doctype-system="{$systemDoctypeI5}">
904 these are, sadly, useless
905 -->
906
907 <idsHeader type="corpus" pattern="text" status="new" version="1.1" TEIform="teiHeader">
Piotr Banskifaa910f2022-06-03 00:46:29 +0200908 <xsl:apply-templates select="$text.doc/tei:teiCorpus/tei:teiHeader/tei:*" mode="corpus-header"/>
bansp5e2d1c02022-03-10 04:51:40 +0100909 </idsHeader>
910 </xsl:result-document>
911 </xsl:template>
912
Piotr Banskifaa910f2022-06-03 00:46:29 +0200913 <xsl:template match="tei:fileDesc" mode="corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100914 <xsl:element name="{local-name()}">
Piotr Banskifaa910f2022-06-03 00:46:29 +0200915 <xsl:apply-templates mode="corpus-header"/>
bansp9103aab2022-03-19 05:10:21 +0100916 </xsl:element>
bansp5e2d1c02022-03-10 04:51:40 +0100917 </xsl:template>
bansp9103aab2022-03-19 05:10:21 +0100918
bansp5e2d1c02022-03-10 04:51:40 +0100919
Piotr Banskifaa910f2022-06-03 00:46:29 +0200920 <xsl:template match="tei:title" mode="corpus-header">
bansp5e2d1c02022-03-10 04:51:40 +0100921 <c.title>
Piotr Banskifaa910f2022-06-03 00:46:29 +0200922 <xsl:apply-templates mode="corpus-header" select="@*"/>
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200923 <xsl:apply-templates mode="text_inside_header"/>
bansp5e2d1c02022-03-10 04:51:40 +0100924 </c.title>
925 </xsl:template>
926
Piotr Banskifaa910f2022-06-03 00:46:29 +0200927 <xsl:template match="tei:titleStmt" mode="corpus-header">
bansp5e2d1c02022-03-10 04:51:40 +0100928 <titleStmt>
929 <korpusSigle>
930 <xsl:value-of select="$corpusID"/>
931 </korpusSigle>
Piotr Banskifaa910f2022-06-03 00:46:29 +0200932 <xsl:apply-templates mode="corpus-header"/>
bansp5e2d1c02022-03-10 04:51:40 +0100933 </titleStmt>
934 </xsl:template>
935
Piotr Banskifaa910f2022-06-03 00:46:29 +0200936 <xsl:template match="tei:publicationStmt" mode="corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100937 <xsl:element name="{local-name()}">
Piotr Banskifaa910f2022-06-03 00:46:29 +0200938 <xsl:apply-templates mode="corpus-header"/>
bansp9103aab2022-03-19 05:10:21 +0100939 </xsl:element>
940 </xsl:template>
941
Piotr Banskifaa910f2022-06-03 00:46:29 +0200942 <xsl:template match="tei:availability" mode="corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100943 <xsl:element name="{local-name()}">
Piotr Banskifaa910f2022-06-03 00:46:29 +0200944 <xsl:apply-templates mode="corpus-header" select="@* | *"/>
bansp9103aab2022-03-19 05:10:21 +0100945 </xsl:element>
946 </xsl:template>
947
Piotr Banskifaa910f2022-06-03 00:46:29 +0200948 <xsl:template match="tei:encodingDesc" mode="corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100949 <xsl:element name="{local-name()}">
Piotr Banskifaa910f2022-06-03 00:46:29 +0200950 <xsl:apply-templates mode="corpus-header"/>
bansp9103aab2022-03-19 05:10:21 +0100951 </xsl:element>
952 </xsl:template>
953
Piotr Banskifaa910f2022-06-03 00:46:29 +0200954 <xsl:template match="tei:classDecl | tei:taxonomy | tei:category | tei:taxonomy/tei:bibl" mode="corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100955 <xsl:element name="{local-name()}">
Piotr Banskifaa910f2022-06-03 00:46:29 +0200956 <xsl:apply-templates mode="corpus-header" select="@* | *"/>
bansp9103aab2022-03-19 05:10:21 +0100957 </xsl:element>
958 </xsl:template>
959
Piotr Banskifaa910f2022-06-03 00:46:29 +0200960 <xsl:template match="tei:bibl/tei:title | tei:edition | tei:desc" mode="corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100961 <xsl:element name="{local-name()}">
Piotr Banskifaa910f2022-06-03 00:46:29 +0200962 <xsl:apply-templates mode="corpus-header" select="@*"/>
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200963 <xsl:apply-templates mode="text_inside_header"/>
bansp9103aab2022-03-19 05:10:21 +0100964 </xsl:element>
965 </xsl:template>
966<!--
Piotr Banskifaa910f2022-06-03 00:46:29 +0200967 <xsl:template match="tei:textClass" mode="corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100968 <xsl:element name="{local-name()}">
969 <xsl:apply-templates mode="corpus" select="@* | *"/>
970 </xsl:element>
971 </xsl:template>
972
Piotr Banskifaa910f2022-06-03 00:46:29 +0200973 <xsl:template match="tei:catRef" mode="corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100974 <xsl:element name="{local-name()}">
975 <xsl:apply-templates mode="corpus" select="@* | *"/>
976 </xsl:element>
977 </xsl:template>
978-->
bansp5e2d1c02022-03-10 04:51:40 +0100979
980
981
982 <!-- this template can be called by the XSPEC test; TODO: find a way to call the main() template directly -->
983 <!-- I have not fully handled the param transmission, which would have to be kludged in just for the sake of XSPec,
984 because I'm disabling this for now, due to XSpec design issues; relevant links, a.o.:
985
986 https://stackoverflow.com/questions/64933277/what-is-the-cause-of-error-cannot-execute-xslresult-document-while-evaluating
987 https://www.balisage.net/Proceedings/vol25/html/Galtman01/BalisageVol25-Galtman01.html
988
989 In short: the internal design of XSpec forces kludges when one wants to use xsl:result-document in their stylesheets. But I don't
990 want to be strangled by kludges at the beginning of work, I've already lost quite a bit of time on this investigation,
991 I will therefore "just code" and then can think of externalizing bits of templates if we want to play with tests. For now,
992 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.
993
994 -->
995 <!--<xsl:template name="test_full">
996 <xsl:param name="corpusID"/>
997 <xsl:param name="docID"/>
998 <xsl:param name="textID"/>
999 <xsl:call-template name="xsl:initial-template"/>
1000 </xsl:template>-->
1001
Akron9a8ee3e2022-01-31 13:51:49 +01001002</xsl:stylesheet>
Piotr Banski6a4a2522022-05-24 01:16:47 +02001003
Piotr Banskifdc858a2022-05-25 02:40:32 +02001004<!-- template for serializing maps in messages <xsl:message select="('map:',serialize($map, map{'method':'adaptive'}))"/> -->