blob: ff1ee5093c2bd0de80f86dfb3778bd3ad00cb3e7 [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"
5 xmlns:map="http://www.w3.org/2005/xpath-functions/map" exclude-result-prefixes="xs f map nkjp tei"
6 version="3.0" expand-text="yes">
Akron9a8ee3e2022-01-31 13:51:49 +01007
bansp5e2d1c02022-03-10 04:51:40 +01008 <xsl:param name="corpusID" as="xs:string"/>
9 <xsl:param name="docID" as="xs:string"/>
10 <xsl:param name="textID" as="xs:string"/>
11
12 <xsl:param name="sourceDir" select="'test/resources/nkjp2korap_sample1/KOT/'" as="xs:string"/>
banspf79443e2022-02-25 14:25:33 +010013 <!-- the select is a fallback, so that it's clear to the reviewer what I'm passing in the param -->
Akron9a8ee3e2022-01-31 13:51:49 +010014
bansp5e2d1c02022-03-10 04:51:40 +010015 <xsl:variable name="targetTextDir"
16 select="'test/output/' || $corpusID || '/' || $docID || '/' || $textID || '/'" as="xs:string"/>
17 <xsl:variable name="targetCorpusDir" select="'test/output/' || $corpusID || '/'" as="xs:string"/>
18
19 <xsl:variable name="systemDoctypeI5"
20 select="'http://corpora.ids-mannheim.de/idsxces1/DTD/ids.xcesdoc.dtd'" as="xs:string"
21 static="true"/>
22
23 <xsl:variable name="publicDoctypeI5" select="'-//IDS//DTD IDS-XCES 1.0//EN'" as="xs:string"
24 static="true"/>
25
26 <xsl:variable name="KorAP_namespace" select="'http://ids-mannheim.de/ns/KorAP'" static="true"
27 as="xs:string"/>
28
bansp5f841732022-03-16 06:27:31 +010029 <xsl:variable name="KorAP-XML_version" select="'KorAP-0.4'" as="xs:string" static="true"/>
30 <!-- this is only a bit funny -->
31
32 <xsl:variable name="compoundID" as="xs:string"
33 select="$corpusID || '_' || $docID || '.' || $textID"/>
34 <!-- this is what occurs in the text and data layers as @docid -->
bansp5e2d1c02022-03-10 04:51:40 +010035
36 <xsl:mode name="corpus" on-no-match="deep-skip"/>
37 <xsl:mode name="text" on-no-match="deep-skip"/>
38
bansp5f841732022-03-16 06:27:31 +010039 <!-- <xsl:variable name="text_depth" as="xs:integer" select="xs:integer('2')" static="true"/>
40 <!-\- this magic number indicates the depth of the <TEI> element inside teiCorpus/TEI -\->
41-->
42 <xsl:function name="f:compute_nesting" as="xs:integer">
43 <xsl:param name="node" as="node()"/>
44 <xsl:variable name="rel_depth"
45 select="count($node/ancestor-or-self::*[local-name(.) ne 'TEI'][local-name(.) ne 'teiCorpus'])"
46 as="xs:integer"/>
47<!-- I think my skills are lacking -->
48 <xsl:sequence select="$rel_depth"/>
49 </xsl:function>
50
51 <xsl:function name="f:calc_content_length" as="xs:integer">
52 <xsl:param name="node" as="node()"/>
53 <xsl:choose>
54 <xsl:when test="$node/self::tei:text or $node/self::tei:body">
55 <xsl:variable name="last_corresp"
56 select="$node/descendant::tei:p[last()]/descendant::tei:s[last()]/descendant::tei:seg[last()]/attribute::corresp"
57 as="attribute(corresp)"/>
58 <xsl:variable name="numbers" select="substring-after(substring-before($last_corresp,')'),',')"/>
59 <xsl:sequence select="xs:integer(substring-before($numbers,',')) + xs:integer(substring-after($numbers,','))"/>
60 </xsl:when>
61 <xsl:when test="$node/self::tei:p">
62 <xsl:variable name="last_corresp"
63 select="$node/descendant::tei:s[last()]/descendant::tei:seg[last()]/attribute::corresp"
64 as="attribute(corresp)"/>
65 <xsl:variable name="numbers" select="substring-after(substring-before($last_corresp,')'),',')"/>
66 <xsl:sequence select="xs:integer(substring-before($numbers,',')) + xs:integer(substring-after($numbers,','))"/>
67 </xsl:when>
68 <xsl:when test="$node/self::tei:s">
69 <xsl:variable name="last_corresp"
70 select="$node/descendant::tei:seg[last()]/attribute::corresp"
71 as="attribute(corresp)"/>
72 <xsl:variable name="numbers" select="substring-after(substring-before($last_corresp,')'),',')"/>
73 <xsl:sequence select="xs:integer(substring-before($numbers,',')) + xs:integer(substring-after($numbers,','))"/>
74 </xsl:when>
75 <xsl:otherwise>
76 <xsl:variable name="numbers" select="substring-after(substring-before($node/@corresp,')'),',')"/>
77 <xsl:sequence select="xs:integer(substring-before($numbers,',')) + xs:integer(substring-after($numbers,','))"/>
78 </xsl:otherwise>
79 </xsl:choose>
80 </xsl:function>
bansp5e2d1c02022-03-10 04:51:40 +010081
82 <xsl:template name="xsl:initial-template">
83 <xsl:variable name="text.xml" as="document-node()" select="doc($sourceDir || 'text.xml')"/>
bansp5f841732022-03-16 06:27:31 +010084 <xsl:variable name="ann_morphosyntax.xml" as="document-node()"
85 select="doc($sourceDir || 'ann_morphosyntax.xml')"/>
86 <xsl:variable name="ann_segmentation.xml" as="document-node()"
87 select="doc($sourceDir || 'ann_segmentation.xml')"/>
bansp5e2d1c02022-03-10 04:51:40 +010088
89 <xsl:call-template name="create_data">
90 <xsl:with-param name="text.xml" select="$text.xml" as="document-node()"/>
bansp5f841732022-03-16 06:27:31 +010091 <xsl:with-param name="target" select="$targetTextDir || 'data.xml'" as="xs:string"/>
92 </xsl:call-template>
93
94 <xsl:call-template name="create_struct">
95 <xsl:with-param name="text.xml" select="$text.xml" as="document-node()"/>
96 <xsl:with-param name="ann_segmentation.xml" select="$ann_segmentation.xml"
97 as="document-node()"/>
98 <xsl:with-param name="target" select="$targetTextDir || 'struct/structure.xml'" as="xs:string"
99 />
100 </xsl:call-template>
101
102 <xsl:call-template name="create_morpho">
103 <xsl:with-param name="text.xml" select="$text.xml" as="document-node()"/>
bansp3e5b20c2022-03-18 20:22:31 +0100104 <xsl:with-param name="ann_segmentation.xml" select="$ann_segmentation.xml"
105 as="document-node()"/>
bansp5f841732022-03-16 06:27:31 +0100106 <xsl:with-param name="ann_morphosyntax.xml" select="$ann_morphosyntax.xml"
107 as="document-node()"/>
108 <xsl:with-param name="target" select="$targetTextDir || 'nkjp/morpho.xml'" as="xs:string"/>
bansp5e2d1c02022-03-10 04:51:40 +0100109 </xsl:call-template>
110
111 <xsl:call-template name="create_text_header">
112 <xsl:with-param name="text.xml" select="$text.xml" as="document-node()"/>
bansp5f841732022-03-16 06:27:31 +0100113 <xsl:with-param name="target" select="$targetTextDir || 'header.xml'" as="xs:string"/>
bansp5e2d1c02022-03-10 04:51:40 +0100114 </xsl:call-template>
115
116 <xsl:call-template name="create_corpus_header">
117 <xsl:with-param name="text.xml" select="$text.xml" as="document-node()"/>
bansp5f841732022-03-16 06:27:31 +0100118 <xsl:with-param name="target" select="$targetCorpusDir || 'header.xml'" as="xs:string"/>
bansp5e2d1c02022-03-10 04:51:40 +0100119 </xsl:call-template>
120 </xsl:template>
121
122 <!-- ************************** data.xml ******************* -->
123
124 <xsl:template name="create_data">
125 <xsl:param name="text.xml" as="document-node()"/>
bansp5f841732022-03-16 06:27:31 +0100126 <xsl:param name="target" as="xs:string"/>
bansp5e2d1c02022-03-10 04:51:40 +0100127 <!-- create the data.xml file -->
128 <xsl:result-document encoding="UTF-8" method="xml" indent="yes"
bansp5f841732022-03-16 06:27:31 +0100129 xpath-default-namespace="{$KorAP_namespace}" href="{$target}">
bansp5e2d1c02022-03-10 04:51:40 +0100130
Akron9a8ee3e2022-01-31 13:51:49 +0100131 <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 +0100132 <xsl:element name="raw_text" namespace="{$KorAP_namespace}">
bansp5f841732022-03-16 06:27:31 +0100133 <xsl:attribute name="docid" select="$compoundID"/>
bansp5e2d1c02022-03-10 04:51:40 +0100134 <xsl:element name="metadata" namespace="{$KorAP_namespace}">
135 <xsl:attribute name="file" select="'metadata.xml'"/>
136 </xsl:element>
137
138 <xsl:element name="text" namespace="{$KorAP_namespace}">
banspf79443e2022-02-25 14:25:33 +0100139 <xsl:value-of select="$text.xml//*[local-name() = 'ab']"/>
bansp5e2d1c02022-03-10 04:51:40 +0100140 </xsl:element>
Akron9a8ee3e2022-01-31 13:51:49 +0100141 </xsl:element>
banspf79443e2022-02-25 14:25:33 +0100142 </xsl:result-document>
Akron9a8ee3e2022-01-31 13:51:49 +0100143 </xsl:template>
144
bansp5f841732022-03-16 06:27:31 +0100145 <!-- ************************** struct ******************* -->
146
147 <xsl:template name="create_struct">
148 <xsl:param name="text.xml" as="document-node()"/>
149 <xsl:param name="ann_segmentation.xml" as="document-node()"/>
150 <xsl:param name="target" as="xs:string"/>
151
152 <xsl:result-document encoding="UTF-8" method="xml" indent="yes"
153 xpath-default-namespace="http://ids-mannheim.de/ns/KorAP" href="{$target}">
154 <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>
155 <xsl:element name="layer" namespace="{$KorAP_namespace}">
156 <xsl:attribute name="docid" select="$compoundID"/>
157 <xsl:attribute name="version" select="$KorAP-XML_version"/>
158
159 <xsl:element name="spanList" namespace="{$KorAP_namespace}">
160 <xsl:apply-templates select="$ann_segmentation.xml//tei:text" mode="struct"/>
161 </xsl:element>
162 </xsl:element>
163 </xsl:result-document>
164 </xsl:template>
165
166 <xsl:template match="tei:*" mode="struct">
167 <xsl:param name="ini" as="xs:integer" required="no" select="0"/>
168 <xsl:param name="fin" as="xs:integer" required="no" select="999999999"/>
169 <xsl:param name="index" as="xs:integer" required="no" select="1"/>
170 <!-- I have made a major mess here, but it works... it's so spread out
171 because I wanted to make sure to be able to look up the individual
bansp3e5b20c2022-03-18 20:22:31 +0100172 constituent values, should anything go wrong; optimization will come when it's worked against a larger dataset -->
bansp5f841732022-03-16 06:27:31 +0100173 <xsl:variable name="my_name" select="local-name()" as="xs:string"/>
174 <xsl:variable name="preceding" select="preceding-sibling::*[local-name(.) eq $my_name]"/>
175 <xsl:variable name="preceding-count" select="count($preceding)"/>
176 <xsl:variable name="outside-preceding-count" as="xs:integer">
177 <xsl:choose>
178 <xsl:when test="self::tei:s or self::tei:p">
179 <xsl:choose>
180 <xsl:when test="$preceding-count">
181 <xsl:sequence select="
182 sum(for $p in $preceding
183 return
184 count($p/descendant::*))"/>
185 </xsl:when>
186 <xsl:otherwise>
187 <xsl:sequence select="0"/>
188 </xsl:otherwise>
189 </xsl:choose>
190 </xsl:when>
191 <xsl:otherwise>
192 <xsl:sequence select="0"/>
193 </xsl:otherwise>
194 </xsl:choose>
195 </xsl:variable>
196 <xsl:variable name="my_index" select="$index + 1 + $preceding-count + $outside-preceding-count"
197 as="xs:integer"/>
198
199 <xsl:variable name="start" as="xs:integer">
200 <xsl:choose>
201 <xsl:when test="self::tei:text or self::tei:body">
202 <xsl:sequence select="0"/>
203 </xsl:when>
204 <xsl:when test="self::tei:p">
205 <xsl:variable name="first_corresp"
206 select="descendant::tei:s[1]/descendant::tei:seg[1]/attribute::corresp"
207 as="attribute(corresp)"/>
208 <xsl:variable name="numbers" select="substring-after(substring-before($first_corresp,')'),',')"/>
209 <xsl:sequence select="xs:integer(substring-before($numbers,','))"/>
210 </xsl:when>
211 <xsl:when test="self::tei:s">
212 <xsl:variable name="first_corresp"
213 select="descendant::tei:seg[1]/attribute::corresp"
214 as="attribute(corresp)"/>
215 <xsl:variable name="numbers" select="substring-after(substring-before($first_corresp,')'),',')"/>
216 <xsl:sequence select="xs:integer(substring-before($numbers,','))"/>
217 </xsl:when>
218 <xsl:when test="self::tei:seg">
219 <xsl:variable name="numbers" select="substring-after(substring-before(@corresp,')'),',')"/>
220 <xsl:sequence select="xs:integer(substring-before($numbers,','))"/>
221 </xsl:when>
222 </xsl:choose>
223 </xsl:variable>
224 <xsl:variable name="end" as="xs:integer" select="f:calc_content_length(.)">
225 </xsl:variable>
bansp3e5b20c2022-03-18 20:22:31 +0100226
bansp5f841732022-03-16 06:27:31 +0100227 <xsl:element name="span" namespace="{$KorAP_namespace}">
228 <xsl:attribute name="id" select="'s' || $my_index"/>
229 <xsl:attribute name="from" select="$start"/>
230 <xsl:attribute name="to" select="$end"/>
231 <xsl:attribute name="l" select="f:compute_nesting(.)"/>
232 <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0">
bansp3e5b20c2022-03-18 20:22:31 +0100233 <xsl:attribute name="type" select="'struct'"></xsl:attribute> <!-- STRUCT vs. LEX -->
bansp5f841732022-03-16 06:27:31 +0100234 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
bansp3e5b20c2022-03-18 20:22:31 +0100235 <xsl:attribute name="name" select="'name'"/>
236 <xsl:value-of select="local-name()"/>
bansp5f841732022-03-16 06:27:31 +0100237 </xsl:element>
238 <xsl:if test="count(@*)">
239 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
240 <xsl:attribute name="name" select="'attr'"/>
241 <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0">
242 <xsl:attribute name="type" select="'attr'"/>
243 <xsl:for-each select="@*">
244 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
245 <xsl:attribute name="name" select="local-name(.)"/>
246 <xsl:value-of select="."/>
247 </xsl:element>
248 </xsl:for-each>
249 </xsl:element>
250 </xsl:element>
251 </xsl:if>
252 </xsl:element>
253 </xsl:element>
254 <xsl:apply-templates mode="struct">
255 <xsl:with-param name="ini" select="$start" as="xs:integer"/>
256 <xsl:with-param name="fin" select="$end" as="xs:integer"/>
257 <xsl:with-param name="index" select="$my_index"/>
258 </xsl:apply-templates>
259 </xsl:template>
260
261 <!-- ************************** morpho ******************* -->
262
263 <xsl:template name="create_morpho">
264 <xsl:param name="text.xml" as="document-node()"/>
bansp3e5b20c2022-03-18 20:22:31 +0100265 <xsl:param name="ann_segmentation.xml" as="document-node()"/>
bansp5f841732022-03-16 06:27:31 +0100266 <xsl:param name="ann_morphosyntax.xml" as="document-node()"/>
267 <xsl:param name="target" as="xs:string"/>
268
269 <xsl:result-document encoding="UTF-8" method="xml" indent="yes"
270 xpath-default-namespace="http://ids-mannheim.de/ns/KorAP" href="{$target}">
271 <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 +0100272 <xsl:element name="layer" namespace="{$KorAP_namespace}">
273 <xsl:attribute name="docid" select="$compoundID"/>
274 <xsl:attribute name="version" select="$KorAP-XML_version"/>
275
276 <xsl:element name="spanList" namespace="{$KorAP_namespace}">
277 <xsl:apply-templates select="$ann_segmentation.xml//tei:text" mode="morpho">
278 <xsl:with-param name="ann_morphosyntax.xml" select="$ann_morphosyntax.xml" as="document-node()"/>
279 </xsl:apply-templates>
280 </xsl:element>
281 </xsl:element>
bansp5f841732022-03-16 06:27:31 +0100282 </xsl:result-document>
283 </xsl:template>
284
bansp3e5b20c2022-03-18 20:22:31 +0100285 <xsl:template match="tei:*" mode="morpho">
286 <xsl:param name="ini" as="xs:integer" required="no" select="0"/>
287 <xsl:param name="fin" as="xs:integer" required="no" select="999999999"/>
288 <xsl:param name="index" as="xs:integer" required="no" select="1"/>
289 <xsl:param name="ann_morphosyntax.xml" as="document-node()"/>
290 <xsl:variable name="my_name" select="local-name()" as="xs:string"/>
291 <xsl:variable name="preceding" select="preceding-sibling::*[local-name(.) eq $my_name]"/>
292 <xsl:variable name="preceding-count" select="count($preceding)"/>
293 <xsl:variable name="outside-preceding-count" as="xs:integer">
294 <xsl:choose>
295 <xsl:when test="self::tei:s or self::tei:p">
296 <xsl:choose>
297 <xsl:when test="$preceding-count">
298 <xsl:sequence select="
299 sum(for $p in $preceding
300 return
301 count($p/descendant::*))"/>
302 </xsl:when>
303 <xsl:otherwise>
304 <xsl:sequence select="0"/>
305 </xsl:otherwise>
306 </xsl:choose>
307 </xsl:when>
308 <xsl:otherwise>
309 <xsl:sequence select="0"/>
310 </xsl:otherwise>
311 </xsl:choose>
312 </xsl:variable>
313 <xsl:variable name="my_index" select="$index + 1 + $preceding-count + $outside-preceding-count"
314 as="xs:integer"/>
315
316 <xsl:variable name="start" as="xs:integer">
317 <xsl:choose>
318 <xsl:when test="self::tei:text or self::tei:body">
319 <xsl:sequence select="0"/>
320 </xsl:when>
321 <xsl:when test="self::tei:p">
322 <xsl:variable name="first_corresp"
323 select="descendant::tei:s[1]/descendant::tei:seg[1]/attribute::corresp"
324 as="attribute(corresp)"/>
325 <xsl:variable name="numbers" select="substring-after(substring-before($first_corresp,')'),',')"/>
326 <xsl:sequence select="xs:integer(substring-before($numbers,','))"/>
327 </xsl:when>
328 <xsl:when test="self::tei:s">
329 <xsl:variable name="first_corresp"
330 select="descendant::tei:seg[1]/attribute::corresp"
331 as="attribute(corresp)"/>
332 <xsl:variable name="numbers" select="substring-after(substring-before($first_corresp,')'),',')"/>
333 <xsl:sequence select="xs:integer(substring-before($numbers,','))"/>
334 </xsl:when>
335 <!--<xsl:when test="self::tei:seg">
336 <xsl:variable name="numbers" select="substring-after(substring-before(@corresp,')'),',')"/>
337 <xsl:sequence select="xs:integer(substring-before($numbers,','))"/>
338 </xsl:when>-->
339 </xsl:choose>
340 </xsl:variable>
341 <xsl:variable name="end" as="xs:integer" select="f:calc_content_length(.)">
342 </xsl:variable>
343
344 <xsl:apply-templates mode="morpho">
345 <xsl:with-param name="ini" select="$start" as="xs:integer"/>
346 <xsl:with-param name="fin" select="$end" as="xs:integer"/>
347 <xsl:with-param name="index" select="$my_index"/>
348 <xsl:with-param name="ann_morphosyntax.xml" select="$ann_morphosyntax.xml" as="document-node()"/>
349 </xsl:apply-templates>
350 </xsl:template>
bansp5f841732022-03-16 06:27:31 +0100351
bansp3e5b20c2022-03-18 20:22:31 +0100352 <xsl:template match="tei:seg" mode="morpho">
353 <xsl:param name="ini" as="xs:integer" required="no" select="0"/>
354 <xsl:param name="fin" as="xs:integer" required="no" select="999999999"/>
355 <xsl:param name="index" as="xs:integer" required="no" select="1"/>
356 <xsl:param name="ann_morphosyntax.xml" as="document-node()"/>
357 <!-- I have made a major mess here, but it works... it's so spread out
358 because I wanted to make sure to be able to look up the individual
359 constituent values, should anything go wrong -->
360 <xsl:variable name="my_name" select="local-name()" as="xs:string"/>
361 <xsl:variable name="my_id" select="@xml:id" as="xs:string"/>
362 <xsl:variable name="my_morph-seg" as="node()" select="$ann_morphosyntax.xml//tei:seg[substring-after(@corresp,'#') eq $my_id]"/>
363 <xsl:variable name="my_disamb" select="$my_morph-seg//tei:fs/tei:f[@name eq 'disamb']" as="node()"/>
364 <xsl:variable name="my_choice-id" select="substring-after($my_disamb//tei:f[@name eq 'choice']/@fVal,'#')" as="xs:string"/>
365 <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()"/>
366 <xsl:variable name="chosen-msd" as="xs:string" select="$my_choice-lex/descendant::tei:symbol[@xml:id eq $my_choice-id]/@value"/>
367 <xsl:variable name="preceding" select="preceding-sibling::*[local-name(.) eq $my_name]"/>
368 <xsl:variable name="preceding-count" select="count($preceding)"/>
369 <xsl:variable name="outside-preceding-count" as="xs:integer">
370 <xsl:choose>
371 <xsl:when test="self::tei:s or self::tei:p">
372 <xsl:choose>
373 <xsl:when test="$preceding-count">
374 <xsl:sequence select="
375 sum(for $p in $preceding
376 return
377 count($p/descendant::*))"/>
378 </xsl:when>
379 <xsl:otherwise>
380 <xsl:sequence select="0"/>
381 </xsl:otherwise>
382 </xsl:choose>
383 </xsl:when>
384 <xsl:otherwise>
385 <xsl:sequence select="0"/>
386 </xsl:otherwise>
387 </xsl:choose>
388 </xsl:variable>
389 <xsl:variable name="my_index" select="$index + 1 + $preceding-count + $outside-preceding-count"
390 as="xs:integer"/>
391
392 <xsl:variable name="start" as="xs:integer">
393 <xsl:variable name="numbers" select="substring-after(substring-before(@corresp,')'),',')"/>
394 <xsl:sequence select="xs:integer(substring-before($numbers,','))"/>
395 </xsl:variable>
396 <xsl:variable name="end" as="xs:integer" select="f:calc_content_length(.)">
397 </xsl:variable>
398 <xsl:element name="span" namespace="{$KorAP_namespace}">
399 <xsl:attribute name="id" select="'s' || $my_index"/>
400 <xsl:attribute name="from" select="$start"/>
401 <xsl:attribute name="to" select="$end"/>
402 <xsl:attribute name="l" select="f:compute_nesting(.)"/>
403 <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0">
404 <xsl:attribute name="type" select="'lex'"/>
405 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
406 <xsl:attribute name="name" select="'lex'"/>
407 <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0">
408 <xsl:comment select="$my_morph-seg//tei:fs/tei:f[@name eq 'orth']/tei:string"/>
409
410
411 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
412 <xsl:attribute name="name" select="'lemma'"/>
413 <xsl:value-of select="$my_choice-lex/tei:f[@name eq 'base']/tei:string"/>
414 </xsl:element>
415 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
416 <xsl:attribute name="name" select="'pos'"/>
417 <xsl:value-of select="$my_choice-lex/tei:f[@name eq 'ctag']/tei:symbol/@value"/>
418 </xsl:element>
419 <xsl:if test="string-length($chosen-msd)">
420 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
421 <xsl:attribute name="name" select="'msd'"/>
422 <xsl:value-of select="$chosen-msd"/>
423 </xsl:element>
424 </xsl:if>
425 <xsl:if test="$my_morph-seg//tei:fs/tei:f[@name eq 'nps']">
426 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
427 <xsl:attribute name="name" select="'join'"/>
428 <xsl:value-of select="'left'"/>
429 </xsl:element>
430 </xsl:if>
431 </xsl:element>
432 </xsl:element>
433 </xsl:element>
434 </xsl:element>
435 <xsl:apply-templates mode="morpho">
436 <xsl:with-param name="ini" select="$start" as="xs:integer"/>
437 <xsl:with-param name="fin" select="$end" as="xs:integer"/>
438 <xsl:with-param name="index" select="$my_index"/>
439 <xsl:with-param name="ann_morphosyntax.xml" select="$ann_morphosyntax.xml" as="document-node()"/>
440 </xsl:apply-templates>
441 </xsl:template>
bansp5f841732022-03-16 06:27:31 +0100442 <!-- ************************** TEXT header ******************* -->
443
444 <xsl:template name="create_text_header">
445 <xsl:param name="text.xml" as="document-node()"/>
446 <xsl:param name="target" as="xs:string"/>
447
448 <!-- create the local header.xml file -->
449 <xsl:result-document encoding="UTF-8" method="xml" indent="yes"
450 xpath-default-namespace="http://ids-mannheim.de/ns/KorAP" href="{$target}">
451
452 <idsHeader type="document" pattern="text" status="new" version="1.1" TEIform="teiHeader">
453 <xsl:apply-templates select="$text.xml//tei:TEI/tei:teiHeader/tei:fileDesc" mode="text"/>
454 </idsHeader>
455 </xsl:result-document>
456 </xsl:template>
457
458 <xsl:template match="tei:fileDesc" mode="text">
459 <fileDesc>
460 <xsl:apply-templates mode="text"/>
461 </fileDesc>
462 </xsl:template>
463
464 <xsl:template match="tei:title" mode="text">
465 <t.title>
466 <xsl:apply-templates/>
467 </t.title>
468 </xsl:template>
469
470 <xsl:template match="tei:titleStmt" mode="text">
471 <titleStmt>
472 <textSigle>
473 <xsl:value-of select="$corpusID || '/' || $textID"/>
474 </textSigle>
475 <xsl:apply-templates mode="text"/>
476 </titleStmt>
477 </xsl:template>
478
479
bansp5e2d1c02022-03-10 04:51:40 +0100480 <!-- ************************** CORPUS header ******************* -->
481 <xsl:template name="create_corpus_header">
482 <xsl:param name="text.xml" as="document-node()"/>
bansp5f841732022-03-16 06:27:31 +0100483 <xsl:param name="target" as="xs:string"/>
bansp5e2d1c02022-03-10 04:51:40 +0100484
485 <!-- create the corpus-level header.xml file -->
bansp5f841732022-03-16 06:27:31 +0100486 <xsl:result-document encoding="UTF-8" method="xml" indent="yes" href="{$target}">
bansp5e2d1c02022-03-10 04:51:40 +0100487
488 <!--doctype-public="{$publicDoctypeI5}"
489 doctype-system="{$systemDoctypeI5}">
490 these are, sadly, useless
491 -->
492
493 <idsHeader type="corpus" pattern="text" status="new" version="1.1" TEIform="teiHeader">
494 <xsl:apply-templates select="$text.xml//tei:TEI/tei:teiHeader/tei:fileDesc" mode="corpus"/>
495 </idsHeader>
496 </xsl:result-document>
497 </xsl:template>
498
499 <xsl:template match="tei:fileDesc" mode="corpus">
500 <fileDesc>
501 <xsl:apply-templates mode="corpus"/>
502 </fileDesc>
503 </xsl:template>
504
505 <xsl:template match="tei:title" mode="corpus">
506 <c.title>
507 <xsl:apply-templates/>
508 </c.title>
509 </xsl:template>
510
511 <xsl:template match="tei:titleStmt" mode="corpus">
512 <titleStmt>
513 <korpusSigle>
514 <xsl:value-of select="$corpusID"/>
515 </korpusSigle>
516 <xsl:apply-templates mode="corpus"/>
517 </titleStmt>
518 </xsl:template>
519
520
bansp5e2d1c02022-03-10 04:51:40 +0100521
522
523
524 <!-- this template can be called by the XSPEC test; TODO: find a way to call the main() template directly -->
525 <!-- I have not fully handled the param transmission, which would have to be kludged in just for the sake of XSPec,
526 because I'm disabling this for now, due to XSpec design issues; relevant links, a.o.:
527
528 https://stackoverflow.com/questions/64933277/what-is-the-cause-of-error-cannot-execute-xslresult-document-while-evaluating
529 https://www.balisage.net/Proceedings/vol25/html/Galtman01/BalisageVol25-Galtman01.html
530
531 In short: the internal design of XSpec forces kludges when one wants to use xsl:result-document in their stylesheets. But I don't
532 want to be strangled by kludges at the beginning of work, I've already lost quite a bit of time on this investigation,
533 I will therefore "just code" and then can think of externalizing bits of templates if we want to play with tests. For now,
534 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.
535
536 -->
537 <!--<xsl:template name="test_full">
538 <xsl:param name="corpusID"/>
539 <xsl:param name="docID"/>
540 <xsl:param name="textID"/>
541 <xsl:call-template name="xsl:initial-template"/>
542 </xsl:template>-->
543
Akron9a8ee3e2022-01-31 13:51:49 +0100544</xsl:stylesheet>