blob: 518aca9f337a1aa361d29297f8e7b0c1021ecde9 [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
Marc Kupietzea684b82024-04-19 11:13:50 +020018 <xsl:variable name="isbn" as="xs:string" select="replace(document-uri(), '.*/([0-9]{9,13}X?).*' , '$1')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010019
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
Marc Kupietzad1f3b82024-04-19 19:21:49 +0200172 test="matches(.,'^[A-Z]') and not(matches(.,'^(Der|Die|Das|Des|Ein|Eine|Eines|Einmal|Von|Mit|Zu|Zur)$'))">
Marc Kupietz1a422662024-03-16 09:34:10 +0100173 <!-- 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"
Marc Kupietzd70fe262024-04-19 20:55:48 +0200188 select="upper-case(substring(normalize-space($autor),1,1))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100189 <xsl:variable name="lastname_aut2"
Marc Kupietzd70fe262024-04-19 20:55:48 +0200190 select="replace($autor, '.*?;.*?([A-Z]).*', '$1')"/>
191 <xsl:value-of select="concat($lastname_aut1, $lastname_aut2)"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100192 </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
Marc Kupietz568240f2024-04-19 19:20:55 +0200205 <xsl:variable name="text_sigle" select="replace($isbn, '.*([0-9]{5})[0-9X]$', '$1')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100206 <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="/">
Marc Kupietzb7a4f6c2024-04-19 11:35:25 +0200225 <xsl:if test="not($j)">
226 <xsl:message terminate="yes">ERROR: No dc:date found for ISBN: <xsl:value-of select="$isbn"/></xsl:message>
227 </xsl:if>
228
Marc Kupietz815cc6c2024-04-19 12:44:44 +0200229 <xsl:if test="not(normalize-space($titel))">
230 <xsl:message terminate="yes">ERROR: No title found for ISBN: <xsl:value-of select="$isbn"/></xsl:message>
231 </xsl:if>
232
Marc Kupietz2badfb12024-04-19 12:59:40 +0200233 <xsl:if test="not(normalize-space($autor))">
234 <xsl:message terminate="yes">ERROR: No author found for ISBN: <xsl:value-of select="$isbn"/></xsl:message>
235 </xsl:if>
236
Marc Kupietz09745e12024-04-21 12:54:10 +0200237 <xsl:if test="not(matches($sigle, '^[A-Z]{3}[0-9]{2}/[A-Z]{3}\.[0-9]{5}$'))">
238 <xsl:message terminate="yes">ERROR: Strange sigle »<xsl:value-of select="$sigle"/>« for ISBN: <xsl:value-of select="$isbn"/></xsl:message>
239 </xsl:if>
240
Marc Kupietz1a422662024-03-16 09:34:10 +0100241 <idsDoc TEIform="TEI.2" type="text" version="1.0">
242 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="document" version="1.1">
243 <fileDesc>
244 <titleStmt>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100245 <dokumentSigle><xsl:value-of select="string-join(($corpus_sigle, $doc_sigle), '/')"/></dokumentSigle>
246 <d.title><xsl:value-of select="$short-reference"/></d.title>
Marc Kupietz1a422662024-03-16 09:34:10 +0100247 </titleStmt>
248 <publicationStmt>
249 <distributor/>
250 <pubAddress/>
251 <availability region="world" status="unknown">QAO-NC</availability>
252 <pubDate/>
253 </publicationStmt>
254 <sourceDesc>
255 <biblStruct>
256 <monogr>
257 <h.title type="main"/>
258 <imprint/>
259 </monogr>
260 </biblStruct>
261 </sourceDesc>
262 </fileDesc>
263 </idsHeader>
264 <idsText version="1.0">
265 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="text" version="1.1">
266 <fileDesc>
267 <titleStmt>
268 <textSigle><xsl:sequence select="$sigle"/></textSigle>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100269 <t.title assemblage="regular"><xsl:value-of select="$long-reference"/></t.title>
Marc Kupietz1a422662024-03-16 09:34:10 +0100270 </titleStmt>
271 <publicationStmt>
272 <distributor/>
273 <pubAddress/>
274 <availability region="world" status="unknown">QAO-NC</availability>
275 <pubDate/>
276 </publicationStmt>
277 <sourceDesc>
278 <biblStruct>
279 <monogr>
280 <h.title type="main"><xsl:value-of select="$titel"/></h.title>
281 <h.title type="sub"><xsl:value-of select="$untertitel"/></h.title>
282 <h.author><xsl:value-of select="$autor"/></h.author>
283 <editor/>
284 <edition>
285 <further/>
286 <kind>E-Book-Ausgabe</kind>
287 <appearance>EPUB-Datei</appearance>
288 </edition>
289 <imprint>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100290 <publisher><xsl:value-of select="$verlag"/></publisher>
Marc Kupietz1a422662024-03-16 09:34:10 +0100291 <pubDate type="year"><xsl:value-of select="$j"/></pubDate>
292 <pubDate type="month"/>
293 <pubDate type="day"/>
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200294 <pubPlace key="{$erscheinungsland}"><xsl:value-of select="$erscheinungsort"/></pubPlace>
Marc Kupietz1a422662024-03-16 09:34:10 +0100295 </imprint>
296 <biblScope type="subsume"/>
297 <biblScope type="pp"/>
298 <biblScope type="vol"/>
299 <biblScope type="volume-title"/>
300 </monogr>
301 </biblStruct>
302 <reference assemblage="regular" type="complete"><xsl:value-of select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/></reference>
Marc Kupietz1a422662024-03-16 09:34:10 +0100303 </sourceDesc>
304 </fileDesc>
305 <profileDesc>
306 <creation>
307 <creatDate><xsl:value-of select="$j"/></creatDate>
308 </creation>
309 <textClass/>
310 <textDesc>
Marc Kupietz7df4ccc2024-03-16 15:27:45 +0100311 <textType><xsl:value-of select="$texttype"/></textType>
312 <textTypeRef><xsl:value-of select="$texttype"/></textTypeRef>
Marc Kupietz1a422662024-03-16 09:34:10 +0100313 <textDomain/>
314 </textDesc>
315 </profileDesc>
316 </idsHeader>
317 <text>
318 <body>
319 <!-- Call the template for each link in the TOC
320 <xsl:apply-templates select="//xhtml:ol[@class='toc']/xhtml:li/xhtml:a" mode="collect"/> -->
Marc Kupietz8f727302024-04-10 16:31:19 +0200321 <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 +0100322 </body>
323 </text>
324 </idsText>
325 </idsDoc>
326 </xsl:template>
327
328 <xsl:template match="opf:item" mode="collect">
329 <xsl:variable name="href" select="@href"/>
330 <xsl:message>
331 <xsl:text>converting: </xsl:text><xsl:value-of select="$href"/><xsl:text> </xsl:text><xsl:value-of select="$isbn"/>
332 </xsl:message>
333 <xsl:apply-templates select="doc(resolve-uri($href, base-uri()))/xhtml:html/xhtml:body"/>
334 </xsl:template>
335
336 <xsl:template match="xhtml:body">
337 <div type="chapter">
338 <xsl:apply-templates/>
339 </div>
340 </xsl:template>
341
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000342 <xsl:template match="xhtml:body/text()">
343 <p>
344 <xsl:value-of select="."/>
345 </p>
346 </xsl:template>
347
Marc Kupietz1a422662024-03-16 09:34:10 +0100348 <xsl:template match="xhtml:title">
349 <head>
350 <xsl:apply-templates/>
351 </head>
352 </xsl:template>
353
354 <xsl:template match="xhtml:h1">
355 <head>
356 <xsl:apply-templates/>
357 </head>
358 </xsl:template>
359
360 <xsl:template match="xhtml:h2|xhtml:h3">
361 <head type="sub">
362 <xsl:apply-templates/>
363 </head>
364 </xsl:template>
365
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100366 <xsl:template match="xhtml:em">
367 <emph>
368 <xsl:apply-templates/>
369 </emph>
370 </xsl:template>
Marc Kupietz1a422662024-03-16 09:34:10 +0100371
Marc Kupietz30cc0802024-04-10 16:37:04 +0200372 <xsl:template match="xhtml:span[matches(@class, '(bold|italic|big|kursiv| )+')]">
373 <xsl:variable name="class" select="replace(@class, 'kursiv', 'italic')"/>
374 <hi rend="{$class}">
375 <xsl:apply-templates/>
376 </hi>
377 </xsl:template>
378
Marc Kupietz5e873112024-04-15 06:51:08 +0200379 <xsl:template match="xhtml:span[matches(@class, 'regular')]">
380 <xsl:apply-templates/>
381 </xsl:template>
382
Marc Kupietz66618ca2024-04-19 20:54:49 +0200383 <xsl:template match="xhtml:b|xhtml:span[@class='b']">
Marc Kupietz30cc0802024-04-10 16:37:04 +0200384 <hi rend="bold">
Marc Kupietz1a422662024-03-16 09:34:10 +0100385 <xsl:apply-templates/>
386 </hi>
387 </xsl:template>
388
Marc Kupietz66618ca2024-04-19 20:54:49 +0200389 <xsl:template match="xhtml:i|xhtml:span[@class='i']">
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000390 <hi rend="italic">
391 <xsl:apply-templates/>
392 </hi>
393 </xsl:template>
394
395
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100396 <xsl:template match="xhtml:sub|xhtml:span[@class='sub']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100397 <hi rend="sub">
398 <xsl:apply-templates/>
399 </hi>
400 </xsl:template>
401
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100402 <xsl:template match="xhtml:sup|xhtml:span[@class='sup']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100403 <hi rend="sup">
404 <xsl:apply-templates/>
405 </hi>
406 </xsl:template>
407
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000408 <xsl:template match="xhtml:div[not(normalize-space(replace(., '&#160;', ' ')))]" priority="1.0"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100409
Marc Kupietzbf47ae72024-04-14 14:21:43 +0200410 <xsl:template match="xhtml:body/xhtml:div[./xhtml:h1|./xhtml:h2|./xhtml:h3]" priority="1.0">
411 <xsl:apply-templates/>
412 </xsl:template>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000413 <xsl:template match="xhtml:div/xhtml:div">
Marc Kupietz1a422662024-03-16 09:34:10 +0100414 <p>
415 <xsl:apply-templates/>
416 </p>
417 </xsl:template>
418
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000419 <xsl:template match="xhtml:body/xhtml:div[(descendant::xhtml:p|descendant::xhtml:div)]">
420 <div type="section">
421 <xsl:apply-templates/>
422 </div>
423 </xsl:template>
424
425 <xsl:template match="xhtml:body/xhtml:div[not(descendant::xhtml:p|descendant::xhtml:div)]">
426 <div type="section">
427 <p>
428 <xsl:apply-templates/>
429 </p>
430 </div>
431 </xsl:template>
432
433 <xsl:template match="xhtml:p[not(descendant::xhtml:p|descendant::xhtml:div)]">
434 <xsl:if test="normalize-space(.)">
435 <p>
436 <xsl:apply-templates/>
437 </p>
438 </xsl:if>
439 </xsl:template>
440
441 <xsl:template match="xhtml:p[descendant::xhtml:p|descendant::xhtml:div]">
442 <xsl:if test="normalize-space(.)">
443 <div type="section">
444 <xsl:apply-templates/>
445 </div>
446 </xsl:if>
447 </xsl:template>
448
Marc Kupietz09745e12024-04-21 12:54:10 +0200449 <xsl:template match="xhtml:ul">
450 <list type="unordered">
451 <xsl:apply-templates/>
452 </list>
453 </xsl:template>
454 <xsl:template match="xhtml:ol">
455 <list type="ordered">
456 <xsl:apply-templates/>
457 </list>
458 </xsl:template>
459 <xsl:template match="xhtml:li">
460 <item>
461 <xsl:apply-templates/>
462 </item>
463 </xsl:template>
464 <xsl:template match="xhtml:nav">
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200465 <!-- <gap reason="toc"/> -->
466 </xsl:template>
467
Marc Kupietz1a422662024-03-16 09:34:10 +0100468 <xsl:template match="xhtml:img">
469 <!-- <gap reason="image"/> -->
470 </xsl:template>
471
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200472 <xsl:template match="xhtml:audio">
473 <!-- <gap reason="audio"/> -->
474 </xsl:template>
475
Marc Kupietz09745e12024-04-21 12:54:10 +0200476 <xsl:template match="xhtml:table">
477 <!-- <gap reason="table"/> -->
478 </xsl:template>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000479 <xsl:template match="xhtml:body/xhtml:a">
Marc Kupietz164a2832024-04-14 21:00:48 +0200480 <xsl:if test="normalize-space(.)">
481 <p>
482 <ref target="{@href}">
483 <xsl:apply-templates />
484 </ref>
485 </p>
486 </xsl:if>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000487 </xsl:template>
488
489 <xsl:template match="xhtml:body/xhtml:span">
490 <xsl:message>
491 <xsl:text>unhandled span element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
492 </xsl:message>
493 <div type="section">
494 <p>
495 <xsl:value-of select="."/>
496 </p>
497 </div>
498 </xsl:template>
499 <xsl:template match="xhtml:span">
500 <xsl:message>
501 <xsl:text>unhandled span element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
502 </xsl:message>
503 <xsl:value-of select="."/>
504 </xsl:template>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100505 <xsl:template match="xhtml:a">
Marc Kupietz164a2832024-04-14 21:00:48 +0200506 <xsl:if test="normalize-space(.)">
507 <ref target="{@href}">
508 <xsl:apply-templates />
509 </ref>
510 </xsl:if>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100511 </xsl:template>
512
513 <xsl:template match="xhtml:br"/>
514
Marc Kupietz1a422662024-03-16 09:34:10 +0100515 <xsl:template match="xhtml:*">
516 <xsl:message>
517 <xsl:text>unhandled element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
518 </xsl:message>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000519 <xsl:choose>
520 <xsl:when test="descendant::xhtml:div|descendant::xhtml:p|parent::xhtml:body">
521 <div type="section">
522 <xsl:apply-templates/>
523 </div>
524 </xsl:when>
525 <xsl:otherwise>
526 <xsl:apply-templates select="./*|node()"/>
527 </xsl:otherwise>
528 </xsl:choose>
Marc Kupietz1a422662024-03-16 09:34:10 +0100529 <xsl:apply-templates/>
530 </xsl:template>
531
532 <xsl:function name="ids:reversedAuthors">
533 <xsl:param name="s" />
534 <xsl:value-of
535 select="
536 if (matches($s, ';')) then
537 concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; ')))
538 else
539 replace($s, '(.+) (.+)', '$2, $1')"
540 />
541 </xsl:function>
542
543 <xsl:function name="hlu:reversedAuthors">
544 <xsl:param name="s"/>
545 <xsl:value-of
546 select="if (matches($s, ';')) then concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; '))) else replace($s, '(.+),(.+)', '$2, $1')"
547 />
548 </xsl:function>
549
Marc Kupietz10903f32024-04-14 14:21:18 +0200550 <xsl:variable name="city-country-map" as="map(xs:string, xs:string)">
551 <xsl:map>
552 <xsl:map-entry key="'Axams'" select="'AT'"/>
553 <xsl:map-entry key="'Vienna'" select="'AT'"/>
554 <xsl:map-entry key="'Klagenfurt'" select="'AT'"/>
555 <xsl:map-entry key="'Graz'" select="'AT'"/>
556 <xsl:map-entry key="'Innsbruck'" select="'AT'"/>
557 <xsl:map-entry key="'Salzburg'" select="'AT'"/>
558 <xsl:map-entry key="'Bern'" select="'CH'"/>
559 <xsl:map-entry key="'Biel/Bienne'" select="'CH'"/>
560 <xsl:map-entry key="'Zurich'" select="'CH'"/>
561 <xsl:map-entry key="'Basel'" select="'CH'"/>
562 <xsl:map-entry key="'Geneva'" select="'CH'"/>
563 <xsl:map-entry key="'Lucerne'" select="'CH'"/>
564 <xsl:map-entry key="'Lausanne'" select="'CH'"/>
565 <xsl:map-entry key="'Winterthur'" select="'CH'"/>
566 <xsl:map-entry key="'St. Gallen'" select="'CH'"/>
567 <xsl:map-entry key="'Interlaken'" select="'CH'"/>
568 <xsl:map-entry key="'Brussels'" select="'BE'"/>
569 <xsl:map-entry key="'Antwerp'" select="'BE'"/>
570 <xsl:map-entry key="'Ghent'" select="'BE'"/>
571 <xsl:map-entry key="'Bruges'" select="'BE'"/>
572 <xsl:map-entry key="'Leuven'" select="'BE'"/>
573 <xsl:map-entry key="'Liege'" select="'BE'"/>
574 <xsl:map-entry key="'Charleroi'" select="'BE'"/>
575 <xsl:map-entry key="'Namur'" select="'BE'"/>
576 <xsl:map-entry key="'Mons'" select="'BE'"/>
577 <xsl:map-entry key="'Bangkok'" select="'TH'"/>
578 <xsl:map-entry key="'Copenhagen'" select="'DK'"/>
579 <xsl:map-entry key="'colatina'" select="'BR'"/>
580 <xsl:map-entry key="'Oakland Park'" select="'US'"/>
581 <xsl:map-entry key="'Istanbul'" select="'TR'"/>
582 <xsl:map-entry key="'Luxemburg'" select="'LU'"/>
583 <xsl:map-entry key="'Palma de Mallorca'" select="'ES'"/>
584 <xsl:map-entry key="'Swakopmund'" select="'NA'"/>
585 <xsl:map-entry key="'Victoria'" select="'CA'"/>
586 <xsl:map-entry key="'Wien'" select="'AT'"/>
587 <xsl:map-entry key="'Windhoek'" select="'NA'"/>
588 <xsl:map-entry key="'Zuerich'" select="'CH'"/>
589 <xsl:map-entry key="'Zürich'" select="'CH'"/>
590 <xsl:map-entry key="'Zug'" select="'CH'"/>
591 <xsl:map-entry key="'ZÜRICH'" select="'CH'"/>
592 </xsl:map>
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200593
Marc Kupietz10903f32024-04-14 14:21:18 +0200594 </xsl:variable>
595
596 <!-- Define the function -->
597 <xsl:function name="ids:country-city" as="xs:string">
598 <xsl:param name="city" as="xs:string"/>
599 <xsl:sequence select="if (map:contains($city-country-map, $city)) then map:get($city-country-map, $city) else 'DE'"/>
600 </xsl:function>
Marc Kupietz1a422662024-03-16 09:34:10 +0100601</xsl:stylesheet>