blob: b23de65429b3ccc6a0b6700f7e46b562e7919610 [file] [log] [blame]
Marc Kupietz7cc8fc72024-05-26 16:49:38 +02001<?xml version="1.0" encoding="UTF-8"?>
Marc Kupietz1a422662024-03-16 09:34:10 +01002<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:xs="http://www.w3.org/2001/XMLSchema"
4 xmlns:opf="http://www.idpf.org/2007/opf"
5 xmlns:dc="http://purl.org/dc/elements/1.1/"
6 xmlns:ids="http://www.ids-mannheim.de/ids"
7 xmlns:hlu="http://www.ids-mannheim.de/hlu"
8 xmlns:saxon="http://saxon.sf.net/"
9 xmlns:xhtml="http://www.w3.org/1999/xhtml"
Marc Kupietz10903f32024-04-14 14:21:18 +020010 xmlns:map="http://www.w3.org/2005/xpath-functions/map"
Rebecca Wilme5f055a2024-05-10 15:07:50 +020011 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
12 xmlns:srw="http://www.loc.gov/zing/srw/"
13 xmlns:oai="http://www.openarchives.org/OAI/2.0/oai_dc/"
14 exclude-result-prefixes="xs opf dc ids hlu map saxon xhtml xsi srw oai">
Marc Kupietz1a422662024-03-16 09:34:10 +010015
16 <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" saxon:line-length="1000"/>
17 <xsl:strip-space elements="*"/>
18
19 <xsl:variable name="ev"/>
20 <xsl:variable name="x"/>
21
Marc Kupietz0c246632024-04-29 07:08:23 +020022 <xsl:variable name="idno" as="xs:string" select="replace(document-uri(), '.*/([0-9]{9,13}X?).*' , '$1')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010023
Rebecca Wilmf614a4b2024-05-07 10:19:43 +020024 <xsl:variable name="idno_type">
Rebecca Wilme5f055a2024-05-10 15:07:50 +020025 <xsl:choose>
26 <xsl:when test="starts-with($idno,'1')">
27 <xsl:value-of select="'IDN'"/>
28 </xsl:when>
29 <xsl:otherwise>
30 <xsl:value-of select="'ISBN'"/>
31 </xsl:otherwise>
32 </xsl:choose>
Rebecca Wilmf614a4b2024-05-07 10:19:43 +020033 </xsl:variable>
34
Marc Kupietz1a422662024-03-16 09:34:10 +010035 <xsl:variable name="dnbBookdata">
Rebecca Wilmf614a4b2024-05-07 10:19:43 +020036 <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 +010037 </xsl:variable>
38
39 <xsl:variable name="autor"
Marc Kupietzde2ca532024-04-26 16:50:53 +020040 select="replace(string-join($dnbBookdata//dc:creator[not(contains(., '[')) or matches(., '\[Verfasser\]')], ' ; '), ' *\[[^\]]*\]', '')"/>
Marc Kupietzeaa90132024-04-26 18:14:40 +020041 <xsl:variable name="straight_autor" select="normalize-space(replace(hlu:reversedAuthors($autor), ',', ''))"/>
42 <xsl:variable name="translator"
43 select="replace(string-join($dnbBookdata//dc:creator[matches(., '\[Übersetzer\]')], ' ; '), ' *\[[^\]]*\]', '')"/>
44 <xsl:variable name="straight_translator" select="normalize-space(replace(hlu:reversedAuthors($translator), ',', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010045
Marc Kupietz15e7d612024-04-26 18:16:39 +020046 <xsl:variable name="herausgeber"
47 select="replace(string-join($dnbBookdata//dc:creator[matches(., '\[(Herausgeber|Hrsg.)\]')], ' ; '), ' *\[[^\]]*\]', '')"/>
48 <xsl:variable name="straight_herausgeber" select="normalize-space(replace(hlu:reversedAuthors($herausgeber), ',', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010049
50 <xsl:variable name="ina"/>
51 <xsl:variable name="_corpus"/>
52 <xsl:variable name="ent_known"/>
53
54
55 <!-- added HLU 2012-02-09: -->
56 <xsl:variable name="ent">
57 <xsl:choose>
58 <xsl:when test="$ent_known">
59 <xsl:value-of select="$ent_known"/>
60 </xsl:when>
61 <xsl:when test="$ev">
62 <xsl:value-of select="$ev"/>
63 </xsl:when>
64 <xsl:otherwise>
65 <xsl:value-of select="$j"/>
66 </xsl:otherwise>
67 </xsl:choose>
68 </xsl:variable>
69
70 <xsl:variable name="titel">
Marc Kupietz49124fa2024-04-10 16:50:01 +020071 <xsl:variable name="title-with-subtitles">
72 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +020073 <xsl:when test="contains(($dnbBookdata//dc:title)[1],':')">
Rebecca Wilme5f055a2024-05-10 15:07:50 +020074 <xsl:value-of select="normalize-space(substring-before(substring-before(($dnbBookdata//dc:title)[1], '/'), ':'))"/>
Marc Kupietz49124fa2024-04-10 16:50:01 +020075 </xsl:when>
76 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +020077 <xsl:value-of select="normalize-space(substring-before(($dnbBookdata//dc:title)[1], '/'))"/>
Marc Kupietz49124fa2024-04-10 16:50:01 +020078 </xsl:otherwise>
79 </xsl:choose>
80 </xsl:variable>
81 <xsl:value-of select="normalize-space(replace($title-with-subtitles, '\|.*', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010082 </xsl:variable>
83
84 <xsl:variable name="erscheinungsort">
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-before(($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
Marc Kupietzd8599fc2024-04-14 13:16:56 +020095 <xsl:variable name="erscheinungsland" select="ids:country-city($erscheinungsort)"/>
96
Marc Kupietz6cb52232024-04-13 12:28:44 +020097 <xsl:variable name="texttype" select="replace(($dnbBookdata//dc:subject[matches(., '^[A-Z] ')])[1], '^[A-Z] (.*)', '$1')"/>
Marc Kupietz7df4ccc2024-03-16 15:27:45 +010098
Marc Kupietz9d87e9d2024-05-05 15:56:50 +020099 <xsl:variable name="genretable">
100 <genres>
101 <genre keyRegex="krimi" genre="Roman: Kriminalroman"/>
102 <genre keyRegex="arztroman" genre="Roman: Arztroman"/>
103 <genre keyRegex="liebesroman" genre="Roman: Liebesroman"/>
104 <genre keyRegex="science.?fiction" genre="Roman: Science-Fiction-Roman"/>
105 <genre keyRegex="horror" genre="Roman: Horrorroman"/>
106 <genre keyRegex="western" genre="Roman: Westernroman"/>
107 <genre keyRegex="fantasy" genre="Roman: Fantasyroman"/>
108 <genre keyRegex="historischer roman" genre="Roman: Historischer Roman"/>
109 <genre keyRegex="erzählung" genre="Erzählung"/>
110 <genre keyRegex="novelle" genre="Novelle"/>
111 <genre keyRegex="anthologie" genre="Anthologie"/>
112 <genre keyRegex="kurzgeschichte" genre="Kurzgeschichte"/>
113 <genre keyRegex="roman" genre="Roman"/>
114 <genre keyRegex="." genre="Roman"/>
115 </genres>
116 </xsl:variable>
117
118 <xsl:variable name="textFullGenre" select="$genretable/genres/genre[matches($dnbBookdata, ./@keyRegex, 'i')][1]/@genre"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100119 <xsl:variable name="verlag">
120 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +0200121 <xsl:when test="contains(($dnbBookdata//dc:publisher)[1], ':')">
122 <xsl:value-of select="normalize-space(substring-after(($dnbBookdata//dc:publisher)[1], ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100123 </xsl:when>
124 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +0200125 <xsl:value-of select="normalize-space(($dnbBookdata//dc:publisher)[1])"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100126 </xsl:otherwise>
127 </xsl:choose>
128 </xsl:variable>
129
130 <xsl:variable name="erscheinungsjahr">
Marc Kupietza5d01182024-04-14 12:24:02 +0200131 <xsl:value-of select="replace(($dnbBookdata//dc:date)[1], '.*?((19|20)[0-9][0-9]).*', '$1')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100132 </xsl:variable>
133
134 <xsl:variable name="untertitel"
Marc Kupietz6cb52232024-04-13 12:28:44 +0200135 select="normalize-space(substring-after(substring-before(($dnbBookdata//dc:title)[1], '/'), ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100136
Marc Kupietza5d01182024-04-14 12:24:02 +0200137 <xsl:variable name="j" select="$erscheinungsjahr"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100138
139 <!-- for BOT+s: -->
140 <xsl:variable name="seiten" select="replace($dnbBookdata//dc:format,'S\.','')"/>
141
142 <!-- fuer BOT+b: -->
143 <xsl:variable name="_b">
144 <xsl:variable name="regexp1" select="'(Band|Bd\.)\s*([0-9]?[0-9]?[0-9])'"/>
145 <xsl:choose>
146 <xsl:when test="matches($dnbBookdata, $regexp1)">
147 <xsl:analyze-string select="$dnbBookdata//dc:title" regex="{$regexp1}">
148 <xsl:matching-substring>
149 <xsl:value-of select="."/>
150 </xsl:matching-substring>
151 </xsl:analyze-string>
152 </xsl:when>
153 <xsl:otherwise>
154 <xsl:value-of select="'.'"/>
155 </xsl:otherwise>
156 </xsl:choose>
157 </xsl:variable>
158
159 <!-- for BOT+x: -->
160 <xsl:variable name="txtart">
161 <xsl:choose>
162 <xsl:when test="$x">
163 <xsl:value-of select="concat('[', $x, ']')"/>
164 </xsl:when>
165 <xsl:when
Nicolas Arnold26355632024-05-10 15:25:41 +0200166 test="matches($untertitel, '([Rr]oman|[Ee]rzählung(en)?|[Aa]nthologie|[Gg]eschichte(n)?|[Nn]ovelle)')">
Marc Kupietz1a422662024-03-16 09:34:10 +0100167 <xsl:value-of
Nicolas Arnold26355632024-05-10 15:25:41 +0200168 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 +0100169 />
170 </xsl:when>
171 <xsl:otherwise>
172 <xsl:value-of>Roman</xsl:value-of>
173 </xsl:otherwise>
174 </xsl:choose>
175 </xsl:variable>
176
177
178
179 <!-- fuer BOTd: -->
180 <xsl:variable name="dok"
181 select="concat((if(string-length($autor) &gt; 0) then concat($straight_autor, ': ') else ''), $titel, ', ', $txtart, ', (', $j, ')')"/>
182
183 <!-- END variables derived from sru request to dnb archive -->
184
185
Marc Kupietz94bbe6b2024-04-10 20:35:48 +0200186 <xsl:variable name="corpus_sigle" select="concat('DNB', substring($erscheinungsjahr, 3, 2))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100187
188 <!-- for BOTD: -->
189 <!-- Dokumentsigle muss zusammen mit Korpussigle (z.B DIV fuer loz-div und loz-div-pub) eindeutig sein -->
190 <xsl:variable name="doc_sigle">
191 <xsl:variable name="firstContentWordTitleInitial">
192 <xsl:variable name="helper">
193 <xsl:analyze-string select="$titel" regex="\w+">
194 <xsl:matching-substring>
195 <xsl:choose>
196 <xsl:when
Marc Kupietzad1f3b82024-04-19 19:21:49 +0200197 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 +0100198 <!-- TODO: Fktnswoerter nachtragen -->
199 <xsl:sequence select="."/>
200 </xsl:when>
201 <xsl:otherwise/>
202 </xsl:choose>
203 </xsl:matching-substring>
204 </xsl:analyze-string>
205 </xsl:variable>
206 <xsl:value-of
Marc Kupietz77b6aa92024-04-21 17:31:43 +0200207 select="upper-case(substring(normalize-space(replace($helper,'\s+.+$','')),1,3))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100208 <!-- longest match of .+ -->
209 </xsl:variable>
Marc Kupietz77b6aa92024-04-21 17:31:43 +0200210 <xsl:variable name="authorInitials">
211 <xsl:choose>
212 <xsl:when test="contains($autor,';')">
213 <xsl:variable name="lastname_aut1"
214 select="upper-case(substring(normalize-space($autor),1,1))"/>
215 <xsl:variable name="lastname_aut2"
216 select="replace($autor, '.*?;.*?([A-Z]).*', '$1')"/>
217 <xsl:value-of select="concat($lastname_aut1, $lastname_aut2)"/>
218 </xsl:when>
219 <xsl:otherwise>
220 <xsl:variable name="lastname_aut1"
221 select="upper-case(substring(normalize-space(substring-before($autor,',')),1,1))"/>
222 <xsl:variable name="firstname_aut1"
223 select="upper-case(substring(normalize-space(substring-after($autor,',')),1,1))"/>
224 <xsl:value-of select="concat($lastname_aut1, $firstname_aut1)"/>
225 </xsl:otherwise>
226 </xsl:choose>
227 </xsl:variable>
Marc Kupietz398b5962024-04-21 17:51:34 +0200228 <xsl:value-of select="substring(replace(normalize-unicode(concat($authorInitials,$firstContentWordTitleInitial), 'NFKD'),'[^A-Z]',''),1,3)"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100229 </xsl:variable>
230
231
Marc Kupietz0c246632024-04-29 07:08:23 +0200232 <xsl:variable name="text_sigle" select="replace($idno, '.*([0-9]{5})[0-9X]$', '$1')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100233 <xsl:variable name="sigle" select="concat($corpus_sigle, '/', $doc_sigle, '.', $text_sigle)"/>
234
235 <!-- fuer BOT+xy: (?) -->
236 <xsl:variable name="xyref">
237 <xsl:value-of select="document-uri(.)"/>
238 <xsl:text>; </xsl:text>
Marc Kupietz0c246632024-04-29 07:08:23 +0200239 <xsl:text>IDNO:</xsl:text>
240 <xsl:value-of select="$idno"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100241 <xsl:text>; </xsl:text>
242 <xsl:value-of select="string-join($dnbBookdata//dc:identifier)"/>
243 </xsl:variable>
244
Marc Kupietzb660ed62024-03-16 11:45:53 +0100245 <xsl:variable name="long-reference"
246 select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/>
247
248 <xsl:variable name="short-reference"
249 select="concat($straight_autor, ': ', $titel, ' (', $erscheinungsjahr, ')')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100250
251 <xsl:template match="/">
Marc Kupietzb7a4f6c2024-04-19 11:35:25 +0200252 <xsl:if test="not($j)">
Marc Kupietz0c246632024-04-29 07:08:23 +0200253 <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 +0200254 </xsl:if>
255
Marc Kupietz815cc6c2024-04-19 12:44:44 +0200256 <xsl:if test="not(normalize-space($titel))">
Marc Kupietz0c246632024-04-29 07:08:23 +0200257 <xsl:message terminate="yes">ERROR: No title found for IDNO: <xsl:value-of select="$idno"/></xsl:message>
Marc Kupietz815cc6c2024-04-19 12:44:44 +0200258 </xsl:if>
259
Marc Kupietz2badfb12024-04-19 12:59:40 +0200260 <xsl:if test="not(normalize-space($autor))">
Marc Kupietz0c246632024-04-29 07:08:23 +0200261 <xsl:message terminate="yes">ERROR: No author found for IDNO: <xsl:value-of select="$idno"/></xsl:message>
Marc Kupietz2badfb12024-04-19 12:59:40 +0200262 </xsl:if>
263
Marc Kupietz52aa5052024-04-21 18:16:06 +0200264 <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 +0200265 <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 +0200266 </xsl:if>
267
Marc Kupietz1a422662024-03-16 09:34:10 +0100268 <idsDoc TEIform="TEI.2" type="text" version="1.0">
269 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="document" version="1.1">
270 <fileDesc>
271 <titleStmt>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100272 <dokumentSigle><xsl:value-of select="string-join(($corpus_sigle, $doc_sigle), '/')"/></dokumentSigle>
273 <d.title><xsl:value-of select="$short-reference"/></d.title>
Marc Kupietz1a422662024-03-16 09:34:10 +0100274 </titleStmt>
275 <publicationStmt>
276 <distributor/>
277 <pubAddress/>
Rebecca Wilme5f055a2024-05-10 15:07:50 +0200278 <xsl:for-each select="$dnbBookdata//dc:identifier">
279 <xsl:variable name="type" select="substring-after(@xsi:type, ':')"/>
280 <xsl:choose>
281 <xsl:when test="@xsi:type='tel:ISBN'">
282 <xsl:if test="matches(.,'(^([0-9]|-)+X?).*')">
283 <idno type="{$type}"><xsl:value-of select="replace(., '(([0-9]|-)+X?).*', '$1')"/></idno>
284 </xsl:if>
285 </xsl:when>
286 <xsl:otherwise><idno type="{$type}"><xsl:value-of select="."/></idno></xsl:otherwise>
287 </xsl:choose>
288 </xsl:for-each>
Marc Kupietz1a422662024-03-16 09:34:10 +0100289 <availability region="world" status="unknown">QAO-NC</availability>
290 <pubDate/>
291 </publicationStmt>
292 <sourceDesc>
293 <biblStruct>
294 <monogr>
295 <h.title type="main"/>
296 <imprint/>
297 </monogr>
298 </biblStruct>
299 </sourceDesc>
300 </fileDesc>
301 </idsHeader>
302 <idsText version="1.0">
303 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="text" version="1.1">
304 <fileDesc>
305 <titleStmt>
306 <textSigle><xsl:sequence select="$sigle"/></textSigle>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100307 <t.title assemblage="regular"><xsl:value-of select="$long-reference"/></t.title>
Marc Kupietz1a422662024-03-16 09:34:10 +0100308 </titleStmt>
309 <publicationStmt>
310 <distributor/>
311 <pubAddress/>
312 <availability region="world" status="unknown">QAO-NC</availability>
313 <pubDate/>
314 </publicationStmt>
315 <sourceDesc>
316 <biblStruct>
317 <monogr>
318 <h.title type="main"><xsl:value-of select="$titel"/></h.title>
319 <h.title type="sub"><xsl:value-of select="$untertitel"/></h.title>
320 <h.author><xsl:value-of select="$autor"/></h.author>
Marc Kupietzeaa90132024-04-26 18:14:40 +0200321 <xsl:if test="$translator">
322 <editor role="translator"><xsl:value-of select="$translator"/></editor>
323 </xsl:if>
Marc Kupietz15e7d612024-04-26 18:16:39 +0200324 <xsl:if test="$herausgeber">
325 <editor role="editor"><xsl:value-of select="$herausgeber"/></editor>
326 </xsl:if>
Marc Kupietz1a422662024-03-16 09:34:10 +0100327 <edition>
328 <further/>
329 <kind>E-Book-Ausgabe</kind>
330 <appearance>EPUB-Datei</appearance>
331 </edition>
332 <imprint>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100333 <publisher><xsl:value-of select="$verlag"/></publisher>
Marc Kupietz1a422662024-03-16 09:34:10 +0100334 <pubDate type="year"><xsl:value-of select="$j"/></pubDate>
335 <pubDate type="month"/>
336 <pubDate type="day"/>
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200337 <pubPlace key="{$erscheinungsland}"><xsl:value-of select="$erscheinungsort"/></pubPlace>
Marc Kupietz1a422662024-03-16 09:34:10 +0100338 </imprint>
339 <biblScope type="subsume"/>
340 <biblScope type="pp"/>
341 <biblScope type="vol"/>
342 <biblScope type="volume-title"/>
343 </monogr>
344 </biblStruct>
345 <reference assemblage="regular" type="complete"><xsl:value-of select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/></reference>
Marc Kupietz1a422662024-03-16 09:34:10 +0100346 </sourceDesc>
347 </fileDesc>
348 <profileDesc>
349 <creation>
350 <creatDate><xsl:value-of select="$j"/></creatDate>
351 </creation>
352 <textClass/>
353 <textDesc>
Marc Kupietz9d87e9d2024-05-05 15:56:50 +0200354 <textType><xsl:value-of select="$textFullGenre"/></textType>
355 <textTypeRef><xsl:value-of select="replace($textFullGenre, '.*: *', '')"/></textTypeRef>
Marc Kupietz1a422662024-03-16 09:34:10 +0100356 <textDomain/>
357 </textDesc>
358 </profileDesc>
359 </idsHeader>
360 <text>
361 <body>
362 <!-- Call the template for each link in the TOC
363 <xsl:apply-templates select="//xhtml:ol[@class='toc']/xhtml:li/xhtml:a" mode="collect"/> -->
Marc Kupietz8f727302024-04-10 16:31:19 +0200364 <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 +0100365 </body>
366 </text>
367 </idsText>
368 </idsDoc>
369 </xsl:template>
370
371 <xsl:template match="opf:item" mode="collect">
372 <xsl:variable name="href" select="@href"/>
373 <xsl:message>
Marc Kupietz0c246632024-04-29 07:08:23 +0200374 <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 +0100375 </xsl:message>
376 <xsl:apply-templates select="doc(resolve-uri($href, base-uri()))/xhtml:html/xhtml:body"/>
377 </xsl:template>
378
379 <xsl:template match="xhtml:body">
380 <div type="chapter">
381 <xsl:apply-templates/>
382 </div>
383 </xsl:template>
384
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000385 <xsl:template match="xhtml:body/text()">
386 <p>
387 <xsl:value-of select="."/>
388 </p>
389 </xsl:template>
390
Marc Kupietz1a422662024-03-16 09:34:10 +0100391 <xsl:template match="xhtml:title">
392 <head>
393 <xsl:apply-templates/>
394 </head>
395 </xsl:template>
396
397 <xsl:template match="xhtml:h1">
398 <head>
399 <xsl:apply-templates/>
400 </head>
401 </xsl:template>
402
Marc Kupietz3989c742024-04-21 17:33:49 +0200403 <xsl:template match="xhtml:h2|xhtml:h3|xhtml:h4|xhtml:h5|xhtml:h6">
Marc Kupietz1a422662024-03-16 09:34:10 +0100404 <head type="sub">
405 <xsl:apply-templates/>
406 </head>
407 </xsl:template>
408
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100409 <xsl:template match="xhtml:em">
410 <emph>
411 <xsl:apply-templates/>
412 </emph>
413 </xsl:template>
Marc Kupietz1a422662024-03-16 09:34:10 +0100414
Marc Kupietz30cc0802024-04-10 16:37:04 +0200415 <xsl:template match="xhtml:span[matches(@class, '(bold|italic|big|kursiv| )+')]">
416 <xsl:variable name="class" select="replace(@class, 'kursiv', 'italic')"/>
417 <hi rend="{$class}">
418 <xsl:apply-templates/>
419 </hi>
420 </xsl:template>
421
Marc Kupietzad4d4462024-04-26 17:43:08 +0200422 <xsl:template match="xhtml:span[matches(@class, '(regular|norm)')]">
Marc Kupietz5e873112024-04-15 06:51:08 +0200423 <xsl:apply-templates/>
424 </xsl:template>
425
Marc Kupietz3989c742024-04-21 17:33:49 +0200426 <xsl:template match="xhtml:b|xhtml:span[@class='b']|xhtml:strong">
Marc Kupietz30cc0802024-04-10 16:37:04 +0200427 <hi rend="bold">
Marc Kupietz1a422662024-03-16 09:34:10 +0100428 <xsl:apply-templates/>
429 </hi>
430 </xsl:template>
431
Marc Kupietzfb0f2c32024-04-26 17:43:18 +0200432 <xsl:template match="xhtml:i|xhtml:span[@class='i' or @class='it']">
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000433 <hi rend="italic">
434 <xsl:apply-templates/>
435 </hi>
436 </xsl:template>
437
438
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100439 <xsl:template match="xhtml:sub|xhtml:span[@class='sub']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100440 <hi rend="sub">
441 <xsl:apply-templates/>
442 </hi>
443 </xsl:template>
444
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100445 <xsl:template match="xhtml:sup|xhtml:span[@class='sup']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100446 <hi rend="sup">
447 <xsl:apply-templates/>
448 </hi>
449 </xsl:template>
450
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000451 <xsl:template match="xhtml:div[not(normalize-space(replace(., '&#160;', ' ')))]" priority="1.0"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100452
Marc Kupietzbf47ae72024-04-14 14:21:43 +0200453 <xsl:template match="xhtml:body/xhtml:div[./xhtml:h1|./xhtml:h2|./xhtml:h3]" priority="1.0">
454 <xsl:apply-templates/>
455 </xsl:template>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000456 <xsl:template match="xhtml:div/xhtml:div">
Marc Kupietz1a422662024-03-16 09:34:10 +0100457 <p>
458 <xsl:apply-templates/>
459 </p>
460 </xsl:template>
461
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000462 <xsl:template match="xhtml:body/xhtml:div[(descendant::xhtml:p|descendant::xhtml:div)]">
463 <div type="section">
464 <xsl:apply-templates/>
465 </div>
466 </xsl:template>
467
468 <xsl:template match="xhtml:body/xhtml:div[not(descendant::xhtml:p|descendant::xhtml:div)]">
469 <div type="section">
470 <p>
471 <xsl:apply-templates/>
472 </p>
473 </div>
474 </xsl:template>
475
476 <xsl:template match="xhtml:p[not(descendant::xhtml:p|descendant::xhtml:div)]">
477 <xsl:if test="normalize-space(.)">
478 <p>
479 <xsl:apply-templates/>
480 </p>
481 </xsl:if>
482 </xsl:template>
483
484 <xsl:template match="xhtml:p[descendant::xhtml:p|descendant::xhtml:div]">
485 <xsl:if test="normalize-space(.)">
486 <div type="section">
487 <xsl:apply-templates/>
488 </div>
489 </xsl:if>
490 </xsl:template>
491
Marc Kupietz09745e12024-04-21 12:54:10 +0200492 <xsl:template match="xhtml:ul">
493 <list type="unordered">
494 <xsl:apply-templates/>
495 </list>
496 </xsl:template>
497 <xsl:template match="xhtml:ol">
498 <list type="ordered">
499 <xsl:apply-templates/>
500 </list>
501 </xsl:template>
502 <xsl:template match="xhtml:li">
503 <item>
504 <xsl:apply-templates/>
505 </item>
506 </xsl:template>
507 <xsl:template match="xhtml:nav">
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200508 <!-- <gap reason="toc"/> -->
509 </xsl:template>
510
Marc Kupietz1a422662024-03-16 09:34:10 +0100511 <xsl:template match="xhtml:img">
512 <!-- <gap reason="image"/> -->
513 </xsl:template>
514
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200515 <xsl:template match="xhtml:audio">
516 <!-- <gap reason="audio"/> -->
517 </xsl:template>
518
Marc Kupietz09745e12024-04-21 12:54:10 +0200519 <xsl:template match="xhtml:table">
520 <!-- <gap reason="table"/> -->
521 </xsl:template>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000522 <xsl:template match="xhtml:body/xhtml:a">
Marc Kupietz164a2832024-04-14 21:00:48 +0200523 <xsl:if test="normalize-space(.)">
524 <p>
525 <ref target="{@href}">
526 <xsl:apply-templates />
527 </ref>
528 </p>
529 </xsl:if>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000530 </xsl:template>
531
532 <xsl:template match="xhtml:body/xhtml:span">
533 <xsl:message>
534 <xsl:text>unhandled span element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
535 </xsl:message>
536 <div type="section">
537 <p>
538 <xsl:value-of select="."/>
539 </p>
540 </div>
541 </xsl:template>
542 <xsl:template match="xhtml:span">
543 <xsl:message>
544 <xsl:text>unhandled span element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
545 </xsl:message>
546 <xsl:value-of select="."/>
547 </xsl:template>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100548 <xsl:template match="xhtml:a">
Marc Kupietz164a2832024-04-14 21:00:48 +0200549 <xsl:if test="normalize-space(.)">
550 <ref target="{@href}">
551 <xsl:apply-templates />
552 </ref>
553 </xsl:if>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100554 </xsl:template>
555
Marc Kupietz54ec28b2024-04-27 10:07:06 +0200556 <xsl:template match="xhtml:br">
557 <lb/><xsl:text>&#10;</xsl:text>
558 </xsl:template>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100559
Marc Kupietz1a422662024-03-16 09:34:10 +0100560 <xsl:template match="xhtml:*">
561 <xsl:message>
562 <xsl:text>unhandled element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
563 </xsl:message>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000564 <xsl:choose>
565 <xsl:when test="descendant::xhtml:div|descendant::xhtml:p|parent::xhtml:body">
566 <div type="section">
567 <xsl:apply-templates/>
568 </div>
569 </xsl:when>
570 <xsl:otherwise>
571 <xsl:apply-templates select="./*|node()"/>
572 </xsl:otherwise>
573 </xsl:choose>
Marc Kupietz1a422662024-03-16 09:34:10 +0100574 <xsl:apply-templates/>
575 </xsl:template>
576
577 <xsl:function name="ids:reversedAuthors">
578 <xsl:param name="s" />
579 <xsl:value-of
580 select="
581 if (matches($s, ';')) then
582 concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; ')))
583 else
584 replace($s, '(.+) (.+)', '$2, $1')"
585 />
586 </xsl:function>
587
588 <xsl:function name="hlu:reversedAuthors">
589 <xsl:param name="s"/>
590 <xsl:value-of
591 select="if (matches($s, ';')) then concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; '))) else replace($s, '(.+),(.+)', '$2, $1')"
592 />
593 </xsl:function>
594
Marc Kupietz10903f32024-04-14 14:21:18 +0200595 <xsl:variable name="city-country-map" as="map(xs:string, xs:string)">
596 <xsl:map>
597 <xsl:map-entry key="'Axams'" select="'AT'"/>
598 <xsl:map-entry key="'Vienna'" select="'AT'"/>
599 <xsl:map-entry key="'Klagenfurt'" select="'AT'"/>
600 <xsl:map-entry key="'Graz'" select="'AT'"/>
601 <xsl:map-entry key="'Innsbruck'" select="'AT'"/>
602 <xsl:map-entry key="'Salzburg'" select="'AT'"/>
603 <xsl:map-entry key="'Bern'" select="'CH'"/>
604 <xsl:map-entry key="'Biel/Bienne'" select="'CH'"/>
605 <xsl:map-entry key="'Zurich'" select="'CH'"/>
606 <xsl:map-entry key="'Basel'" select="'CH'"/>
607 <xsl:map-entry key="'Geneva'" select="'CH'"/>
608 <xsl:map-entry key="'Lucerne'" select="'CH'"/>
609 <xsl:map-entry key="'Lausanne'" select="'CH'"/>
610 <xsl:map-entry key="'Winterthur'" select="'CH'"/>
611 <xsl:map-entry key="'St. Gallen'" select="'CH'"/>
612 <xsl:map-entry key="'Interlaken'" select="'CH'"/>
613 <xsl:map-entry key="'Brussels'" select="'BE'"/>
614 <xsl:map-entry key="'Antwerp'" select="'BE'"/>
615 <xsl:map-entry key="'Ghent'" select="'BE'"/>
616 <xsl:map-entry key="'Bruges'" select="'BE'"/>
617 <xsl:map-entry key="'Leuven'" select="'BE'"/>
618 <xsl:map-entry key="'Liege'" select="'BE'"/>
619 <xsl:map-entry key="'Charleroi'" select="'BE'"/>
620 <xsl:map-entry key="'Namur'" select="'BE'"/>
621 <xsl:map-entry key="'Mons'" select="'BE'"/>
622 <xsl:map-entry key="'Bangkok'" select="'TH'"/>
623 <xsl:map-entry key="'Copenhagen'" select="'DK'"/>
624 <xsl:map-entry key="'colatina'" select="'BR'"/>
625 <xsl:map-entry key="'Oakland Park'" select="'US'"/>
626 <xsl:map-entry key="'Istanbul'" select="'TR'"/>
627 <xsl:map-entry key="'Luxemburg'" select="'LU'"/>
628 <xsl:map-entry key="'Palma de Mallorca'" select="'ES'"/>
629 <xsl:map-entry key="'Swakopmund'" select="'NA'"/>
630 <xsl:map-entry key="'Victoria'" select="'CA'"/>
631 <xsl:map-entry key="'Wien'" select="'AT'"/>
632 <xsl:map-entry key="'Windhoek'" select="'NA'"/>
633 <xsl:map-entry key="'Zuerich'" select="'CH'"/>
634 <xsl:map-entry key="'Zürich'" select="'CH'"/>
635 <xsl:map-entry key="'Zug'" select="'CH'"/>
636 <xsl:map-entry key="'ZÜRICH'" select="'CH'"/>
637 </xsl:map>
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200638
Marc Kupietz10903f32024-04-14 14:21:18 +0200639 </xsl:variable>
640
641 <!-- Define the function -->
642 <xsl:function name="ids:country-city" as="xs:string">
643 <xsl:param name="city" as="xs:string"/>
644 <xsl:sequence select="if (map:contains($city-country-map, $city)) then map:get($city-country-map, $city) else 'DE'"/>
645 </xsl:function>
Marc Kupietz1a422662024-03-16 09:34:10 +0100646</xsl:stylesheet>