blob: b0b1de0cf73116da3783341828ec79bd63371a0e [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')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010019
Rebecca Wilmf614a4b2024-05-07 10:19:43 +020020 <xsl:variable name="idno_type">
21 <xsl:choose>
22 <xsl:when test="starts-with($idno,'1')">
23 <xsl:value-of select="'IDN'"/>
24 </xsl:when>
25 <xsl:otherwise>
26 <xsl:value-of select="'ISBN'"/>
27 </xsl:otherwise>
28 </xsl:choose>
29 </xsl:variable>
30
Marc Kupietz1a422662024-03-16 09:34:10 +010031 <xsl:variable name="dnbBookdata">
Rebecca Wilmf614a4b2024-05-07 10:19:43 +020032 <xsl:copy-of select="doc(concat('https://services.dnb.de/sru/dnb?version=1.1&amp;operation=searchRetrieve&amp;query=', $idno_type, '%3D', $idno, '&amp;recordSchema=oai_dc'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010033 </xsl:variable>
34
35 <xsl:variable name="autor"
Marc Kupietzde2ca532024-04-26 16:50:53 +020036 select="replace(string-join($dnbBookdata//dc:creator[not(contains(., '[')) or matches(., '\[Verfasser\]')], ' ; '), ' *\[[^\]]*\]', '')"/>
Marc Kupietzeaa90132024-04-26 18:14:40 +020037 <xsl:variable name="straight_autor" select="normalize-space(replace(hlu:reversedAuthors($autor), ',', ''))"/>
38 <xsl:variable name="translator"
39 select="replace(string-join($dnbBookdata//dc:creator[matches(., '\[Übersetzer\]')], ' ; '), ' *\[[^\]]*\]', '')"/>
40 <xsl:variable name="straight_translator" select="normalize-space(replace(hlu:reversedAuthors($translator), ',', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010041
Marc Kupietz15e7d612024-04-26 18:16:39 +020042 <xsl:variable name="herausgeber"
43 select="replace(string-join($dnbBookdata//dc:creator[matches(., '\[(Herausgeber|Hrsg.)\]')], ' ; '), ' *\[[^\]]*\]', '')"/>
44 <xsl:variable name="straight_herausgeber" select="normalize-space(replace(hlu:reversedAuthors($herausgeber), ',', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010045
46 <xsl:variable name="ina"/>
47 <xsl:variable name="_corpus"/>
48 <xsl:variable name="ent_known"/>
49
50
51 <!-- added HLU 2012-02-09: -->
52 <xsl:variable name="ent">
53 <xsl:choose>
54 <xsl:when test="$ent_known">
55 <xsl:value-of select="$ent_known"/>
56 </xsl:when>
57 <xsl:when test="$ev">
58 <xsl:value-of select="$ev"/>
59 </xsl:when>
60 <xsl:otherwise>
61 <xsl:value-of select="$j"/>
62 </xsl:otherwise>
63 </xsl:choose>
64 </xsl:variable>
65
66 <xsl:variable name="titel">
Marc Kupietz49124fa2024-04-10 16:50:01 +020067 <xsl:variable name="title-with-subtitles">
68 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +020069 <xsl:when test="contains(($dnbBookdata//dc:title)[1],':')">
70 <xsl:value-of select="normalize-space(substring-before(substring-before(($dnbBookdata//dc:title)[1], '/'), ':'))"
Marc Kupietz49124fa2024-04-10 16:50:01 +020071 />
72 </xsl:when>
73 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +020074 <xsl:value-of select="normalize-space(substring-before(($dnbBookdata//dc:title)[1], '/'))"/>
Marc Kupietz49124fa2024-04-10 16:50:01 +020075 </xsl:otherwise>
76 </xsl:choose>
77 </xsl:variable>
78 <xsl:value-of select="normalize-space(replace($title-with-subtitles, '\|.*', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010079 </xsl:variable>
80
81 <xsl:variable name="erscheinungsort">
82 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +020083 <xsl:when test="contains(($dnbBookdata//dc:publisher)[1], ':')">
84 <xsl:value-of select="normalize-space(substring-before(($dnbBookdata//dc:publisher)[1], ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010085 </xsl:when>
86 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +020087 <xsl:value-of select="normalize-space(($dnbBookdata//dc:publisher)[1])"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010088 </xsl:otherwise>
89 </xsl:choose>
90 </xsl:variable>
91
Marc Kupietzd8599fc2024-04-14 13:16:56 +020092 <xsl:variable name="erscheinungsland" select="ids:country-city($erscheinungsort)"/>
93
Marc Kupietz6cb52232024-04-13 12:28:44 +020094 <xsl:variable name="texttype" select="replace(($dnbBookdata//dc:subject[matches(., '^[A-Z] ')])[1], '^[A-Z] (.*)', '$1')"/>
Marc Kupietz7df4ccc2024-03-16 15:27:45 +010095
Marc Kupietz9d87e9d2024-05-05 15:56:50 +020096 <xsl:variable name="genretable">
97 <genres>
98 <genre keyRegex="krimi" genre="Roman: Kriminalroman"/>
99 <genre keyRegex="arztroman" genre="Roman: Arztroman"/>
100 <genre keyRegex="liebesroman" genre="Roman: Liebesroman"/>
101 <genre keyRegex="science.?fiction" genre="Roman: Science-Fiction-Roman"/>
102 <genre keyRegex="horror" genre="Roman: Horrorroman"/>
103 <genre keyRegex="western" genre="Roman: Westernroman"/>
104 <genre keyRegex="fantasy" genre="Roman: Fantasyroman"/>
105 <genre keyRegex="historischer roman" genre="Roman: Historischer Roman"/>
106 <genre keyRegex="erzählung" genre="Erzählung"/>
107 <genre keyRegex="novelle" genre="Novelle"/>
108 <genre keyRegex="anthologie" genre="Anthologie"/>
109 <genre keyRegex="kurzgeschichte" genre="Kurzgeschichte"/>
110 <genre keyRegex="roman" genre="Roman"/>
111 <genre keyRegex="." genre="Roman"/>
112 </genres>
113 </xsl:variable>
114
115 <xsl:variable name="textFullGenre" select="$genretable/genres/genre[matches($dnbBookdata, ./@keyRegex, 'i')][1]/@genre"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100116 <xsl:variable name="verlag">
117 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +0200118 <xsl:when test="contains(($dnbBookdata//dc:publisher)[1], ':')">
119 <xsl:value-of select="normalize-space(substring-after(($dnbBookdata//dc:publisher)[1], ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100120 </xsl:when>
121 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +0200122 <xsl:value-of select="normalize-space(($dnbBookdata//dc:publisher)[1])"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100123 </xsl:otherwise>
124 </xsl:choose>
125 </xsl:variable>
126
127 <xsl:variable name="erscheinungsjahr">
Marc Kupietza5d01182024-04-14 12:24:02 +0200128 <xsl:value-of select="replace(($dnbBookdata//dc:date)[1], '.*?((19|20)[0-9][0-9]).*', '$1')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100129 </xsl:variable>
130
131 <xsl:variable name="untertitel"
Marc Kupietz6cb52232024-04-13 12:28:44 +0200132 select="normalize-space(substring-after(substring-before(($dnbBookdata//dc:title)[1], '/'), ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100133
Marc Kupietza5d01182024-04-14 12:24:02 +0200134 <xsl:variable name="j" select="$erscheinungsjahr"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100135
136 <!-- for BOT+s: -->
137 <xsl:variable name="seiten" select="replace($dnbBookdata//dc:format,'S\.','')"/>
138
139 <!-- fuer BOT+b: -->
140 <xsl:variable name="_b">
141 <xsl:variable name="regexp1" select="'(Band|Bd\.)\s*([0-9]?[0-9]?[0-9])'"/>
142 <xsl:choose>
143 <xsl:when test="matches($dnbBookdata, $regexp1)">
144 <xsl:analyze-string select="$dnbBookdata//dc:title" regex="{$regexp1}">
145 <xsl:matching-substring>
146 <xsl:value-of select="."/>
147 </xsl:matching-substring>
148 </xsl:analyze-string>
149 </xsl:when>
150 <xsl:otherwise>
151 <xsl:value-of select="'.'"/>
152 </xsl:otherwise>
153 </xsl:choose>
154 </xsl:variable>
155
156 <!-- for BOT+x: -->
157 <xsl:variable name="txtart">
158 <xsl:choose>
159 <xsl:when test="$x">
160 <xsl:value-of select="concat('[', $x, ']')"/>
161 </xsl:when>
162 <xsl:when
Nicolas Arnold72aa7a12024-05-08 12:42:15 +0200163 test="matches($untertitel, '([Rr]oman|[Ee]rzä?hlung(en)?|[Aa]nthologie|[Gg]eschichte(n)?|[Nn]ovelle)')">
Marc Kupietz1a422662024-03-16 09:34:10 +0100164 <xsl:value-of
Nicolas Arnold72aa7a12024-05-08 12:42:15 +0200165 select="concat('[', replace(replace($untertitel, '.*?(((^|\P{L})\p{L}+)?([Rr]oman|[Ee]rzä?hlung(en)?|[Aa]nthologie|[Gg]eschichte(n)?|[Nn]ovelle)).*', '$1'), '\P{L}*(.+)', '$1'), ']')"
Marc Kupietz1a422662024-03-16 09:34:10 +0100166 />
167 </xsl:when>
168 <xsl:otherwise>
169 <xsl:value-of>Roman</xsl:value-of>
170 </xsl:otherwise>
171 </xsl:choose>
172 </xsl:variable>
173
174
175
176 <!-- fuer BOTd: -->
177 <xsl:variable name="dok"
178 select="concat((if(string-length($autor) &gt; 0) then concat($straight_autor, ': ') else ''), $titel, ', ', $txtart, ', (', $j, ')')"/>
179
180 <!-- END variables derived from sru request to dnb archive -->
181
182
Marc Kupietz94bbe6b2024-04-10 20:35:48 +0200183 <xsl:variable name="corpus_sigle" select="concat('DNB', substring($erscheinungsjahr, 3, 2))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100184
185 <!-- for BOTD: -->
186 <!-- Dokumentsigle muss zusammen mit Korpussigle (z.B DIV fuer loz-div und loz-div-pub) eindeutig sein -->
187 <xsl:variable name="doc_sigle">
188 <xsl:variable name="firstContentWordTitleInitial">
189 <xsl:variable name="helper">
190 <xsl:analyze-string select="$titel" regex="\w+">
191 <xsl:matching-substring>
192 <xsl:choose>
193 <xsl:when
Marc Kupietzad1f3b82024-04-19 19:21:49 +0200194 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 +0100195 <!-- TODO: Fktnswoerter nachtragen -->
196 <xsl:sequence select="."/>
197 </xsl:when>
198 <xsl:otherwise/>
199 </xsl:choose>
200 </xsl:matching-substring>
201 </xsl:analyze-string>
202 </xsl:variable>
203 <xsl:value-of
Marc Kupietz77b6aa92024-04-21 17:31:43 +0200204 select="upper-case(substring(normalize-space(replace($helper,'\s+.+$','')),1,3))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100205 <!-- longest match of .+ -->
206 </xsl:variable>
Marc Kupietz77b6aa92024-04-21 17:31:43 +0200207 <xsl:variable name="authorInitials">
208 <xsl:choose>
209 <xsl:when test="contains($autor,';')">
210 <xsl:variable name="lastname_aut1"
211 select="upper-case(substring(normalize-space($autor),1,1))"/>
212 <xsl:variable name="lastname_aut2"
213 select="replace($autor, '.*?;.*?([A-Z]).*', '$1')"/>
214 <xsl:value-of select="concat($lastname_aut1, $lastname_aut2)"/>
215 </xsl:when>
216 <xsl:otherwise>
217 <xsl:variable name="lastname_aut1"
218 select="upper-case(substring(normalize-space(substring-before($autor,',')),1,1))"/>
219 <xsl:variable name="firstname_aut1"
220 select="upper-case(substring(normalize-space(substring-after($autor,',')),1,1))"/>
221 <xsl:value-of select="concat($lastname_aut1, $firstname_aut1)"/>
222 </xsl:otherwise>
223 </xsl:choose>
224 </xsl:variable>
Marc Kupietz398b5962024-04-21 17:51:34 +0200225 <xsl:value-of select="substring(replace(normalize-unicode(concat($authorInitials,$firstContentWordTitleInitial), 'NFKD'),'[^A-Z]',''),1,3)"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100226 </xsl:variable>
227
228
Marc Kupietz0c246632024-04-29 07:08:23 +0200229 <xsl:variable name="text_sigle" select="replace($idno, '.*([0-9]{5})[0-9X]$', '$1')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100230 <xsl:variable name="sigle" select="concat($corpus_sigle, '/', $doc_sigle, '.', $text_sigle)"/>
231
232 <!-- fuer BOT+xy: (?) -->
233 <xsl:variable name="xyref">
234 <xsl:value-of select="document-uri(.)"/>
235 <xsl:text>; </xsl:text>
Marc Kupietz0c246632024-04-29 07:08:23 +0200236 <xsl:text>IDNO:</xsl:text>
237 <xsl:value-of select="$idno"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100238 <xsl:text>; </xsl:text>
239 <xsl:value-of select="string-join($dnbBookdata//dc:identifier)"/>
240 </xsl:variable>
241
Marc Kupietzb660ed62024-03-16 11:45:53 +0100242 <xsl:variable name="long-reference"
243 select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/>
244
245 <xsl:variable name="short-reference"
246 select="concat($straight_autor, ': ', $titel, ' (', $erscheinungsjahr, ')')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100247
248 <xsl:template match="/">
Marc Kupietzb7a4f6c2024-04-19 11:35:25 +0200249 <xsl:if test="not($j)">
Marc Kupietz0c246632024-04-29 07:08:23 +0200250 <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 +0200251 </xsl:if>
252
Marc Kupietz815cc6c2024-04-19 12:44:44 +0200253 <xsl:if test="not(normalize-space($titel))">
Marc Kupietz0c246632024-04-29 07:08:23 +0200254 <xsl:message terminate="yes">ERROR: No title found for IDNO: <xsl:value-of select="$idno"/></xsl:message>
Marc Kupietz815cc6c2024-04-19 12:44:44 +0200255 </xsl:if>
256
Marc Kupietz2badfb12024-04-19 12:59:40 +0200257 <xsl:if test="not(normalize-space($autor))">
Marc Kupietz0c246632024-04-29 07:08:23 +0200258 <xsl:message terminate="yes">ERROR: No author found for IDNO: <xsl:value-of select="$idno"/></xsl:message>
Marc Kupietz2badfb12024-04-19 12:59:40 +0200259 </xsl:if>
260
Marc Kupietz52aa5052024-04-21 18:16:06 +0200261 <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 +0200262 <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 +0200263 </xsl:if>
264
Marc Kupietz1a422662024-03-16 09:34:10 +0100265 <idsDoc TEIform="TEI.2" type="text" version="1.0">
266 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="document" version="1.1">
267 <fileDesc>
268 <titleStmt>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100269 <dokumentSigle><xsl:value-of select="string-join(($corpus_sigle, $doc_sigle), '/')"/></dokumentSigle>
270 <d.title><xsl:value-of select="$short-reference"/></d.title>
Marc Kupietz1a422662024-03-16 09:34:10 +0100271 </titleStmt>
272 <publicationStmt>
273 <distributor/>
274 <pubAddress/>
275 <availability region="world" status="unknown">QAO-NC</availability>
276 <pubDate/>
277 </publicationStmt>
278 <sourceDesc>
279 <biblStruct>
280 <monogr>
281 <h.title type="main"/>
282 <imprint/>
283 </monogr>
284 </biblStruct>
285 </sourceDesc>
286 </fileDesc>
287 </idsHeader>
288 <idsText version="1.0">
289 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="text" version="1.1">
290 <fileDesc>
291 <titleStmt>
292 <textSigle><xsl:sequence select="$sigle"/></textSigle>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100293 <t.title assemblage="regular"><xsl:value-of select="$long-reference"/></t.title>
Marc Kupietz1a422662024-03-16 09:34:10 +0100294 </titleStmt>
295 <publicationStmt>
296 <distributor/>
297 <pubAddress/>
298 <availability region="world" status="unknown">QAO-NC</availability>
299 <pubDate/>
300 </publicationStmt>
301 <sourceDesc>
302 <biblStruct>
303 <monogr>
304 <h.title type="main"><xsl:value-of select="$titel"/></h.title>
305 <h.title type="sub"><xsl:value-of select="$untertitel"/></h.title>
306 <h.author><xsl:value-of select="$autor"/></h.author>
Marc Kupietzeaa90132024-04-26 18:14:40 +0200307 <xsl:if test="$translator">
308 <editor role="translator"><xsl:value-of select="$translator"/></editor>
309 </xsl:if>
Marc Kupietz15e7d612024-04-26 18:16:39 +0200310 <xsl:if test="$herausgeber">
311 <editor role="editor"><xsl:value-of select="$herausgeber"/></editor>
312 </xsl:if>
Marc Kupietz1a422662024-03-16 09:34:10 +0100313 <edition>
314 <further/>
315 <kind>E-Book-Ausgabe</kind>
316 <appearance>EPUB-Datei</appearance>
317 </edition>
318 <imprint>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100319 <publisher><xsl:value-of select="$verlag"/></publisher>
Marc Kupietz1a422662024-03-16 09:34:10 +0100320 <pubDate type="year"><xsl:value-of select="$j"/></pubDate>
321 <pubDate type="month"/>
322 <pubDate type="day"/>
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200323 <pubPlace key="{$erscheinungsland}"><xsl:value-of select="$erscheinungsort"/></pubPlace>
Marc Kupietz1a422662024-03-16 09:34:10 +0100324 </imprint>
325 <biblScope type="subsume"/>
326 <biblScope type="pp"/>
327 <biblScope type="vol"/>
328 <biblScope type="volume-title"/>
329 </monogr>
330 </biblStruct>
331 <reference assemblage="regular" type="complete"><xsl:value-of select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/></reference>
Marc Kupietz1a422662024-03-16 09:34:10 +0100332 </sourceDesc>
333 </fileDesc>
334 <profileDesc>
335 <creation>
336 <creatDate><xsl:value-of select="$j"/></creatDate>
337 </creation>
338 <textClass/>
339 <textDesc>
Marc Kupietz9d87e9d2024-05-05 15:56:50 +0200340 <textType><xsl:value-of select="$textFullGenre"/></textType>
341 <textTypeRef><xsl:value-of select="replace($textFullGenre, '.*: *', '')"/></textTypeRef>
Marc Kupietz1a422662024-03-16 09:34:10 +0100342 <textDomain/>
343 </textDesc>
344 </profileDesc>
345 </idsHeader>
346 <text>
347 <body>
348 <!-- Call the template for each link in the TOC
349 <xsl:apply-templates select="//xhtml:ol[@class='toc']/xhtml:li/xhtml:a" mode="collect"/> -->
Marc Kupietz8f727302024-04-10 16:31:19 +0200350 <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 +0100351 </body>
352 </text>
353 </idsText>
354 </idsDoc>
355 </xsl:template>
356
357 <xsl:template match="opf:item" mode="collect">
358 <xsl:variable name="href" select="@href"/>
359 <xsl:message>
Marc Kupietz0c246632024-04-29 07:08:23 +0200360 <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 +0100361 </xsl:message>
362 <xsl:apply-templates select="doc(resolve-uri($href, base-uri()))/xhtml:html/xhtml:body"/>
363 </xsl:template>
364
365 <xsl:template match="xhtml:body">
366 <div type="chapter">
367 <xsl:apply-templates/>
368 </div>
369 </xsl:template>
370
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000371 <xsl:template match="xhtml:body/text()">
372 <p>
373 <xsl:value-of select="."/>
374 </p>
375 </xsl:template>
376
Marc Kupietz1a422662024-03-16 09:34:10 +0100377 <xsl:template match="xhtml:title">
378 <head>
379 <xsl:apply-templates/>
380 </head>
381 </xsl:template>
382
383 <xsl:template match="xhtml:h1">
384 <head>
385 <xsl:apply-templates/>
386 </head>
387 </xsl:template>
388
Marc Kupietz3989c742024-04-21 17:33:49 +0200389 <xsl:template match="xhtml:h2|xhtml:h3|xhtml:h4|xhtml:h5|xhtml:h6">
Marc Kupietz1a422662024-03-16 09:34:10 +0100390 <head type="sub">
391 <xsl:apply-templates/>
392 </head>
393 </xsl:template>
394
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100395 <xsl:template match="xhtml:em">
396 <emph>
397 <xsl:apply-templates/>
398 </emph>
399 </xsl:template>
Marc Kupietz1a422662024-03-16 09:34:10 +0100400
Marc Kupietz30cc0802024-04-10 16:37:04 +0200401 <xsl:template match="xhtml:span[matches(@class, '(bold|italic|big|kursiv| )+')]">
402 <xsl:variable name="class" select="replace(@class, 'kursiv', 'italic')"/>
403 <hi rend="{$class}">
404 <xsl:apply-templates/>
405 </hi>
406 </xsl:template>
407
Marc Kupietzad4d4462024-04-26 17:43:08 +0200408 <xsl:template match="xhtml:span[matches(@class, '(regular|norm)')]">
Marc Kupietz5e873112024-04-15 06:51:08 +0200409 <xsl:apply-templates/>
410 </xsl:template>
411
Marc Kupietz3989c742024-04-21 17:33:49 +0200412 <xsl:template match="xhtml:b|xhtml:span[@class='b']|xhtml:strong">
Marc Kupietz30cc0802024-04-10 16:37:04 +0200413 <hi rend="bold">
Marc Kupietz1a422662024-03-16 09:34:10 +0100414 <xsl:apply-templates/>
415 </hi>
416 </xsl:template>
417
Marc Kupietzfb0f2c32024-04-26 17:43:18 +0200418 <xsl:template match="xhtml:i|xhtml:span[@class='i' or @class='it']">
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000419 <hi rend="italic">
420 <xsl:apply-templates/>
421 </hi>
422 </xsl:template>
423
424
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100425 <xsl:template match="xhtml:sub|xhtml:span[@class='sub']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100426 <hi rend="sub">
427 <xsl:apply-templates/>
428 </hi>
429 </xsl:template>
430
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100431 <xsl:template match="xhtml:sup|xhtml:span[@class='sup']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100432 <hi rend="sup">
433 <xsl:apply-templates/>
434 </hi>
435 </xsl:template>
436
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000437 <xsl:template match="xhtml:div[not(normalize-space(replace(., '&#160;', ' ')))]" priority="1.0"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100438
Marc Kupietzbf47ae72024-04-14 14:21:43 +0200439 <xsl:template match="xhtml:body/xhtml:div[./xhtml:h1|./xhtml:h2|./xhtml:h3]" priority="1.0">
440 <xsl:apply-templates/>
441 </xsl:template>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000442 <xsl:template match="xhtml:div/xhtml:div">
Marc Kupietz1a422662024-03-16 09:34:10 +0100443 <p>
444 <xsl:apply-templates/>
445 </p>
446 </xsl:template>
447
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000448 <xsl:template match="xhtml:body/xhtml:div[(descendant::xhtml:p|descendant::xhtml:div)]">
449 <div type="section">
450 <xsl:apply-templates/>
451 </div>
452 </xsl:template>
453
454 <xsl:template match="xhtml:body/xhtml:div[not(descendant::xhtml:p|descendant::xhtml:div)]">
455 <div type="section">
456 <p>
457 <xsl:apply-templates/>
458 </p>
459 </div>
460 </xsl:template>
461
462 <xsl:template match="xhtml:p[not(descendant::xhtml:p|descendant::xhtml:div)]">
463 <xsl:if test="normalize-space(.)">
464 <p>
465 <xsl:apply-templates/>
466 </p>
467 </xsl:if>
468 </xsl:template>
469
470 <xsl:template match="xhtml:p[descendant::xhtml:p|descendant::xhtml:div]">
471 <xsl:if test="normalize-space(.)">
472 <div type="section">
473 <xsl:apply-templates/>
474 </div>
475 </xsl:if>
476 </xsl:template>
477
Marc Kupietz09745e12024-04-21 12:54:10 +0200478 <xsl:template match="xhtml:ul">
479 <list type="unordered">
480 <xsl:apply-templates/>
481 </list>
482 </xsl:template>
483 <xsl:template match="xhtml:ol">
484 <list type="ordered">
485 <xsl:apply-templates/>
486 </list>
487 </xsl:template>
488 <xsl:template match="xhtml:li">
489 <item>
490 <xsl:apply-templates/>
491 </item>
492 </xsl:template>
493 <xsl:template match="xhtml:nav">
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200494 <!-- <gap reason="toc"/> -->
495 </xsl:template>
496
Marc Kupietz1a422662024-03-16 09:34:10 +0100497 <xsl:template match="xhtml:img">
498 <!-- <gap reason="image"/> -->
499 </xsl:template>
500
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200501 <xsl:template match="xhtml:audio">
502 <!-- <gap reason="audio"/> -->
503 </xsl:template>
504
Marc Kupietz09745e12024-04-21 12:54:10 +0200505 <xsl:template match="xhtml:table">
506 <!-- <gap reason="table"/> -->
507 </xsl:template>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000508 <xsl:template match="xhtml:body/xhtml:a">
Marc Kupietz164a2832024-04-14 21:00:48 +0200509 <xsl:if test="normalize-space(.)">
510 <p>
511 <ref target="{@href}">
512 <xsl:apply-templates />
513 </ref>
514 </p>
515 </xsl:if>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000516 </xsl:template>
517
518 <xsl:template match="xhtml:body/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 <div type="section">
523 <p>
524 <xsl:value-of select="."/>
525 </p>
526 </div>
527 </xsl:template>
528 <xsl:template match="xhtml:span">
529 <xsl:message>
530 <xsl:text>unhandled span element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
531 </xsl:message>
532 <xsl:value-of select="."/>
533 </xsl:template>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100534 <xsl:template match="xhtml:a">
Marc Kupietz164a2832024-04-14 21:00:48 +0200535 <xsl:if test="normalize-space(.)">
536 <ref target="{@href}">
537 <xsl:apply-templates />
538 </ref>
539 </xsl:if>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100540 </xsl:template>
541
Marc Kupietz54ec28b2024-04-27 10:07:06 +0200542 <xsl:template match="xhtml:br">
543 <lb/><xsl:text>&#10;</xsl:text>
544 </xsl:template>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100545
Marc Kupietz1a422662024-03-16 09:34:10 +0100546 <xsl:template match="xhtml:*">
547 <xsl:message>
548 <xsl:text>unhandled element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
549 </xsl:message>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000550 <xsl:choose>
551 <xsl:when test="descendant::xhtml:div|descendant::xhtml:p|parent::xhtml:body">
552 <div type="section">
553 <xsl:apply-templates/>
554 </div>
555 </xsl:when>
556 <xsl:otherwise>
557 <xsl:apply-templates select="./*|node()"/>
558 </xsl:otherwise>
559 </xsl:choose>
Marc Kupietz1a422662024-03-16 09:34:10 +0100560 <xsl:apply-templates/>
561 </xsl:template>
562
563 <xsl:function name="ids:reversedAuthors">
564 <xsl:param name="s" />
565 <xsl:value-of
566 select="
567 if (matches($s, ';')) then
568 concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; ')))
569 else
570 replace($s, '(.+) (.+)', '$2, $1')"
571 />
572 </xsl:function>
573
574 <xsl:function name="hlu:reversedAuthors">
575 <xsl:param name="s"/>
576 <xsl:value-of
577 select="if (matches($s, ';')) then concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; '))) else replace($s, '(.+),(.+)', '$2, $1')"
578 />
579 </xsl:function>
580
Marc Kupietz10903f32024-04-14 14:21:18 +0200581 <xsl:variable name="city-country-map" as="map(xs:string, xs:string)">
582 <xsl:map>
583 <xsl:map-entry key="'Axams'" select="'AT'"/>
584 <xsl:map-entry key="'Vienna'" select="'AT'"/>
585 <xsl:map-entry key="'Klagenfurt'" select="'AT'"/>
586 <xsl:map-entry key="'Graz'" select="'AT'"/>
587 <xsl:map-entry key="'Innsbruck'" select="'AT'"/>
588 <xsl:map-entry key="'Salzburg'" select="'AT'"/>
589 <xsl:map-entry key="'Bern'" select="'CH'"/>
590 <xsl:map-entry key="'Biel/Bienne'" select="'CH'"/>
591 <xsl:map-entry key="'Zurich'" select="'CH'"/>
592 <xsl:map-entry key="'Basel'" select="'CH'"/>
593 <xsl:map-entry key="'Geneva'" select="'CH'"/>
594 <xsl:map-entry key="'Lucerne'" select="'CH'"/>
595 <xsl:map-entry key="'Lausanne'" select="'CH'"/>
596 <xsl:map-entry key="'Winterthur'" select="'CH'"/>
597 <xsl:map-entry key="'St. Gallen'" select="'CH'"/>
598 <xsl:map-entry key="'Interlaken'" select="'CH'"/>
599 <xsl:map-entry key="'Brussels'" select="'BE'"/>
600 <xsl:map-entry key="'Antwerp'" select="'BE'"/>
601 <xsl:map-entry key="'Ghent'" select="'BE'"/>
602 <xsl:map-entry key="'Bruges'" select="'BE'"/>
603 <xsl:map-entry key="'Leuven'" select="'BE'"/>
604 <xsl:map-entry key="'Liege'" select="'BE'"/>
605 <xsl:map-entry key="'Charleroi'" select="'BE'"/>
606 <xsl:map-entry key="'Namur'" select="'BE'"/>
607 <xsl:map-entry key="'Mons'" select="'BE'"/>
608 <xsl:map-entry key="'Bangkok'" select="'TH'"/>
609 <xsl:map-entry key="'Copenhagen'" select="'DK'"/>
610 <xsl:map-entry key="'colatina'" select="'BR'"/>
611 <xsl:map-entry key="'Oakland Park'" select="'US'"/>
612 <xsl:map-entry key="'Istanbul'" select="'TR'"/>
613 <xsl:map-entry key="'Luxemburg'" select="'LU'"/>
614 <xsl:map-entry key="'Palma de Mallorca'" select="'ES'"/>
615 <xsl:map-entry key="'Swakopmund'" select="'NA'"/>
616 <xsl:map-entry key="'Victoria'" select="'CA'"/>
617 <xsl:map-entry key="'Wien'" select="'AT'"/>
618 <xsl:map-entry key="'Windhoek'" select="'NA'"/>
619 <xsl:map-entry key="'Zuerich'" select="'CH'"/>
620 <xsl:map-entry key="'Zürich'" select="'CH'"/>
621 <xsl:map-entry key="'Zug'" select="'CH'"/>
622 <xsl:map-entry key="'ZÜRICH'" select="'CH'"/>
623 </xsl:map>
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200624
Marc Kupietz10903f32024-04-14 14:21:18 +0200625 </xsl:variable>
626
627 <!-- Define the function -->
628 <xsl:function name="ids:country-city" as="xs:string">
629 <xsl:param name="city" as="xs:string"/>
630 <xsl:sequence select="if (map:contains($city-country-map, $city)) then map:get($city-country-map, $city) else 'DE'"/>
631 </xsl:function>
Marc Kupietz1a422662024-03-16 09:34:10 +0100632</xsl:stylesheet>