blob: d8a460376d765d3097ba81e3cc16833898b952a4 [file] [log] [blame]
Akron9a8ee3e2022-01-31 13:51:49 +01001<?xml version="1.0" encoding="UTF-8"?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
bansp5e2d1c02022-03-10 04:51:40 +01003 xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:nkjp="http://www.nkjp.pl/ns/1.0"
4 xmlns:tei="http://www.tei-c.org/ns/1.0" xmlns:f="func"
Piotr Banskif8af3a92022-05-23 03:20:10 +02005 xmlns:fn="http://www.w3.org/2005/xpath-functions"
Piotr Banski763b41f2022-06-02 01:13:23 +02006 xmlns:xi="http://www.w3.org/2001/XInclude"
7 xmlns:map="http://www.w3.org/2005/xpath-functions/map" exclude-result-prefixes="xs f fn map nkjp tei xi"
bansp5e2d1c02022-03-10 04:51:40 +01008 version="3.0" expand-text="yes">
Akron9a8ee3e2022-01-31 13:51:49 +01009
banspe726b4a2022-03-28 05:47:45 +020010
11<!-- PARAMETERS -->
bansp5e2d1c02022-03-10 04:51:40 +010012
Piotr Banskib28e5882022-06-08 20:41:20 +020013 <xsl:param name="sourceDir" select="'test/resources/nkjp2korap_sample3'" as="xs:string"/>
banspd1bf1db2022-04-04 02:16:24 +020014 <!-- the directory containing NKJP files, in the form of a collection of text-level dirs
15 (that is how we know both the $corpusID and the $docID) -->
Akron9a8ee3e2022-01-31 13:51:49 +010016
bansp8f6700b2022-03-27 05:27:09 +020017 <xsl:param name="targetDir" select="'test/output'" as="xs:string"/>
banspd1bf1db2022-04-04 02:16:24 +020018 <!-- where the corpus/document/text/annotations hierarchy is going to be created -->
banspf2b24e62022-03-28 18:12:08 +020019
20 <xsl:param name="skip_docID" as="xs:string">
Piotr Banskia78e59d2022-06-03 19:35:32 +020021 <xsl:value-of select="''"/>
Piotr Banskib28e5882022-06-08 20:41:20 +020022 <!--<xsl:value-of select="'HellerPodgladanie,IsakowiczZaleskiMoje,KOT,MysliwskiKamien,WilkWilczy,ZycieWarszawy_Zycie'"/>-->
banspb5992532022-03-29 15:55:44 +020023 </xsl:param>
24 <!-- comma-separated list of document IDs to be skipped from processing
banspf2b24e62022-03-28 18:12:08 +020025 example: HellerPodgladanie,KOT
banspd1bf1db2022-04-04 02:16:24 +020026 no functionality beyond string identity is supported
27 (this is just for testing) -->
banspb5992532022-03-29 15:55:44 +020028
Piotr Banski1ae16bd2022-05-25 15:59:40 +020029 <xsl:param name="SHOW_ORTH_IN_STRUCT" as="xs:boolean" select="true()"/>
Piotr Banskid2b78b82022-06-03 17:05:59 +020030 <!-- for debugging structure.xml production; otherwise we don't see the referenced span -->
31
32 <xsl:param name="SHOW_REDUNDANT_ORTH" as="xs:boolean" select="true()"/>
33 <!-- in layers such as morpho or named, one can recover the orth, so this is a bit of
34 space-wasting luxury, useful at the early stages -->
Piotr Banski09096ee2022-05-25 13:41:03 +020035
bansp8f6700b2022-03-27 05:27:09 +020036
bansp9dc10002022-05-17 22:33:34 +020037<!-- VARIABLES (= constants...) -->
banspe726b4a2022-03-28 05:47:45 +020038
39 <xsl:variable name="corpusID" as="xs:string" select="'NKJP'" static="yes"/>
40 <xsl:variable name="docID" as="xs:string" select="'NKJP'" static="yes"/>
bansp8f6700b2022-03-27 05:27:09 +020041
42 <xsl:variable name="targetCorpusDir_slashed" select="$targetDir || '/' || $corpusID || '/'" as="xs:string"/>
bansp5e2d1c02022-03-10 04:51:40 +010043
banspd1bf1db2022-04-04 02:16:24 +020044 <xsl:variable name="systemDoctypeI5" as="xs:string"
45 select="'http://corpora.ids-mannheim.de/I5/DTD/i5.dtd'" static="true"/>
bansp5e2d1c02022-03-10 04:51:40 +010046
banspd1bf1db2022-04-04 02:16:24 +020047 <xsl:variable name="publicDoctypeI5" as="xs:string" static="true"
48 select="'-//IDS//DTD I5 1.0//EN'"/>
bansp5e2d1c02022-03-10 04:51:40 +010049
banspd1bf1db2022-04-04 02:16:24 +020050 <xsl:variable name="KorAP_namespace" static="true" as="xs:string"
51 select="'http://ids-mannheim.de/ns/KorAP'"/>
bansp5e2d1c02022-03-10 04:51:40 +010052
bansp5f841732022-03-16 06:27:31 +010053 <xsl:variable name="KorAP-XML_version" select="'KorAP-0.4'" as="xs:string" static="true"/>
54 <!-- this is only a bit funny -->
55
banspe726b4a2022-03-28 05:47:45 +020056 <xsl:variable name="collection_params" as="xs:string" static="yes"
57 select="'recurse=yes;validation=strip;select=text.xml;content-type=application/xml;on-error=warning;xinclude=yes'"
58 />
59 <!-- see https://www.saxonica.com/documentation11/index.html#!sourcedocs/collections/collection-directories -->
60
61 <xsl:variable name="collection_of_text" select="collection($sourceDir || '?' || $collection_params)" as="document-node()+"/>
banspd1bf1db2022-04-04 02:16:24 +020062
banspe726b4a2022-03-28 05:47:45 +020063<!-- MODES -->
bansp5e2d1c02022-03-10 04:51:40 +010064
Piotr Banski43b9db02022-06-03 02:38:42 +020065 <xsl:mode name="struct" on-no-match="deep-skip"/>
Piotr Banskid2b78b82022-06-03 17:05:59 +020066 <xsl:mode name="morpho" on-no-match="deep-skip"/>
Piotr Banskifaa910f2022-06-03 00:46:29 +020067 <xsl:mode name="corpus-header" on-no-match="deep-skip"/>
Piotr Banskia0a9fc02022-06-03 01:20:18 +020068 <xsl:mode name="text-header" on-no-match="deep-skip"/>
69 <xsl:mode name="text_inside_header" on-no-match="text-only-copy"/>
Piotr Banski763b41f2022-06-02 01:13:23 +020070 <xsl:mode name="copy" on-no-match="shallow-copy"/>
Piotr Banski6a4a2522022-05-24 01:16:47 +020071 <xsl:mode use-accumulators="#all"/>
Piotr Banski09096ee2022-05-25 13:41:03 +020072
Piotr Banskie1ac5202022-05-30 21:25:21 +020073 <xsl:accumulator name="element-index" as="xs:integer" initial-value="0">
Piotr Banskid2b78b82022-06-03 17:05:59 +020074 <!--<xsl:accumulator-rule match="tei:*[ancestor-or-self::tei:text]" select="$value + 1" phase="start"/>-->
75 <xsl:accumulator-rule
76 match="tei:teiCorpus/tei:TEI/(tei:text | tei:text/tei:body | tei:text/tei:body/tei:p | tei:text/tei:body/tei:p/tei:s | tei:text/tei:body/tei:p/tei:s/tei:seg)"
77 select="$value + 1" phase="start"/>
Piotr Banski09096ee2022-05-25 13:41:03 +020078 </xsl:accumulator>
Piotr Banskid2b78b82022-06-03 17:05:59 +020079
Piotr Banski65a6d0b2022-05-31 17:23:08 +020080 <xsl:accumulator name="morpho-offsets" as="map(xs:string, item()+)+" initial-value="(map{'null':(0,0)})">
Piotr Banskifdc858a2022-05-25 02:40:32 +020081
82 <xsl:accumulator-rule match="tei:body/tei:p" phase="start">
83 <xsl:variable name="preceding_index" as="xs:integer">
84 <xsl:variable name="the_tail" as="map(*)" select="head(reverse($value))"/>
85 <xsl:sequence select="map:get($the_tail,map:keys($the_tail)[1])[2]"/>
Piotr Banski6a4a2522022-05-24 01:16:47 +020086 </xsl:variable>
87
Piotr Banskifdc858a2022-05-25 02:40:32 +020088 <xsl:variable name="our_base" as="xs:integer" select="if($preceding_index eq 0) then $preceding_index else $preceding_index + 1"/>
89 <!-- for paragraphs, it's in either being initial or not -->
Piotr Banski09096ee2022-05-25 13:41:03 +020090
Piotr Banskifdc858a2022-05-25 02:40:32 +020091 <xsl:sequence select="
92 $value,
93 map {
94 string(@xml:id): ($preceding_index,$our_base)
95 }"/>
96 </xsl:accumulator-rule>
Piotr Banskid2b78b82022-06-03 17:05:59 +020097
Piotr Banskifdc858a2022-05-25 02:40:32 +020098 <xsl:accumulator-rule match="tei:s" phase="start">
99 <xsl:variable name="preceding_index" as="xs:integer">
100 <xsl:variable name="the_tail" as="map(*)" select="head(reverse($value))"/>
101 <xsl:sequence select="map:get($the_tail,map:keys($the_tail)[1])[2]"/>
Piotr Banskifdc858a2022-05-25 02:40:32 +0200102 </xsl:variable>
Piotr Banski92791a22022-05-26 01:41:10 +0200103 <xsl:variable name="our_base" as="xs:integer" select="if($preceding_index eq 0) then $preceding_index else $preceding_index + xs:integer(f:is_preceded_by_ws(.,true()))"/>
Piotr Banski09096ee2022-05-25 13:41:03 +0200104
Piotr Banskifdc858a2022-05-25 02:40:32 +0200105 <xsl:sequence select="
106 $value,
107 map {
108 string(@xml:id): ($preceding_index,$our_base)
109 }"/>
110 </xsl:accumulator-rule>
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200111
112<!-- I want something that won't be matched in other layers, for efficiency - that
113 may allow me to merge the accumulators, eventually;
114 but I also want to filter out the rejected tokenization alternatives already here -->
115 <xsl:accumulator-rule match="tei:seg[tei:fs[@type eq 'morph' and tei:f[@name eq 'disamb']]]" phase="end">
116
Piotr Banskifdc858a2022-05-25 02:40:32 +0200117 <xsl:variable name="preceding_index" as="xs:integer">
118 <xsl:variable name="the_tail" as="map(*)" select="head(reverse($value))"/>
119 <xsl:sequence select="map:get($the_tail,map:keys($the_tail)[1])[2]"/>
Piotr Banskifdc858a2022-05-25 02:40:32 +0200120 </xsl:variable>
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200121 <xsl:variable name="our_base" as="xs:integer" select="$preceding_index + xs:integer(f:is_preceded_by_ws(.,true()))"/>
Piotr Banski09096ee2022-05-25 13:41:03 +0200122
Piotr Banski6a4a2522022-05-24 01:16:47 +0200123 <xsl:sequence select="
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200124 $value,
125 map {
126 string(@xml:id): ($our_base,$our_base + string-length(tei:fs/tei:f[@name eq 'orth']/tei:string))
127 }"/>
128
Piotr Banski6a4a2522022-05-24 01:16:47 +0200129 </xsl:accumulator-rule>
Piotr Banskid2b78b82022-06-03 17:05:59 +0200130
Piotr Banskifdc858a2022-05-25 02:40:32 +0200131 <xsl:accumulator-rule match="tei:s" phase="end">
132 <xsl:variable name="preceding_index" as="xs:integer">
133 <xsl:variable name="the_tail" as="map(*)" select="head(reverse($value))"/>
134 <xsl:sequence select="map:get($the_tail,map:keys($the_tail)[1])[2]"/>
Piotr Banski09096ee2022-05-25 13:41:03 +0200135
Piotr Banskifdc858a2022-05-25 02:40:32 +0200136 </xsl:variable>
137 <xsl:variable name="our_base" as="xs:integer">
138 <xsl:variable name="incomplete" select="map:find($value,string(@xml:id))(1)" as="xs:integer+"/>
139 <xsl:sequence select="$incomplete[2]"/>
140 </xsl:variable>
Piotr Banski09096ee2022-05-25 13:41:03 +0200141
Piotr Banskifdc858a2022-05-25 02:40:32 +0200142 <xsl:sequence select="
143 $value,
144 map {
145 string(@xml:id): ($our_base,$preceding_index)
146 }"/>
147 </xsl:accumulator-rule>
Piotr Banskid2b78b82022-06-03 17:05:59 +0200148
Piotr Banskifdc858a2022-05-25 02:40:32 +0200149 <xsl:accumulator-rule match="tei:body/tei:p" phase="end">
150 <xsl:variable name="preceding_index" as="xs:integer">
151 <xsl:variable name="the_tail" as="map(*)" select="head(reverse($value))"/>
152 <xsl:sequence select="map:get($the_tail,map:keys($the_tail)[1])[2]"/>
153
Piotr Banskifdc858a2022-05-25 02:40:32 +0200154 </xsl:variable>
155 <xsl:variable name="our_base" as="xs:integer">
156 <xsl:variable name="incomplete" select="map:find($value,string(@xml:id))(1)" as="xs:integer+"/>
157 <xsl:sequence select="$incomplete[2]"/>
158 </xsl:variable>
Piotr Banski09096ee2022-05-25 13:41:03 +0200159
Piotr Banskifdc858a2022-05-25 02:40:32 +0200160 <xsl:sequence select="
161 $value,
162 map {
163 string(@xml:id): ($our_base,$preceding_index)
164 }"/>
165 </xsl:accumulator-rule>
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200166
Piotr Banskifdc858a2022-05-25 02:40:32 +0200167 <xsl:accumulator-rule match="tei:body" phase="end">
168 <xsl:variable name="preceding_index" as="xs:integer">
169 <xsl:variable name="the_tail" as="map(*)" select="head(reverse($value))"/>
170 <xsl:sequence select="map:get($the_tail, map:keys($the_tail)[1])[2]"/>
171 </xsl:variable>
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200172
Piotr Banskifdc858a2022-05-25 02:40:32 +0200173 <xsl:sequence select="
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200174 $value,
175 map {
176 string(@xml:id): (0, $preceding_index)
177 }"/>
Piotr Banskifdc858a2022-05-25 02:40:32 +0200178 </xsl:accumulator-rule>
Piotr Banskid2b78b82022-06-03 17:05:59 +0200179
Piotr Banskifdc858a2022-05-25 02:40:32 +0200180 <xsl:accumulator-rule match="tei:text" phase="end">
181 <xsl:variable name="preceding_index" as="xs:integer">
182 <xsl:variable name="the_tail" as="map(*)" select="head(reverse($value))"/>
183 <xsl:sequence select="map:get($the_tail, map:keys($the_tail)[1])[2]"/>
184 </xsl:variable>
185
186 <xsl:sequence select="
187 $value,
188 map {
189 string(@xml:id): (0, $preceding_index)
190 }"/>
191 </xsl:accumulator-rule>
Piotr Banskid2b78b82022-06-03 17:05:59 +0200192
Piotr Banski6a4a2522022-05-24 01:16:47 +0200193 </xsl:accumulator>
bansp5e2d1c02022-03-10 04:51:40 +0100194
banspe726b4a2022-03-28 05:47:45 +0200195 <!-- FUNCTIONS -->
196
bansp5f841732022-03-16 06:27:31 +0100197 <xsl:function name="f:compute_nesting" as="xs:integer">
banspd1bf1db2022-04-04 02:16:24 +0200198 <xsl:param name="node" as="element()"/>
bansp5f841732022-03-16 06:27:31 +0100199 <xsl:variable name="rel_depth"
200 select="count($node/ancestor-or-self::*[local-name(.) ne 'TEI'][local-name(.) ne 'teiCorpus'])"
201 as="xs:integer"/>
bansp5f841732022-03-16 06:27:31 +0100202 <xsl:sequence select="$rel_depth"/>
203 </xsl:function>
204
Piotr Banski92791a22022-05-26 01:41:10 +0200205 <xsl:function name="f:is_preceded_by_ws" as="xs:boolean">
bansp9dc10002022-05-17 22:33:34 +0200206 <xsl:param name="node" as="element()"/>
Piotr Banskifdc858a2022-05-25 02:40:32 +0200207 <xsl:param name="suppress_initial" as="xs:boolean"/>
Piotr Banski4f4c2d22022-05-19 01:44:32 +0200208
Piotr Banski92791a22022-05-26 01:41:10 +0200209 <xsl:choose>
210 <xsl:when test="local-name($node) eq 'seg'">
211 <xsl:choose>
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200212 <xsl:when test="$node/tei:fs/tei:f[@name eq 'nps']">
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200213 <xsl:sequence select="fn:false()"/>
214 </xsl:when>
Piotr Banski92791a22022-05-26 01:41:10 +0200215 <xsl:when
216 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])">
217 <xsl:sequence select="fn:false()"/>
218 <!-- the otherwise very costly check for preceding segs fires only if the first two are true, so it will have minimal search space -->
219 </xsl:when>
220 <xsl:when
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200221 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">
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200222 <xsl:sequence select="fn:false()"/>
223 </xsl:when>
Piotr Banski92791a22022-05-26 01:41:10 +0200224 <xsl:otherwise>
225 <xsl:sequence select="fn:true()"/>
226 </xsl:otherwise>
227 </xsl:choose>
228 </xsl:when>
229 <xsl:when test="local-name($node) eq 's'">
230 <xsl:choose>
231 <xsl:when test="exists($node/preceding-sibling::tei:s)">
232 <xsl:sequence select="fn:true()"/>
233 </xsl:when>
234 <xsl:otherwise>
235 <xsl:sequence
236 select="not($suppress_initial) and exists($node/ancestor::tei:p[1]/preceding-sibling::tei:p)"
237 />
238 </xsl:otherwise>
239 </xsl:choose>
240
241 </xsl:when>
242 <xsl:when test="local-name($node) eq 'p'">
243 <xsl:sequence select="exists($node/preceding-sibling::tei:p)"/>
244 </xsl:when>
245 <xsl:otherwise>
246 <xsl:message terminate="yes"
247 select="'Wrong argument passed to f:is_preceded_by_ws(): ' || local-name($node) || ' Only p, s, seg are allowed.'"
248 />
249 </xsl:otherwise>
250 </xsl:choose>
251 </xsl:function>
banspd1bf1db2022-04-04 02:16:24 +0200252
banspb5992532022-03-29 15:55:44 +0200253<!-- UTILITY TEMPLATES -->
254
bansp9103aab2022-03-19 05:10:21 +0100255 <xsl:template match="@default" mode="#all"/>
bansp97ba7ce2022-03-26 05:14:06 +0100256 <!-- this is to delete some auto-inserted attribute throughout -->
bansp9103aab2022-03-19 05:10:21 +0100257
banspb5992532022-03-29 15:55:44 +0200258 <!-- MAIN PROCESSING -->
259
bansp5e2d1c02022-03-10 04:51:40 +0100260 <xsl:template name="xsl:initial-template">
banspf2b24e62022-03-28 18:12:08 +0200261 <xsl:variable name="IDs_to_skip" select="tokenize($skip_docID,',')" as="xs:string*"/>
banspd1bf1db2022-04-04 02:16:24 +0200262
banspe726b4a2022-03-28 05:47:45 +0200263 <!-- we only want to call the template below once, and we process a random NKJP corpus file for that purpose,
bansp8f6700b2022-03-27 05:27:09 +0200264 because all we need is the main corpus header, and we can (should) get to that from any NKJP corpus document -->
265 <xsl:call-template name="create_corpus_header">
Piotr Banskifaa910f2022-06-03 00:46:29 +0200266 <xsl:with-param name="text.doc" select="$collection_of_text[1]" as="document-node()"/>
bansp8f6700b2022-03-27 05:27:09 +0200267 <xsl:with-param name="target" select="$targetCorpusDir_slashed || 'header.xml'" as="xs:string"/>
268 </xsl:call-template>
269
banspe726b4a2022-03-28 05:47:45 +0200270 <xsl:for-each select="$collection_of_text">
271 <xsl:variable name="my_dir" as="xs:string" select="replace(base-uri(),'/text\.xml','')"/>
272 <xsl:variable name="my_textID" as="xs:string" select="tokenize($my_dir,'/')[last()]"/>
273 <xsl:variable name="ann_morphosyntax.uri" select="$my_dir || '/ann_morphosyntax.xml'" as="xs:string"/>
Piotr Banski081c5de2022-06-03 01:57:13 +0200274 <!--<xsl:variable name="ann_segmentation.uri" select="$my_dir || '/ann_segmentation.xml'" as="xs:string"/>-->
Piotr Banskic5950ce2022-05-27 15:07:08 +0200275 <xsl:variable name="ann_named.uri" select="$my_dir || '/ann_named.xml'" as="xs:string"/>
276 <xsl:variable name="ann_groups.uri" select="$my_dir || '/ann_groups.xml'" as="xs:string"/>
277 <xsl:variable name="ann_words.uri" select="$my_dir || '/ann_words.xml'" as="xs:string"/>
banspe726b4a2022-03-28 05:47:45 +0200278
banspf2b24e62022-03-28 18:12:08 +0200279 <xsl:choose>
280 <xsl:when test="$my_textID = $IDs_to_skip"/>
bansp9dc10002022-05-17 22:33:34 +0200281 <!-- this is a utility step, for when we want to ignore some texts for any reason (debugging, selective update) -->
banspf2b24e62022-03-28 18:12:08 +0200282 <xsl:otherwise>
banspd1bf1db2022-04-04 02:16:24 +0200283
bansp9dc10002022-05-17 22:33:34 +0200284 <xsl:call-template name="process_single_sample">
Piotr Banskif9590692022-06-02 15:39:48 +0200285 <xsl:with-param name="text.doc" as="document-node()" select="."/>
286 <xsl:with-param name="ann_morphosyntax.doc" as="document-node()"
banspf2b24e62022-03-28 18:12:08 +0200287 select="doc($ann_morphosyntax.uri)"/>
Piotr Banski081c5de2022-06-03 01:57:13 +0200288<!-- <xsl:with-param name="ann_segmentation.xml" as="document-node()"
289 select="doc($ann_segmentation.uri)"/>-->
banspf2b24e62022-03-28 18:12:08 +0200290 <xsl:with-param name="my_textID" select="$my_textID" as="xs:string"/>
Piotr Banskic5950ce2022-05-27 15:07:08 +0200291 <!-- the following parameters may happen to be null -->
Piotr Banskif9590692022-06-02 15:39:48 +0200292 <xsl:with-param name="ann_named.doc" as="document-node()*"
Piotr Banskic5950ce2022-05-27 15:07:08 +0200293 select="if(fn:doc-available($ann_named.uri)) then doc($ann_named.uri) else ()"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200294 <xsl:with-param name="ann_groups.doc" as="document-node()*"
Piotr Banskic5950ce2022-05-27 15:07:08 +0200295 select="if(fn:doc-available($ann_groups.uri)) then doc($ann_groups.uri) else ()"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200296 <xsl:with-param name="ann_words.doc" as="document-node()*"
Piotr Banskic5950ce2022-05-27 15:07:08 +0200297 select="if(fn:doc-available($ann_words.uri)) then doc($ann_words.uri) else ()"/>
298
bansp9dc10002022-05-17 22:33:34 +0200299 </xsl:call-template>
banspf2b24e62022-03-28 18:12:08 +0200300 </xsl:otherwise>
301 </xsl:choose>
banspe726b4a2022-03-28 05:47:45 +0200302 </xsl:for-each>
bansp8f6700b2022-03-27 05:27:09 +0200303 </xsl:template>
304
305 <xsl:template name="process_single_sample">
Piotr Banskif9590692022-06-02 15:39:48 +0200306 <xsl:param name="text.doc" as="document-node()"/>
307 <xsl:param name="ann_morphosyntax.doc" as="document-node()"/>
banspd1bf1db2022-04-04 02:16:24 +0200308 <xsl:param name="my_textID" as="xs:string" select="'0-BAD_textID'"/>
bansp9dc10002022-05-17 22:33:34 +0200309 <!-- empty textID should never happen, but if it does, it will be signalled at the top of the output -->
Piotr Banskif9590692022-06-02 15:39:48 +0200310 <xsl:param name="ann_named.doc" as="document-node()*"/>
311 <xsl:param name="ann_groups.doc" as="document-node()*"/>
312 <xsl:param name="ann_words.doc" as="document-node()*"/>
banspe726b4a2022-03-28 05:47:45 +0200313
314 <xsl:variable name="targetBaseDir" as="xs:string" select="$targetCorpusDir_slashed || $docID || '/' || $my_textID"/>
315
316 <xsl:variable name="compoundID" as="xs:string"
317 select="$corpusID || '_' || $docID || '.' || $my_textID"/>
318 <!-- this is what occurs in the text and data layers as @docid -->
319
bansp5e2d1c02022-03-10 04:51:40 +0100320 <xsl:call-template name="create_data">
Piotr Banski081c5de2022-06-03 01:57:13 +0200321 <xsl:with-param name="ann_morphosyntax.doc" select="$ann_morphosyntax.doc" as="document-node()"/>
banspe726b4a2022-03-28 05:47:45 +0200322 <xsl:with-param name="compoundID" select="$compoundID" as="xs:string"/>
323 <xsl:with-param name="target" select="$targetBaseDir || '/data.xml'" as="xs:string"/>
bansp5f841732022-03-16 06:27:31 +0100324 </xsl:call-template>
325
Piotr Banski43b9db02022-06-03 02:38:42 +0200326 <xsl:call-template name="create_struct">
banspe726b4a2022-03-28 05:47:45 +0200327 <xsl:with-param name="compoundID" select="$compoundID" as="xs:string"/>
Piotr Banski43b9db02022-06-03 02:38:42 +0200328 <xsl:with-param name="ann_morphosyntax.doc" select="$ann_morphosyntax.doc"
bansp5f841732022-03-16 06:27:31 +0100329 as="document-node()"/>
banspe726b4a2022-03-28 05:47:45 +0200330 <xsl:with-param name="target" select="$targetBaseDir || '/struct/structure.xml'" as="xs:string"
bansp5f841732022-03-16 06:27:31 +0100331 />
Piotr Banski43b9db02022-06-03 02:38:42 +0200332 </xsl:call-template>
Piotr Banski92791a22022-05-26 01:41:10 +0200333
Piotr Banskiba6cc632022-06-03 14:07:33 +0200334 <xsl:call-template name="create_morpho">
banspe726b4a2022-03-28 05:47:45 +0200335 <xsl:with-param name="compoundID" select="$compoundID" as="xs:string"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200336 <xsl:with-param name="ann_morphosyntax.doc" select="$ann_morphosyntax.doc"
bansp5f841732022-03-16 06:27:31 +0100337 as="document-node()"/>
banspe726b4a2022-03-28 05:47:45 +0200338 <xsl:with-param name="target" select="$targetBaseDir || '/nkjp/morpho.xml'" as="xs:string"/>
Piotr Banskiba6cc632022-06-03 14:07:33 +0200339 </xsl:call-template>
Piotr Banskia51907c2022-05-25 15:09:41 +0200340
Piotr Banskid2b78b82022-06-03 17:05:59 +0200341 <xsl:call-template name="create_text_header">
Piotr Banskif9590692022-06-02 15:39:48 +0200342 <xsl:with-param name="text.doc" select="$text.doc" as="document-node()"/>
banspe726b4a2022-03-28 05:47:45 +0200343 <xsl:with-param name="compoundID" select="$compoundID" as="xs:string"/>
344 <xsl:with-param name="target" select="$targetBaseDir || '/header.xml'" as="xs:string"/>
Piotr Banski09096ee2022-05-25 13:41:03 +0200345 </xsl:call-template>
Piotr Banski6a4a2522022-05-24 01:16:47 +0200346
Piotr Banskif9590692022-06-02 15:39:48 +0200347 <xsl:if test="$ann_named.doc">
Piotr Banski763b41f2022-06-02 01:13:23 +0200348 <xsl:variable name="rev_lookup-seq" as="map(*)+">
Piotr Banskib28e5882022-06-08 20:41:20 +0200349 <xsl:for-each select="$ann_named.doc//tei:seg/tei:ptr">
350 <xsl:variable name="trg" as="xs:string" select="fn:substring-before(@target, '#')"/>
351 <!-- caution: as of 01-June-2022, some of the pointers are malformed (missing '#' when referencing locally).
Piotr Banskid2b78b82022-06-03 17:05:59 +0200352 so we need to act around it but also sustainably - in case that error gets corrected -->
Piotr Banski763b41f2022-06-02 01:13:23 +0200353
Piotr Banskib28e5882022-06-08 20:41:20 +0200354 <xsl:if test="fn:string-length($trg) and $trg eq 'ann_morphosyntax.xml'">
Piotr Banski763b41f2022-06-02 01:13:23 +0200355 <xsl:sequence>
356 <xsl:map-entry key="fn:substring-after(fn:string(@target), '#')" select="fn:current()"
357 />
358 </xsl:sequence>
Piotr Banskib28e5882022-06-08 20:41:20 +0200359 </xsl:if>
360 </xsl:for-each>
Piotr Banski763b41f2022-06-02 01:13:23 +0200361 </xsl:variable>
Piotr Banskib28e5882022-06-08 20:41:20 +0200362 <xsl:variable name="rev_lookup" as="map(*)"
363 select="map:merge($rev_lookup-seq, map {'duplicates': 'combine'})"/>
364
Piotr Banskic5950ce2022-05-27 15:07:08 +0200365 <xsl:call-template name="create_named">
366 <xsl:with-param name="compoundID" select="$compoundID" as="xs:string"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200367 <xsl:with-param name="ann_morphosyntax.doc" select="$ann_morphosyntax.doc"
Piotr Banskic5950ce2022-05-27 15:07:08 +0200368 as="document-node()"/>
Piotr Banskib28e5882022-06-08 20:41:20 +0200369 <xsl:with-param name="ann_named.doc" select="$ann_named.doc" as="document-node()"/>
Piotr Banskic5950ce2022-05-27 15:07:08 +0200370 <xsl:with-param name="target" select="$targetBaseDir || '/nkjp/named.xml'" as="xs:string"/>
Piotr Banski763b41f2022-06-02 01:13:23 +0200371 <xsl:with-param name="rev_lookup" select="$rev_lookup" as="map(*)"/>
Piotr Banskic5950ce2022-05-27 15:07:08 +0200372 </xsl:call-template>
373 </xsl:if>
Piotr Banskid2b78b82022-06-03 17:05:59 +0200374
Piotr Banskib28e5882022-06-08 20:41:20 +0200375<!-- <xsl:if test="$ann_words.doc and $ann_groups.doc">
Piotr Banskic5950ce2022-05-27 15:07:08 +0200376 <xsl:call-template name="create_groups">
377 <xsl:with-param name="compoundID" select="$compoundID" as="xs:string"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200378 <xsl:with-param name="ann_morphosyntax.doc" select="$ann_morphosyntax.doc"
Piotr Banskic5950ce2022-05-27 15:07:08 +0200379 as="document-node()"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200380 <xsl:with-param name="ann_words.doc" select="$ann_words.doc"
Piotr Banskic5950ce2022-05-27 15:07:08 +0200381 as="document-node()"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200382 <xsl:with-param name="ann_groups.doc" select="$ann_groups.doc"
Piotr Banskic5950ce2022-05-27 15:07:08 +0200383 as="document-node()"/>
384 <xsl:with-param name="target" select="$targetBaseDir || '/nkjp/groups.xml'" as="xs:string"/>
385 </xsl:call-template>
Piotr Banskib28e5882022-06-08 20:41:20 +0200386 </xsl:if>-->
Piotr Banskic5950ce2022-05-27 15:07:08 +0200387
bansp5e2d1c02022-03-10 04:51:40 +0100388 </xsl:template>
389
390 <!-- ************************** data.xml ******************* -->
391
392 <xsl:template name="create_data">
Piotr Banski081c5de2022-06-03 01:57:13 +0200393 <xsl:param name="ann_morphosyntax.doc" as="document-node()"/>
banspe726b4a2022-03-28 05:47:45 +0200394 <xsl:param name="compoundID" as="xs:string"/>
bansp5f841732022-03-16 06:27:31 +0100395 <xsl:param name="target" as="xs:string"/>
bansp5e2d1c02022-03-10 04:51:40 +0100396 <!-- create the data.xml file -->
397 <xsl:result-document encoding="UTF-8" method="xml" indent="yes"
bansp5f841732022-03-16 06:27:31 +0100398 xpath-default-namespace="{$KorAP_namespace}" href="{$target}">
bansp5e2d1c02022-03-10 04:51:40 +0100399
Akron9a8ee3e2022-01-31 13:51:49 +0100400 <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 +0100401 <xsl:element name="raw_text" namespace="{$KorAP_namespace}">
bansp5f841732022-03-16 06:27:31 +0100402 <xsl:attribute name="docid" select="$compoundID"/>
bansp5e2d1c02022-03-10 04:51:40 +0100403 <xsl:element name="metadata" namespace="{$KorAP_namespace}">
404 <xsl:attribute name="file" select="'metadata.xml'"/>
405 </xsl:element>
406
407 <xsl:element name="text" namespace="{$KorAP_namespace}">
bansp9dc10002022-05-17 22:33:34 +0200408 <xsl:variable name="content" as="xs:string+">
Piotr Banski081c5de2022-06-03 01:57:13 +0200409 <xsl:for-each select="$ann_morphosyntax.doc/tei:teiCorpus/tei:TEI/tei:text/tei:body/tei:p/tei:s/tei:seg[tei:fs/tei:f[@name eq 'disamb']]">
bansp9dc10002022-05-17 22:33:34 +0200410 <xsl:sequence select="
Piotr Banskifdc858a2022-05-25 02:40:32 +0200411 if (f:is_preceded_by_ws(.,false())) then
bansp9dc10002022-05-17 22:33:34 +0200412 ' '
413 else
Piotr Banski081c5de2022-06-03 01:57:13 +0200414 '', ./tei:fs/tei:f[@name eq 'orth']/tei:string"/>
bansp9dc10002022-05-17 22:33:34 +0200415 </xsl:for-each>
416 </xsl:variable>
417 <xsl:value-of select="string-join($content)"/>
bansp5e2d1c02022-03-10 04:51:40 +0100418 </xsl:element>
Akron9a8ee3e2022-01-31 13:51:49 +0100419 </xsl:element>
banspf79443e2022-02-25 14:25:33 +0100420 </xsl:result-document>
Akron9a8ee3e2022-01-31 13:51:49 +0100421 </xsl:template>
422
bansp5f841732022-03-16 06:27:31 +0100423 <!-- ************************** struct ******************* -->
424
425 <xsl:template name="create_struct">
banspe726b4a2022-03-28 05:47:45 +0200426 <xsl:param name="compoundID" as="xs:string"/>
Piotr Banski43b9db02022-06-03 02:38:42 +0200427 <xsl:param name="ann_morphosyntax.doc" as="document-node()"/>
bansp5f841732022-03-16 06:27:31 +0100428 <xsl:param name="target" as="xs:string"/>
Piotr Banski4f4c2d22022-05-19 01:44:32 +0200429
bansp5f841732022-03-16 06:27:31 +0100430 <xsl:result-document encoding="UTF-8" method="xml" indent="yes"
431 xpath-default-namespace="http://ids-mannheim.de/ns/KorAP" href="{$target}">
432 <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>
433 <xsl:element name="layer" namespace="{$KorAP_namespace}">
434 <xsl:attribute name="docid" select="$compoundID"/>
435 <xsl:attribute name="version" select="$KorAP-XML_version"/>
436
437 <xsl:element name="spanList" namespace="{$KorAP_namespace}">
Piotr Banski43b9db02022-06-03 02:38:42 +0200438 <xsl:apply-templates select="$ann_morphosyntax.doc/tei:teiCorpus/tei:TEI/tei:text" mode="struct"/>
bansp5f841732022-03-16 06:27:31 +0100439 </xsl:element>
440 </xsl:element>
441 </xsl:result-document>
442 </xsl:template>
443
Piotr Banski43b9db02022-06-03 02:38:42 +0200444 <xsl:template match="tei:text | tei:body | tei:p | tei:s | tei:seg[tei:fs/tei:f[@name eq 'disamb']]" mode="struct">
Piotr Banski09096ee2022-05-25 13:41:03 +0200445 <xsl:variable name="offsets" as="xs:integer+">
Piotr Banski43b9db02022-06-03 02:38:42 +0200446 <xsl:sequence select="map:get(fn:accumulator-after('morpho-offsets')[last()], string(@xml:id))"/>
Piotr Banski09096ee2022-05-25 13:41:03 +0200447 </xsl:variable>
Piotr Banski6a4a2522022-05-24 01:16:47 +0200448
bansp5f841732022-03-16 06:27:31 +0100449 <xsl:variable name="my_name" select="local-name()" as="xs:string"/>
Piotr Banskie1ac5202022-05-30 21:25:21 +0200450 <xsl:variable name="my_index" select="fn:accumulator-before('element-index')" as="xs:integer"/>
bansp3e5b20c2022-03-18 20:22:31 +0100451
bansp5f841732022-03-16 06:27:31 +0100452 <xsl:element name="span" namespace="{$KorAP_namespace}">
453 <xsl:attribute name="id" select="'s' || $my_index"/>
Piotr Banski09096ee2022-05-25 13:41:03 +0200454 <xsl:attribute name="from" select="$offsets[1]"/>
455 <xsl:attribute name="to" select="$offsets[2]"/>
bansp5f841732022-03-16 06:27:31 +0100456 <xsl:attribute name="l" select="f:compute_nesting(.)"/>
Piotr Banski09096ee2022-05-25 13:41:03 +0200457 <xsl:if test="local-name() eq 'seg' and $SHOW_ORTH_IN_STRUCT">
Piotr Banskid2b78b82022-06-03 17:05:59 +0200458 <xsl:comment select="
459 (if (tei:fs/tei:f[@name eq 'nps']) then
460 ' '
461 else
462 ' _') || tei:fs/tei:f[@name eq 'orth']/tei:string"/>
Piotr Banski09096ee2022-05-25 13:41:03 +0200463 </xsl:if>
bansp5f841732022-03-16 06:27:31 +0100464 <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0">
Piotr Banskifdc858a2022-05-25 02:40:32 +0200465 <xsl:attribute name="type" select="'struct'"></xsl:attribute> <!-- STRUCT vs. LEX for morpho -->
bansp5f841732022-03-16 06:27:31 +0100466 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
bansp3e5b20c2022-03-18 20:22:31 +0100467 <xsl:attribute name="name" select="'name'"/>
468 <xsl:value-of select="local-name()"/>
bansp5f841732022-03-16 06:27:31 +0100469 </xsl:element>
470 <xsl:if test="count(@*)">
471 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
472 <xsl:attribute name="name" select="'attr'"/>
473 <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0">
474 <xsl:attribute name="type" select="'attr'"/>
475 <xsl:for-each select="@*">
476 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
477 <xsl:attribute name="name" select="local-name(.)"/>
478 <xsl:value-of select="."/>
479 </xsl:element>
480 </xsl:for-each>
481 </xsl:element>
482 </xsl:element>
483 </xsl:if>
484 </xsl:element>
485 </xsl:element>
Piotr Banskia51907c2022-05-25 15:09:41 +0200486 <xsl:apply-templates mode="struct"/>
bansp5f841732022-03-16 06:27:31 +0100487 </xsl:template>
488
489 <!-- ************************** morpho ******************* -->
490
491 <xsl:template name="create_morpho">
banspe726b4a2022-03-28 05:47:45 +0200492 <xsl:param name="compoundID" as="xs:string"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200493 <xsl:param name="ann_morphosyntax.doc" as="document-node()"/>
bansp5f841732022-03-16 06:27:31 +0100494 <xsl:param name="target" as="xs:string"/>
495
496 <xsl:result-document encoding="UTF-8" method="xml" indent="yes"
497 xpath-default-namespace="http://ids-mannheim.de/ns/KorAP" href="{$target}">
498 <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 +0100499 <xsl:element name="layer" namespace="{$KorAP_namespace}">
500 <xsl:attribute name="docid" select="$compoundID"/>
501 <xsl:attribute name="version" select="$KorAP-XML_version"/>
502
503 <xsl:element name="spanList" namespace="{$KorAP_namespace}">
Piotr Banskid2b78b82022-06-03 17:05:59 +0200504 <xsl:apply-templates select="$ann_morphosyntax.doc/tei:teiCorpus/tei:TEI/tei:text/tei:body/tei:p/tei:s/tei:seg" mode="morpho"/>
bansp3e5b20c2022-03-18 20:22:31 +0100505 </xsl:element>
506 </xsl:element>
bansp5f841732022-03-16 06:27:31 +0100507 </xsl:result-document>
508 </xsl:template>
509
Piotr Banskiba6cc632022-06-03 14:07:33 +0200510 <xsl:template match="tei:seg[tei:fs/tei:f[@name eq 'disamb']]" mode="morpho">
511
Piotr Banskia51907c2022-05-25 15:09:41 +0200512 <!-- it's so spread out because I wanted to make sure to be able to look up the individual
513 constituent values, should anything go wrong; it might get compacted at some point, but
514 the increase in efficiency will probably be minimal, compared to the decrease of readability -->
515 <xsl:variable name="offsets" as="xs:integer+">
Piotr Banskiba6cc632022-06-03 14:07:33 +0200516 <xsl:sequence select="map:get(fn:accumulator-after('morpho-offsets')[last()], string(@xml:id))"/>
Piotr Banskia51907c2022-05-25 15:09:41 +0200517 </xsl:variable>
Piotr Banskiba6cc632022-06-03 14:07:33 +0200518
Piotr Banskiba6cc632022-06-03 14:07:33 +0200519 <xsl:variable name="my_disamb" select="tei:fs/tei:f[@name eq 'disamb']" as="node()"/>
bansp3e5b20c2022-03-18 20:22:31 +0100520 <xsl:variable name="my_choice-id" select="substring-after($my_disamb//tei:f[@name eq 'choice']/@fVal,'#')" as="xs:string"/>
Piotr Banskiba6cc632022-06-03 14:07:33 +0200521 <xsl:variable name="my_choice-lex" select="tei:fs/tei:f[@name eq 'interps']/tei:fs[@type eq 'lex'][descendant::tei:symbol[@xml:id eq $my_choice-id]]" as="node()"/>
bansp3e5b20c2022-03-18 20:22:31 +0100522 <xsl:variable name="chosen-msd" as="xs:string" select="$my_choice-lex/descendant::tei:symbol[@xml:id eq $my_choice-id]/@value"/>
Piotr Banskie1ac5202022-05-30 21:25:21 +0200523 <xsl:variable name="my_index" select="fn:accumulator-before('element-index')" as="xs:integer"/>
bansp3e5b20c2022-03-18 20:22:31 +0100524
bansp3e5b20c2022-03-18 20:22:31 +0100525 <xsl:element name="span" namespace="{$KorAP_namespace}">
Piotr Banskia51907c2022-05-25 15:09:41 +0200526 <xsl:attribute name="id" select="'m' || $my_index"/>
527 <xsl:attribute name="from" select="$offsets[1]"/>
528 <xsl:attribute name="to" select="$offsets[2]"/>
bansp3e5b20c2022-03-18 20:22:31 +0100529 <xsl:attribute name="l" select="f:compute_nesting(.)"/>
530 <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0">
531 <xsl:attribute name="type" select="'lex'"/>
532 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
533 <xsl:attribute name="name" select="'lex'"/>
Piotr Banskid2b78b82022-06-03 17:05:59 +0200534 <xsl:if test="$SHOW_REDUNDANT_ORTH">
535 <xsl:comment select="
Piotr Banskiba6cc632022-06-03 14:07:33 +0200536 (if (tei:fs/tei:f[@name eq 'nps']) then
537 ' '
538 else
539 ' _') || tei:fs/tei:f[@name eq 'orth']/tei:string"/>
Piotr Banskid2b78b82022-06-03 17:05:59 +0200540 </xsl:if>
bansp3e5b20c2022-03-18 20:22:31 +0100541 <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0">
bansp3e5b20c2022-03-18 20:22:31 +0100542 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
Piotr Banskia44cd7a2022-06-03 19:19:50 +0200543 <xsl:attribute name="name" select="'orig'"/>
544 <xsl:value-of select="tei:fs/tei:f[@name eq 'orth']/tei:string"/>
545 </xsl:element>
546 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
bansp3e5b20c2022-03-18 20:22:31 +0100547 <xsl:attribute name="name" select="'lemma'"/>
548 <xsl:value-of select="$my_choice-lex/tei:f[@name eq 'base']/tei:string"/>
549 </xsl:element>
550 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
551 <xsl:attribute name="name" select="'pos'"/>
552 <xsl:value-of select="$my_choice-lex/tei:f[@name eq 'ctag']/tei:symbol/@value"/>
553 </xsl:element>
554 <xsl:if test="string-length($chosen-msd)">
555 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
556 <xsl:attribute name="name" select="'msd'"/>
557 <xsl:value-of select="$chosen-msd"/>
558 </xsl:element>
559 </xsl:if>
Piotr Banskiba6cc632022-06-03 14:07:33 +0200560 <xsl:if test="tei:fs/tei:f[@name eq 'nps']">
bansp3e5b20c2022-03-18 20:22:31 +0100561 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
562 <xsl:attribute name="name" select="'join'"/>
563 <xsl:value-of select="'left'"/>
564 </xsl:element>
565 </xsl:if>
566 </xsl:element>
567 </xsl:element>
Piotr Banskia44cd7a2022-06-03 19:19:50 +0200568 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
569 <xsl:attribute name="name" select="'interps'"/>
570 <xsl:for-each select="tei:fs/tei:f[@name eq 'interps']/tei:fs">
571 <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0">
572 <xsl:attribute name="type" select="'alt'"/>
573 <xsl:if test="tei:f[@name eq 'msd']//tei:symbol/@xml:id = $my_choice-id">
574 <xsl:attribute name="n" select="'choice'"/>
575 </xsl:if>
576 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
577 <xsl:attribute name="name" select="'lemma'"/>
578 <xsl:value-of select="tei:f[@name eq 'base']/tei:string"/>
579 </xsl:element>
580 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
581 <xsl:attribute name="name" select="'pos'"/>
582 <xsl:value-of select="tei:f[@name eq 'ctag']/tei:symbol/@value"/>
583 </xsl:element>
584 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
585 <xsl:attribute name="name" select="'msd'"/>
586 <xsl:apply-templates select="tei:f[@name eq 'msd']/*" mode="inside-interps">
587 <xsl:with-param name="choice" select="$my_choice-id" as="xs:string" tunnel="yes"/>
588 </xsl:apply-templates>
589 </xsl:element>
590 </xsl:element>
591 </xsl:for-each>
592 </xsl:element>
bansp3e5b20c2022-03-18 20:22:31 +0100593 </xsl:element>
594 </xsl:element>
bansp3e5b20c2022-03-18 20:22:31 +0100595 </xsl:template>
banspe726b4a2022-03-28 05:47:45 +0200596
Piotr Banskia44cd7a2022-06-03 19:19:50 +0200597 <xsl:template match="tei:vAlt" mode="inside-interps">
598 <xsl:copy select="." copy-namespaces="no">
599 <xsl:apply-templates mode="inside-interps" select="*"/>
600 </xsl:copy>
601 </xsl:template>
602
603 <xsl:template match="tei:symbol" mode="inside-interps">
604 <xsl:param name="choice" as="xs:string" tunnel="yes"/>
605 <xsl:copy select="." copy-namespaces="no">
606 <xsl:attribute name="value" select="
607 if (@value eq '') then
608 0
609 else
610 @value"/>
611<!-- the check above is to appease the validator, which won't allow for empty values of @value -->
612 <xsl:if test="@xml:id eq $choice">
613 <xsl:attribute name="n" select="'choice'"/>
614 </xsl:if>
615 </xsl:copy>
616 </xsl:template>
617
Piotr Banskic5950ce2022-05-27 15:07:08 +0200618 <!-- ************************** named entities ******************* -->
619
620 <xsl:template name="create_named">
621 <xsl:param name="compoundID" as="xs:string"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200622 <xsl:param name="ann_morphosyntax.doc" as="document-node()"/>
623 <xsl:param name="ann_named.doc" as="document-node()"/>
Piotr Banskic5950ce2022-05-27 15:07:08 +0200624 <xsl:param name="target" as="xs:string"/>
Piotr Banski763b41f2022-06-02 01:13:23 +0200625 <xsl:param name="rev_lookup" as="map(*)"/>
626
Piotr Banskic5950ce2022-05-27 15:07:08 +0200627 <xsl:result-document encoding="UTF-8" method="xml" indent="yes"
628 xpath-default-namespace="http://ids-mannheim.de/ns/KorAP" href="{$target}">
629 <xsl:processing-instruction name="xml-model">href=&quot;span.rng&quot; type=&quot;application/xml&quot; schematypens=&quot;http://relaxng.org/ns/structure/1.0&quot;</xsl:processing-instruction>
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 Banskif9590692022-06-02 15:39:48 +0200635 <xsl:apply-templates select="$ann_morphosyntax.doc//tei:text" mode="named">
636 <xsl:with-param name="ann_named.doc" select="$ann_named.doc" as="document-node()" tunnel="yes"/>
Piotr Banski763b41f2022-06-02 01:13:23 +0200637 <xsl:with-param name="rev_lookup" select="$rev_lookup" as="map(*)" tunnel="yes"/>
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200638 </xsl:apply-templates>
Piotr Banskic5950ce2022-05-27 15:07:08 +0200639 </xsl:element>
640 </xsl:element>
641 </xsl:result-document>
642 </xsl:template>
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200643
644 <xsl:template match="tei:seg" mode="named"/>
645
646 <xsl:template match="tei:seg[tei:fs[tei:f[@name eq 'disamb']]]" mode="named">
Piotr Banskif9590692022-06-02 15:39:48 +0200647 <xsl:param name="ann_named.doc" as="document-node()" tunnel="yes"/>
Piotr Banski763b41f2022-06-02 01:13:23 +0200648 <xsl:param name="rev_lookup" as="map(*)" tunnel="yes"/>
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200649
650 <xsl:variable name="offsets" as="xs:integer+">
651 <xsl:sequence select="map:get(fn:accumulator-after('morpho-offsets')[last()], string(@xml:id))"/>
652 </xsl:variable>
653
Piotr Banski763b41f2022-06-02 01:13:23 +0200654 <xsl:variable name="ptr" select="map:get($rev_lookup,fn:string(@xml:id))" as="element(tei:ptr)*"/>
655 <!-- it's an element, because we need to see where it stands in a sequence... -->
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200656
Piotr Banski763b41f2022-06-02 01:13:23 +0200657 <xsl:if test="$ptr">
658 <xsl:variable name="my_id" select="@xml:id" as="xs:string"/>
659 <xsl:variable name="my_index" select="fn:accumulator-before('element-index')" as="xs:integer"/>
660
661 <xsl:element name="span" namespace="{$KorAP_namespace}">
662 <xsl:attribute name="id" select="'n' || $my_index"/>
663 <xsl:attribute name="from" select="$offsets[1]"/>
664 <xsl:attribute name="to" select="$offsets[2]"/>
665 <xsl:attribute name="l" select="f:compute_nesting(.)"/>
666 <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0">
667 <xsl:attribute name="type" select="'ne'"/>
668 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
669 <xsl:attribute name="name" select="'ne'"/>
Piotr Banskid2b78b82022-06-03 17:05:59 +0200670 <xsl:if test="$SHOW_REDUNDANT_ORTH">
671 <xsl:comment select="
672 (if (tei:fs/tei:f[@name eq 'nps']) then
673 ' '
674 else
675 ' _') || tei:fs/tei:f[@name eq 'orth']/tei:string"/>
676 </xsl:if>
Piotr Banski763b41f2022-06-02 01:13:23 +0200677 <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0">
678 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
679 <xsl:attribute name="name" select="'complex-ent'"/>
680 <xsl:for-each select="$ptr">
681 <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0">
682 <xsl:attribute name="type" select="'complex-ent'"/>
683 <xsl:for-each select="parent::tei:seg/tei:fs[1]/tei:f">
684 <xsl:if test="@name eq 'type' or @name eq 'subtype'">
685 <xsl:copy-of select="." copy-namespaces="no"/>
686 </xsl:if>
687 </xsl:for-each>
688 <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
689 <xsl:attribute name="name" select="'nkjp-named'"/>
690 <xsl:copy-of select="parent::tei:seg/tei:fs[1]" copy-namespaces="no"/>
691 </xsl:element>
692 </xsl:element>
693 </xsl:for-each>
694
695 </xsl:element>
696
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200697 </xsl:element>
698 </xsl:element>
699 </xsl:element>
700 </xsl:element>
Piotr Banski763b41f2022-06-02 01:13:23 +0200701 </xsl:if>
Piotr Banski65a6d0b2022-05-31 17:23:08 +0200702 </xsl:template>
703
Piotr Banskic5950ce2022-05-27 15:07:08 +0200704
705 <!-- ************************** syntactic chunks ******************* -->
706
707 <xsl:template name="create_groups">
708 <xsl:param name="compoundID" as="xs:string"/>
Piotr Banskif9590692022-06-02 15:39:48 +0200709 <xsl:param name="ann_morphosyntax.doc" as="document-node()"/>
710 <xsl:param name="ann_words.doc" as="document-node()"/>
711 <xsl:param name="ann_groups.doc" as="document-node()"/>
Piotr Banskic5950ce2022-05-27 15:07:08 +0200712 <xsl:param name="target" as="xs:string"/>
713
714 <xsl:result-document encoding="UTF-8" method="xml" indent="yes"
715 xpath-default-namespace="http://ids-mannheim.de/ns/KorAP" href="{$target}">
716 <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>
717 <xsl:element name="layer" namespace="{$KorAP_namespace}">
718 <xsl:attribute name="docid" select="$compoundID"/>
719 <xsl:attribute name="version" select="$KorAP-XML_version"/>
720
721 <xsl:element name="spanList" namespace="{$KorAP_namespace}">
Piotr Banskid2b78b82022-06-03 17:05:59 +0200722 <!--<xsl:apply-templates select="$ann_morphosyntax.doc//tei:text" mode="groups">
Piotr Banskif9590692022-06-02 15:39:48 +0200723 <xsl:with-param name="ann_words.doc" select="$ann_words.doc" as="document-node()" tunnel="yes"/>
724 <xsl:with-param name="ann_groups.doc" select="$ann_groups.doc" as="document-node()" tunnel="yes"/>
Piotr Banskic5950ce2022-05-27 15:07:08 +0200725 </xsl:apply-templates>-->
726 </xsl:element>
727 </xsl:element>
728 </xsl:result-document>
729 </xsl:template>
730
bansp5f841732022-03-16 06:27:31 +0100731 <!-- ************************** TEXT header ******************* -->
732
733 <xsl:template name="create_text_header">
Piotr Banskif9590692022-06-02 15:39:48 +0200734 <xsl:param name="text.doc" as="document-node()"/>
banspe726b4a2022-03-28 05:47:45 +0200735 <xsl:param name="compoundID" as="xs:string"/>
bansp5f841732022-03-16 06:27:31 +0100736 <xsl:param name="target" as="xs:string"/>
737
738 <!-- create the local header.xml file -->
739 <xsl:result-document encoding="UTF-8" method="xml" indent="yes"
740 xpath-default-namespace="http://ids-mannheim.de/ns/KorAP" href="{$target}">
741
742 <idsHeader type="document" pattern="text" status="new" version="1.1" TEIform="teiHeader">
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200743 <xsl:apply-templates select="$text.doc//tei:TEI/tei:teiHeader/tei:*" mode="text-header">
banspe726b4a2022-03-28 05:47:45 +0200744 <xsl:with-param name="compoundID" as="xs:string" select="$compoundID" tunnel="yes"/>
745 </xsl:apply-templates>
bansp5f841732022-03-16 06:27:31 +0100746 </idsHeader>
747 </xsl:result-document>
748 </xsl:template>
749
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200750 <xsl:template match="tei:fileDesc" mode="text-header">
bansp9103aab2022-03-19 05:10:21 +0100751 <xsl:element name="{local-name()}">
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200752 <xsl:apply-templates mode="text-header"/>
bansp9103aab2022-03-19 05:10:21 +0100753 </xsl:element>
bansp5f841732022-03-16 06:27:31 +0100754 </xsl:template>
755
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200756 <xsl:template match="tei:title" mode="text-header">
bansp5f841732022-03-16 06:27:31 +0100757 <t.title>
758 <xsl:apply-templates/>
759 </t.title>
760 </xsl:template>
761
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200762 <xsl:template match="tei:titleStmt" mode="text-header">
banspe726b4a2022-03-28 05:47:45 +0200763 <xsl:param name="compoundID" as="xs:string" tunnel="yes"/>
bansp5f841732022-03-16 06:27:31 +0100764 <titleStmt>
765 <textSigle>
banspe726b4a2022-03-28 05:47:45 +0200766 <xsl:value-of select="$compoundID"/>
bansp5f841732022-03-16 06:27:31 +0100767 </textSigle>
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200768 <xsl:apply-templates mode="text-header"/>
bansp5f841732022-03-16 06:27:31 +0100769 </titleStmt>
770 </xsl:template>
771
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200772 <xsl:template match="tei:publicationStmt" mode="text-header">
bansp9103aab2022-03-19 05:10:21 +0100773 <xsl:element name="{local-name()}">
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200774 <xsl:apply-templates mode="text-header"/>
bansp9103aab2022-03-19 05:10:21 +0100775 </xsl:element>
776 </xsl:template>
777
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200778 <xsl:template match="tei:availability" mode="text-header">
bansp9103aab2022-03-19 05:10:21 +0100779 <xsl:element name="{local-name()}">
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200780 <xsl:apply-templates mode="text-header" select="@* | *"/>
bansp9103aab2022-03-19 05:10:21 +0100781 </xsl:element>
782 </xsl:template>
783
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200784 <xsl:template match="tei:profileDesc" mode="text-header">
bansp9103aab2022-03-19 05:10:21 +0100785 <xsl:element name="{local-name()}">
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200786 <xsl:apply-templates mode="text-header"/>
bansp9103aab2022-03-19 05:10:21 +0100787 </xsl:element>
788 </xsl:template>
bansp5f841732022-03-16 06:27:31 +0100789
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200790 <xsl:template match="tei:textClass" mode="text-header">
bansp9103aab2022-03-19 05:10:21 +0100791 <xsl:element name="{local-name()}">
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200792 <xsl:apply-templates mode="text-header" select="@* | *"/>
bansp9103aab2022-03-19 05:10:21 +0100793 </xsl:element>
794 </xsl:template>
795
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200796 <xsl:template match="tei:catRef" mode="text-header corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100797 <xsl:element name="{local-name()}">
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200798 <xsl:apply-templates mode="text-header" select="@* | *"/>
bansp9103aab2022-03-19 05:10:21 +0100799 </xsl:element>
800 </xsl:template>
801
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200802 <xsl:template match="@status | @scheme | @target | @type | @xml:id[ancestor::tei:classDecl] | @xml:lang" mode="text-header corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100803 <xsl:copy-of select="."/>
804 </xsl:template>
805
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200806 <xsl:template match="tei:p" mode="text-header corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100807 <xsl:element name="{local-name()}">
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200808 <xsl:apply-templates mode="text_inside_header"/>
bansp9103aab2022-03-19 05:10:21 +0100809 </xsl:element>
810 </xsl:template>
811
812
813 <!-- OPTIMIZATION has to take modes into account -->
bansp5e2d1c02022-03-10 04:51:40 +0100814 <!-- ************************** CORPUS header ******************* -->
815 <xsl:template name="create_corpus_header">
Piotr Banskifaa910f2022-06-03 00:46:29 +0200816 <xsl:param name="text.doc" as="document-node()"/>
bansp5f841732022-03-16 06:27:31 +0100817 <xsl:param name="target" as="xs:string"/>
bansp5e2d1c02022-03-10 04:51:40 +0100818
819 <!-- create the corpus-level header.xml file -->
bansp5f841732022-03-16 06:27:31 +0100820 <xsl:result-document encoding="UTF-8" method="xml" indent="yes" href="{$target}">
bansp5e2d1c02022-03-10 04:51:40 +0100821
822 <!--doctype-public="{$publicDoctypeI5}"
823 doctype-system="{$systemDoctypeI5}">
824 these are, sadly, useless
825 -->
826
827 <idsHeader type="corpus" pattern="text" status="new" version="1.1" TEIform="teiHeader">
Piotr Banskifaa910f2022-06-03 00:46:29 +0200828 <xsl:apply-templates select="$text.doc/tei:teiCorpus/tei:teiHeader/tei:*" mode="corpus-header"/>
bansp5e2d1c02022-03-10 04:51:40 +0100829 </idsHeader>
830 </xsl:result-document>
831 </xsl:template>
832
Piotr Banskifaa910f2022-06-03 00:46:29 +0200833 <xsl:template match="tei:fileDesc" mode="corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100834 <xsl:element name="{local-name()}">
Piotr Banskifaa910f2022-06-03 00:46:29 +0200835 <xsl:apply-templates mode="corpus-header"/>
bansp9103aab2022-03-19 05:10:21 +0100836 </xsl:element>
bansp5e2d1c02022-03-10 04:51:40 +0100837 </xsl:template>
bansp9103aab2022-03-19 05:10:21 +0100838
bansp5e2d1c02022-03-10 04:51:40 +0100839
Piotr Banskifaa910f2022-06-03 00:46:29 +0200840 <xsl:template match="tei:title" mode="corpus-header">
bansp5e2d1c02022-03-10 04:51:40 +0100841 <c.title>
Piotr Banskifaa910f2022-06-03 00:46:29 +0200842 <xsl:apply-templates mode="corpus-header" select="@*"/>
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200843 <xsl:apply-templates mode="text_inside_header"/>
bansp5e2d1c02022-03-10 04:51:40 +0100844 </c.title>
845 </xsl:template>
846
Piotr Banskifaa910f2022-06-03 00:46:29 +0200847 <xsl:template match="tei:titleStmt" mode="corpus-header">
bansp5e2d1c02022-03-10 04:51:40 +0100848 <titleStmt>
849 <korpusSigle>
850 <xsl:value-of select="$corpusID"/>
851 </korpusSigle>
Piotr Banskifaa910f2022-06-03 00:46:29 +0200852 <xsl:apply-templates mode="corpus-header"/>
bansp5e2d1c02022-03-10 04:51:40 +0100853 </titleStmt>
854 </xsl:template>
855
Piotr Banskifaa910f2022-06-03 00:46:29 +0200856 <xsl:template match="tei:publicationStmt" mode="corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100857 <xsl:element name="{local-name()}">
Piotr Banskifaa910f2022-06-03 00:46:29 +0200858 <xsl:apply-templates mode="corpus-header"/>
bansp9103aab2022-03-19 05:10:21 +0100859 </xsl:element>
860 </xsl:template>
861
Piotr Banskifaa910f2022-06-03 00:46:29 +0200862 <xsl:template match="tei:availability" mode="corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100863 <xsl:element name="{local-name()}">
Piotr Banskifaa910f2022-06-03 00:46:29 +0200864 <xsl:apply-templates mode="corpus-header" select="@* | *"/>
bansp9103aab2022-03-19 05:10:21 +0100865 </xsl:element>
866 </xsl:template>
867
Piotr Banskifaa910f2022-06-03 00:46:29 +0200868 <xsl:template match="tei:encodingDesc" mode="corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100869 <xsl:element name="{local-name()}">
Piotr Banskifaa910f2022-06-03 00:46:29 +0200870 <xsl:apply-templates mode="corpus-header"/>
bansp9103aab2022-03-19 05:10:21 +0100871 </xsl:element>
872 </xsl:template>
873
Piotr Banskifaa910f2022-06-03 00:46:29 +0200874 <xsl:template match="tei:classDecl | tei:taxonomy | tei:category | tei:taxonomy/tei:bibl" mode="corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100875 <xsl:element name="{local-name()}">
Piotr Banskifaa910f2022-06-03 00:46:29 +0200876 <xsl:apply-templates mode="corpus-header" select="@* | *"/>
bansp9103aab2022-03-19 05:10:21 +0100877 </xsl:element>
878 </xsl:template>
879
Piotr Banskifaa910f2022-06-03 00:46:29 +0200880 <xsl:template match="tei:bibl/tei:title | tei:edition | tei:desc" mode="corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100881 <xsl:element name="{local-name()}">
Piotr Banskifaa910f2022-06-03 00:46:29 +0200882 <xsl:apply-templates mode="corpus-header" select="@*"/>
Piotr Banskia0a9fc02022-06-03 01:20:18 +0200883 <xsl:apply-templates mode="text_inside_header"/>
bansp9103aab2022-03-19 05:10:21 +0100884 </xsl:element>
885 </xsl:template>
886<!--
Piotr Banskifaa910f2022-06-03 00:46:29 +0200887 <xsl:template match="tei:textClass" mode="corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100888 <xsl:element name="{local-name()}">
889 <xsl:apply-templates mode="corpus" select="@* | *"/>
890 </xsl:element>
891 </xsl:template>
892
Piotr Banskifaa910f2022-06-03 00:46:29 +0200893 <xsl:template match="tei:catRef" mode="corpus-header">
bansp9103aab2022-03-19 05:10:21 +0100894 <xsl:element name="{local-name()}">
895 <xsl:apply-templates mode="corpus" select="@* | *"/>
896 </xsl:element>
897 </xsl:template>
898-->
bansp5e2d1c02022-03-10 04:51:40 +0100899
900
901
902 <!-- this template can be called by the XSPEC test; TODO: find a way to call the main() template directly -->
903 <!-- I have not fully handled the param transmission, which would have to be kludged in just for the sake of XSPec,
904 because I'm disabling this for now, due to XSpec design issues; relevant links, a.o.:
905
906 https://stackoverflow.com/questions/64933277/what-is-the-cause-of-error-cannot-execute-xslresult-document-while-evaluating
907 https://www.balisage.net/Proceedings/vol25/html/Galtman01/BalisageVol25-Galtman01.html
908
909 In short: the internal design of XSpec forces kludges when one wants to use xsl:result-document in their stylesheets. But I don't
910 want to be strangled by kludges at the beginning of work, I've already lost quite a bit of time on this investigation,
911 I will therefore "just code" and then can think of externalizing bits of templates if we want to play with tests. For now,
912 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.
913
914 -->
915 <!--<xsl:template name="test_full">
916 <xsl:param name="corpusID"/>
917 <xsl:param name="docID"/>
918 <xsl:param name="textID"/>
919 <xsl:call-template name="xsl:initial-template"/>
920 </xsl:template>-->
921
Akron9a8ee3e2022-01-31 13:51:49 +0100922</xsl:stylesheet>
Piotr Banski6a4a2522022-05-24 01:16:47 +0200923
Piotr Banskifdc858a2022-05-25 02:40:32 +0200924<!-- template for serializing maps in messages <xsl:message select="('map:',serialize($map, map{'method':'adaptive'}))"/> -->