blob: 34ed0901c0c1c2fc152b77ba7c142cd9ec5537f4 [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 Kupietz1a422662024-03-16 09:34:10 +010086 <xsl:variable name="verlag">
87 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +020088 <xsl:when test="contains(($dnbBookdata//dc:publisher)[1], ':')">
89 <xsl:value-of select="normalize-space(substring-after(($dnbBookdata//dc:publisher)[1], ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010090 </xsl:when>
91 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +020092 <xsl:value-of select="normalize-space(($dnbBookdata//dc:publisher)[1])"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010093 </xsl:otherwise>
94 </xsl:choose>
95 </xsl:variable>
96
97 <xsl:variable name="erscheinungsjahr">
Marc Kupietza5d01182024-04-14 12:24:02 +020098 <xsl:value-of select="replace(($dnbBookdata//dc:date)[1], '.*?((19|20)[0-9][0-9]).*', '$1')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010099 </xsl:variable>
100
101 <xsl:variable name="untertitel"
Marc Kupietz6cb52232024-04-13 12:28:44 +0200102 select="normalize-space(substring-after(substring-before(($dnbBookdata//dc:title)[1], '/'), ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100103
Marc Kupietza5d01182024-04-14 12:24:02 +0200104 <xsl:variable name="j" select="$erscheinungsjahr"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100105
106 <!-- for BOT+s: -->
107 <xsl:variable name="seiten" select="replace($dnbBookdata//dc:format,'S\.','')"/>
108
109 <!-- fuer BOT+b: -->
110 <xsl:variable name="_b">
111 <xsl:variable name="regexp1" select="'(Band|Bd\.)\s*([0-9]?[0-9]?[0-9])'"/>
112 <xsl:choose>
113 <xsl:when test="matches($dnbBookdata, $regexp1)">
114 <xsl:analyze-string select="$dnbBookdata//dc:title" regex="{$regexp1}">
115 <xsl:matching-substring>
116 <xsl:value-of select="."/>
117 </xsl:matching-substring>
118 </xsl:analyze-string>
119 </xsl:when>
120 <xsl:otherwise>
121 <xsl:value-of select="'.'"/>
122 </xsl:otherwise>
123 </xsl:choose>
124 </xsl:variable>
125
126 <!-- for BOT+x: -->
127 <xsl:variable name="txtart">
128 <xsl:choose>
129 <xsl:when test="$x">
130 <xsl:value-of select="concat('[', $x, ']')"/>
131 </xsl:when>
132 <xsl:when
133 test="matches($untertitel, '([Rr]oman|[Ee]rzhlung(en)?|[Aa]nthologie|[Gg]eschichte(n)?|[Nn]ovelle)')">
134 <xsl:value-of
135 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'), ']')"
136 />
137 </xsl:when>
138 <xsl:otherwise>
139 <xsl:value-of>Roman</xsl:value-of>
140 </xsl:otherwise>
141 </xsl:choose>
142 </xsl:variable>
143
144
145
146 <!-- fuer BOTd: -->
147 <xsl:variable name="dok"
148 select="concat((if(string-length($autor) &gt; 0) then concat($straight_autor, ': ') else ''), $titel, ', ', $txtart, ', (', $j, ')')"/>
149
150 <!-- END variables derived from sru request to dnb archive -->
151
152
Marc Kupietz94bbe6b2024-04-10 20:35:48 +0200153 <xsl:variable name="corpus_sigle" select="concat('DNB', substring($erscheinungsjahr, 3, 2))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100154
155 <!-- for BOTD: -->
156 <!-- Dokumentsigle muss zusammen mit Korpussigle (z.B DIV fuer loz-div und loz-div-pub) eindeutig sein -->
157 <xsl:variable name="doc_sigle">
158 <xsl:variable name="firstContentWordTitleInitial">
159 <xsl:variable name="helper">
160 <xsl:analyze-string select="$titel" regex="\w+">
161 <xsl:matching-substring>
162 <xsl:choose>
163 <xsl:when
Marc Kupietzad1f3b82024-04-19 19:21:49 +0200164 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 +0100165 <!-- TODO: Fktnswoerter nachtragen -->
166 <xsl:sequence select="."/>
167 </xsl:when>
168 <xsl:otherwise/>
169 </xsl:choose>
170 </xsl:matching-substring>
171 </xsl:analyze-string>
172 </xsl:variable>
173 <xsl:value-of
Marc Kupietz77b6aa92024-04-21 17:31:43 +0200174 select="upper-case(substring(normalize-space(replace($helper,'\s+.+$','')),1,3))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100175 <!-- longest match of .+ -->
176 </xsl:variable>
Marc Kupietz77b6aa92024-04-21 17:31:43 +0200177 <xsl:variable name="authorInitials">
178 <xsl:choose>
179 <xsl:when test="contains($autor,';')">
180 <xsl:variable name="lastname_aut1"
181 select="upper-case(substring(normalize-space($autor),1,1))"/>
182 <xsl:variable name="lastname_aut2"
183 select="replace($autor, '.*?;.*?([A-Z]).*', '$1')"/>
184 <xsl:value-of select="concat($lastname_aut1, $lastname_aut2)"/>
185 </xsl:when>
186 <xsl:otherwise>
187 <xsl:variable name="lastname_aut1"
188 select="upper-case(substring(normalize-space(substring-before($autor,',')),1,1))"/>
189 <xsl:variable name="firstname_aut1"
190 select="upper-case(substring(normalize-space(substring-after($autor,',')),1,1))"/>
191 <xsl:value-of select="concat($lastname_aut1, $firstname_aut1)"/>
192 </xsl:otherwise>
193 </xsl:choose>
194 </xsl:variable>
Marc Kupietz398b5962024-04-21 17:51:34 +0200195 <xsl:value-of select="substring(replace(normalize-unicode(concat($authorInitials,$firstContentWordTitleInitial), 'NFKD'),'[^A-Z]',''),1,3)"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100196 </xsl:variable>
197
198
Marc Kupietz0c246632024-04-29 07:08:23 +0200199 <xsl:variable name="text_sigle" select="replace($idno, '.*([0-9]{5})[0-9X]$', '$1')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100200 <xsl:variable name="sigle" select="concat($corpus_sigle, '/', $doc_sigle, '.', $text_sigle)"/>
201
202 <!-- fuer BOT+xy: (?) -->
203 <xsl:variable name="xyref">
204 <xsl:value-of select="document-uri(.)"/>
205 <xsl:text>; </xsl:text>
Marc Kupietz0c246632024-04-29 07:08:23 +0200206 <xsl:text>IDNO:</xsl:text>
207 <xsl:value-of select="$idno"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100208 <xsl:text>; </xsl:text>
209 <xsl:value-of select="string-join($dnbBookdata//dc:identifier)"/>
210 </xsl:variable>
211
Marc Kupietzb660ed62024-03-16 11:45:53 +0100212 <xsl:variable name="long-reference"
213 select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/>
214
215 <xsl:variable name="short-reference"
216 select="concat($straight_autor, ': ', $titel, ' (', $erscheinungsjahr, ')')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100217
218 <xsl:template match="/">
Marc Kupietzb7a4f6c2024-04-19 11:35:25 +0200219 <xsl:if test="not($j)">
Marc Kupietz0c246632024-04-29 07:08:23 +0200220 <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 +0200221 </xsl:if>
222
Marc Kupietz815cc6c2024-04-19 12:44:44 +0200223 <xsl:if test="not(normalize-space($titel))">
Marc Kupietz0c246632024-04-29 07:08:23 +0200224 <xsl:message terminate="yes">ERROR: No title found for IDNO: <xsl:value-of select="$idno"/></xsl:message>
Marc Kupietz815cc6c2024-04-19 12:44:44 +0200225 </xsl:if>
226
Marc Kupietz2badfb12024-04-19 12:59:40 +0200227 <xsl:if test="not(normalize-space($autor))">
Marc Kupietz0c246632024-04-29 07:08:23 +0200228 <xsl:message terminate="yes">ERROR: No author found for IDNO: <xsl:value-of select="$idno"/></xsl:message>
Marc Kupietz2badfb12024-04-19 12:59:40 +0200229 </xsl:if>
230
Marc Kupietz52aa5052024-04-21 18:16:06 +0200231 <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 +0200232 <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 +0200233 </xsl:if>
234
Marc Kupietz1a422662024-03-16 09:34:10 +0100235 <idsDoc TEIform="TEI.2" type="text" version="1.0">
236 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="document" version="1.1">
237 <fileDesc>
238 <titleStmt>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100239 <dokumentSigle><xsl:value-of select="string-join(($corpus_sigle, $doc_sigle), '/')"/></dokumentSigle>
240 <d.title><xsl:value-of select="$short-reference"/></d.title>
Marc Kupietz1a422662024-03-16 09:34:10 +0100241 </titleStmt>
242 <publicationStmt>
243 <distributor/>
244 <pubAddress/>
245 <availability region="world" status="unknown">QAO-NC</availability>
246 <pubDate/>
247 </publicationStmt>
248 <sourceDesc>
249 <biblStruct>
250 <monogr>
251 <h.title type="main"/>
252 <imprint/>
253 </monogr>
254 </biblStruct>
255 </sourceDesc>
256 </fileDesc>
257 </idsHeader>
258 <idsText version="1.0">
259 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="text" version="1.1">
260 <fileDesc>
261 <titleStmt>
262 <textSigle><xsl:sequence select="$sigle"/></textSigle>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100263 <t.title assemblage="regular"><xsl:value-of select="$long-reference"/></t.title>
Marc Kupietz1a422662024-03-16 09:34:10 +0100264 </titleStmt>
265 <publicationStmt>
266 <distributor/>
267 <pubAddress/>
268 <availability region="world" status="unknown">QAO-NC</availability>
269 <pubDate/>
270 </publicationStmt>
271 <sourceDesc>
272 <biblStruct>
273 <monogr>
274 <h.title type="main"><xsl:value-of select="$titel"/></h.title>
275 <h.title type="sub"><xsl:value-of select="$untertitel"/></h.title>
276 <h.author><xsl:value-of select="$autor"/></h.author>
Marc Kupietzeaa90132024-04-26 18:14:40 +0200277 <xsl:if test="$translator">
278 <editor role="translator"><xsl:value-of select="$translator"/></editor>
279 </xsl:if>
Marc Kupietz15e7d612024-04-26 18:16:39 +0200280 <xsl:if test="$herausgeber">
281 <editor role="editor"><xsl:value-of select="$herausgeber"/></editor>
282 </xsl:if>
Marc Kupietz1a422662024-03-16 09:34:10 +0100283 <edition>
284 <further/>
285 <kind>E-Book-Ausgabe</kind>
286 <appearance>EPUB-Datei</appearance>
287 </edition>
288 <imprint>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100289 <publisher><xsl:value-of select="$verlag"/></publisher>
Marc Kupietz1a422662024-03-16 09:34:10 +0100290 <pubDate type="year"><xsl:value-of select="$j"/></pubDate>
291 <pubDate type="month"/>
292 <pubDate type="day"/>
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200293 <pubPlace key="{$erscheinungsland}"><xsl:value-of select="$erscheinungsort"/></pubPlace>
Marc Kupietz1a422662024-03-16 09:34:10 +0100294 </imprint>
295 <biblScope type="subsume"/>
296 <biblScope type="pp"/>
297 <biblScope type="vol"/>
298 <biblScope type="volume-title"/>
299 </monogr>
300 </biblStruct>
301 <reference assemblage="regular" type="complete"><xsl:value-of select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/></reference>
Marc Kupietz1a422662024-03-16 09:34:10 +0100302 </sourceDesc>
303 </fileDesc>
304 <profileDesc>
305 <creation>
306 <creatDate><xsl:value-of select="$j"/></creatDate>
307 </creation>
308 <textClass/>
309 <textDesc>
Marc Kupietz7df4ccc2024-03-16 15:27:45 +0100310 <textType><xsl:value-of select="$texttype"/></textType>
311 <textTypeRef><xsl:value-of select="$texttype"/></textTypeRef>
Marc Kupietz1a422662024-03-16 09:34:10 +0100312 <textDomain/>
313 </textDesc>
314 </profileDesc>
315 </idsHeader>
316 <text>
317 <body>
318 <!-- Call the template for each link in the TOC
319 <xsl:apply-templates select="//xhtml:ol[@class='toc']/xhtml:li/xhtml:a" mode="collect"/> -->
Marc Kupietz8f727302024-04-10 16:31:19 +0200320 <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 +0100321 </body>
322 </text>
323 </idsText>
324 </idsDoc>
325 </xsl:template>
326
327 <xsl:template match="opf:item" mode="collect">
328 <xsl:variable name="href" select="@href"/>
329 <xsl:message>
Marc Kupietz0c246632024-04-29 07:08:23 +0200330 <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 +0100331 </xsl:message>
332 <xsl:apply-templates select="doc(resolve-uri($href, base-uri()))/xhtml:html/xhtml:body"/>
333 </xsl:template>
334
335 <xsl:template match="xhtml:body">
336 <div type="chapter">
337 <xsl:apply-templates/>
338 </div>
339 </xsl:template>
340
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000341 <xsl:template match="xhtml:body/text()">
342 <p>
343 <xsl:value-of select="."/>
344 </p>
345 </xsl:template>
346
Marc Kupietz1a422662024-03-16 09:34:10 +0100347 <xsl:template match="xhtml:title">
348 <head>
349 <xsl:apply-templates/>
350 </head>
351 </xsl:template>
352
353 <xsl:template match="xhtml:h1">
354 <head>
355 <xsl:apply-templates/>
356 </head>
357 </xsl:template>
358
Marc Kupietz3989c742024-04-21 17:33:49 +0200359 <xsl:template match="xhtml:h2|xhtml:h3|xhtml:h4|xhtml:h5|xhtml:h6">
Marc Kupietz1a422662024-03-16 09:34:10 +0100360 <head type="sub">
361 <xsl:apply-templates/>
362 </head>
363 </xsl:template>
364
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100365 <xsl:template match="xhtml:em">
366 <emph>
367 <xsl:apply-templates/>
368 </emph>
369 </xsl:template>
Marc Kupietz1a422662024-03-16 09:34:10 +0100370
Marc Kupietz30cc0802024-04-10 16:37:04 +0200371 <xsl:template match="xhtml:span[matches(@class, '(bold|italic|big|kursiv| )+')]">
372 <xsl:variable name="class" select="replace(@class, 'kursiv', 'italic')"/>
373 <hi rend="{$class}">
374 <xsl:apply-templates/>
375 </hi>
376 </xsl:template>
377
Marc Kupietzad4d4462024-04-26 17:43:08 +0200378 <xsl:template match="xhtml:span[matches(@class, '(regular|norm)')]">
Marc Kupietz5e873112024-04-15 06:51:08 +0200379 <xsl:apply-templates/>
380 </xsl:template>
381
Marc Kupietz3989c742024-04-21 17:33:49 +0200382 <xsl:template match="xhtml:b|xhtml:span[@class='b']|xhtml:strong">
Marc Kupietz30cc0802024-04-10 16:37:04 +0200383 <hi rend="bold">
Marc Kupietz1a422662024-03-16 09:34:10 +0100384 <xsl:apply-templates/>
385 </hi>
386 </xsl:template>
387
Marc Kupietzfb0f2c32024-04-26 17:43:18 +0200388 <xsl:template match="xhtml:i|xhtml:span[@class='i' or @class='it']">
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000389 <hi rend="italic">
390 <xsl:apply-templates/>
391 </hi>
392 </xsl:template>
393
394
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100395 <xsl:template match="xhtml:sub|xhtml:span[@class='sub']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100396 <hi rend="sub">
397 <xsl:apply-templates/>
398 </hi>
399 </xsl:template>
400
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100401 <xsl:template match="xhtml:sup|xhtml:span[@class='sup']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100402 <hi rend="sup">
403 <xsl:apply-templates/>
404 </hi>
405 </xsl:template>
406
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000407 <xsl:template match="xhtml:div[not(normalize-space(replace(., '&#160;', ' ')))]" priority="1.0"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100408
Marc Kupietzbf47ae72024-04-14 14:21:43 +0200409 <xsl:template match="xhtml:body/xhtml:div[./xhtml:h1|./xhtml:h2|./xhtml:h3]" priority="1.0">
410 <xsl:apply-templates/>
411 </xsl:template>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000412 <xsl:template match="xhtml:div/xhtml:div">
Marc Kupietz1a422662024-03-16 09:34:10 +0100413 <p>
414 <xsl:apply-templates/>
415 </p>
416 </xsl:template>
417
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000418 <xsl:template match="xhtml:body/xhtml:div[(descendant::xhtml:p|descendant::xhtml:div)]">
419 <div type="section">
420 <xsl:apply-templates/>
421 </div>
422 </xsl:template>
423
424 <xsl:template match="xhtml:body/xhtml:div[not(descendant::xhtml:p|descendant::xhtml:div)]">
425 <div type="section">
426 <p>
427 <xsl:apply-templates/>
428 </p>
429 </div>
430 </xsl:template>
431
432 <xsl:template match="xhtml:p[not(descendant::xhtml:p|descendant::xhtml:div)]">
433 <xsl:if test="normalize-space(.)">
434 <p>
435 <xsl:apply-templates/>
436 </p>
437 </xsl:if>
438 </xsl:template>
439
440 <xsl:template match="xhtml:p[descendant::xhtml:p|descendant::xhtml:div]">
441 <xsl:if test="normalize-space(.)">
442 <div type="section">
443 <xsl:apply-templates/>
444 </div>
445 </xsl:if>
446 </xsl:template>
447
Marc Kupietz09745e12024-04-21 12:54:10 +0200448 <xsl:template match="xhtml:ul">
449 <list type="unordered">
450 <xsl:apply-templates/>
451 </list>
452 </xsl:template>
453 <xsl:template match="xhtml:ol">
454 <list type="ordered">
455 <xsl:apply-templates/>
456 </list>
457 </xsl:template>
458 <xsl:template match="xhtml:li">
459 <item>
460 <xsl:apply-templates/>
461 </item>
462 </xsl:template>
463 <xsl:template match="xhtml:nav">
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200464 <!-- <gap reason="toc"/> -->
465 </xsl:template>
466
Marc Kupietz1a422662024-03-16 09:34:10 +0100467 <xsl:template match="xhtml:img">
468 <!-- <gap reason="image"/> -->
469 </xsl:template>
470
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200471 <xsl:template match="xhtml:audio">
472 <!-- <gap reason="audio"/> -->
473 </xsl:template>
474
Marc Kupietz09745e12024-04-21 12:54:10 +0200475 <xsl:template match="xhtml:table">
476 <!-- <gap reason="table"/> -->
477 </xsl:template>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000478 <xsl:template match="xhtml:body/xhtml:a">
Marc Kupietz164a2832024-04-14 21:00:48 +0200479 <xsl:if test="normalize-space(.)">
480 <p>
481 <ref target="{@href}">
482 <xsl:apply-templates />
483 </ref>
484 </p>
485 </xsl:if>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000486 </xsl:template>
487
488 <xsl:template match="xhtml:body/xhtml:span">
489 <xsl:message>
490 <xsl:text>unhandled span element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
491 </xsl:message>
492 <div type="section">
493 <p>
494 <xsl:value-of select="."/>
495 </p>
496 </div>
497 </xsl:template>
498 <xsl:template match="xhtml:span">
499 <xsl:message>
500 <xsl:text>unhandled span element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
501 </xsl:message>
502 <xsl:value-of select="."/>
503 </xsl:template>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100504 <xsl:template match="xhtml:a">
Marc Kupietz164a2832024-04-14 21:00:48 +0200505 <xsl:if test="normalize-space(.)">
506 <ref target="{@href}">
507 <xsl:apply-templates />
508 </ref>
509 </xsl:if>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100510 </xsl:template>
511
Marc Kupietz54ec28b2024-04-27 10:07:06 +0200512 <xsl:template match="xhtml:br">
513 <lb/><xsl:text>&#10;</xsl:text>
514 </xsl:template>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100515
Marc Kupietz1a422662024-03-16 09:34:10 +0100516 <xsl:template match="xhtml:*">
517 <xsl:message>
518 <xsl:text>unhandled element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
519 </xsl:message>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000520 <xsl:choose>
521 <xsl:when test="descendant::xhtml:div|descendant::xhtml:p|parent::xhtml:body">
522 <div type="section">
523 <xsl:apply-templates/>
524 </div>
525 </xsl:when>
526 <xsl:otherwise>
527 <xsl:apply-templates select="./*|node()"/>
528 </xsl:otherwise>
529 </xsl:choose>
Marc Kupietz1a422662024-03-16 09:34:10 +0100530 <xsl:apply-templates/>
531 </xsl:template>
532
533 <xsl:function name="ids:reversedAuthors">
534 <xsl:param name="s" />
535 <xsl:value-of
536 select="
537 if (matches($s, ';')) then
538 concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; ')))
539 else
540 replace($s, '(.+) (.+)', '$2, $1')"
541 />
542 </xsl:function>
543
544 <xsl:function name="hlu:reversedAuthors">
545 <xsl:param name="s"/>
546 <xsl:value-of
547 select="if (matches($s, ';')) then concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; '))) else replace($s, '(.+),(.+)', '$2, $1')"
548 />
549 </xsl:function>
550
Marc Kupietz10903f32024-04-14 14:21:18 +0200551 <xsl:variable name="city-country-map" as="map(xs:string, xs:string)">
552 <xsl:map>
553 <xsl:map-entry key="'Axams'" select="'AT'"/>
554 <xsl:map-entry key="'Vienna'" select="'AT'"/>
555 <xsl:map-entry key="'Klagenfurt'" select="'AT'"/>
556 <xsl:map-entry key="'Graz'" select="'AT'"/>
557 <xsl:map-entry key="'Innsbruck'" select="'AT'"/>
558 <xsl:map-entry key="'Salzburg'" select="'AT'"/>
559 <xsl:map-entry key="'Bern'" select="'CH'"/>
560 <xsl:map-entry key="'Biel/Bienne'" select="'CH'"/>
561 <xsl:map-entry key="'Zurich'" select="'CH'"/>
562 <xsl:map-entry key="'Basel'" select="'CH'"/>
563 <xsl:map-entry key="'Geneva'" select="'CH'"/>
564 <xsl:map-entry key="'Lucerne'" select="'CH'"/>
565 <xsl:map-entry key="'Lausanne'" select="'CH'"/>
566 <xsl:map-entry key="'Winterthur'" select="'CH'"/>
567 <xsl:map-entry key="'St. Gallen'" select="'CH'"/>
568 <xsl:map-entry key="'Interlaken'" select="'CH'"/>
569 <xsl:map-entry key="'Brussels'" select="'BE'"/>
570 <xsl:map-entry key="'Antwerp'" select="'BE'"/>
571 <xsl:map-entry key="'Ghent'" select="'BE'"/>
572 <xsl:map-entry key="'Bruges'" select="'BE'"/>
573 <xsl:map-entry key="'Leuven'" select="'BE'"/>
574 <xsl:map-entry key="'Liege'" select="'BE'"/>
575 <xsl:map-entry key="'Charleroi'" select="'BE'"/>
576 <xsl:map-entry key="'Namur'" select="'BE'"/>
577 <xsl:map-entry key="'Mons'" select="'BE'"/>
578 <xsl:map-entry key="'Bangkok'" select="'TH'"/>
579 <xsl:map-entry key="'Copenhagen'" select="'DK'"/>
580 <xsl:map-entry key="'colatina'" select="'BR'"/>
581 <xsl:map-entry key="'Oakland Park'" select="'US'"/>
582 <xsl:map-entry key="'Istanbul'" select="'TR'"/>
583 <xsl:map-entry key="'Luxemburg'" select="'LU'"/>
584 <xsl:map-entry key="'Palma de Mallorca'" select="'ES'"/>
585 <xsl:map-entry key="'Swakopmund'" select="'NA'"/>
586 <xsl:map-entry key="'Victoria'" select="'CA'"/>
587 <xsl:map-entry key="'Wien'" select="'AT'"/>
588 <xsl:map-entry key="'Windhoek'" select="'NA'"/>
589 <xsl:map-entry key="'Zuerich'" select="'CH'"/>
590 <xsl:map-entry key="'Zürich'" select="'CH'"/>
591 <xsl:map-entry key="'Zug'" select="'CH'"/>
592 <xsl:map-entry key="'ZÜRICH'" select="'CH'"/>
593 </xsl:map>
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200594
Marc Kupietz10903f32024-04-14 14:21:18 +0200595 </xsl:variable>
596
597 <!-- Define the function -->
598 <xsl:function name="ids:country-city" as="xs:string">
599 <xsl:param name="city" as="xs:string"/>
600 <xsl:sequence select="if (map:contains($city-country-map, $city)) then map:get($city-country-map, $city) else 'DE'"/>
601 </xsl:function>
Marc Kupietz1a422662024-03-16 09:34:10 +0100602</xsl:stylesheet>