blob: d6e0d6811adb6d3026dc9b4df2cc67a0c16eabb8 [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 Kupietzde2ca532024-04-26 16:50:53 +020026 select="replace(string-join($dnbBookdata//dc:creator[not(contains(., '[')) or matches(., '\[Verfasser\]')], ' ; '), ' *\[[^\]]*\]', '')"/>
Marc Kupietzeaa90132024-04-26 18:14:40 +020027 <xsl:variable name="straight_autor" select="normalize-space(replace(hlu:reversedAuthors($autor), ',', ''))"/>
28 <xsl:variable name="translator"
29 select="replace(string-join($dnbBookdata//dc:creator[matches(., '\[Übersetzer\]')], ' ; '), ' *\[[^\]]*\]', '')"/>
30 <xsl:variable name="straight_translator" select="normalize-space(replace(hlu:reversedAuthors($translator), ',', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010031
Marc Kupietzb660ed62024-03-16 11:45:53 +010032 <xsl:variable name="straight_autor" select="normalize-space(replace(hlu:reversedAuthors($autor), ',', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010033
34 <xsl:variable name="ina"/>
35 <xsl:variable name="_corpus"/>
36 <xsl:variable name="ent_known"/>
37
38
39 <!-- added HLU 2012-02-09: -->
40 <xsl:variable name="ent">
41 <xsl:choose>
42 <xsl:when test="$ent_known">
43 <xsl:value-of select="$ent_known"/>
44 </xsl:when>
45 <xsl:when test="$ev">
46 <xsl:value-of select="$ev"/>
47 </xsl:when>
48 <xsl:otherwise>
49 <xsl:value-of select="$j"/>
50 </xsl:otherwise>
51 </xsl:choose>
52 </xsl:variable>
53
54 <xsl:variable name="titel">
Marc Kupietz49124fa2024-04-10 16:50:01 +020055 <xsl:variable name="title-with-subtitles">
56 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +020057 <xsl:when test="contains(($dnbBookdata//dc:title)[1],':')">
58 <xsl:value-of select="normalize-space(substring-before(substring-before(($dnbBookdata//dc:title)[1], '/'), ':'))"
Marc Kupietz49124fa2024-04-10 16:50:01 +020059 />
60 </xsl:when>
61 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +020062 <xsl:value-of select="normalize-space(substring-before(($dnbBookdata//dc:title)[1], '/'))"/>
Marc Kupietz49124fa2024-04-10 16:50:01 +020063 </xsl:otherwise>
64 </xsl:choose>
65 </xsl:variable>
66 <xsl:value-of select="normalize-space(replace($title-with-subtitles, '\|.*', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010067 </xsl:variable>
68
69 <xsl:variable name="erscheinungsort">
70 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +020071 <xsl:when test="contains(($dnbBookdata//dc:publisher)[1], ':')">
72 <xsl:value-of select="normalize-space(substring-before(($dnbBookdata//dc:publisher)[1], ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010073 </xsl:when>
74 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +020075 <xsl:value-of select="normalize-space(($dnbBookdata//dc:publisher)[1])"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010076 </xsl:otherwise>
77 </xsl:choose>
78 </xsl:variable>
79
Marc Kupietzd8599fc2024-04-14 13:16:56 +020080 <xsl:variable name="erscheinungsland" select="ids:country-city($erscheinungsort)"/>
81
Marc Kupietz6cb52232024-04-13 12:28:44 +020082 <xsl:variable name="texttype" select="replace(($dnbBookdata//dc:subject[matches(., '^[A-Z] ')])[1], '^[A-Z] (.*)', '$1')"/>
Marc Kupietz7df4ccc2024-03-16 15:27:45 +010083
Marc Kupietz1a422662024-03-16 09:34:10 +010084 <xsl:variable name="verlag">
85 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +020086 <xsl:when test="contains(($dnbBookdata//dc:publisher)[1], ':')">
87 <xsl:value-of select="normalize-space(substring-after(($dnbBookdata//dc:publisher)[1], ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010088 </xsl:when>
89 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +020090 <xsl:value-of select="normalize-space(($dnbBookdata//dc:publisher)[1])"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010091 </xsl:otherwise>
92 </xsl:choose>
93 </xsl:variable>
94
95 <xsl:variable name="erscheinungsjahr">
Marc Kupietza5d01182024-04-14 12:24:02 +020096 <xsl:value-of select="replace(($dnbBookdata//dc:date)[1], '.*?((19|20)[0-9][0-9]).*', '$1')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010097 </xsl:variable>
98
99 <xsl:variable name="untertitel"
Marc Kupietz6cb52232024-04-13 12:28:44 +0200100 select="normalize-space(substring-after(substring-before(($dnbBookdata//dc:title)[1], '/'), ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100101
102 <xsl:variable name="herausgeber">
103 <xsl:choose>
104 <xsl:when test="$dnbBookdata//dc:creator[ends-with(.,'[Hrsg.]')]">
105 <xsl:value-of
Marc Kupietz6cb52232024-04-13 12:28:44 +0200106 select="replace(string-join($dnbBookdata//dc:creator[ends-with(.,'[Hrsg.]')][1], ' ; '),'\s?\[Hrsg.\]','')"
Marc Kupietz1a422662024-03-16 09:34:10 +0100107 />
108 </xsl:when>
109 <xsl:otherwise>.</xsl:otherwise>
110 </xsl:choose>
111 </xsl:variable>
112
113 <xsl:variable name="straight_herausgeber"
114 select="replace(hlu:reversedAuthors($herausgeber), ',', '')"/>
115
Marc Kupietza5d01182024-04-14 12:24:02 +0200116 <xsl:variable name="j" select="$erscheinungsjahr"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100117
118 <!-- for BOT+s: -->
119 <xsl:variable name="seiten" select="replace($dnbBookdata//dc:format,'S\.','')"/>
120
121 <!-- fuer BOT+b: -->
122 <xsl:variable name="_b">
123 <xsl:variable name="regexp1" select="'(Band|Bd\.)\s*([0-9]?[0-9]?[0-9])'"/>
124 <xsl:choose>
125 <xsl:when test="matches($dnbBookdata, $regexp1)">
126 <xsl:analyze-string select="$dnbBookdata//dc:title" regex="{$regexp1}">
127 <xsl:matching-substring>
128 <xsl:value-of select="."/>
129 </xsl:matching-substring>
130 </xsl:analyze-string>
131 </xsl:when>
132 <xsl:otherwise>
133 <xsl:value-of select="'.'"/>
134 </xsl:otherwise>
135 </xsl:choose>
136 </xsl:variable>
137
138 <!-- for BOT+x: -->
139 <xsl:variable name="txtart">
140 <xsl:choose>
141 <xsl:when test="$x">
142 <xsl:value-of select="concat('[', $x, ']')"/>
143 </xsl:when>
144 <xsl:when
145 test="matches($untertitel, '([Rr]oman|[Ee]rzhlung(en)?|[Aa]nthologie|[Gg]eschichte(n)?|[Nn]ovelle)')">
146 <xsl:value-of
147 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'), ']')"
148 />
149 </xsl:when>
150 <xsl:otherwise>
151 <xsl:value-of>Roman</xsl:value-of>
152 </xsl:otherwise>
153 </xsl:choose>
154 </xsl:variable>
155
156
157
158 <!-- fuer BOTd: -->
159 <xsl:variable name="dok"
160 select="concat((if(string-length($autor) &gt; 0) then concat($straight_autor, ': ') else ''), $titel, ', ', $txtart, ', (', $j, ')')"/>
161
162 <!-- END variables derived from sru request to dnb archive -->
163
164
Marc Kupietz94bbe6b2024-04-10 20:35:48 +0200165 <xsl:variable name="corpus_sigle" select="concat('DNB', substring($erscheinungsjahr, 3, 2))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100166
167 <!-- for BOTD: -->
168 <!-- Dokumentsigle muss zusammen mit Korpussigle (z.B DIV fuer loz-div und loz-div-pub) eindeutig sein -->
169 <xsl:variable name="doc_sigle">
170 <xsl:variable name="firstContentWordTitleInitial">
171 <xsl:variable name="helper">
172 <xsl:analyze-string select="$titel" regex="\w+">
173 <xsl:matching-substring>
174 <xsl:choose>
175 <xsl:when
Marc Kupietzad1f3b82024-04-19 19:21:49 +0200176 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 +0100177 <!-- TODO: Fktnswoerter nachtragen -->
178 <xsl:sequence select="."/>
179 </xsl:when>
180 <xsl:otherwise/>
181 </xsl:choose>
182 </xsl:matching-substring>
183 </xsl:analyze-string>
184 </xsl:variable>
185 <xsl:value-of
Marc Kupietz77b6aa92024-04-21 17:31:43 +0200186 select="upper-case(substring(normalize-space(replace($helper,'\s+.+$','')),1,3))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100187 <!-- longest match of .+ -->
188 </xsl:variable>
Marc Kupietz77b6aa92024-04-21 17:31:43 +0200189 <xsl:variable name="authorInitials">
190 <xsl:choose>
191 <xsl:when test="contains($autor,';')">
192 <xsl:variable name="lastname_aut1"
193 select="upper-case(substring(normalize-space($autor),1,1))"/>
194 <xsl:variable name="lastname_aut2"
195 select="replace($autor, '.*?;.*?([A-Z]).*', '$1')"/>
196 <xsl:value-of select="concat($lastname_aut1, $lastname_aut2)"/>
197 </xsl:when>
198 <xsl:otherwise>
199 <xsl:variable name="lastname_aut1"
200 select="upper-case(substring(normalize-space(substring-before($autor,',')),1,1))"/>
201 <xsl:variable name="firstname_aut1"
202 select="upper-case(substring(normalize-space(substring-after($autor,',')),1,1))"/>
203 <xsl:value-of select="concat($lastname_aut1, $firstname_aut1)"/>
204 </xsl:otherwise>
205 </xsl:choose>
206 </xsl:variable>
Marc Kupietz398b5962024-04-21 17:51:34 +0200207 <xsl:value-of select="substring(replace(normalize-unicode(concat($authorInitials,$firstContentWordTitleInitial), 'NFKD'),'[^A-Z]',''),1,3)"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100208 </xsl:variable>
209
210
Marc Kupietz568240f2024-04-19 19:20:55 +0200211 <xsl:variable name="text_sigle" select="replace($isbn, '.*([0-9]{5})[0-9X]$', '$1')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100212 <xsl:variable name="sigle" select="concat($corpus_sigle, '/', $doc_sigle, '.', $text_sigle)"/>
213
214 <!-- fuer BOT+xy: (?) -->
215 <xsl:variable name="xyref">
216 <xsl:value-of select="document-uri(.)"/>
217 <xsl:text>; </xsl:text>
218 <xsl:text>ISBN:</xsl:text>
219 <xsl:value-of select="$isbn"/>
220 <xsl:text>; </xsl:text>
221 <xsl:value-of select="string-join($dnbBookdata//dc:identifier)"/>
222 </xsl:variable>
223
Marc Kupietzb660ed62024-03-16 11:45:53 +0100224 <xsl:variable name="long-reference"
225 select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/>
226
227 <xsl:variable name="short-reference"
228 select="concat($straight_autor, ': ', $titel, ' (', $erscheinungsjahr, ')')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100229
230 <xsl:template match="/">
Marc Kupietzb7a4f6c2024-04-19 11:35:25 +0200231 <xsl:if test="not($j)">
232 <xsl:message terminate="yes">ERROR: No dc:date found for ISBN: <xsl:value-of select="$isbn"/></xsl:message>
233 </xsl:if>
234
Marc Kupietz815cc6c2024-04-19 12:44:44 +0200235 <xsl:if test="not(normalize-space($titel))">
236 <xsl:message terminate="yes">ERROR: No title found for ISBN: <xsl:value-of select="$isbn"/></xsl:message>
237 </xsl:if>
238
Marc Kupietz2badfb12024-04-19 12:59:40 +0200239 <xsl:if test="not(normalize-space($autor))">
240 <xsl:message terminate="yes">ERROR: No author found for ISBN: <xsl:value-of select="$isbn"/></xsl:message>
241 </xsl:if>
242
Marc Kupietz52aa5052024-04-21 18:16:06 +0200243 <xsl:if test="not(matches($sigle, '^[A-Z]{3}[0-9]{2}/[A-Z]{2,3}\.[0-9]{5}$'))">
244 <xsl:message terminate="yes">ERROR: Invalid sigle »<xsl:value-of select="$sigle"/>« for ISBN: <xsl:value-of select="$isbn"/></xsl:message>
Marc Kupietz09745e12024-04-21 12:54:10 +0200245 </xsl:if>
246
Marc Kupietz1a422662024-03-16 09:34:10 +0100247 <idsDoc TEIform="TEI.2" type="text" version="1.0">
248 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="document" version="1.1">
249 <fileDesc>
250 <titleStmt>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100251 <dokumentSigle><xsl:value-of select="string-join(($corpus_sigle, $doc_sigle), '/')"/></dokumentSigle>
252 <d.title><xsl:value-of select="$short-reference"/></d.title>
Marc Kupietz1a422662024-03-16 09:34:10 +0100253 </titleStmt>
254 <publicationStmt>
255 <distributor/>
256 <pubAddress/>
257 <availability region="world" status="unknown">QAO-NC</availability>
258 <pubDate/>
259 </publicationStmt>
260 <sourceDesc>
261 <biblStruct>
262 <monogr>
263 <h.title type="main"/>
264 <imprint/>
265 </monogr>
266 </biblStruct>
267 </sourceDesc>
268 </fileDesc>
269 </idsHeader>
270 <idsText version="1.0">
271 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="text" version="1.1">
272 <fileDesc>
273 <titleStmt>
274 <textSigle><xsl:sequence select="$sigle"/></textSigle>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100275 <t.title assemblage="regular"><xsl:value-of select="$long-reference"/></t.title>
Marc Kupietz1a422662024-03-16 09:34:10 +0100276 </titleStmt>
277 <publicationStmt>
278 <distributor/>
279 <pubAddress/>
280 <availability region="world" status="unknown">QAO-NC</availability>
281 <pubDate/>
282 </publicationStmt>
283 <sourceDesc>
284 <biblStruct>
285 <monogr>
286 <h.title type="main"><xsl:value-of select="$titel"/></h.title>
287 <h.title type="sub"><xsl:value-of select="$untertitel"/></h.title>
288 <h.author><xsl:value-of select="$autor"/></h.author>
Marc Kupietzeaa90132024-04-26 18:14:40 +0200289 <xsl:if test="$translator">
290 <editor role="translator"><xsl:value-of select="$translator"/></editor>
291 </xsl:if>
Marc Kupietz1a422662024-03-16 09:34:10 +0100292 <edition>
293 <further/>
294 <kind>E-Book-Ausgabe</kind>
295 <appearance>EPUB-Datei</appearance>
296 </edition>
297 <imprint>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100298 <publisher><xsl:value-of select="$verlag"/></publisher>
Marc Kupietz1a422662024-03-16 09:34:10 +0100299 <pubDate type="year"><xsl:value-of select="$j"/></pubDate>
300 <pubDate type="month"/>
301 <pubDate type="day"/>
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200302 <pubPlace key="{$erscheinungsland}"><xsl:value-of select="$erscheinungsort"/></pubPlace>
Marc Kupietz1a422662024-03-16 09:34:10 +0100303 </imprint>
304 <biblScope type="subsume"/>
305 <biblScope type="pp"/>
306 <biblScope type="vol"/>
307 <biblScope type="volume-title"/>
308 </monogr>
309 </biblStruct>
310 <reference assemblage="regular" type="complete"><xsl:value-of select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/></reference>
Marc Kupietz1a422662024-03-16 09:34:10 +0100311 </sourceDesc>
312 </fileDesc>
313 <profileDesc>
314 <creation>
315 <creatDate><xsl:value-of select="$j"/></creatDate>
316 </creation>
317 <textClass/>
318 <textDesc>
Marc Kupietz7df4ccc2024-03-16 15:27:45 +0100319 <textType><xsl:value-of select="$texttype"/></textType>
320 <textTypeRef><xsl:value-of select="$texttype"/></textTypeRef>
Marc Kupietz1a422662024-03-16 09:34:10 +0100321 <textDomain/>
322 </textDesc>
323 </profileDesc>
324 </idsHeader>
325 <text>
326 <body>
327 <!-- Call the template for each link in the TOC
328 <xsl:apply-templates select="//xhtml:ol[@class='toc']/xhtml:li/xhtml:a" mode="collect"/> -->
Marc Kupietz8f727302024-04-10 16:31:19 +0200329 <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 +0100330 </body>
331 </text>
332 </idsText>
333 </idsDoc>
334 </xsl:template>
335
336 <xsl:template match="opf:item" mode="collect">
337 <xsl:variable name="href" select="@href"/>
338 <xsl:message>
339 <xsl:text>converting: </xsl:text><xsl:value-of select="$href"/><xsl:text> </xsl:text><xsl:value-of select="$isbn"/>
340 </xsl:message>
341 <xsl:apply-templates select="doc(resolve-uri($href, base-uri()))/xhtml:html/xhtml:body"/>
342 </xsl:template>
343
344 <xsl:template match="xhtml:body">
345 <div type="chapter">
346 <xsl:apply-templates/>
347 </div>
348 </xsl:template>
349
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000350 <xsl:template match="xhtml:body/text()">
351 <p>
352 <xsl:value-of select="."/>
353 </p>
354 </xsl:template>
355
Marc Kupietz1a422662024-03-16 09:34:10 +0100356 <xsl:template match="xhtml:title">
357 <head>
358 <xsl:apply-templates/>
359 </head>
360 </xsl:template>
361
362 <xsl:template match="xhtml:h1">
363 <head>
364 <xsl:apply-templates/>
365 </head>
366 </xsl:template>
367
Marc Kupietz3989c742024-04-21 17:33:49 +0200368 <xsl:template match="xhtml:h2|xhtml:h3|xhtml:h4|xhtml:h5|xhtml:h6">
Marc Kupietz1a422662024-03-16 09:34:10 +0100369 <head type="sub">
370 <xsl:apply-templates/>
371 </head>
372 </xsl:template>
373
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100374 <xsl:template match="xhtml:em">
375 <emph>
376 <xsl:apply-templates/>
377 </emph>
378 </xsl:template>
Marc Kupietz1a422662024-03-16 09:34:10 +0100379
Marc Kupietz30cc0802024-04-10 16:37:04 +0200380 <xsl:template match="xhtml:span[matches(@class, '(bold|italic|big|kursiv| )+')]">
381 <xsl:variable name="class" select="replace(@class, 'kursiv', 'italic')"/>
382 <hi rend="{$class}">
383 <xsl:apply-templates/>
384 </hi>
385 </xsl:template>
386
Marc Kupietzad4d4462024-04-26 17:43:08 +0200387 <xsl:template match="xhtml:span[matches(@class, '(regular|norm)')]">
Marc Kupietz5e873112024-04-15 06:51:08 +0200388 <xsl:apply-templates/>
389 </xsl:template>
390
Marc Kupietz3989c742024-04-21 17:33:49 +0200391 <xsl:template match="xhtml:b|xhtml:span[@class='b']|xhtml:strong">
Marc Kupietz30cc0802024-04-10 16:37:04 +0200392 <hi rend="bold">
Marc Kupietz1a422662024-03-16 09:34:10 +0100393 <xsl:apply-templates/>
394 </hi>
395 </xsl:template>
396
Marc Kupietzfb0f2c32024-04-26 17:43:18 +0200397 <xsl:template match="xhtml:i|xhtml:span[@class='i' or @class='it']">
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000398 <hi rend="italic">
399 <xsl:apply-templates/>
400 </hi>
401 </xsl:template>
402
403
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100404 <xsl:template match="xhtml:sub|xhtml:span[@class='sub']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100405 <hi rend="sub">
406 <xsl:apply-templates/>
407 </hi>
408 </xsl:template>
409
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100410 <xsl:template match="xhtml:sup|xhtml:span[@class='sup']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100411 <hi rend="sup">
412 <xsl:apply-templates/>
413 </hi>
414 </xsl:template>
415
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000416 <xsl:template match="xhtml:div[not(normalize-space(replace(., '&#160;', ' ')))]" priority="1.0"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100417
Marc Kupietzbf47ae72024-04-14 14:21:43 +0200418 <xsl:template match="xhtml:body/xhtml:div[./xhtml:h1|./xhtml:h2|./xhtml:h3]" priority="1.0">
419 <xsl:apply-templates/>
420 </xsl:template>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000421 <xsl:template match="xhtml:div/xhtml:div">
Marc Kupietz1a422662024-03-16 09:34:10 +0100422 <p>
423 <xsl:apply-templates/>
424 </p>
425 </xsl:template>
426
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000427 <xsl:template match="xhtml:body/xhtml:div[(descendant::xhtml:p|descendant::xhtml:div)]">
428 <div type="section">
429 <xsl:apply-templates/>
430 </div>
431 </xsl:template>
432
433 <xsl:template match="xhtml:body/xhtml:div[not(descendant::xhtml:p|descendant::xhtml:div)]">
434 <div type="section">
435 <p>
436 <xsl:apply-templates/>
437 </p>
438 </div>
439 </xsl:template>
440
441 <xsl:template match="xhtml:p[not(descendant::xhtml:p|descendant::xhtml:div)]">
442 <xsl:if test="normalize-space(.)">
443 <p>
444 <xsl:apply-templates/>
445 </p>
446 </xsl:if>
447 </xsl:template>
448
449 <xsl:template match="xhtml:p[descendant::xhtml:p|descendant::xhtml:div]">
450 <xsl:if test="normalize-space(.)">
451 <div type="section">
452 <xsl:apply-templates/>
453 </div>
454 </xsl:if>
455 </xsl:template>
456
Marc Kupietz09745e12024-04-21 12:54:10 +0200457 <xsl:template match="xhtml:ul">
458 <list type="unordered">
459 <xsl:apply-templates/>
460 </list>
461 </xsl:template>
462 <xsl:template match="xhtml:ol">
463 <list type="ordered">
464 <xsl:apply-templates/>
465 </list>
466 </xsl:template>
467 <xsl:template match="xhtml:li">
468 <item>
469 <xsl:apply-templates/>
470 </item>
471 </xsl:template>
472 <xsl:template match="xhtml:nav">
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200473 <!-- <gap reason="toc"/> -->
474 </xsl:template>
475
Marc Kupietz1a422662024-03-16 09:34:10 +0100476 <xsl:template match="xhtml:img">
477 <!-- <gap reason="image"/> -->
478 </xsl:template>
479
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200480 <xsl:template match="xhtml:audio">
481 <!-- <gap reason="audio"/> -->
482 </xsl:template>
483
Marc Kupietz09745e12024-04-21 12:54:10 +0200484 <xsl:template match="xhtml:table">
485 <!-- <gap reason="table"/> -->
486 </xsl:template>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000487 <xsl:template match="xhtml:body/xhtml:a">
Marc Kupietz164a2832024-04-14 21:00:48 +0200488 <xsl:if test="normalize-space(.)">
489 <p>
490 <ref target="{@href}">
491 <xsl:apply-templates />
492 </ref>
493 </p>
494 </xsl:if>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000495 </xsl:template>
496
497 <xsl:template match="xhtml:body/xhtml:span">
498 <xsl:message>
499 <xsl:text>unhandled span element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
500 </xsl:message>
501 <div type="section">
502 <p>
503 <xsl:value-of select="."/>
504 </p>
505 </div>
506 </xsl:template>
507 <xsl:template match="xhtml:span">
508 <xsl:message>
509 <xsl:text>unhandled span element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
510 </xsl:message>
511 <xsl:value-of select="."/>
512 </xsl:template>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100513 <xsl:template match="xhtml:a">
Marc Kupietz164a2832024-04-14 21:00:48 +0200514 <xsl:if test="normalize-space(.)">
515 <ref target="{@href}">
516 <xsl:apply-templates />
517 </ref>
518 </xsl:if>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100519 </xsl:template>
520
521 <xsl:template match="xhtml:br"/>
522
Marc Kupietz1a422662024-03-16 09:34:10 +0100523 <xsl:template match="xhtml:*">
524 <xsl:message>
525 <xsl:text>unhandled element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
526 </xsl:message>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000527 <xsl:choose>
528 <xsl:when test="descendant::xhtml:div|descendant::xhtml:p|parent::xhtml:body">
529 <div type="section">
530 <xsl:apply-templates/>
531 </div>
532 </xsl:when>
533 <xsl:otherwise>
534 <xsl:apply-templates select="./*|node()"/>
535 </xsl:otherwise>
536 </xsl:choose>
Marc Kupietz1a422662024-03-16 09:34:10 +0100537 <xsl:apply-templates/>
538 </xsl:template>
539
540 <xsl:function name="ids:reversedAuthors">
541 <xsl:param name="s" />
542 <xsl:value-of
543 select="
544 if (matches($s, ';')) then
545 concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; ')))
546 else
547 replace($s, '(.+) (.+)', '$2, $1')"
548 />
549 </xsl:function>
550
551 <xsl:function name="hlu:reversedAuthors">
552 <xsl:param name="s"/>
553 <xsl:value-of
554 select="if (matches($s, ';')) then concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; '))) else replace($s, '(.+),(.+)', '$2, $1')"
555 />
556 </xsl:function>
557
Marc Kupietz10903f32024-04-14 14:21:18 +0200558 <xsl:variable name="city-country-map" as="map(xs:string, xs:string)">
559 <xsl:map>
560 <xsl:map-entry key="'Axams'" select="'AT'"/>
561 <xsl:map-entry key="'Vienna'" select="'AT'"/>
562 <xsl:map-entry key="'Klagenfurt'" select="'AT'"/>
563 <xsl:map-entry key="'Graz'" select="'AT'"/>
564 <xsl:map-entry key="'Innsbruck'" select="'AT'"/>
565 <xsl:map-entry key="'Salzburg'" select="'AT'"/>
566 <xsl:map-entry key="'Bern'" select="'CH'"/>
567 <xsl:map-entry key="'Biel/Bienne'" select="'CH'"/>
568 <xsl:map-entry key="'Zurich'" select="'CH'"/>
569 <xsl:map-entry key="'Basel'" select="'CH'"/>
570 <xsl:map-entry key="'Geneva'" select="'CH'"/>
571 <xsl:map-entry key="'Lucerne'" select="'CH'"/>
572 <xsl:map-entry key="'Lausanne'" select="'CH'"/>
573 <xsl:map-entry key="'Winterthur'" select="'CH'"/>
574 <xsl:map-entry key="'St. Gallen'" select="'CH'"/>
575 <xsl:map-entry key="'Interlaken'" select="'CH'"/>
576 <xsl:map-entry key="'Brussels'" select="'BE'"/>
577 <xsl:map-entry key="'Antwerp'" select="'BE'"/>
578 <xsl:map-entry key="'Ghent'" select="'BE'"/>
579 <xsl:map-entry key="'Bruges'" select="'BE'"/>
580 <xsl:map-entry key="'Leuven'" select="'BE'"/>
581 <xsl:map-entry key="'Liege'" select="'BE'"/>
582 <xsl:map-entry key="'Charleroi'" select="'BE'"/>
583 <xsl:map-entry key="'Namur'" select="'BE'"/>
584 <xsl:map-entry key="'Mons'" select="'BE'"/>
585 <xsl:map-entry key="'Bangkok'" select="'TH'"/>
586 <xsl:map-entry key="'Copenhagen'" select="'DK'"/>
587 <xsl:map-entry key="'colatina'" select="'BR'"/>
588 <xsl:map-entry key="'Oakland Park'" select="'US'"/>
589 <xsl:map-entry key="'Istanbul'" select="'TR'"/>
590 <xsl:map-entry key="'Luxemburg'" select="'LU'"/>
591 <xsl:map-entry key="'Palma de Mallorca'" select="'ES'"/>
592 <xsl:map-entry key="'Swakopmund'" select="'NA'"/>
593 <xsl:map-entry key="'Victoria'" select="'CA'"/>
594 <xsl:map-entry key="'Wien'" select="'AT'"/>
595 <xsl:map-entry key="'Windhoek'" select="'NA'"/>
596 <xsl:map-entry key="'Zuerich'" select="'CH'"/>
597 <xsl:map-entry key="'Zürich'" select="'CH'"/>
598 <xsl:map-entry key="'Zug'" select="'CH'"/>
599 <xsl:map-entry key="'ZÜRICH'" select="'CH'"/>
600 </xsl:map>
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200601
Marc Kupietz10903f32024-04-14 14:21:18 +0200602 </xsl:variable>
603
604 <!-- Define the function -->
605 <xsl:function name="ids:country-city" as="xs:string">
606 <xsl:param name="city" as="xs:string"/>
607 <xsl:sequence select="if (map:contains($city-country-map, $city)) then map:get($city-country-map, $city) else 'DE'"/>
608 </xsl:function>
Marc Kupietz1a422662024-03-16 09:34:10 +0100609</xsl:stylesheet>