blob: 277dfbf565f93d00f25ee27656667c0c69d566d5 [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 Kupietz0c246632024-04-29 07:08:23 +020018 <xsl:variable name="idno" as="xs:string" select="replace(document-uri(), '.*/([0-9]{9,13}X?).*' , '$1')"/>
19
Marc Kupietz1a422662024-03-16 09:34:10 +010020
21 <xsl:variable name="dnbBookdata">
Marc Kupietz0c246632024-04-29 07:08:23 +020022 <xsl:copy-of select="doc(concat('https://services.dnb.de/sru/dnb?version=1.1&amp;operation=searchRetrieve&amp;query=NUM%3D', $idno, '&amp;recordSchema=oai_dc'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010023 </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 Kupietz15e7d612024-04-26 18:16:39 +020032 <xsl:variable name="herausgeber"
33 select="replace(string-join($dnbBookdata//dc:creator[matches(., '\[(Herausgeber|Hrsg.)\]')], ' ; '), ' *\[[^\]]*\]', '')"/>
34 <xsl:variable name="straight_herausgeber" select="normalize-space(replace(hlu:reversedAuthors($herausgeber), ',', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010035
36 <xsl:variable name="ina"/>
37 <xsl:variable name="_corpus"/>
38 <xsl:variable name="ent_known"/>
39
40
41 <!-- added HLU 2012-02-09: -->
42 <xsl:variable name="ent">
43 <xsl:choose>
44 <xsl:when test="$ent_known">
45 <xsl:value-of select="$ent_known"/>
46 </xsl:when>
47 <xsl:when test="$ev">
48 <xsl:value-of select="$ev"/>
49 </xsl:when>
50 <xsl:otherwise>
51 <xsl:value-of select="$j"/>
52 </xsl:otherwise>
53 </xsl:choose>
54 </xsl:variable>
55
56 <xsl:variable name="titel">
Marc Kupietz49124fa2024-04-10 16:50:01 +020057 <xsl:variable name="title-with-subtitles">
58 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +020059 <xsl:when test="contains(($dnbBookdata//dc:title)[1],':')">
60 <xsl:value-of select="normalize-space(substring-before(substring-before(($dnbBookdata//dc:title)[1], '/'), ':'))"
Marc Kupietz49124fa2024-04-10 16:50:01 +020061 />
62 </xsl:when>
63 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +020064 <xsl:value-of select="normalize-space(substring-before(($dnbBookdata//dc:title)[1], '/'))"/>
Marc Kupietz49124fa2024-04-10 16:50:01 +020065 </xsl:otherwise>
66 </xsl:choose>
67 </xsl:variable>
68 <xsl:value-of select="normalize-space(replace($title-with-subtitles, '\|.*', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010069 </xsl:variable>
70
71 <xsl:variable name="erscheinungsort">
72 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +020073 <xsl:when test="contains(($dnbBookdata//dc:publisher)[1], ':')">
74 <xsl:value-of select="normalize-space(substring-before(($dnbBookdata//dc:publisher)[1], ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010075 </xsl:when>
76 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +020077 <xsl:value-of select="normalize-space(($dnbBookdata//dc:publisher)[1])"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010078 </xsl:otherwise>
79 </xsl:choose>
80 </xsl:variable>
81
Marc Kupietzd8599fc2024-04-14 13:16:56 +020082 <xsl:variable name="erscheinungsland" select="ids:country-city($erscheinungsort)"/>
83
Marc Kupietz6cb52232024-04-13 12:28:44 +020084 <xsl:variable name="texttype" select="replace(($dnbBookdata//dc:subject[matches(., '^[A-Z] ')])[1], '^[A-Z] (.*)', '$1')"/>
Marc Kupietz7df4ccc2024-03-16 15:27:45 +010085
Marc Kupietz9d87e9d2024-05-05 15:56:50 +020086 <xsl:variable name="genretable">
87 <genres>
88 <genre keyRegex="krimi" genre="Roman: Kriminalroman"/>
89 <genre keyRegex="arztroman" genre="Roman: Arztroman"/>
90 <genre keyRegex="liebesroman" genre="Roman: Liebesroman"/>
91 <genre keyRegex="science.?fiction" genre="Roman: Science-Fiction-Roman"/>
92 <genre keyRegex="horror" genre="Roman: Horrorroman"/>
93 <genre keyRegex="western" genre="Roman: Westernroman"/>
94 <genre keyRegex="fantasy" genre="Roman: Fantasyroman"/>
95 <genre keyRegex="historischer roman" genre="Roman: Historischer Roman"/>
96 <genre keyRegex="erzählung" genre="Erzählung"/>
97 <genre keyRegex="novelle" genre="Novelle"/>
98 <genre keyRegex="anthologie" genre="Anthologie"/>
99 <genre keyRegex="kurzgeschichte" genre="Kurzgeschichte"/>
100 <genre keyRegex="roman" genre="Roman"/>
101 <genre keyRegex="." genre="Roman"/>
102 </genres>
103 </xsl:variable>
104
105 <xsl:variable name="textFullGenre" select="$genretable/genres/genre[matches($dnbBookdata, ./@keyRegex, 'i')][1]/@genre"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100106 <xsl:variable name="verlag">
107 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +0200108 <xsl:when test="contains(($dnbBookdata//dc:publisher)[1], ':')">
109 <xsl:value-of select="normalize-space(substring-after(($dnbBookdata//dc:publisher)[1], ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100110 </xsl:when>
111 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +0200112 <xsl:value-of select="normalize-space(($dnbBookdata//dc:publisher)[1])"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100113 </xsl:otherwise>
114 </xsl:choose>
115 </xsl:variable>
116
117 <xsl:variable name="erscheinungsjahr">
Marc Kupietza5d01182024-04-14 12:24:02 +0200118 <xsl:value-of select="replace(($dnbBookdata//dc:date)[1], '.*?((19|20)[0-9][0-9]).*', '$1')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100119 </xsl:variable>
120
121 <xsl:variable name="untertitel"
Marc Kupietz6cb52232024-04-13 12:28:44 +0200122 select="normalize-space(substring-after(substring-before(($dnbBookdata//dc:title)[1], '/'), ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100123
Marc Kupietza5d01182024-04-14 12:24:02 +0200124 <xsl:variable name="j" select="$erscheinungsjahr"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100125
126 <!-- for BOT+s: -->
127 <xsl:variable name="seiten" select="replace($dnbBookdata//dc:format,'S\.','')"/>
128
129 <!-- fuer BOT+b: -->
130 <xsl:variable name="_b">
131 <xsl:variable name="regexp1" select="'(Band|Bd\.)\s*([0-9]?[0-9]?[0-9])'"/>
132 <xsl:choose>
133 <xsl:when test="matches($dnbBookdata, $regexp1)">
134 <xsl:analyze-string select="$dnbBookdata//dc:title" regex="{$regexp1}">
135 <xsl:matching-substring>
136 <xsl:value-of select="."/>
137 </xsl:matching-substring>
138 </xsl:analyze-string>
139 </xsl:when>
140 <xsl:otherwise>
141 <xsl:value-of select="'.'"/>
142 </xsl:otherwise>
143 </xsl:choose>
144 </xsl:variable>
145
146 <!-- for BOT+x: -->
147 <xsl:variable name="txtart">
148 <xsl:choose>
149 <xsl:when test="$x">
150 <xsl:value-of select="concat('[', $x, ']')"/>
151 </xsl:when>
152 <xsl:when
153 test="matches($untertitel, '([Rr]oman|[Ee]rzhlung(en)?|[Aa]nthologie|[Gg]eschichte(n)?|[Nn]ovelle)')">
154 <xsl:value-of
155 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'), ']')"
156 />
157 </xsl:when>
158 <xsl:otherwise>
159 <xsl:value-of>Roman</xsl:value-of>
160 </xsl:otherwise>
161 </xsl:choose>
162 </xsl:variable>
163
164
165
166 <!-- fuer BOTd: -->
167 <xsl:variable name="dok"
168 select="concat((if(string-length($autor) &gt; 0) then concat($straight_autor, ': ') else ''), $titel, ', ', $txtart, ', (', $j, ')')"/>
169
170 <!-- END variables derived from sru request to dnb archive -->
171
172
Marc Kupietz94bbe6b2024-04-10 20:35:48 +0200173 <xsl:variable name="corpus_sigle" select="concat('DNB', substring($erscheinungsjahr, 3, 2))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100174
175 <!-- for BOTD: -->
176 <!-- Dokumentsigle muss zusammen mit Korpussigle (z.B DIV fuer loz-div und loz-div-pub) eindeutig sein -->
177 <xsl:variable name="doc_sigle">
178 <xsl:variable name="firstContentWordTitleInitial">
179 <xsl:variable name="helper">
180 <xsl:analyze-string select="$titel" regex="\w+">
181 <xsl:matching-substring>
182 <xsl:choose>
183 <xsl:when
Marc Kupietzad1f3b82024-04-19 19:21:49 +0200184 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 +0100185 <!-- TODO: Fktnswoerter nachtragen -->
186 <xsl:sequence select="."/>
187 </xsl:when>
188 <xsl:otherwise/>
189 </xsl:choose>
190 </xsl:matching-substring>
191 </xsl:analyze-string>
192 </xsl:variable>
193 <xsl:value-of
Marc Kupietz77b6aa92024-04-21 17:31:43 +0200194 select="upper-case(substring(normalize-space(replace($helper,'\s+.+$','')),1,3))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100195 <!-- longest match of .+ -->
196 </xsl:variable>
Marc Kupietz77b6aa92024-04-21 17:31:43 +0200197 <xsl:variable name="authorInitials">
198 <xsl:choose>
199 <xsl:when test="contains($autor,';')">
200 <xsl:variable name="lastname_aut1"
201 select="upper-case(substring(normalize-space($autor),1,1))"/>
202 <xsl:variable name="lastname_aut2"
203 select="replace($autor, '.*?;.*?([A-Z]).*', '$1')"/>
204 <xsl:value-of select="concat($lastname_aut1, $lastname_aut2)"/>
205 </xsl:when>
206 <xsl:otherwise>
207 <xsl:variable name="lastname_aut1"
208 select="upper-case(substring(normalize-space(substring-before($autor,',')),1,1))"/>
209 <xsl:variable name="firstname_aut1"
210 select="upper-case(substring(normalize-space(substring-after($autor,',')),1,1))"/>
211 <xsl:value-of select="concat($lastname_aut1, $firstname_aut1)"/>
212 </xsl:otherwise>
213 </xsl:choose>
214 </xsl:variable>
Marc Kupietz398b5962024-04-21 17:51:34 +0200215 <xsl:value-of select="substring(replace(normalize-unicode(concat($authorInitials,$firstContentWordTitleInitial), 'NFKD'),'[^A-Z]',''),1,3)"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100216 </xsl:variable>
217
218
Marc Kupietz0c246632024-04-29 07:08:23 +0200219 <xsl:variable name="text_sigle" select="replace($idno, '.*([0-9]{5})[0-9X]$', '$1')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100220 <xsl:variable name="sigle" select="concat($corpus_sigle, '/', $doc_sigle, '.', $text_sigle)"/>
221
222 <!-- fuer BOT+xy: (?) -->
223 <xsl:variable name="xyref">
224 <xsl:value-of select="document-uri(.)"/>
225 <xsl:text>; </xsl:text>
Marc Kupietz0c246632024-04-29 07:08:23 +0200226 <xsl:text>IDNO:</xsl:text>
227 <xsl:value-of select="$idno"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100228 <xsl:text>; </xsl:text>
229 <xsl:value-of select="string-join($dnbBookdata//dc:identifier)"/>
230 </xsl:variable>
231
Marc Kupietzb660ed62024-03-16 11:45:53 +0100232 <xsl:variable name="long-reference"
233 select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/>
234
235 <xsl:variable name="short-reference"
236 select="concat($straight_autor, ': ', $titel, ' (', $erscheinungsjahr, ')')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100237
238 <xsl:template match="/">
Marc Kupietzb7a4f6c2024-04-19 11:35:25 +0200239 <xsl:if test="not($j)">
Marc Kupietz0c246632024-04-29 07:08:23 +0200240 <xsl:message terminate="yes">ERROR: No dc:date found for IDNO: <xsl:value-of select="$idno"/></xsl:message>
Marc Kupietzb7a4f6c2024-04-19 11:35:25 +0200241 </xsl:if>
242
Marc Kupietz815cc6c2024-04-19 12:44:44 +0200243 <xsl:if test="not(normalize-space($titel))">
Marc Kupietz0c246632024-04-29 07:08:23 +0200244 <xsl:message terminate="yes">ERROR: No title found for IDNO: <xsl:value-of select="$idno"/></xsl:message>
Marc Kupietz815cc6c2024-04-19 12:44:44 +0200245 </xsl:if>
246
Marc Kupietz2badfb12024-04-19 12:59:40 +0200247 <xsl:if test="not(normalize-space($autor))">
Marc Kupietz0c246632024-04-29 07:08:23 +0200248 <xsl:message terminate="yes">ERROR: No author found for IDNO: <xsl:value-of select="$idno"/></xsl:message>
Marc Kupietz2badfb12024-04-19 12:59:40 +0200249 </xsl:if>
250
Marc Kupietz52aa5052024-04-21 18:16:06 +0200251 <xsl:if test="not(matches($sigle, '^[A-Z]{3}[0-9]{2}/[A-Z]{2,3}\.[0-9]{5}$'))">
Marc Kupietz0c246632024-04-29 07:08:23 +0200252 <xsl:message terminate="yes">ERROR: Invalid sigle »<xsl:value-of select="$sigle"/>« for IDNO: <xsl:value-of select="$idno"/></xsl:message>
Marc Kupietz09745e12024-04-21 12:54:10 +0200253 </xsl:if>
254
Marc Kupietz1a422662024-03-16 09:34:10 +0100255 <idsDoc TEIform="TEI.2" type="text" version="1.0">
256 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="document" version="1.1">
257 <fileDesc>
258 <titleStmt>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100259 <dokumentSigle><xsl:value-of select="string-join(($corpus_sigle, $doc_sigle), '/')"/></dokumentSigle>
260 <d.title><xsl:value-of select="$short-reference"/></d.title>
Marc Kupietz1a422662024-03-16 09:34:10 +0100261 </titleStmt>
262 <publicationStmt>
263 <distributor/>
264 <pubAddress/>
265 <availability region="world" status="unknown">QAO-NC</availability>
266 <pubDate/>
267 </publicationStmt>
268 <sourceDesc>
269 <biblStruct>
270 <monogr>
271 <h.title type="main"/>
272 <imprint/>
273 </monogr>
274 </biblStruct>
275 </sourceDesc>
276 </fileDesc>
277 </idsHeader>
278 <idsText version="1.0">
279 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="text" version="1.1">
280 <fileDesc>
281 <titleStmt>
282 <textSigle><xsl:sequence select="$sigle"/></textSigle>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100283 <t.title assemblage="regular"><xsl:value-of select="$long-reference"/></t.title>
Marc Kupietz1a422662024-03-16 09:34:10 +0100284 </titleStmt>
285 <publicationStmt>
286 <distributor/>
287 <pubAddress/>
288 <availability region="world" status="unknown">QAO-NC</availability>
289 <pubDate/>
290 </publicationStmt>
291 <sourceDesc>
292 <biblStruct>
293 <monogr>
294 <h.title type="main"><xsl:value-of select="$titel"/></h.title>
295 <h.title type="sub"><xsl:value-of select="$untertitel"/></h.title>
296 <h.author><xsl:value-of select="$autor"/></h.author>
Marc Kupietzeaa90132024-04-26 18:14:40 +0200297 <xsl:if test="$translator">
298 <editor role="translator"><xsl:value-of select="$translator"/></editor>
299 </xsl:if>
Marc Kupietz15e7d612024-04-26 18:16:39 +0200300 <xsl:if test="$herausgeber">
301 <editor role="editor"><xsl:value-of select="$herausgeber"/></editor>
302 </xsl:if>
Marc Kupietz1a422662024-03-16 09:34:10 +0100303 <edition>
304 <further/>
305 <kind>E-Book-Ausgabe</kind>
306 <appearance>EPUB-Datei</appearance>
307 </edition>
308 <imprint>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100309 <publisher><xsl:value-of select="$verlag"/></publisher>
Marc Kupietz1a422662024-03-16 09:34:10 +0100310 <pubDate type="year"><xsl:value-of select="$j"/></pubDate>
311 <pubDate type="month"/>
312 <pubDate type="day"/>
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200313 <pubPlace key="{$erscheinungsland}"><xsl:value-of select="$erscheinungsort"/></pubPlace>
Marc Kupietz1a422662024-03-16 09:34:10 +0100314 </imprint>
315 <biblScope type="subsume"/>
316 <biblScope type="pp"/>
317 <biblScope type="vol"/>
318 <biblScope type="volume-title"/>
319 </monogr>
320 </biblStruct>
321 <reference assemblage="regular" type="complete"><xsl:value-of select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/></reference>
Marc Kupietz1a422662024-03-16 09:34:10 +0100322 </sourceDesc>
323 </fileDesc>
324 <profileDesc>
325 <creation>
326 <creatDate><xsl:value-of select="$j"/></creatDate>
327 </creation>
328 <textClass/>
329 <textDesc>
Marc Kupietz9d87e9d2024-05-05 15:56:50 +0200330 <textType><xsl:value-of select="$textFullGenre"/></textType>
331 <textTypeRef><xsl:value-of select="replace($textFullGenre, '.*: *', '')"/></textTypeRef>
Marc Kupietz1a422662024-03-16 09:34:10 +0100332 <textDomain/>
333 </textDesc>
334 </profileDesc>
335 </idsHeader>
336 <text>
337 <body>
338 <!-- Call the template for each link in the TOC
339 <xsl:apply-templates select="//xhtml:ol[@class='toc']/xhtml:li/xhtml:a" mode="collect"/> -->
Marc Kupietz8f727302024-04-10 16:31:19 +0200340 <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 +0100341 </body>
342 </text>
343 </idsText>
344 </idsDoc>
345 </xsl:template>
346
347 <xsl:template match="opf:item" mode="collect">
348 <xsl:variable name="href" select="@href"/>
349 <xsl:message>
Marc Kupietz0c246632024-04-29 07:08:23 +0200350 <xsl:text>converting: </xsl:text><xsl:value-of select="$href"/><xsl:text> </xsl:text><xsl:value-of select="$idno"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100351 </xsl:message>
352 <xsl:apply-templates select="doc(resolve-uri($href, base-uri()))/xhtml:html/xhtml:body"/>
353 </xsl:template>
354
355 <xsl:template match="xhtml:body">
356 <div type="chapter">
357 <xsl:apply-templates/>
358 </div>
359 </xsl:template>
360
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000361 <xsl:template match="xhtml:body/text()">
362 <p>
363 <xsl:value-of select="."/>
364 </p>
365 </xsl:template>
366
Marc Kupietz1a422662024-03-16 09:34:10 +0100367 <xsl:template match="xhtml:title">
368 <head>
369 <xsl:apply-templates/>
370 </head>
371 </xsl:template>
372
373 <xsl:template match="xhtml:h1">
374 <head>
375 <xsl:apply-templates/>
376 </head>
377 </xsl:template>
378
Marc Kupietz3989c742024-04-21 17:33:49 +0200379 <xsl:template match="xhtml:h2|xhtml:h3|xhtml:h4|xhtml:h5|xhtml:h6">
Marc Kupietz1a422662024-03-16 09:34:10 +0100380 <head type="sub">
381 <xsl:apply-templates/>
382 </head>
383 </xsl:template>
384
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100385 <xsl:template match="xhtml:em">
386 <emph>
387 <xsl:apply-templates/>
388 </emph>
389 </xsl:template>
Marc Kupietz1a422662024-03-16 09:34:10 +0100390
Marc Kupietz30cc0802024-04-10 16:37:04 +0200391 <xsl:template match="xhtml:span[matches(@class, '(bold|italic|big|kursiv| )+')]">
392 <xsl:variable name="class" select="replace(@class, 'kursiv', 'italic')"/>
393 <hi rend="{$class}">
394 <xsl:apply-templates/>
395 </hi>
396 </xsl:template>
397
Marc Kupietzad4d4462024-04-26 17:43:08 +0200398 <xsl:template match="xhtml:span[matches(@class, '(regular|norm)')]">
Marc Kupietz5e873112024-04-15 06:51:08 +0200399 <xsl:apply-templates/>
400 </xsl:template>
401
Marc Kupietz3989c742024-04-21 17:33:49 +0200402 <xsl:template match="xhtml:b|xhtml:span[@class='b']|xhtml:strong">
Marc Kupietz30cc0802024-04-10 16:37:04 +0200403 <hi rend="bold">
Marc Kupietz1a422662024-03-16 09:34:10 +0100404 <xsl:apply-templates/>
405 </hi>
406 </xsl:template>
407
Marc Kupietzfb0f2c32024-04-26 17:43:18 +0200408 <xsl:template match="xhtml:i|xhtml:span[@class='i' or @class='it']">
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000409 <hi rend="italic">
410 <xsl:apply-templates/>
411 </hi>
412 </xsl:template>
413
414
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100415 <xsl:template match="xhtml:sub|xhtml:span[@class='sub']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100416 <hi rend="sub">
417 <xsl:apply-templates/>
418 </hi>
419 </xsl:template>
420
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100421 <xsl:template match="xhtml:sup|xhtml:span[@class='sup']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100422 <hi rend="sup">
423 <xsl:apply-templates/>
424 </hi>
425 </xsl:template>
426
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000427 <xsl:template match="xhtml:div[not(normalize-space(replace(., '&#160;', ' ')))]" priority="1.0"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100428
Marc Kupietzbf47ae72024-04-14 14:21:43 +0200429 <xsl:template match="xhtml:body/xhtml:div[./xhtml:h1|./xhtml:h2|./xhtml:h3]" priority="1.0">
430 <xsl:apply-templates/>
431 </xsl:template>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000432 <xsl:template match="xhtml:div/xhtml:div">
Marc Kupietz1a422662024-03-16 09:34:10 +0100433 <p>
434 <xsl:apply-templates/>
435 </p>
436 </xsl:template>
437
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000438 <xsl:template match="xhtml:body/xhtml:div[(descendant::xhtml:p|descendant::xhtml:div)]">
439 <div type="section">
440 <xsl:apply-templates/>
441 </div>
442 </xsl:template>
443
444 <xsl:template match="xhtml:body/xhtml:div[not(descendant::xhtml:p|descendant::xhtml:div)]">
445 <div type="section">
446 <p>
447 <xsl:apply-templates/>
448 </p>
449 </div>
450 </xsl:template>
451
452 <xsl:template match="xhtml:p[not(descendant::xhtml:p|descendant::xhtml:div)]">
453 <xsl:if test="normalize-space(.)">
454 <p>
455 <xsl:apply-templates/>
456 </p>
457 </xsl:if>
458 </xsl:template>
459
460 <xsl:template match="xhtml:p[descendant::xhtml:p|descendant::xhtml:div]">
461 <xsl:if test="normalize-space(.)">
462 <div type="section">
463 <xsl:apply-templates/>
464 </div>
465 </xsl:if>
466 </xsl:template>
467
Marc Kupietz09745e12024-04-21 12:54:10 +0200468 <xsl:template match="xhtml:ul">
469 <list type="unordered">
470 <xsl:apply-templates/>
471 </list>
472 </xsl:template>
473 <xsl:template match="xhtml:ol">
474 <list type="ordered">
475 <xsl:apply-templates/>
476 </list>
477 </xsl:template>
478 <xsl:template match="xhtml:li">
479 <item>
480 <xsl:apply-templates/>
481 </item>
482 </xsl:template>
483 <xsl:template match="xhtml:nav">
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200484 <!-- <gap reason="toc"/> -->
485 </xsl:template>
486
Marc Kupietz1a422662024-03-16 09:34:10 +0100487 <xsl:template match="xhtml:img">
488 <!-- <gap reason="image"/> -->
489 </xsl:template>
490
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200491 <xsl:template match="xhtml:audio">
492 <!-- <gap reason="audio"/> -->
493 </xsl:template>
494
Marc Kupietz09745e12024-04-21 12:54:10 +0200495 <xsl:template match="xhtml:table">
496 <!-- <gap reason="table"/> -->
497 </xsl:template>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000498 <xsl:template match="xhtml:body/xhtml:a">
Marc Kupietz164a2832024-04-14 21:00:48 +0200499 <xsl:if test="normalize-space(.)">
500 <p>
501 <ref target="{@href}">
502 <xsl:apply-templates />
503 </ref>
504 </p>
505 </xsl:if>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000506 </xsl:template>
507
508 <xsl:template match="xhtml:body/xhtml:span">
509 <xsl:message>
510 <xsl:text>unhandled span element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
511 </xsl:message>
512 <div type="section">
513 <p>
514 <xsl:value-of select="."/>
515 </p>
516 </div>
517 </xsl:template>
518 <xsl:template match="xhtml:span">
519 <xsl:message>
520 <xsl:text>unhandled span element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
521 </xsl:message>
522 <xsl:value-of select="."/>
523 </xsl:template>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100524 <xsl:template match="xhtml:a">
Marc Kupietz164a2832024-04-14 21:00:48 +0200525 <xsl:if test="normalize-space(.)">
526 <ref target="{@href}">
527 <xsl:apply-templates />
528 </ref>
529 </xsl:if>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100530 </xsl:template>
531
Marc Kupietz54ec28b2024-04-27 10:07:06 +0200532 <xsl:template match="xhtml:br">
533 <lb/><xsl:text>&#10;</xsl:text>
534 </xsl:template>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100535
Marc Kupietz1a422662024-03-16 09:34:10 +0100536 <xsl:template match="xhtml:*">
537 <xsl:message>
538 <xsl:text>unhandled element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
539 </xsl:message>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000540 <xsl:choose>
541 <xsl:when test="descendant::xhtml:div|descendant::xhtml:p|parent::xhtml:body">
542 <div type="section">
543 <xsl:apply-templates/>
544 </div>
545 </xsl:when>
546 <xsl:otherwise>
547 <xsl:apply-templates select="./*|node()"/>
548 </xsl:otherwise>
549 </xsl:choose>
Marc Kupietz1a422662024-03-16 09:34:10 +0100550 <xsl:apply-templates/>
551 </xsl:template>
552
553 <xsl:function name="ids:reversedAuthors">
554 <xsl:param name="s" />
555 <xsl:value-of
556 select="
557 if (matches($s, ';')) then
558 concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; ')))
559 else
560 replace($s, '(.+) (.+)', '$2, $1')"
561 />
562 </xsl:function>
563
564 <xsl:function name="hlu:reversedAuthors">
565 <xsl:param name="s"/>
566 <xsl:value-of
567 select="if (matches($s, ';')) then concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; '))) else replace($s, '(.+),(.+)', '$2, $1')"
568 />
569 </xsl:function>
570
Marc Kupietz10903f32024-04-14 14:21:18 +0200571 <xsl:variable name="city-country-map" as="map(xs:string, xs:string)">
572 <xsl:map>
573 <xsl:map-entry key="'Axams'" select="'AT'"/>
574 <xsl:map-entry key="'Vienna'" select="'AT'"/>
575 <xsl:map-entry key="'Klagenfurt'" select="'AT'"/>
576 <xsl:map-entry key="'Graz'" select="'AT'"/>
577 <xsl:map-entry key="'Innsbruck'" select="'AT'"/>
578 <xsl:map-entry key="'Salzburg'" select="'AT'"/>
579 <xsl:map-entry key="'Bern'" select="'CH'"/>
580 <xsl:map-entry key="'Biel/Bienne'" select="'CH'"/>
581 <xsl:map-entry key="'Zurich'" select="'CH'"/>
582 <xsl:map-entry key="'Basel'" select="'CH'"/>
583 <xsl:map-entry key="'Geneva'" select="'CH'"/>
584 <xsl:map-entry key="'Lucerne'" select="'CH'"/>
585 <xsl:map-entry key="'Lausanne'" select="'CH'"/>
586 <xsl:map-entry key="'Winterthur'" select="'CH'"/>
587 <xsl:map-entry key="'St. Gallen'" select="'CH'"/>
588 <xsl:map-entry key="'Interlaken'" select="'CH'"/>
589 <xsl:map-entry key="'Brussels'" select="'BE'"/>
590 <xsl:map-entry key="'Antwerp'" select="'BE'"/>
591 <xsl:map-entry key="'Ghent'" select="'BE'"/>
592 <xsl:map-entry key="'Bruges'" select="'BE'"/>
593 <xsl:map-entry key="'Leuven'" select="'BE'"/>
594 <xsl:map-entry key="'Liege'" select="'BE'"/>
595 <xsl:map-entry key="'Charleroi'" select="'BE'"/>
596 <xsl:map-entry key="'Namur'" select="'BE'"/>
597 <xsl:map-entry key="'Mons'" select="'BE'"/>
598 <xsl:map-entry key="'Bangkok'" select="'TH'"/>
599 <xsl:map-entry key="'Copenhagen'" select="'DK'"/>
600 <xsl:map-entry key="'colatina'" select="'BR'"/>
601 <xsl:map-entry key="'Oakland Park'" select="'US'"/>
602 <xsl:map-entry key="'Istanbul'" select="'TR'"/>
603 <xsl:map-entry key="'Luxemburg'" select="'LU'"/>
604 <xsl:map-entry key="'Palma de Mallorca'" select="'ES'"/>
605 <xsl:map-entry key="'Swakopmund'" select="'NA'"/>
606 <xsl:map-entry key="'Victoria'" select="'CA'"/>
607 <xsl:map-entry key="'Wien'" select="'AT'"/>
608 <xsl:map-entry key="'Windhoek'" select="'NA'"/>
609 <xsl:map-entry key="'Zuerich'" select="'CH'"/>
610 <xsl:map-entry key="'Zürich'" select="'CH'"/>
611 <xsl:map-entry key="'Zug'" select="'CH'"/>
612 <xsl:map-entry key="'ZÜRICH'" select="'CH'"/>
613 </xsl:map>
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200614
Marc Kupietz10903f32024-04-14 14:21:18 +0200615 </xsl:variable>
616
617 <!-- Define the function -->
618 <xsl:function name="ids:country-city" as="xs:string">
619 <xsl:param name="city" as="xs:string"/>
620 <xsl:sequence select="if (map:contains($city-country-map, $city)) then map:get($city-country-map, $city) else 'DE'"/>
621 </xsl:function>
Marc Kupietz1a422662024-03-16 09:34:10 +0100622</xsl:stylesheet>