Akron | 9a8ee3e | 2022-01-31 13:51:49 +0100 | [diff] [blame] | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
bansp | 5e2d1c0 | 2022-03-10 04:51:40 +0100 | [diff] [blame] | 3 | 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 Banski | f8af3a9 | 2022-05-23 03:20:10 +0200 | [diff] [blame] | 5 | xmlns:fn="http://www.w3.org/2005/xpath-functions" |
Piotr Banski | 763b41f | 2022-06-02 01:13:23 +0200 | [diff] [blame] | 6 | 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" |
bansp | 5e2d1c0 | 2022-03-10 04:51:40 +0100 | [diff] [blame] | 8 | version="3.0" expand-text="yes"> |
Akron | 9a8ee3e | 2022-01-31 13:51:49 +0100 | [diff] [blame] | 9 | |
bansp | e726b4a | 2022-03-28 05:47:45 +0200 | [diff] [blame] | 10 | |
| 11 | <!-- PARAMETERS --> |
bansp | 5e2d1c0 | 2022-03-10 04:51:40 +0100 | [diff] [blame] | 12 | |
bansp | 8f6700b | 2022-03-27 05:27:09 +0200 | [diff] [blame] | 13 | <xsl:param name="sourceDir" select="'test/resources/nkjp2korap_sample2'" as="xs:string"/> |
bansp | d1bf1db | 2022-04-04 02:16:24 +0200 | [diff] [blame] | 14 | <!-- 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) --> |
Akron | 9a8ee3e | 2022-01-31 13:51:49 +0100 | [diff] [blame] | 16 | |
bansp | 8f6700b | 2022-03-27 05:27:09 +0200 | [diff] [blame] | 17 | <xsl:param name="targetDir" select="'test/output'" as="xs:string"/> |
bansp | d1bf1db | 2022-04-04 02:16:24 +0200 | [diff] [blame] | 18 | <!-- where the corpus/document/text/annotations hierarchy is going to be created --> |
bansp | f2b24e6 | 2022-03-28 18:12:08 +0200 | [diff] [blame] | 19 | |
| 20 | <xsl:param name="skip_docID" as="xs:string"> |
Piotr Banski | c5950ce | 2022-05-27 15:07:08 +0200 | [diff] [blame] | 21 | <!--<xsl:value-of select="''"/>--> |
| 22 | <xsl:value-of select="'HellerPodgladanie,IsakowiczZaleskiMoje,KolakowskiOco,MysliwskiKamien,WilkWilczy,ZycieWarszawy_Zycie'"/> |
bansp | b599253 | 2022-03-29 15:55:44 +0200 | [diff] [blame] | 23 | </xsl:param> |
| 24 | <!-- comma-separated list of document IDs to be skipped from processing |
bansp | f2b24e6 | 2022-03-28 18:12:08 +0200 | [diff] [blame] | 25 | example: HellerPodgladanie,KOT |
bansp | d1bf1db | 2022-04-04 02:16:24 +0200 | [diff] [blame] | 26 | no functionality beyond string identity is supported |
| 27 | (this is just for testing) --> |
bansp | b599253 | 2022-03-29 15:55:44 +0200 | [diff] [blame] | 28 | |
Piotr Banski | 1ae16bd | 2022-05-25 15:59:40 +0200 | [diff] [blame] | 29 | <xsl:param name="SHOW_ORTH_IN_STRUCT" as="xs:boolean" select="true()"/> |
Piotr Banski | 09096ee | 2022-05-25 13:41:03 +0200 | [diff] [blame] | 30 | <!-- for debugging structure.xml production --> |
| 31 | |
bansp | 8f6700b | 2022-03-27 05:27:09 +0200 | [diff] [blame] | 32 | |
bansp | 9dc1000 | 2022-05-17 22:33:34 +0200 | [diff] [blame] | 33 | <!-- VARIABLES (= constants...) --> |
bansp | e726b4a | 2022-03-28 05:47:45 +0200 | [diff] [blame] | 34 | |
| 35 | <xsl:variable name="corpusID" as="xs:string" select="'NKJP'" static="yes"/> |
| 36 | <xsl:variable name="docID" as="xs:string" select="'NKJP'" static="yes"/> |
bansp | 8f6700b | 2022-03-27 05:27:09 +0200 | [diff] [blame] | 37 | |
| 38 | <xsl:variable name="targetCorpusDir_slashed" select="$targetDir || '/' || $corpusID || '/'" as="xs:string"/> |
bansp | 5e2d1c0 | 2022-03-10 04:51:40 +0100 | [diff] [blame] | 39 | |
bansp | d1bf1db | 2022-04-04 02:16:24 +0200 | [diff] [blame] | 40 | <xsl:variable name="systemDoctypeI5" as="xs:string" |
| 41 | select="'http://corpora.ids-mannheim.de/I5/DTD/i5.dtd'" static="true"/> |
bansp | 5e2d1c0 | 2022-03-10 04:51:40 +0100 | [diff] [blame] | 42 | |
bansp | d1bf1db | 2022-04-04 02:16:24 +0200 | [diff] [blame] | 43 | <xsl:variable name="publicDoctypeI5" as="xs:string" static="true" |
| 44 | select="'-//IDS//DTD I5 1.0//EN'"/> |
bansp | 5e2d1c0 | 2022-03-10 04:51:40 +0100 | [diff] [blame] | 45 | |
bansp | d1bf1db | 2022-04-04 02:16:24 +0200 | [diff] [blame] | 46 | <xsl:variable name="KorAP_namespace" static="true" as="xs:string" |
| 47 | select="'http://ids-mannheim.de/ns/KorAP'"/> |
bansp | 5e2d1c0 | 2022-03-10 04:51:40 +0100 | [diff] [blame] | 48 | |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 49 | <xsl:variable name="KorAP-XML_version" select="'KorAP-0.4'" as="xs:string" static="true"/> |
| 50 | <!-- this is only a bit funny --> |
| 51 | |
bansp | e726b4a | 2022-03-28 05:47:45 +0200 | [diff] [blame] | 52 | <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()+"/> |
bansp | d1bf1db | 2022-04-04 02:16:24 +0200 | [diff] [blame] | 58 | |
bansp | e726b4a | 2022-03-28 05:47:45 +0200 | [diff] [blame] | 59 | <!-- MODES --> |
bansp | 5e2d1c0 | 2022-03-10 04:51:40 +0100 | [diff] [blame] | 60 | |
Piotr Banski | 43b9db0 | 2022-06-03 02:38:42 +0200 | [diff] [blame] | 61 | <xsl:mode name="struct" on-no-match="deep-skip"/> |
Piotr Banski | faa910f | 2022-06-03 00:46:29 +0200 | [diff] [blame] | 62 | <xsl:mode name="corpus-header" on-no-match="deep-skip"/> |
Piotr Banski | a0a9fc0 | 2022-06-03 01:20:18 +0200 | [diff] [blame] | 63 | <xsl:mode name="text-header" on-no-match="deep-skip"/> |
| 64 | <xsl:mode name="text_inside_header" on-no-match="text-only-copy"/> |
Piotr Banski | 763b41f | 2022-06-02 01:13:23 +0200 | [diff] [blame] | 65 | <xsl:mode name="copy" on-no-match="shallow-copy"/> |
Piotr Banski | 6a4a252 | 2022-05-24 01:16:47 +0200 | [diff] [blame] | 66 | <xsl:mode use-accumulators="#all"/> |
Piotr Banski | 09096ee | 2022-05-25 13:41:03 +0200 | [diff] [blame] | 67 | |
Piotr Banski | e1ac520 | 2022-05-30 21:25:21 +0200 | [diff] [blame] | 68 | <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 Banski | 09096ee | 2022-05-25 13:41:03 +0200 | [diff] [blame] | 70 | </xsl:accumulator> |
Piotr Banski | fdc858a | 2022-05-25 02:40:32 +0200 | [diff] [blame] | 71 | |
Piotr Banski | 65a6d0b | 2022-05-31 17:23:08 +0200 | [diff] [blame] | 72 | |
| 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 Banski | fdc858a | 2022-05-25 02:40:32 +0200 | [diff] [blame] | 76 | |
| 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 Banski | 6a4a252 | 2022-05-24 01:16:47 +0200 | [diff] [blame] | 81 | </xsl:variable> |
| 82 | |
Piotr Banski | fdc858a | 2022-05-25 02:40:32 +0200 | [diff] [blame] | 83 | <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 Banski | 09096ee | 2022-05-25 13:41:03 +0200 | [diff] [blame] | 85 | |
Piotr Banski | fdc858a | 2022-05-25 02:40:32 +0200 | [diff] [blame] | 86 | <xsl:sequence select=" |
| 87 | $value, |
| 88 | map { |
| 89 | string(@xml:id): ($preceding_index,$our_base) |
| 90 | }"/> |
| 91 | </xsl:accumulator-rule> |
Piotr Banski | 65a6d0b | 2022-05-31 17:23:08 +0200 | [diff] [blame] | 92 | <!-- this is morpho-offsets --> |
Piotr Banski | fdc858a | 2022-05-25 02:40:32 +0200 | [diff] [blame] | 93 | <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 Banski | fdc858a | 2022-05-25 02:40:32 +0200 | [diff] [blame] | 97 | </xsl:variable> |
Piotr Banski | 92791a2 | 2022-05-26 01:41:10 +0200 | [diff] [blame] | 98 | <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 Banski | 09096ee | 2022-05-25 13:41:03 +0200 | [diff] [blame] | 99 | |
Piotr Banski | fdc858a | 2022-05-25 02:40:32 +0200 | [diff] [blame] | 100 | <xsl:sequence select=" |
| 101 | $value, |
| 102 | map { |
| 103 | string(@xml:id): ($preceding_index,$our_base) |
| 104 | }"/> |
| 105 | </xsl:accumulator-rule> |
Piotr Banski | 65a6d0b | 2022-05-31 17:23:08 +0200 | [diff] [blame] | 106 | <!-- 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 Banski | fdc858a | 2022-05-25 02:40:32 +0200 | [diff] [blame] | 113 | <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 Banski | fdc858a | 2022-05-25 02:40:32 +0200 | [diff] [blame] | 116 | </xsl:variable> |
Piotr Banski | 65a6d0b | 2022-05-31 17:23:08 +0200 | [diff] [blame] | 117 | <xsl:variable name="our_base" as="xs:integer" select="$preceding_index + xs:integer(f:is_preceded_by_ws(.,true()))"/> |
Piotr Banski | 09096ee | 2022-05-25 13:41:03 +0200 | [diff] [blame] | 118 | |
Piotr Banski | 6a4a252 | 2022-05-24 01:16:47 +0200 | [diff] [blame] | 119 | <xsl:sequence select=" |
Piotr Banski | 65a6d0b | 2022-05-31 17:23:08 +0200 | [diff] [blame] | 120 | $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 Banski | 6a4a252 | 2022-05-24 01:16:47 +0200 | [diff] [blame] | 125 | </xsl:accumulator-rule> |
Piotr Banski | 65a6d0b | 2022-05-31 17:23:08 +0200 | [diff] [blame] | 126 | <!-- this is morpho-offsets --> |
Piotr Banski | fdc858a | 2022-05-25 02:40:32 +0200 | [diff] [blame] | 127 | <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 Banski | 09096ee | 2022-05-25 13:41:03 +0200 | [diff] [blame] | 131 | |
Piotr Banski | fdc858a | 2022-05-25 02:40:32 +0200 | [diff] [blame] | 132 | </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 Banski | 09096ee | 2022-05-25 13:41:03 +0200 | [diff] [blame] | 137 | |
Piotr Banski | fdc858a | 2022-05-25 02:40:32 +0200 | [diff] [blame] | 138 | <xsl:sequence select=" |
| 139 | $value, |
| 140 | map { |
| 141 | string(@xml:id): ($our_base,$preceding_index) |
| 142 | }"/> |
| 143 | </xsl:accumulator-rule> |
Piotr Banski | 65a6d0b | 2022-05-31 17:23:08 +0200 | [diff] [blame] | 144 | <!-- this is morpho-offsets --> |
Piotr Banski | fdc858a | 2022-05-25 02:40:32 +0200 | [diff] [blame] | 145 | <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 Banski | fdc858a | 2022-05-25 02:40:32 +0200 | [diff] [blame] | 150 | </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 Banski | 09096ee | 2022-05-25 13:41:03 +0200 | [diff] [blame] | 155 | |
Piotr Banski | fdc858a | 2022-05-25 02:40:32 +0200 | [diff] [blame] | 156 | <xsl:sequence select=" |
| 157 | $value, |
| 158 | map { |
| 159 | string(@xml:id): ($our_base,$preceding_index) |
| 160 | }"/> |
| 161 | </xsl:accumulator-rule> |
Piotr Banski | 43b9db0 | 2022-06-03 02:38:42 +0200 | [diff] [blame] | 162 | |
| 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 Banski | 65a6d0b | 2022-05-31 17:23:08 +0200 | [diff] [blame] | 189 | </xsl:accumulator> |
Piotr Banski | 65a6d0b | 2022-05-31 17:23:08 +0200 | [diff] [blame] | 190 | |
| 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 Banski | fdc858a | 2022-05-25 02:40:32 +0200 | [diff] [blame] | 272 | |
| 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 Banski | 65a6d0b | 2022-05-31 17:23:08 +0200 | [diff] [blame] | 278 | |
Piotr Banski | fdc858a | 2022-05-25 02:40:32 +0200 | [diff] [blame] | 279 | <xsl:sequence select=" |
Piotr Banski | 65a6d0b | 2022-05-31 17:23:08 +0200 | [diff] [blame] | 280 | $value, |
| 281 | map { |
| 282 | string(@xml:id): (0, $preceding_index) |
| 283 | }"/> |
Piotr Banski | fdc858a | 2022-05-25 02:40:32 +0200 | [diff] [blame] | 284 | </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 Banski | 6a4a252 | 2022-05-24 01:16:47 +0200 | [diff] [blame] | 298 | </xsl:accumulator> |
bansp | 5e2d1c0 | 2022-03-10 04:51:40 +0100 | [diff] [blame] | 299 | |
bansp | e726b4a | 2022-03-28 05:47:45 +0200 | [diff] [blame] | 300 | <!-- FUNCTIONS --> |
| 301 | |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 302 | <xsl:function name="f:compute_nesting" as="xs:integer"> |
bansp | d1bf1db | 2022-04-04 02:16:24 +0200 | [diff] [blame] | 303 | <xsl:param name="node" as="element()"/> |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 304 | <xsl:variable name="rel_depth" |
| 305 | select="count($node/ancestor-or-self::*[local-name(.) ne 'TEI'][local-name(.) ne 'teiCorpus'])" |
| 306 | as="xs:integer"/> |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 307 | <xsl:sequence select="$rel_depth"/> |
| 308 | </xsl:function> |
| 309 | |
Piotr Banski | 92791a2 | 2022-05-26 01:41:10 +0200 | [diff] [blame] | 310 | <xsl:function name="f:is_preceded_by_ws" as="xs:boolean"> |
bansp | 9dc1000 | 2022-05-17 22:33:34 +0200 | [diff] [blame] | 311 | <xsl:param name="node" as="element()"/> |
Piotr Banski | fdc858a | 2022-05-25 02:40:32 +0200 | [diff] [blame] | 312 | <xsl:param name="suppress_initial" as="xs:boolean"/> |
Piotr Banski | 4f4c2d2 | 2022-05-19 01:44:32 +0200 | [diff] [blame] | 313 | |
Piotr Banski | 92791a2 | 2022-05-26 01:41:10 +0200 | [diff] [blame] | 314 | <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 Banski | 65a6d0b | 2022-05-31 17:23:08 +0200 | [diff] [blame] | 320 | <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 Banski | 92791a2 | 2022-05-26 01:41:10 +0200 | [diff] [blame] | 324 | <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 Banski | 65a6d0b | 2022-05-31 17:23:08 +0200 | [diff] [blame] | 334 | <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 Banski | 92791a2 | 2022-05-26 01:41:10 +0200 | [diff] [blame] | 339 | <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> |
bansp | d1bf1db | 2022-04-04 02:16:24 +0200 | [diff] [blame] | 367 | |
bansp | b599253 | 2022-03-29 15:55:44 +0200 | [diff] [blame] | 368 | <!-- UTILITY TEMPLATES --> |
| 369 | |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 370 | <xsl:template match="@default" mode="#all"/> |
bansp | 97ba7ce | 2022-03-26 05:14:06 +0100 | [diff] [blame] | 371 | <!-- this is to delete some auto-inserted attribute throughout --> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 372 | |
Piotr Banski | 6a4a252 | 2022-05-24 01:16:47 +0200 | [diff] [blame] | 373 | <xsl:template match="tei:w" mode="#all"/> |
bansp | e726b4a | 2022-03-28 05:47:45 +0200 | [diff] [blame] | 374 | <!-- NKJP-SGJP has apparently resigned from standoff representations by adding <w> everywhere; |
Piotr Banski | fdc858a | 2022-05-25 02:40:32 +0200 | [diff] [blame] | 375 | we reach for them, but from the level of <seg>, so we don't need to process <w> separately --> |
bansp | 8f6700b | 2022-03-27 05:27:09 +0200 | [diff] [blame] | 376 | |
Piotr Banski | 09096ee | 2022-05-25 13:41:03 +0200 | [diff] [blame] | 377 | <!-- fall-thru, skipping the potential <paren> element and filtering out the bad guys --> |
Piotr Banski | 6a4a252 | 2022-05-24 01:16:47 +0200 | [diff] [blame] | 378 | <xsl:template match="tei:choice" mode="struct"> |
Piotr Banski | 09096ee | 2022-05-25 13:41:03 +0200 | [diff] [blame] | 379 | <xsl:apply-templates select="descendant::tei:seg[count(@nkjp:rejected) eq 0]" mode="struct"/> |
Piotr Banski | 6a4a252 | 2022-05-24 01:16:47 +0200 | [diff] [blame] | 380 | </xsl:template> |
Piotr Banski | a51907c | 2022-05-25 15:09:41 +0200 | [diff] [blame] | 381 | <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> |
bansp | b599253 | 2022-03-29 15:55:44 +0200 | [diff] [blame] | 384 | |
| 385 | <!-- MAIN PROCESSING --> |
| 386 | |
bansp | 5e2d1c0 | 2022-03-10 04:51:40 +0100 | [diff] [blame] | 387 | <xsl:template name="xsl:initial-template"> |
bansp | f2b24e6 | 2022-03-28 18:12:08 +0200 | [diff] [blame] | 388 | <xsl:variable name="IDs_to_skip" select="tokenize($skip_docID,',')" as="xs:string*"/> |
bansp | d1bf1db | 2022-04-04 02:16:24 +0200 | [diff] [blame] | 389 | |
bansp | e726b4a | 2022-03-28 05:47:45 +0200 | [diff] [blame] | 390 | <!-- we only want to call the template below once, and we process a random NKJP corpus file for that purpose, |
bansp | 8f6700b | 2022-03-27 05:27:09 +0200 | [diff] [blame] | 391 | 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 Banski | faa910f | 2022-06-03 00:46:29 +0200 | [diff] [blame] | 393 | <xsl:with-param name="text.doc" select="$collection_of_text[1]" as="document-node()"/> |
bansp | 8f6700b | 2022-03-27 05:27:09 +0200 | [diff] [blame] | 394 | <xsl:with-param name="target" select="$targetCorpusDir_slashed || 'header.xml'" as="xs:string"/> |
| 395 | </xsl:call-template> |
| 396 | |
bansp | e726b4a | 2022-03-28 05:47:45 +0200 | [diff] [blame] | 397 | <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 Banski | 081c5de | 2022-06-03 01:57:13 +0200 | [diff] [blame] | 401 | <!--<xsl:variable name="ann_segmentation.uri" select="$my_dir || '/ann_segmentation.xml'" as="xs:string"/>--> |
Piotr Banski | c5950ce | 2022-05-27 15:07:08 +0200 | [diff] [blame] | 402 | <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"/> |
bansp | e726b4a | 2022-03-28 05:47:45 +0200 | [diff] [blame] | 405 | |
bansp | f2b24e6 | 2022-03-28 18:12:08 +0200 | [diff] [blame] | 406 | <xsl:choose> |
| 407 | <xsl:when test="$my_textID = $IDs_to_skip"/> |
bansp | 9dc1000 | 2022-05-17 22:33:34 +0200 | [diff] [blame] | 408 | <!-- this is a utility step, for when we want to ignore some texts for any reason (debugging, selective update) --> |
bansp | f2b24e6 | 2022-03-28 18:12:08 +0200 | [diff] [blame] | 409 | <xsl:otherwise> |
bansp | d1bf1db | 2022-04-04 02:16:24 +0200 | [diff] [blame] | 410 | |
bansp | 9dc1000 | 2022-05-17 22:33:34 +0200 | [diff] [blame] | 411 | <xsl:call-template name="process_single_sample"> |
Piotr Banski | f959069 | 2022-06-02 15:39:48 +0200 | [diff] [blame] | 412 | <xsl:with-param name="text.doc" as="document-node()" select="."/> |
| 413 | <xsl:with-param name="ann_morphosyntax.doc" as="document-node()" |
bansp | f2b24e6 | 2022-03-28 18:12:08 +0200 | [diff] [blame] | 414 | select="doc($ann_morphosyntax.uri)"/> |
Piotr Banski | 081c5de | 2022-06-03 01:57:13 +0200 | [diff] [blame] | 415 | <!-- <xsl:with-param name="ann_segmentation.xml" as="document-node()" |
| 416 | select="doc($ann_segmentation.uri)"/>--> |
bansp | f2b24e6 | 2022-03-28 18:12:08 +0200 | [diff] [blame] | 417 | <xsl:with-param name="my_textID" select="$my_textID" as="xs:string"/> |
Piotr Banski | c5950ce | 2022-05-27 15:07:08 +0200 | [diff] [blame] | 418 | <!-- the following parameters may happen to be null --> |
Piotr Banski | f959069 | 2022-06-02 15:39:48 +0200 | [diff] [blame] | 419 | <xsl:with-param name="ann_named.doc" as="document-node()*" |
Piotr Banski | c5950ce | 2022-05-27 15:07:08 +0200 | [diff] [blame] | 420 | select="if(fn:doc-available($ann_named.uri)) then doc($ann_named.uri) else ()"/> |
Piotr Banski | f959069 | 2022-06-02 15:39:48 +0200 | [diff] [blame] | 421 | <xsl:with-param name="ann_groups.doc" as="document-node()*" |
Piotr Banski | c5950ce | 2022-05-27 15:07:08 +0200 | [diff] [blame] | 422 | select="if(fn:doc-available($ann_groups.uri)) then doc($ann_groups.uri) else ()"/> |
Piotr Banski | f959069 | 2022-06-02 15:39:48 +0200 | [diff] [blame] | 423 | <xsl:with-param name="ann_words.doc" as="document-node()*" |
Piotr Banski | c5950ce | 2022-05-27 15:07:08 +0200 | [diff] [blame] | 424 | select="if(fn:doc-available($ann_words.uri)) then doc($ann_words.uri) else ()"/> |
| 425 | |
bansp | 9dc1000 | 2022-05-17 22:33:34 +0200 | [diff] [blame] | 426 | </xsl:call-template> |
bansp | f2b24e6 | 2022-03-28 18:12:08 +0200 | [diff] [blame] | 427 | </xsl:otherwise> |
| 428 | </xsl:choose> |
bansp | e726b4a | 2022-03-28 05:47:45 +0200 | [diff] [blame] | 429 | </xsl:for-each> |
bansp | 8f6700b | 2022-03-27 05:27:09 +0200 | [diff] [blame] | 430 | </xsl:template> |
| 431 | |
| 432 | <xsl:template name="process_single_sample"> |
Piotr Banski | f959069 | 2022-06-02 15:39:48 +0200 | [diff] [blame] | 433 | <xsl:param name="text.doc" as="document-node()"/> |
| 434 | <xsl:param name="ann_morphosyntax.doc" as="document-node()"/> |
Piotr Banski | 081c5de | 2022-06-03 01:57:13 +0200 | [diff] [blame] | 435 | <!-- <xsl:param name="ann_segmentation.xml" as="document-node()"/>--> |
bansp | d1bf1db | 2022-04-04 02:16:24 +0200 | [diff] [blame] | 436 | <xsl:param name="my_textID" as="xs:string" select="'0-BAD_textID'"/> |
bansp | 9dc1000 | 2022-05-17 22:33:34 +0200 | [diff] [blame] | 437 | <!-- empty textID should never happen, but if it does, it will be signalled at the top of the output --> |
Piotr Banski | f959069 | 2022-06-02 15:39:48 +0200 | [diff] [blame] | 438 | <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()*"/> |
bansp | e726b4a | 2022-03-28 05:47:45 +0200 | [diff] [blame] | 441 | |
| 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 | |
bansp | 5e2d1c0 | 2022-03-10 04:51:40 +0100 | [diff] [blame] | 448 | <xsl:call-template name="create_data"> |
Piotr Banski | 081c5de | 2022-06-03 01:57:13 +0200 | [diff] [blame] | 449 | <xsl:with-param name="ann_morphosyntax.doc" select="$ann_morphosyntax.doc" as="document-node()"/> |
bansp | e726b4a | 2022-03-28 05:47:45 +0200 | [diff] [blame] | 450 | <xsl:with-param name="compoundID" select="$compoundID" as="xs:string"/> |
| 451 | <xsl:with-param name="target" select="$targetBaseDir || '/data.xml'" as="xs:string"/> |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 452 | </xsl:call-template> |
| 453 | |
Piotr Banski | 43b9db0 | 2022-06-03 02:38:42 +0200 | [diff] [blame] | 454 | <xsl:call-template name="create_struct"> |
bansp | e726b4a | 2022-03-28 05:47:45 +0200 | [diff] [blame] | 455 | <xsl:with-param name="compoundID" select="$compoundID" as="xs:string"/> |
Piotr Banski | 43b9db0 | 2022-06-03 02:38:42 +0200 | [diff] [blame] | 456 | <xsl:with-param name="ann_morphosyntax.doc" select="$ann_morphosyntax.doc" |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 457 | as="document-node()"/> |
bansp | e726b4a | 2022-03-28 05:47:45 +0200 | [diff] [blame] | 458 | <xsl:with-param name="target" select="$targetBaseDir || '/struct/structure.xml'" as="xs:string" |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 459 | /> |
Piotr Banski | 43b9db0 | 2022-06-03 02:38:42 +0200 | [diff] [blame] | 460 | </xsl:call-template> |
Piotr Banski | 92791a2 | 2022-05-26 01:41:10 +0200 | [diff] [blame] | 461 | |
Piotr Banski | ba6cc63 | 2022-06-03 14:07:33 +0200 | [diff] [blame^] | 462 | <xsl:call-template name="create_morpho"> |
bansp | e726b4a | 2022-03-28 05:47:45 +0200 | [diff] [blame] | 463 | <xsl:with-param name="compoundID" select="$compoundID" as="xs:string"/> |
Piotr Banski | f959069 | 2022-06-02 15:39:48 +0200 | [diff] [blame] | 464 | <xsl:with-param name="ann_morphosyntax.doc" select="$ann_morphosyntax.doc" |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 465 | as="document-node()"/> |
bansp | e726b4a | 2022-03-28 05:47:45 +0200 | [diff] [blame] | 466 | <xsl:with-param name="target" select="$targetBaseDir || '/nkjp/morpho.xml'" as="xs:string"/> |
Piotr Banski | ba6cc63 | 2022-06-03 14:07:33 +0200 | [diff] [blame^] | 467 | </xsl:call-template> |
Piotr Banski | a51907c | 2022-05-25 15:09:41 +0200 | [diff] [blame] | 468 | |
Piotr Banski | 081c5de | 2022-06-03 01:57:13 +0200 | [diff] [blame] | 469 | <!-- |
| 470 | |
| 471 | THESE ARE SAFE |
| 472 | |
| 473 | |
| 474 | <xsl:call-template name="create_text_header"> |
Piotr Banski | f959069 | 2022-06-02 15:39:48 +0200 | [diff] [blame] | 475 | <xsl:with-param name="text.doc" select="$text.doc" as="document-node()"/> |
bansp | e726b4a | 2022-03-28 05:47:45 +0200 | [diff] [blame] | 476 | <xsl:with-param name="compoundID" select="$compoundID" as="xs:string"/> |
| 477 | <xsl:with-param name="target" select="$targetBaseDir || '/header.xml'" as="xs:string"/> |
Piotr Banski | 09096ee | 2022-05-25 13:41:03 +0200 | [diff] [blame] | 478 | </xsl:call-template> |
Piotr Banski | 6a4a252 | 2022-05-24 01:16:47 +0200 | [diff] [blame] | 479 | |
Piotr Banski | f959069 | 2022-06-02 15:39:48 +0200 | [diff] [blame] | 480 | <xsl:if test="$ann_named.doc"> |
Piotr Banski | 763b41f | 2022-06-02 01:13:23 +0200 | [diff] [blame] | 481 | <xsl:variable name="rev_lookup-seq" as="map(*)+"> |
| 482 | <xsl:for-each |
Piotr Banski | f959069 | 2022-06-02 15:39:48 +0200 | [diff] [blame] | 483 | select="$ann_named.doc//tei:seg/tei:ptr"> |
Piotr Banski | 763b41f | 2022-06-02 01:13:23 +0200 | [diff] [blame] | 484 | <xsl:variable name="trg" as="xs:string" select="fn:substring-before(@target, '#')"/> |
Piotr Banski | 081c5de | 2022-06-03 01:57:13 +0200 | [diff] [blame] | 485 | <!-\- 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 Banski | 763b41f | 2022-06-02 01:13:23 +0200 | [diff] [blame] | 487 | |
| 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 Banski | c5950ce | 2022-05-27 15:07:08 +0200 | [diff] [blame] | 498 | <xsl:call-template name="create_named"> |
| 499 | <xsl:with-param name="compoundID" select="$compoundID" as="xs:string"/> |
Piotr Banski | f959069 | 2022-06-02 15:39:48 +0200 | [diff] [blame] | 500 | <xsl:with-param name="ann_morphosyntax.doc" select="$ann_morphosyntax.doc" |
Piotr Banski | c5950ce | 2022-05-27 15:07:08 +0200 | [diff] [blame] | 501 | as="document-node()"/> |
Piotr Banski | f959069 | 2022-06-02 15:39:48 +0200 | [diff] [blame] | 502 | <xsl:with-param name="ann_named.doc" select="$ann_named.doc" |
Piotr Banski | c5950ce | 2022-05-27 15:07:08 +0200 | [diff] [blame] | 503 | as="document-node()"/> |
| 504 | <xsl:with-param name="target" select="$targetBaseDir || '/nkjp/named.xml'" as="xs:string"/> |
Piotr Banski | 763b41f | 2022-06-02 01:13:23 +0200 | [diff] [blame] | 505 | <xsl:with-param name="rev_lookup" select="$rev_lookup" as="map(*)"/> |
Piotr Banski | c5950ce | 2022-05-27 15:07:08 +0200 | [diff] [blame] | 506 | </xsl:call-template> |
| 507 | </xsl:if> |
Piotr Banski | 081c5de | 2022-06-03 01:57:13 +0200 | [diff] [blame] | 508 | --> |
Piotr Banski | f959069 | 2022-06-02 15:39:48 +0200 | [diff] [blame] | 509 | <xsl:if test="$ann_words.doc and $ann_groups.doc"> |
Piotr Banski | c5950ce | 2022-05-27 15:07:08 +0200 | [diff] [blame] | 510 | <xsl:call-template name="create_groups"> |
| 511 | <xsl:with-param name="compoundID" select="$compoundID" as="xs:string"/> |
Piotr Banski | f959069 | 2022-06-02 15:39:48 +0200 | [diff] [blame] | 512 | <xsl:with-param name="ann_morphosyntax.doc" select="$ann_morphosyntax.doc" |
Piotr Banski | c5950ce | 2022-05-27 15:07:08 +0200 | [diff] [blame] | 513 | as="document-node()"/> |
Piotr Banski | f959069 | 2022-06-02 15:39:48 +0200 | [diff] [blame] | 514 | <xsl:with-param name="ann_words.doc" select="$ann_words.doc" |
Piotr Banski | c5950ce | 2022-05-27 15:07:08 +0200 | [diff] [blame] | 515 | as="document-node()"/> |
Piotr Banski | f959069 | 2022-06-02 15:39:48 +0200 | [diff] [blame] | 516 | <xsl:with-param name="ann_groups.doc" select="$ann_groups.doc" |
Piotr Banski | c5950ce | 2022-05-27 15:07:08 +0200 | [diff] [blame] | 517 | 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 | |
bansp | 5e2d1c0 | 2022-03-10 04:51:40 +0100 | [diff] [blame] | 522 | </xsl:template> |
| 523 | |
| 524 | <!-- ************************** data.xml ******************* --> |
| 525 | |
| 526 | <xsl:template name="create_data"> |
Piotr Banski | 081c5de | 2022-06-03 01:57:13 +0200 | [diff] [blame] | 527 | <xsl:param name="ann_morphosyntax.doc" as="document-node()"/> |
bansp | e726b4a | 2022-03-28 05:47:45 +0200 | [diff] [blame] | 528 | <xsl:param name="compoundID" as="xs:string"/> |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 529 | <xsl:param name="target" as="xs:string"/> |
bansp | 5e2d1c0 | 2022-03-10 04:51:40 +0100 | [diff] [blame] | 530 | <!-- create the data.xml file --> |
| 531 | <xsl:result-document encoding="UTF-8" method="xml" indent="yes" |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 532 | xpath-default-namespace="{$KorAP_namespace}" href="{$target}"> |
bansp | 5e2d1c0 | 2022-03-10 04:51:40 +0100 | [diff] [blame] | 533 | |
Akron | 9a8ee3e | 2022-01-31 13:51:49 +0100 | [diff] [blame] | 534 | <xsl:processing-instruction name="xml-model">href="text.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"</xsl:processing-instruction> |
bansp | 5e2d1c0 | 2022-03-10 04:51:40 +0100 | [diff] [blame] | 535 | <xsl:element name="raw_text" namespace="{$KorAP_namespace}"> |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 536 | <xsl:attribute name="docid" select="$compoundID"/> |
bansp | 5e2d1c0 | 2022-03-10 04:51:40 +0100 | [diff] [blame] | 537 | <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}"> |
bansp | 9dc1000 | 2022-05-17 22:33:34 +0200 | [diff] [blame] | 542 | <xsl:variable name="content" as="xs:string+"> |
Piotr Banski | 081c5de | 2022-06-03 01:57:13 +0200 | [diff] [blame] | 543 | <!--<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']]"> |
bansp | 9dc1000 | 2022-05-17 22:33:34 +0200 | [diff] [blame] | 545 | <xsl:sequence select=" |
Piotr Banski | fdc858a | 2022-05-25 02:40:32 +0200 | [diff] [blame] | 546 | if (f:is_preceded_by_ws(.,false())) then |
bansp | 9dc1000 | 2022-05-17 22:33:34 +0200 | [diff] [blame] | 547 | ' ' |
| 548 | else |
Piotr Banski | 081c5de | 2022-06-03 01:57:13 +0200 | [diff] [blame] | 549 | '', ./tei:fs/tei:f[@name eq 'orth']/tei:string"/> |
bansp | 9dc1000 | 2022-05-17 22:33:34 +0200 | [diff] [blame] | 550 | </xsl:for-each> |
| 551 | </xsl:variable> |
| 552 | <xsl:value-of select="string-join($content)"/> |
bansp | 5e2d1c0 | 2022-03-10 04:51:40 +0100 | [diff] [blame] | 553 | </xsl:element> |
Akron | 9a8ee3e | 2022-01-31 13:51:49 +0100 | [diff] [blame] | 554 | </xsl:element> |
bansp | f79443e | 2022-02-25 14:25:33 +0100 | [diff] [blame] | 555 | </xsl:result-document> |
Akron | 9a8ee3e | 2022-01-31 13:51:49 +0100 | [diff] [blame] | 556 | </xsl:template> |
| 557 | |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 558 | <!-- ************************** struct ******************* --> |
| 559 | |
| 560 | <xsl:template name="create_struct"> |
bansp | e726b4a | 2022-03-28 05:47:45 +0200 | [diff] [blame] | 561 | <xsl:param name="compoundID" as="xs:string"/> |
Piotr Banski | 43b9db0 | 2022-06-03 02:38:42 +0200 | [diff] [blame] | 562 | <xsl:param name="ann_morphosyntax.doc" as="document-node()"/> |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 563 | <xsl:param name="target" as="xs:string"/> |
Piotr Banski | 4f4c2d2 | 2022-05-19 01:44:32 +0200 | [diff] [blame] | 564 | |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 565 | <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="span.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"</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 Banski | 43b9db0 | 2022-06-03 02:38:42 +0200 | [diff] [blame] | 573 | <xsl:apply-templates select="$ann_morphosyntax.doc/tei:teiCorpus/tei:TEI/tei:text" mode="struct"/> |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 574 | </xsl:element> |
| 575 | </xsl:element> |
| 576 | </xsl:result-document> |
| 577 | </xsl:template> |
| 578 | |
Piotr Banski | 43b9db0 | 2022-06-03 02:38:42 +0200 | [diff] [blame] | 579 | <xsl:template match="tei:text | tei:body | tei:p | tei:s | tei:seg[tei:fs/tei:f[@name eq 'disamb']]" mode="struct"> |
Piotr Banski | 09096ee | 2022-05-25 13:41:03 +0200 | [diff] [blame] | 580 | <xsl:variable name="offsets" as="xs:integer+"> |
Piotr Banski | 43b9db0 | 2022-06-03 02:38:42 +0200 | [diff] [blame] | 581 | <xsl:sequence select="map:get(fn:accumulator-after('morpho-offsets')[last()], string(@xml:id))"/> |
Piotr Banski | 09096ee | 2022-05-25 13:41:03 +0200 | [diff] [blame] | 582 | </xsl:variable> |
Piotr Banski | 6a4a252 | 2022-05-24 01:16:47 +0200 | [diff] [blame] | 583 | |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 584 | <xsl:variable name="my_name" select="local-name()" as="xs:string"/> |
Piotr Banski | e1ac520 | 2022-05-30 21:25:21 +0200 | [diff] [blame] | 585 | <xsl:variable name="my_index" select="fn:accumulator-before('element-index')" as="xs:integer"/> |
bansp | 3e5b20c | 2022-03-18 20:22:31 +0100 | [diff] [blame] | 586 | |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 587 | <xsl:element name="span" namespace="{$KorAP_namespace}"> |
| 588 | <xsl:attribute name="id" select="'s' || $my_index"/> |
Piotr Banski | 09096ee | 2022-05-25 13:41:03 +0200 | [diff] [blame] | 589 | <xsl:attribute name="from" select="$offsets[1]"/> |
| 590 | <xsl:attribute name="to" select="$offsets[2]"/> |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 591 | <xsl:attribute name="l" select="f:compute_nesting(.)"/> |
Piotr Banski | 09096ee | 2022-05-25 13:41:03 +0200 | [diff] [blame] | 592 | <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> |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 595 | <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0"> |
Piotr Banski | fdc858a | 2022-05-25 02:40:32 +0200 | [diff] [blame] | 596 | <xsl:attribute name="type" select="'struct'"></xsl:attribute> <!-- STRUCT vs. LEX for morpho --> |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 597 | <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0"> |
bansp | 3e5b20c | 2022-03-18 20:22:31 +0100 | [diff] [blame] | 598 | <xsl:attribute name="name" select="'name'"/> |
| 599 | <xsl:value-of select="local-name()"/> |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 600 | </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 Banski | a51907c | 2022-05-25 15:09:41 +0200 | [diff] [blame] | 617 | <xsl:apply-templates mode="struct"/> |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 618 | </xsl:template> |
| 619 | |
| 620 | <!-- ************************** morpho ******************* --> |
| 621 | |
| 622 | <xsl:template name="create_morpho"> |
bansp | e726b4a | 2022-03-28 05:47:45 +0200 | [diff] [blame] | 623 | <xsl:param name="compoundID" as="xs:string"/> |
Piotr Banski | f959069 | 2022-06-02 15:39:48 +0200 | [diff] [blame] | 624 | <xsl:param name="ann_morphosyntax.doc" as="document-node()"/> |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 625 | <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="span.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"</xsl:processing-instruction> |
bansp | 3e5b20c | 2022-03-18 20:22:31 +0100 | [diff] [blame] | 630 | <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 Banski | ba6cc63 | 2022-06-03 14:07:33 +0200 | [diff] [blame^] | 635 | <xsl:apply-templates select="$ann_morphosyntax.doc//tei:text" mode="morpho"/> |
bansp | 3e5b20c | 2022-03-18 20:22:31 +0100 | [diff] [blame] | 636 | </xsl:element> |
| 637 | </xsl:element> |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 638 | </xsl:result-document> |
| 639 | </xsl:template> |
| 640 | |
Piotr Banski | ba6cc63 | 2022-06-03 14:07:33 +0200 | [diff] [blame^] | 641 | <xsl:template match="tei:seg[tei:fs/tei:f[@name eq 'disamb']]" mode="morpho"> |
| 642 | |
Piotr Banski | a51907c | 2022-05-25 15:09:41 +0200 | [diff] [blame] | 643 | <!-- 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 Banski | ba6cc63 | 2022-06-03 14:07:33 +0200 | [diff] [blame^] | 647 | <xsl:sequence select="map:get(fn:accumulator-after('morpho-offsets')[last()], string(@xml:id))"/> |
Piotr Banski | a51907c | 2022-05-25 15:09:41 +0200 | [diff] [blame] | 648 | </xsl:variable> |
Piotr Banski | ba6cc63 | 2022-06-03 14:07:33 +0200 | [diff] [blame^] | 649 | |
bansp | 3e5b20c | 2022-03-18 20:22:31 +0100 | [diff] [blame] | 650 | <xsl:variable name="my_id" select="@xml:id" as="xs:string"/> |
Piotr Banski | ba6cc63 | 2022-06-03 14:07:33 +0200 | [diff] [blame^] | 651 | <!--<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()"/> |
bansp | 3e5b20c | 2022-03-18 20:22:31 +0100 | [diff] [blame] | 653 | <xsl:variable name="my_choice-id" select="substring-after($my_disamb//tei:f[@name eq 'choice']/@fVal,'#')" as="xs:string"/> |
Piotr Banski | ba6cc63 | 2022-06-03 14:07:33 +0200 | [diff] [blame^] | 654 | <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()"/> |
bansp | 3e5b20c | 2022-03-18 20:22:31 +0100 | [diff] [blame] | 655 | <xsl:variable name="chosen-msd" as="xs:string" select="$my_choice-lex/descendant::tei:symbol[@xml:id eq $my_choice-id]/@value"/> |
Piotr Banski | e1ac520 | 2022-05-30 21:25:21 +0200 | [diff] [blame] | 656 | <xsl:variable name="my_index" select="fn:accumulator-before('element-index')" as="xs:integer"/> |
bansp | 3e5b20c | 2022-03-18 20:22:31 +0100 | [diff] [blame] | 657 | |
bansp | 3e5b20c | 2022-03-18 20:22:31 +0100 | [diff] [blame] | 658 | <xsl:element name="span" namespace="{$KorAP_namespace}"> |
Piotr Banski | a51907c | 2022-05-25 15:09:41 +0200 | [diff] [blame] | 659 | <xsl:attribute name="id" select="'m' || $my_index"/> |
| 660 | <xsl:attribute name="from" select="$offsets[1]"/> |
| 661 | <xsl:attribute name="to" select="$offsets[2]"/> |
bansp | 3e5b20c | 2022-03-18 20:22:31 +0100 | [diff] [blame] | 662 | <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 Banski | ba6cc63 | 2022-06-03 14:07:33 +0200 | [diff] [blame^] | 667 | <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"/> |
bansp | 3e5b20c | 2022-03-18 20:22:31 +0100 | [diff] [blame] | 672 | <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0"> |
bansp | 3e5b20c | 2022-03-18 20:22:31 +0100 | [diff] [blame] | 673 | <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 Banski | ba6cc63 | 2022-06-03 14:07:33 +0200 | [diff] [blame^] | 687 | <xsl:if test="tei:fs/tei:f[@name eq 'nps']"> |
bansp | 3e5b20c | 2022-03-18 20:22:31 +0100 | [diff] [blame] | 688 | <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> |
bansp | 3e5b20c | 2022-03-18 20:22:31 +0100 | [diff] [blame] | 697 | </xsl:template> |
bansp | e726b4a | 2022-03-28 05:47:45 +0200 | [diff] [blame] | 698 | |
Piotr Banski | c5950ce | 2022-05-27 15:07:08 +0200 | [diff] [blame] | 699 | <!-- ************************** named entities ******************* --> |
| 700 | |
| 701 | <xsl:template name="create_named"> |
| 702 | <xsl:param name="compoundID" as="xs:string"/> |
Piotr Banski | f959069 | 2022-06-02 15:39:48 +0200 | [diff] [blame] | 703 | <xsl:param name="ann_morphosyntax.doc" as="document-node()"/> |
| 704 | <xsl:param name="ann_named.doc" as="document-node()"/> |
Piotr Banski | c5950ce | 2022-05-27 15:07:08 +0200 | [diff] [blame] | 705 | <xsl:param name="target" as="xs:string"/> |
Piotr Banski | 763b41f | 2022-06-02 01:13:23 +0200 | [diff] [blame] | 706 | <xsl:param name="rev_lookup" as="map(*)"/> |
| 707 | |
Piotr Banski | c5950ce | 2022-05-27 15:07:08 +0200 | [diff] [blame] | 708 | <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="span.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"</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 Banski | f959069 | 2022-06-02 15:39:48 +0200 | [diff] [blame] | 716 | <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 Banski | 763b41f | 2022-06-02 01:13:23 +0200 | [diff] [blame] | 718 | <xsl:with-param name="rev_lookup" select="$rev_lookup" as="map(*)" tunnel="yes"/> |
Piotr Banski | 65a6d0b | 2022-05-31 17:23:08 +0200 | [diff] [blame] | 719 | </xsl:apply-templates> |
Piotr Banski | c5950ce | 2022-05-27 15:07:08 +0200 | [diff] [blame] | 720 | </xsl:element> |
| 721 | </xsl:element> |
| 722 | </xsl:result-document> |
| 723 | </xsl:template> |
Piotr Banski | 65a6d0b | 2022-05-31 17:23:08 +0200 | [diff] [blame] | 724 | |
| 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 Banski | f959069 | 2022-06-02 15:39:48 +0200 | [diff] [blame] | 728 | <xsl:param name="ann_named.doc" as="document-node()" tunnel="yes"/> |
Piotr Banski | 763b41f | 2022-06-02 01:13:23 +0200 | [diff] [blame] | 729 | <xsl:param name="rev_lookup" as="map(*)" tunnel="yes"/> |
Piotr Banski | 65a6d0b | 2022-05-31 17:23:08 +0200 | [diff] [blame] | 730 | |
| 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 Banski | 763b41f | 2022-06-02 01:13:23 +0200 | [diff] [blame] | 735 | <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 Banski | 65a6d0b | 2022-05-31 17:23:08 +0200 | [diff] [blame] | 737 | |
Piotr Banski | 763b41f | 2022-06-02 01:13:23 +0200 | [diff] [blame] | 738 | <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 Banski | ba6cc63 | 2022-06-03 14:07:33 +0200 | [diff] [blame^] | 755 | ' _') || tei:fs/tei:f[@name eq 'orth']/tei:string"/> |
Piotr Banski | 763b41f | 2022-06-02 01:13:23 +0200 | [diff] [blame] | 756 | <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 Banski | 65a6d0b | 2022-05-31 17:23:08 +0200 | [diff] [blame] | 776 | </xsl:element> |
| 777 | </xsl:element> |
| 778 | </xsl:element> |
| 779 | </xsl:element> |
Piotr Banski | 763b41f | 2022-06-02 01:13:23 +0200 | [diff] [blame] | 780 | </xsl:if> |
Piotr Banski | 65a6d0b | 2022-05-31 17:23:08 +0200 | [diff] [blame] | 781 | </xsl:template> |
| 782 | |
Piotr Banski | c5950ce | 2022-05-27 15:07:08 +0200 | [diff] [blame] | 783 | |
| 784 | <!-- ************************** syntactic chunks ******************* --> |
| 785 | |
| 786 | <xsl:template name="create_groups"> |
| 787 | <xsl:param name="compoundID" as="xs:string"/> |
Piotr Banski | f959069 | 2022-06-02 15:39:48 +0200 | [diff] [blame] | 788 | <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 Banski | c5950ce | 2022-05-27 15:07:08 +0200 | [diff] [blame] | 791 | <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="span.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"</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 Banski | f959069 | 2022-06-02 15:39:48 +0200 | [diff] [blame] | 802 | <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 Banski | c5950ce | 2022-05-27 15:07:08 +0200 | [diff] [blame] | 805 | </xsl:apply-templates>--> |
| 806 | </xsl:element> |
| 807 | </xsl:element> |
| 808 | </xsl:result-document> |
| 809 | </xsl:template> |
| 810 | |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 811 | <!-- ************************** TEXT header ******************* --> |
| 812 | |
| 813 | <xsl:template name="create_text_header"> |
Piotr Banski | f959069 | 2022-06-02 15:39:48 +0200 | [diff] [blame] | 814 | <xsl:param name="text.doc" as="document-node()"/> |
bansp | e726b4a | 2022-03-28 05:47:45 +0200 | [diff] [blame] | 815 | <xsl:param name="compoundID" as="xs:string"/> |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 816 | <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 Banski | a0a9fc0 | 2022-06-03 01:20:18 +0200 | [diff] [blame] | 823 | <xsl:apply-templates select="$text.doc//tei:TEI/tei:teiHeader/tei:*" mode="text-header"> |
bansp | e726b4a | 2022-03-28 05:47:45 +0200 | [diff] [blame] | 824 | <xsl:with-param name="compoundID" as="xs:string" select="$compoundID" tunnel="yes"/> |
| 825 | </xsl:apply-templates> |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 826 | </idsHeader> |
| 827 | </xsl:result-document> |
| 828 | </xsl:template> |
| 829 | |
Piotr Banski | a0a9fc0 | 2022-06-03 01:20:18 +0200 | [diff] [blame] | 830 | <xsl:template match="tei:fileDesc" mode="text-header"> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 831 | <xsl:element name="{local-name()}"> |
Piotr Banski | a0a9fc0 | 2022-06-03 01:20:18 +0200 | [diff] [blame] | 832 | <xsl:apply-templates mode="text-header"/> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 833 | </xsl:element> |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 834 | </xsl:template> |
| 835 | |
Piotr Banski | a0a9fc0 | 2022-06-03 01:20:18 +0200 | [diff] [blame] | 836 | <xsl:template match="tei:title" mode="text-header"> |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 837 | <t.title> |
| 838 | <xsl:apply-templates/> |
| 839 | </t.title> |
| 840 | </xsl:template> |
| 841 | |
Piotr Banski | a0a9fc0 | 2022-06-03 01:20:18 +0200 | [diff] [blame] | 842 | <xsl:template match="tei:titleStmt" mode="text-header"> |
bansp | e726b4a | 2022-03-28 05:47:45 +0200 | [diff] [blame] | 843 | <xsl:param name="compoundID" as="xs:string" tunnel="yes"/> |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 844 | <titleStmt> |
| 845 | <textSigle> |
bansp | e726b4a | 2022-03-28 05:47:45 +0200 | [diff] [blame] | 846 | <xsl:value-of select="$compoundID"/> |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 847 | </textSigle> |
Piotr Banski | a0a9fc0 | 2022-06-03 01:20:18 +0200 | [diff] [blame] | 848 | <xsl:apply-templates mode="text-header"/> |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 849 | </titleStmt> |
| 850 | </xsl:template> |
| 851 | |
Piotr Banski | a0a9fc0 | 2022-06-03 01:20:18 +0200 | [diff] [blame] | 852 | <xsl:template match="tei:publicationStmt" mode="text-header"> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 853 | <xsl:element name="{local-name()}"> |
Piotr Banski | a0a9fc0 | 2022-06-03 01:20:18 +0200 | [diff] [blame] | 854 | <xsl:apply-templates mode="text-header"/> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 855 | </xsl:element> |
| 856 | </xsl:template> |
| 857 | |
Piotr Banski | a0a9fc0 | 2022-06-03 01:20:18 +0200 | [diff] [blame] | 858 | <xsl:template match="tei:availability" mode="text-header"> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 859 | <xsl:element name="{local-name()}"> |
Piotr Banski | a0a9fc0 | 2022-06-03 01:20:18 +0200 | [diff] [blame] | 860 | <xsl:apply-templates mode="text-header" select="@* | *"/> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 861 | </xsl:element> |
| 862 | </xsl:template> |
| 863 | |
Piotr Banski | a0a9fc0 | 2022-06-03 01:20:18 +0200 | [diff] [blame] | 864 | <xsl:template match="tei:profileDesc" mode="text-header"> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 865 | <xsl:element name="{local-name()}"> |
Piotr Banski | a0a9fc0 | 2022-06-03 01:20:18 +0200 | [diff] [blame] | 866 | <xsl:apply-templates mode="text-header"/> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 867 | </xsl:element> |
| 868 | </xsl:template> |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 869 | |
Piotr Banski | a0a9fc0 | 2022-06-03 01:20:18 +0200 | [diff] [blame] | 870 | <xsl:template match="tei:textClass" mode="text-header"> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 871 | <xsl:element name="{local-name()}"> |
Piotr Banski | a0a9fc0 | 2022-06-03 01:20:18 +0200 | [diff] [blame] | 872 | <xsl:apply-templates mode="text-header" select="@* | *"/> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 873 | </xsl:element> |
| 874 | </xsl:template> |
| 875 | |
Piotr Banski | a0a9fc0 | 2022-06-03 01:20:18 +0200 | [diff] [blame] | 876 | <xsl:template match="tei:catRef" mode="text-header corpus-header"> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 877 | <xsl:element name="{local-name()}"> |
Piotr Banski | a0a9fc0 | 2022-06-03 01:20:18 +0200 | [diff] [blame] | 878 | <xsl:apply-templates mode="text-header" select="@* | *"/> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 879 | </xsl:element> |
| 880 | </xsl:template> |
| 881 | |
Piotr Banski | a0a9fc0 | 2022-06-03 01:20:18 +0200 | [diff] [blame] | 882 | <xsl:template match="@status | @scheme | @target | @type | @xml:id[ancestor::tei:classDecl] | @xml:lang" mode="text-header corpus-header"> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 883 | <xsl:copy-of select="."/> |
| 884 | </xsl:template> |
| 885 | |
Piotr Banski | a0a9fc0 | 2022-06-03 01:20:18 +0200 | [diff] [blame] | 886 | <xsl:template match="tei:p" mode="text-header corpus-header"> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 887 | <xsl:element name="{local-name()}"> |
Piotr Banski | a0a9fc0 | 2022-06-03 01:20:18 +0200 | [diff] [blame] | 888 | <xsl:apply-templates mode="text_inside_header"/> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 889 | </xsl:element> |
| 890 | </xsl:template> |
| 891 | |
| 892 | |
| 893 | <!-- OPTIMIZATION has to take modes into account --> |
bansp | 5e2d1c0 | 2022-03-10 04:51:40 +0100 | [diff] [blame] | 894 | <!-- ************************** CORPUS header ******************* --> |
| 895 | <xsl:template name="create_corpus_header"> |
Piotr Banski | faa910f | 2022-06-03 00:46:29 +0200 | [diff] [blame] | 896 | <xsl:param name="text.doc" as="document-node()"/> |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 897 | <xsl:param name="target" as="xs:string"/> |
bansp | 5e2d1c0 | 2022-03-10 04:51:40 +0100 | [diff] [blame] | 898 | |
| 899 | <!-- create the corpus-level header.xml file --> |
bansp | 5f84173 | 2022-03-16 06:27:31 +0100 | [diff] [blame] | 900 | <xsl:result-document encoding="UTF-8" method="xml" indent="yes" href="{$target}"> |
bansp | 5e2d1c0 | 2022-03-10 04:51:40 +0100 | [diff] [blame] | 901 | |
| 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 Banski | faa910f | 2022-06-03 00:46:29 +0200 | [diff] [blame] | 908 | <xsl:apply-templates select="$text.doc/tei:teiCorpus/tei:teiHeader/tei:*" mode="corpus-header"/> |
bansp | 5e2d1c0 | 2022-03-10 04:51:40 +0100 | [diff] [blame] | 909 | </idsHeader> |
| 910 | </xsl:result-document> |
| 911 | </xsl:template> |
| 912 | |
Piotr Banski | faa910f | 2022-06-03 00:46:29 +0200 | [diff] [blame] | 913 | <xsl:template match="tei:fileDesc" mode="corpus-header"> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 914 | <xsl:element name="{local-name()}"> |
Piotr Banski | faa910f | 2022-06-03 00:46:29 +0200 | [diff] [blame] | 915 | <xsl:apply-templates mode="corpus-header"/> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 916 | </xsl:element> |
bansp | 5e2d1c0 | 2022-03-10 04:51:40 +0100 | [diff] [blame] | 917 | </xsl:template> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 918 | |
bansp | 5e2d1c0 | 2022-03-10 04:51:40 +0100 | [diff] [blame] | 919 | |
Piotr Banski | faa910f | 2022-06-03 00:46:29 +0200 | [diff] [blame] | 920 | <xsl:template match="tei:title" mode="corpus-header"> |
bansp | 5e2d1c0 | 2022-03-10 04:51:40 +0100 | [diff] [blame] | 921 | <c.title> |
Piotr Banski | faa910f | 2022-06-03 00:46:29 +0200 | [diff] [blame] | 922 | <xsl:apply-templates mode="corpus-header" select="@*"/> |
Piotr Banski | a0a9fc0 | 2022-06-03 01:20:18 +0200 | [diff] [blame] | 923 | <xsl:apply-templates mode="text_inside_header"/> |
bansp | 5e2d1c0 | 2022-03-10 04:51:40 +0100 | [diff] [blame] | 924 | </c.title> |
| 925 | </xsl:template> |
| 926 | |
Piotr Banski | faa910f | 2022-06-03 00:46:29 +0200 | [diff] [blame] | 927 | <xsl:template match="tei:titleStmt" mode="corpus-header"> |
bansp | 5e2d1c0 | 2022-03-10 04:51:40 +0100 | [diff] [blame] | 928 | <titleStmt> |
| 929 | <korpusSigle> |
| 930 | <xsl:value-of select="$corpusID"/> |
| 931 | </korpusSigle> |
Piotr Banski | faa910f | 2022-06-03 00:46:29 +0200 | [diff] [blame] | 932 | <xsl:apply-templates mode="corpus-header"/> |
bansp | 5e2d1c0 | 2022-03-10 04:51:40 +0100 | [diff] [blame] | 933 | </titleStmt> |
| 934 | </xsl:template> |
| 935 | |
Piotr Banski | faa910f | 2022-06-03 00:46:29 +0200 | [diff] [blame] | 936 | <xsl:template match="tei:publicationStmt" mode="corpus-header"> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 937 | <xsl:element name="{local-name()}"> |
Piotr Banski | faa910f | 2022-06-03 00:46:29 +0200 | [diff] [blame] | 938 | <xsl:apply-templates mode="corpus-header"/> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 939 | </xsl:element> |
| 940 | </xsl:template> |
| 941 | |
Piotr Banski | faa910f | 2022-06-03 00:46:29 +0200 | [diff] [blame] | 942 | <xsl:template match="tei:availability" mode="corpus-header"> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 943 | <xsl:element name="{local-name()}"> |
Piotr Banski | faa910f | 2022-06-03 00:46:29 +0200 | [diff] [blame] | 944 | <xsl:apply-templates mode="corpus-header" select="@* | *"/> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 945 | </xsl:element> |
| 946 | </xsl:template> |
| 947 | |
Piotr Banski | faa910f | 2022-06-03 00:46:29 +0200 | [diff] [blame] | 948 | <xsl:template match="tei:encodingDesc" mode="corpus-header"> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 949 | <xsl:element name="{local-name()}"> |
Piotr Banski | faa910f | 2022-06-03 00:46:29 +0200 | [diff] [blame] | 950 | <xsl:apply-templates mode="corpus-header"/> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 951 | </xsl:element> |
| 952 | </xsl:template> |
| 953 | |
Piotr Banski | faa910f | 2022-06-03 00:46:29 +0200 | [diff] [blame] | 954 | <xsl:template match="tei:classDecl | tei:taxonomy | tei:category | tei:taxonomy/tei:bibl" mode="corpus-header"> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 955 | <xsl:element name="{local-name()}"> |
Piotr Banski | faa910f | 2022-06-03 00:46:29 +0200 | [diff] [blame] | 956 | <xsl:apply-templates mode="corpus-header" select="@* | *"/> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 957 | </xsl:element> |
| 958 | </xsl:template> |
| 959 | |
Piotr Banski | faa910f | 2022-06-03 00:46:29 +0200 | [diff] [blame] | 960 | <xsl:template match="tei:bibl/tei:title | tei:edition | tei:desc" mode="corpus-header"> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 961 | <xsl:element name="{local-name()}"> |
Piotr Banski | faa910f | 2022-06-03 00:46:29 +0200 | [diff] [blame] | 962 | <xsl:apply-templates mode="corpus-header" select="@*"/> |
Piotr Banski | a0a9fc0 | 2022-06-03 01:20:18 +0200 | [diff] [blame] | 963 | <xsl:apply-templates mode="text_inside_header"/> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 964 | </xsl:element> |
| 965 | </xsl:template> |
| 966 | <!-- |
Piotr Banski | faa910f | 2022-06-03 00:46:29 +0200 | [diff] [blame] | 967 | <xsl:template match="tei:textClass" mode="corpus-header"> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 968 | <xsl:element name="{local-name()}"> |
| 969 | <xsl:apply-templates mode="corpus" select="@* | *"/> |
| 970 | </xsl:element> |
| 971 | </xsl:template> |
| 972 | |
Piotr Banski | faa910f | 2022-06-03 00:46:29 +0200 | [diff] [blame] | 973 | <xsl:template match="tei:catRef" mode="corpus-header"> |
bansp | 9103aab | 2022-03-19 05:10:21 +0100 | [diff] [blame] | 974 | <xsl:element name="{local-name()}"> |
| 975 | <xsl:apply-templates mode="corpus" select="@* | *"/> |
| 976 | </xsl:element> |
| 977 | </xsl:template> |
| 978 | --> |
bansp | 5e2d1c0 | 2022-03-10 04:51:40 +0100 | [diff] [blame] | 979 | |
| 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 | |
Akron | 9a8ee3e | 2022-01-31 13:51:49 +0100 | [diff] [blame] | 1002 | </xsl:stylesheet> |
Piotr Banski | 6a4a252 | 2022-05-24 01:16:47 +0200 | [diff] [blame] | 1003 | |
Piotr Banski | fdc858a | 2022-05-25 02:40:32 +0200 | [diff] [blame] | 1004 | <!-- template for serializing maps in messages <xsl:message select="('map:',serialize($map, map{'method':'adaptive'}))"/> --> |