blob: 23f452a503270dbeb230cc787b935b83e8574606 [file] [log] [blame]
Marc Kupietz1a422662024-03-16 09:34:10 +01001<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
2 xmlns:xs="http://www.w3.org/2001/XMLSchema"
3 xmlns:opf="http://www.idpf.org/2007/opf"
4 xmlns:dc="http://purl.org/dc/elements/1.1/"
5 xmlns:ids="http://www.ids-mannheim.de/ids"
6 xmlns:hlu="http://www.ids-mannheim.de/hlu"
7 xmlns:saxon="http://saxon.sf.net/"
8 xmlns:xhtml="http://www.w3.org/1999/xhtml"
Marc Kupietz10903f32024-04-14 14:21:18 +02009 xmlns:map="http://www.w3.org/2005/xpath-functions/map"
10 exclude-result-prefixes="xs opf dc ids hlu map saxon xhtml">
Marc Kupietz1a422662024-03-16 09:34:10 +010011
12 <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" saxon:line-length="1000"/>
13 <xsl:strip-space elements="*"/>
14
15 <xsl:variable name="ev"/>
16 <xsl:variable name="x"/>
17
18 <xsl:variable name="isbn" as="xs:string" select="replace(document-uri(), '.*([0-9]{13,}).*' , '$1')"/>
19
20
21 <xsl:variable name="dnbBookdata">
22 <xsl:copy-of select="doc(concat('https://services.dnb.de/sru/dnb?version=1.1&amp;operation=searchRetrieve&amp;query=NUM%3D', $isbn, '&amp;recordSchema=oai_dc'))"/>
23 </xsl:variable>
24
25 <xsl:variable name="autor"
Marc Kupietzea387372024-04-10 16:34:57 +020026 select="replace(string-join($dnbBookdata//dc:creator[not(matches(., '\[(Erzähler)\]'))], ' ; '), ' *\[[^\]]*\]', '')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010027
Marc Kupietzb660ed62024-03-16 11:45:53 +010028 <xsl:variable name="straight_autor" select="normalize-space(replace(hlu:reversedAuthors($autor), ',', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010029
30 <xsl:variable name="ina"/>
31 <xsl:variable name="_corpus"/>
32 <xsl:variable name="ent_known"/>
33
34
35 <!-- added HLU 2012-02-09: -->
36 <xsl:variable name="ent">
37 <xsl:choose>
38 <xsl:when test="$ent_known">
39 <xsl:value-of select="$ent_known"/>
40 </xsl:when>
41 <xsl:when test="$ev">
42 <xsl:value-of select="$ev"/>
43 </xsl:when>
44 <xsl:otherwise>
45 <xsl:value-of select="$j"/>
46 </xsl:otherwise>
47 </xsl:choose>
48 </xsl:variable>
49
50 <xsl:variable name="titel">
Marc Kupietz49124fa2024-04-10 16:50:01 +020051 <xsl:variable name="title-with-subtitles">
52 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +020053 <xsl:when test="contains(($dnbBookdata//dc:title)[1],':')">
54 <xsl:value-of select="normalize-space(substring-before(substring-before(($dnbBookdata//dc:title)[1], '/'), ':'))"
Marc Kupietz49124fa2024-04-10 16:50:01 +020055 />
56 </xsl:when>
57 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +020058 <xsl:value-of select="normalize-space(substring-before(($dnbBookdata//dc:title)[1], '/'))"/>
Marc Kupietz49124fa2024-04-10 16:50:01 +020059 </xsl:otherwise>
60 </xsl:choose>
61 </xsl:variable>
62 <xsl:value-of select="normalize-space(replace($title-with-subtitles, '\|.*', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010063 </xsl:variable>
64
65 <xsl:variable name="erscheinungsort">
66 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +020067 <xsl:when test="contains(($dnbBookdata//dc:publisher)[1], ':')">
68 <xsl:value-of select="normalize-space(substring-before(($dnbBookdata//dc:publisher)[1], ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010069 </xsl:when>
70 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +020071 <xsl:value-of select="normalize-space(($dnbBookdata//dc:publisher)[1])"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010072 </xsl:otherwise>
73 </xsl:choose>
74 </xsl:variable>
75
Marc Kupietzd8599fc2024-04-14 13:16:56 +020076 <xsl:variable name="erscheinungsland" select="ids:country-city($erscheinungsort)"/>
77
Marc Kupietz6cb52232024-04-13 12:28:44 +020078 <xsl:variable name="texttype" select="replace(($dnbBookdata//dc:subject[matches(., '^[A-Z] ')])[1], '^[A-Z] (.*)', '$1')"/>
Marc Kupietz7df4ccc2024-03-16 15:27:45 +010079
Marc Kupietz1a422662024-03-16 09:34:10 +010080 <xsl:variable name="verlag">
81 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +020082 <xsl:when test="contains(($dnbBookdata//dc:publisher)[1], ':')">
83 <xsl:value-of select="normalize-space(substring-after(($dnbBookdata//dc:publisher)[1], ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010084 </xsl:when>
85 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +020086 <xsl:value-of select="normalize-space(($dnbBookdata//dc:publisher)[1])"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010087 </xsl:otherwise>
88 </xsl:choose>
89 </xsl:variable>
90
91 <xsl:variable name="erscheinungsjahr">
Marc Kupietza5d01182024-04-14 12:24:02 +020092 <xsl:value-of select="replace(($dnbBookdata//dc:date)[1], '.*?((19|20)[0-9][0-9]).*', '$1')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010093 </xsl:variable>
94
95 <xsl:variable name="untertitel"
Marc Kupietz6cb52232024-04-13 12:28:44 +020096 select="normalize-space(substring-after(substring-before(($dnbBookdata//dc:title)[1], '/'), ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010097
98 <xsl:variable name="herausgeber">
99 <xsl:choose>
100 <xsl:when test="$dnbBookdata//dc:creator[ends-with(.,'[Hrsg.]')]">
101 <xsl:value-of
Marc Kupietz6cb52232024-04-13 12:28:44 +0200102 select="replace(string-join($dnbBookdata//dc:creator[ends-with(.,'[Hrsg.]')][1], ' ; '),'\s?\[Hrsg.\]','')"
Marc Kupietz1a422662024-03-16 09:34:10 +0100103 />
104 </xsl:when>
105 <xsl:otherwise>.</xsl:otherwise>
106 </xsl:choose>
107 </xsl:variable>
108
109 <xsl:variable name="straight_herausgeber"
110 select="replace(hlu:reversedAuthors($herausgeber), ',', '')"/>
111
Marc Kupietza5d01182024-04-14 12:24:02 +0200112 <xsl:variable name="j" select="$erscheinungsjahr"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100113
114 <!-- for BOT+s: -->
115 <xsl:variable name="seiten" select="replace($dnbBookdata//dc:format,'S\.','')"/>
116
117 <!-- fuer BOT+b: -->
118 <xsl:variable name="_b">
119 <xsl:variable name="regexp1" select="'(Band|Bd\.)\s*([0-9]?[0-9]?[0-9])'"/>
120 <xsl:choose>
121 <xsl:when test="matches($dnbBookdata, $regexp1)">
122 <xsl:analyze-string select="$dnbBookdata//dc:title" regex="{$regexp1}">
123 <xsl:matching-substring>
124 <xsl:value-of select="."/>
125 </xsl:matching-substring>
126 </xsl:analyze-string>
127 </xsl:when>
128 <xsl:otherwise>
129 <xsl:value-of select="'.'"/>
130 </xsl:otherwise>
131 </xsl:choose>
132 </xsl:variable>
133
134 <!-- for BOT+x: -->
135 <xsl:variable name="txtart">
136 <xsl:choose>
137 <xsl:when test="$x">
138 <xsl:value-of select="concat('[', $x, ']')"/>
139 </xsl:when>
140 <xsl:when
141 test="matches($untertitel, '([Rr]oman|[Ee]rzhlung(en)?|[Aa]nthologie|[Gg]eschichte(n)?|[Nn]ovelle)')">
142 <xsl:value-of
143 select="concat('[', replace(replace($untertitel, '.*?(((^|\P{L})\p{L}+)?([Rr]oman|[Ee]rzhlung(en)?|[Aa]nthologie|[Gg]eschichte(n)?|[Nn]ovelle)).*', '$1'), '\P{L}*(.+)', '$1'), ']')"
144 />
145 </xsl:when>
146 <xsl:otherwise>
147 <xsl:value-of>Roman</xsl:value-of>
148 </xsl:otherwise>
149 </xsl:choose>
150 </xsl:variable>
151
152
153
154 <!-- fuer BOTd: -->
155 <xsl:variable name="dok"
156 select="concat((if(string-length($autor) &gt; 0) then concat($straight_autor, ': ') else ''), $titel, ', ', $txtart, ', (', $j, ')')"/>
157
158 <!-- END variables derived from sru request to dnb archive -->
159
160
Marc Kupietz94bbe6b2024-04-10 20:35:48 +0200161 <xsl:variable name="corpus_sigle" select="concat('DNB', substring($erscheinungsjahr, 3, 2))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100162
163 <!-- for BOTD: -->
164 <!-- Dokumentsigle muss zusammen mit Korpussigle (z.B DIV fuer loz-div und loz-div-pub) eindeutig sein -->
165 <xsl:variable name="doc_sigle">
166 <xsl:variable name="firstContentWordTitleInitial">
167 <xsl:variable name="helper">
168 <xsl:analyze-string select="$titel" regex="\w+">
169 <xsl:matching-substring>
170 <xsl:choose>
171 <xsl:when
172 test="matches(.,'^[A-Z]') and not(matches(.,'^(Der|Die|Das|Des|Ein|Eine|Eines|Einmal|Von|Mit|Zu|Zurck)$'))">
173 <!-- TODO: Fktnswoerter nachtragen -->
174 <xsl:sequence select="."/>
175 </xsl:when>
176 <xsl:otherwise/>
177 </xsl:choose>
178 </xsl:matching-substring>
179 </xsl:analyze-string>
180 </xsl:variable>
181 <xsl:value-of
182 select="upper-case(substring(normalize-space(replace($helper,'\s+.+$','')),1,1))"/>
183 <!-- longest match of .+ -->
184 </xsl:variable>
185 <xsl:choose>
186 <xsl:when test="contains($autor,';')">
187 <xsl:variable name="lastname_aut1"
188 select="upper-case(substring(normalize-space(substring-before(substring-before($autor,';'),',')), 1, 1))"/>
189 <xsl:variable name="lastname_aut2"
190 select="upper-case(substring(normalize-space(substring-before(substring-before(substring-after($autor, ';'),';'),',')), 1, 1))"/>
191 <xsl:value-of select="concat($lastname_aut1, $lastname_aut2)"/>
192 </xsl:when>
193 <xsl:otherwise>
194 <xsl:variable name="lastname_aut1"
195 select="upper-case(substring(normalize-space(substring-before($autor,',')),1,1))"/>
196 <xsl:variable name="firstname_aut1"
197 select="upper-case(substring(normalize-space(substring-after($autor,',')),1,1))"/>
198 <xsl:value-of select="concat($lastname_aut1, $firstname_aut1)"/>
199 </xsl:otherwise>
200 </xsl:choose>
201 <xsl:value-of select="$firstContentWordTitleInitial"/>
202 </xsl:variable>
203
204
205 <xsl:variable name="text_sigle" select="substring($isbn, 8, 5)"/>
206 <xsl:variable name="sigle" select="concat($corpus_sigle, '/', $doc_sigle, '.', $text_sigle)"/>
207
208 <!-- fuer BOT+xy: (?) -->
209 <xsl:variable name="xyref">
210 <xsl:value-of select="document-uri(.)"/>
211 <xsl:text>; </xsl:text>
212 <xsl:text>ISBN:</xsl:text>
213 <xsl:value-of select="$isbn"/>
214 <xsl:text>; </xsl:text>
215 <xsl:value-of select="string-join($dnbBookdata//dc:identifier)"/>
216 </xsl:variable>
217
Marc Kupietzb660ed62024-03-16 11:45:53 +0100218 <xsl:variable name="long-reference"
219 select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/>
220
221 <xsl:variable name="short-reference"
222 select="concat($straight_autor, ': ', $titel, ' (', $erscheinungsjahr, ')')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100223
224 <xsl:template match="/">
225 <idsDoc TEIform="TEI.2" type="text" version="1.0">
226 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="document" version="1.1">
227 <fileDesc>
228 <titleStmt>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100229 <dokumentSigle><xsl:value-of select="string-join(($corpus_sigle, $doc_sigle), '/')"/></dokumentSigle>
230 <d.title><xsl:value-of select="$short-reference"/></d.title>
Marc Kupietz1a422662024-03-16 09:34:10 +0100231 </titleStmt>
232 <publicationStmt>
233 <distributor/>
234 <pubAddress/>
235 <availability region="world" status="unknown">QAO-NC</availability>
236 <pubDate/>
237 </publicationStmt>
238 <sourceDesc>
239 <biblStruct>
240 <monogr>
241 <h.title type="main"/>
242 <imprint/>
243 </monogr>
244 </biblStruct>
245 </sourceDesc>
246 </fileDesc>
247 </idsHeader>
248 <idsText version="1.0">
249 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="text" version="1.1">
250 <fileDesc>
251 <titleStmt>
252 <textSigle><xsl:sequence select="$sigle"/></textSigle>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100253 <t.title assemblage="regular"><xsl:value-of select="$long-reference"/></t.title>
Marc Kupietz1a422662024-03-16 09:34:10 +0100254 </titleStmt>
255 <publicationStmt>
256 <distributor/>
257 <pubAddress/>
258 <availability region="world" status="unknown">QAO-NC</availability>
259 <pubDate/>
260 </publicationStmt>
261 <sourceDesc>
262 <biblStruct>
263 <monogr>
264 <h.title type="main"><xsl:value-of select="$titel"/></h.title>
265 <h.title type="sub"><xsl:value-of select="$untertitel"/></h.title>
266 <h.author><xsl:value-of select="$autor"/></h.author>
267 <editor/>
268 <edition>
269 <further/>
270 <kind>E-Book-Ausgabe</kind>
271 <appearance>EPUB-Datei</appearance>
272 </edition>
273 <imprint>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100274 <publisher><xsl:value-of select="$verlag"/></publisher>
Marc Kupietz1a422662024-03-16 09:34:10 +0100275 <pubDate type="year"><xsl:value-of select="$j"/></pubDate>
276 <pubDate type="month"/>
277 <pubDate type="day"/>
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200278 <pubPlace key="{$erscheinungsland}"><xsl:value-of select="$erscheinungsort"/></pubPlace>
Marc Kupietz1a422662024-03-16 09:34:10 +0100279 </imprint>
280 <biblScope type="subsume"/>
281 <biblScope type="pp"/>
282 <biblScope type="vol"/>
283 <biblScope type="volume-title"/>
284 </monogr>
285 </biblStruct>
286 <reference assemblage="regular" type="complete"><xsl:value-of select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/></reference>
Marc Kupietz1a422662024-03-16 09:34:10 +0100287 </sourceDesc>
288 </fileDesc>
289 <profileDesc>
290 <creation>
291 <creatDate><xsl:value-of select="$j"/></creatDate>
292 </creation>
293 <textClass/>
294 <textDesc>
Marc Kupietz7df4ccc2024-03-16 15:27:45 +0100295 <textType><xsl:value-of select="$texttype"/></textType>
296 <textTypeRef><xsl:value-of select="$texttype"/></textTypeRef>
Marc Kupietz1a422662024-03-16 09:34:10 +0100297 <textDomain/>
298 </textDesc>
299 </profileDesc>
300 </idsHeader>
301 <text>
302 <body>
303 <!-- Call the template for each link in the TOC
304 <xsl:apply-templates select="//xhtml:ol[@class='toc']/xhtml:li/xhtml:a" mode="collect"/> -->
Marc Kupietz8f727302024-04-10 16:31:19 +0200305 <xsl:apply-templates select="//opf:package/opf:manifest/opf:item[matches(@href, '\.x?html$') and not(matches(@href, '(cover|toc|copyright|feedback|inhalt|nav|titlepage).*'))]" mode="collect"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100306 </body>
307 </text>
308 </idsText>
309 </idsDoc>
310 </xsl:template>
311
312 <xsl:template match="opf:item" mode="collect">
313 <xsl:variable name="href" select="@href"/>
314 <xsl:message>
315 <xsl:text>converting: </xsl:text><xsl:value-of select="$href"/><xsl:text> </xsl:text><xsl:value-of select="$isbn"/>
316 </xsl:message>
317 <xsl:apply-templates select="doc(resolve-uri($href, base-uri()))/xhtml:html/xhtml:body"/>
318 </xsl:template>
319
320 <xsl:template match="xhtml:body">
321 <div type="chapter">
322 <xsl:apply-templates/>
323 </div>
324 </xsl:template>
325
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000326 <xsl:template match="xhtml:body/text()">
327 <p>
328 <xsl:value-of select="."/>
329 </p>
330 </xsl:template>
331
Marc Kupietz1a422662024-03-16 09:34:10 +0100332 <xsl:template match="xhtml:title">
333 <head>
334 <xsl:apply-templates/>
335 </head>
336 </xsl:template>
337
338 <xsl:template match="xhtml:h1">
339 <head>
340 <xsl:apply-templates/>
341 </head>
342 </xsl:template>
343
344 <xsl:template match="xhtml:h2|xhtml:h3">
345 <head type="sub">
346 <xsl:apply-templates/>
347 </head>
348 </xsl:template>
349
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100350 <xsl:template match="xhtml:em">
351 <emph>
352 <xsl:apply-templates/>
353 </emph>
354 </xsl:template>
Marc Kupietz1a422662024-03-16 09:34:10 +0100355
Marc Kupietz30cc0802024-04-10 16:37:04 +0200356 <xsl:template match="xhtml:span[matches(@class, '(bold|italic|big|kursiv| )+')]">
357 <xsl:variable name="class" select="replace(@class, 'kursiv', 'italic')"/>
358 <hi rend="{$class}">
359 <xsl:apply-templates/>
360 </hi>
361 </xsl:template>
362
363 <xsl:template match="xhtml:b">
364 <hi rend="bold">
Marc Kupietz1a422662024-03-16 09:34:10 +0100365 <xsl:apply-templates/>
366 </hi>
367 </xsl:template>
368
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000369 <xsl:template match="xhtml:i">
370 <hi rend="italic">
371 <xsl:apply-templates/>
372 </hi>
373 </xsl:template>
374
375
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100376 <xsl:template match="xhtml:sub|xhtml:span[@class='sub']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100377 <hi rend="sub">
378 <xsl:apply-templates/>
379 </hi>
380 </xsl:template>
381
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100382 <xsl:template match="xhtml:sup|xhtml:span[@class='sup']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100383 <hi rend="sup">
384 <xsl:apply-templates/>
385 </hi>
386 </xsl:template>
387
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000388 <xsl:template match="xhtml:div[not(normalize-space(replace(., '&#160;', ' ')))]" priority="1.0"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100389
Marc Kupietzbf47ae72024-04-14 14:21:43 +0200390 <xsl:template match="xhtml:body/xhtml:div[./xhtml:h1|./xhtml:h2|./xhtml:h3]" priority="1.0">
391 <xsl:apply-templates/>
392 </xsl:template>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000393 <xsl:template match="xhtml:div/xhtml:div">
Marc Kupietz1a422662024-03-16 09:34:10 +0100394 <p>
395 <xsl:apply-templates/>
396 </p>
397 </xsl:template>
398
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000399 <xsl:template match="xhtml:body/xhtml:div[(descendant::xhtml:p|descendant::xhtml:div)]">
400 <div type="section">
401 <xsl:apply-templates/>
402 </div>
403 </xsl:template>
404
405 <xsl:template match="xhtml:body/xhtml:div[not(descendant::xhtml:p|descendant::xhtml:div)]">
406 <div type="section">
407 <p>
408 <xsl:apply-templates/>
409 </p>
410 </div>
411 </xsl:template>
412
413 <xsl:template match="xhtml:p[not(descendant::xhtml:p|descendant::xhtml:div)]">
414 <xsl:if test="normalize-space(.)">
415 <p>
416 <xsl:apply-templates/>
417 </p>
418 </xsl:if>
419 </xsl:template>
420
421 <xsl:template match="xhtml:p[descendant::xhtml:p|descendant::xhtml:div]">
422 <xsl:if test="normalize-space(.)">
423 <div type="section">
424 <xsl:apply-templates/>
425 </div>
426 </xsl:if>
427 </xsl:template>
428
429 <xsl:template match="xhtml:nav">
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200430 <!-- <gap reason="toc"/> -->
431 </xsl:template>
432
Marc Kupietz1a422662024-03-16 09:34:10 +0100433 <xsl:template match="xhtml:img">
434 <!-- <gap reason="image"/> -->
435 </xsl:template>
436
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200437 <xsl:template match="xhtml:audio">
438 <!-- <gap reason="audio"/> -->
439 </xsl:template>
440
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000441 <xsl:template match="xhtml:body/xhtml:a">
442 <p>
443 <ref target="{@href}">
444 <xsl:apply-templates />
445 </ref>
446 </p>
447 </xsl:template>
448
449 <xsl:template match="xhtml:body/xhtml:span">
450 <xsl:message>
451 <xsl:text>unhandled span element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
452 </xsl:message>
453 <div type="section">
454 <p>
455 <xsl:value-of select="."/>
456 </p>
457 </div>
458 </xsl:template>
459 <xsl:template match="xhtml:span">
460 <xsl:message>
461 <xsl:text>unhandled span element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
462 </xsl:message>
463 <xsl:value-of select="."/>
464 </xsl:template>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100465 <xsl:template match="xhtml:a">
466 <ref target="{@href}">
467 <xsl:apply-templates />
468 </ref>
469 </xsl:template>
470
471 <xsl:template match="xhtml:br"/>
472
Marc Kupietz1a422662024-03-16 09:34:10 +0100473 <xsl:template match="xhtml:*">
474 <xsl:message>
475 <xsl:text>unhandled element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
476 </xsl:message>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000477 <xsl:choose>
478 <xsl:when test="descendant::xhtml:div|descendant::xhtml:p|parent::xhtml:body">
479 <div type="section">
480 <xsl:apply-templates/>
481 </div>
482 </xsl:when>
483 <xsl:otherwise>
484 <xsl:apply-templates select="./*|node()"/>
485 </xsl:otherwise>
486 </xsl:choose>
Marc Kupietz1a422662024-03-16 09:34:10 +0100487 <xsl:apply-templates/>
488 </xsl:template>
489
490 <xsl:function name="ids:reversedAuthors">
491 <xsl:param name="s" />
492 <xsl:value-of
493 select="
494 if (matches($s, ';')) then
495 concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; ')))
496 else
497 replace($s, '(.+) (.+)', '$2, $1')"
498 />
499 </xsl:function>
500
501 <xsl:function name="hlu:reversedAuthors">
502 <xsl:param name="s"/>
503 <xsl:value-of
504 select="if (matches($s, ';')) then concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; '))) else replace($s, '(.+),(.+)', '$2, $1')"
505 />
506 </xsl:function>
507
Marc Kupietz10903f32024-04-14 14:21:18 +0200508 <xsl:variable name="city-country-map" as="map(xs:string, xs:string)">
509 <xsl:map>
510 <xsl:map-entry key="'Axams'" select="'AT'"/>
511 <xsl:map-entry key="'Vienna'" select="'AT'"/>
512 <xsl:map-entry key="'Klagenfurt'" select="'AT'"/>
513 <xsl:map-entry key="'Graz'" select="'AT'"/>
514 <xsl:map-entry key="'Innsbruck'" select="'AT'"/>
515 <xsl:map-entry key="'Salzburg'" select="'AT'"/>
516 <xsl:map-entry key="'Bern'" select="'CH'"/>
517 <xsl:map-entry key="'Biel/Bienne'" select="'CH'"/>
518 <xsl:map-entry key="'Zurich'" select="'CH'"/>
519 <xsl:map-entry key="'Basel'" select="'CH'"/>
520 <xsl:map-entry key="'Geneva'" select="'CH'"/>
521 <xsl:map-entry key="'Lucerne'" select="'CH'"/>
522 <xsl:map-entry key="'Lausanne'" select="'CH'"/>
523 <xsl:map-entry key="'Winterthur'" select="'CH'"/>
524 <xsl:map-entry key="'St. Gallen'" select="'CH'"/>
525 <xsl:map-entry key="'Interlaken'" select="'CH'"/>
526 <xsl:map-entry key="'Brussels'" select="'BE'"/>
527 <xsl:map-entry key="'Antwerp'" select="'BE'"/>
528 <xsl:map-entry key="'Ghent'" select="'BE'"/>
529 <xsl:map-entry key="'Bruges'" select="'BE'"/>
530 <xsl:map-entry key="'Leuven'" select="'BE'"/>
531 <xsl:map-entry key="'Liege'" select="'BE'"/>
532 <xsl:map-entry key="'Charleroi'" select="'BE'"/>
533 <xsl:map-entry key="'Namur'" select="'BE'"/>
534 <xsl:map-entry key="'Mons'" select="'BE'"/>
535 <xsl:map-entry key="'Bangkok'" select="'TH'"/>
536 <xsl:map-entry key="'Copenhagen'" select="'DK'"/>
537 <xsl:map-entry key="'colatina'" select="'BR'"/>
538 <xsl:map-entry key="'Oakland Park'" select="'US'"/>
539 <xsl:map-entry key="'Istanbul'" select="'TR'"/>
540 <xsl:map-entry key="'Luxemburg'" select="'LU'"/>
541 <xsl:map-entry key="'Palma de Mallorca'" select="'ES'"/>
542 <xsl:map-entry key="'Swakopmund'" select="'NA'"/>
543 <xsl:map-entry key="'Victoria'" select="'CA'"/>
544 <xsl:map-entry key="'Wien'" select="'AT'"/>
545 <xsl:map-entry key="'Windhoek'" select="'NA'"/>
546 <xsl:map-entry key="'Zuerich'" select="'CH'"/>
547 <xsl:map-entry key="'Zürich'" select="'CH'"/>
548 <xsl:map-entry key="'Zug'" select="'CH'"/>
549 <xsl:map-entry key="'ZÜRICH'" select="'CH'"/>
550 </xsl:map>
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200551
Marc Kupietz10903f32024-04-14 14:21:18 +0200552 </xsl:variable>
553
554 <!-- Define the function -->
555 <xsl:function name="ids:country-city" as="xs:string">
556 <xsl:param name="city" as="xs:string"/>
557 <xsl:sequence select="if (map:contains($city-country-map, $city)) then map:get($city-country-map, $city) else 'DE'"/>
558 </xsl:function>
Marc Kupietz1a422662024-03-16 09:34:10 +0100559</xsl:stylesheet>