blob: f786ed8c05630fcc5dc395ca99fe5443ac0048ef [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"
Rebecca Wilme5f055a2024-05-10 15:07:50 +020010 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
11 xmlns:srw="http://www.loc.gov/zing/srw/"
12 xmlns:oai="http://www.openarchives.org/OAI/2.0/oai_dc/"
13 exclude-result-prefixes="xs opf dc ids hlu map saxon xhtml xsi srw oai">
Marc Kupietz1a422662024-03-16 09:34:10 +010014
15 <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" saxon:line-length="1000"/>
16 <xsl:strip-space elements="*"/>
17
18 <xsl:variable name="ev"/>
19 <xsl:variable name="x"/>
20
Marc Kupietz0c246632024-04-29 07:08:23 +020021 <xsl:variable name="idno" as="xs:string" select="replace(document-uri(), '.*/([0-9]{9,13}X?).*' , '$1')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010022
Rebecca Wilmf614a4b2024-05-07 10:19:43 +020023 <xsl:variable name="idno_type">
Rebecca Wilme5f055a2024-05-10 15:07:50 +020024 <xsl:choose>
25 <xsl:when test="starts-with($idno,'1')">
26 <xsl:value-of select="'IDN'"/>
27 </xsl:when>
28 <xsl:otherwise>
29 <xsl:value-of select="'ISBN'"/>
30 </xsl:otherwise>
31 </xsl:choose>
Rebecca Wilmf614a4b2024-05-07 10:19:43 +020032 </xsl:variable>
33
Marc Kupietz1a422662024-03-16 09:34:10 +010034 <xsl:variable name="dnbBookdata">
Rebecca Wilmf614a4b2024-05-07 10:19:43 +020035 <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 +010036 </xsl:variable>
37
38 <xsl:variable name="autor"
Marc Kupietzde2ca532024-04-26 16:50:53 +020039 select="replace(string-join($dnbBookdata//dc:creator[not(contains(., '[')) or matches(., '\[Verfasser\]')], ' ; '), ' *\[[^\]]*\]', '')"/>
Marc Kupietzeaa90132024-04-26 18:14:40 +020040 <xsl:variable name="straight_autor" select="normalize-space(replace(hlu:reversedAuthors($autor), ',', ''))"/>
41 <xsl:variable name="translator"
42 select="replace(string-join($dnbBookdata//dc:creator[matches(., '\[Übersetzer\]')], ' ; '), ' *\[[^\]]*\]', '')"/>
43 <xsl:variable name="straight_translator" select="normalize-space(replace(hlu:reversedAuthors($translator), ',', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010044
Marc Kupietz15e7d612024-04-26 18:16:39 +020045 <xsl:variable name="herausgeber"
46 select="replace(string-join($dnbBookdata//dc:creator[matches(., '\[(Herausgeber|Hrsg.)\]')], ' ; '), ' *\[[^\]]*\]', '')"/>
47 <xsl:variable name="straight_herausgeber" select="normalize-space(replace(hlu:reversedAuthors($herausgeber), ',', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010048
49 <xsl:variable name="ina"/>
50 <xsl:variable name="_corpus"/>
51 <xsl:variable name="ent_known"/>
52
53
54 <!-- added HLU 2012-02-09: -->
55 <xsl:variable name="ent">
56 <xsl:choose>
57 <xsl:when test="$ent_known">
58 <xsl:value-of select="$ent_known"/>
59 </xsl:when>
60 <xsl:when test="$ev">
61 <xsl:value-of select="$ev"/>
62 </xsl:when>
63 <xsl:otherwise>
64 <xsl:value-of select="$j"/>
65 </xsl:otherwise>
66 </xsl:choose>
67 </xsl:variable>
68
69 <xsl:variable name="titel">
Marc Kupietz49124fa2024-04-10 16:50:01 +020070 <xsl:variable name="title-with-subtitles">
71 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +020072 <xsl:when test="contains(($dnbBookdata//dc:title)[1],':')">
Rebecca Wilme5f055a2024-05-10 15:07:50 +020073 <xsl:value-of select="normalize-space(substring-before(substring-before(($dnbBookdata//dc:title)[1], '/'), ':'))"/>
Marc Kupietz49124fa2024-04-10 16:50:01 +020074 </xsl:when>
75 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +020076 <xsl:value-of select="normalize-space(substring-before(($dnbBookdata//dc:title)[1], '/'))"/>
Marc Kupietz49124fa2024-04-10 16:50:01 +020077 </xsl:otherwise>
78 </xsl:choose>
79 </xsl:variable>
80 <xsl:value-of select="normalize-space(replace($title-with-subtitles, '\|.*', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010081 </xsl:variable>
82
83 <xsl:variable name="erscheinungsort">
84 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +020085 <xsl:when test="contains(($dnbBookdata//dc:publisher)[1], ':')">
86 <xsl:value-of select="normalize-space(substring-before(($dnbBookdata//dc:publisher)[1], ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010087 </xsl:when>
88 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +020089 <xsl:value-of select="normalize-space(($dnbBookdata//dc:publisher)[1])"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010090 </xsl:otherwise>
91 </xsl:choose>
92 </xsl:variable>
93
Marc Kupietzd8599fc2024-04-14 13:16:56 +020094 <xsl:variable name="erscheinungsland" select="ids:country-city($erscheinungsort)"/>
95
Marc Kupietz6cb52232024-04-13 12:28:44 +020096 <xsl:variable name="texttype" select="replace(($dnbBookdata//dc:subject[matches(., '^[A-Z] ')])[1], '^[A-Z] (.*)', '$1')"/>
Marc Kupietz7df4ccc2024-03-16 15:27:45 +010097
Marc Kupietz9d87e9d2024-05-05 15:56:50 +020098 <xsl:variable name="genretable">
99 <genres>
100 <genre keyRegex="krimi" genre="Roman: Kriminalroman"/>
101 <genre keyRegex="arztroman" genre="Roman: Arztroman"/>
102 <genre keyRegex="liebesroman" genre="Roman: Liebesroman"/>
103 <genre keyRegex="science.?fiction" genre="Roman: Science-Fiction-Roman"/>
104 <genre keyRegex="horror" genre="Roman: Horrorroman"/>
105 <genre keyRegex="western" genre="Roman: Westernroman"/>
106 <genre keyRegex="fantasy" genre="Roman: Fantasyroman"/>
107 <genre keyRegex="historischer roman" genre="Roman: Historischer Roman"/>
108 <genre keyRegex="erzählung" genre="Erzählung"/>
109 <genre keyRegex="novelle" genre="Novelle"/>
110 <genre keyRegex="anthologie" genre="Anthologie"/>
111 <genre keyRegex="kurzgeschichte" genre="Kurzgeschichte"/>
112 <genre keyRegex="roman" genre="Roman"/>
113 <genre keyRegex="." genre="Roman"/>
114 </genres>
115 </xsl:variable>
116
117 <xsl:variable name="textFullGenre" select="$genretable/genres/genre[matches($dnbBookdata, ./@keyRegex, 'i')][1]/@genre"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100118 <xsl:variable name="verlag">
119 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +0200120 <xsl:when test="contains(($dnbBookdata//dc:publisher)[1], ':')">
121 <xsl:value-of select="normalize-space(substring-after(($dnbBookdata//dc:publisher)[1], ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100122 </xsl:when>
123 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +0200124 <xsl:value-of select="normalize-space(($dnbBookdata//dc:publisher)[1])"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100125 </xsl:otherwise>
126 </xsl:choose>
127 </xsl:variable>
128
129 <xsl:variable name="erscheinungsjahr">
Marc Kupietza5d01182024-04-14 12:24:02 +0200130 <xsl:value-of select="replace(($dnbBookdata//dc:date)[1], '.*?((19|20)[0-9][0-9]).*', '$1')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100131 </xsl:variable>
132
133 <xsl:variable name="untertitel"
Marc Kupietz6cb52232024-04-13 12:28:44 +0200134 select="normalize-space(substring-after(substring-before(($dnbBookdata//dc:title)[1], '/'), ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100135
Marc Kupietza5d01182024-04-14 12:24:02 +0200136 <xsl:variable name="j" select="$erscheinungsjahr"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100137
138 <!-- for BOT+s: -->
139 <xsl:variable name="seiten" select="replace($dnbBookdata//dc:format,'S\.','')"/>
140
141 <!-- fuer BOT+b: -->
142 <xsl:variable name="_b">
143 <xsl:variable name="regexp1" select="'(Band|Bd\.)\s*([0-9]?[0-9]?[0-9])'"/>
144 <xsl:choose>
145 <xsl:when test="matches($dnbBookdata, $regexp1)">
146 <xsl:analyze-string select="$dnbBookdata//dc:title" regex="{$regexp1}">
147 <xsl:matching-substring>
148 <xsl:value-of select="."/>
149 </xsl:matching-substring>
150 </xsl:analyze-string>
151 </xsl:when>
152 <xsl:otherwise>
153 <xsl:value-of select="'.'"/>
154 </xsl:otherwise>
155 </xsl:choose>
156 </xsl:variable>
157
158 <!-- for BOT+x: -->
159 <xsl:variable name="txtart">
160 <xsl:choose>
161 <xsl:when test="$x">
162 <xsl:value-of select="concat('[', $x, ']')"/>
163 </xsl:when>
164 <xsl:when
Nicolas Arnold26355632024-05-10 15:25:41 +0200165 test="matches($untertitel, '([Rr]oman|[Ee]rzählung(en)?|[Aa]nthologie|[Gg]eschichte(n)?|[Nn]ovelle)')">
Marc Kupietz1a422662024-03-16 09:34:10 +0100166 <xsl:value-of
Nicolas Arnold26355632024-05-10 15:25:41 +0200167 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 +0100168 />
169 </xsl:when>
170 <xsl:otherwise>
171 <xsl:value-of>Roman</xsl:value-of>
172 </xsl:otherwise>
173 </xsl:choose>
174 </xsl:variable>
175
176
177
178 <!-- fuer BOTd: -->
179 <xsl:variable name="dok"
180 select="concat((if(string-length($autor) &gt; 0) then concat($straight_autor, ': ') else ''), $titel, ', ', $txtart, ', (', $j, ')')"/>
181
182 <!-- END variables derived from sru request to dnb archive -->
183
184
Marc Kupietz94bbe6b2024-04-10 20:35:48 +0200185 <xsl:variable name="corpus_sigle" select="concat('DNB', substring($erscheinungsjahr, 3, 2))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100186
187 <!-- for BOTD: -->
188 <!-- Dokumentsigle muss zusammen mit Korpussigle (z.B DIV fuer loz-div und loz-div-pub) eindeutig sein -->
189 <xsl:variable name="doc_sigle">
190 <xsl:variable name="firstContentWordTitleInitial">
191 <xsl:variable name="helper">
192 <xsl:analyze-string select="$titel" regex="\w+">
193 <xsl:matching-substring>
194 <xsl:choose>
195 <xsl:when
Marc Kupietzad1f3b82024-04-19 19:21:49 +0200196 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 +0100197 <!-- TODO: Fktnswoerter nachtragen -->
198 <xsl:sequence select="."/>
199 </xsl:when>
200 <xsl:otherwise/>
201 </xsl:choose>
202 </xsl:matching-substring>
203 </xsl:analyze-string>
204 </xsl:variable>
205 <xsl:value-of
Marc Kupietz77b6aa92024-04-21 17:31:43 +0200206 select="upper-case(substring(normalize-space(replace($helper,'\s+.+$','')),1,3))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100207 <!-- longest match of .+ -->
208 </xsl:variable>
Marc Kupietz77b6aa92024-04-21 17:31:43 +0200209 <xsl:variable name="authorInitials">
210 <xsl:choose>
211 <xsl:when test="contains($autor,';')">
212 <xsl:variable name="lastname_aut1"
213 select="upper-case(substring(normalize-space($autor),1,1))"/>
214 <xsl:variable name="lastname_aut2"
215 select="replace($autor, '.*?;.*?([A-Z]).*', '$1')"/>
216 <xsl:value-of select="concat($lastname_aut1, $lastname_aut2)"/>
217 </xsl:when>
218 <xsl:otherwise>
219 <xsl:variable name="lastname_aut1"
220 select="upper-case(substring(normalize-space(substring-before($autor,',')),1,1))"/>
221 <xsl:variable name="firstname_aut1"
222 select="upper-case(substring(normalize-space(substring-after($autor,',')),1,1))"/>
223 <xsl:value-of select="concat($lastname_aut1, $firstname_aut1)"/>
224 </xsl:otherwise>
225 </xsl:choose>
226 </xsl:variable>
Marc Kupietz398b5962024-04-21 17:51:34 +0200227 <xsl:value-of select="substring(replace(normalize-unicode(concat($authorInitials,$firstContentWordTitleInitial), 'NFKD'),'[^A-Z]',''),1,3)"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100228 </xsl:variable>
229
230
Marc Kupietz0c246632024-04-29 07:08:23 +0200231 <xsl:variable name="text_sigle" select="replace($idno, '.*([0-9]{5})[0-9X]$', '$1')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100232 <xsl:variable name="sigle" select="concat($corpus_sigle, '/', $doc_sigle, '.', $text_sigle)"/>
233
234 <!-- fuer BOT+xy: (?) -->
235 <xsl:variable name="xyref">
236 <xsl:value-of select="document-uri(.)"/>
237 <xsl:text>; </xsl:text>
Marc Kupietz0c246632024-04-29 07:08:23 +0200238 <xsl:text>IDNO:</xsl:text>
239 <xsl:value-of select="$idno"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100240 <xsl:text>; </xsl:text>
241 <xsl:value-of select="string-join($dnbBookdata//dc:identifier)"/>
242 </xsl:variable>
243
Marc Kupietzb660ed62024-03-16 11:45:53 +0100244 <xsl:variable name="long-reference"
245 select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/>
246
247 <xsl:variable name="short-reference"
248 select="concat($straight_autor, ': ', $titel, ' (', $erscheinungsjahr, ')')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100249
250 <xsl:template match="/">
Marc Kupietzb7a4f6c2024-04-19 11:35:25 +0200251 <xsl:if test="not($j)">
Marc Kupietz0c246632024-04-29 07:08:23 +0200252 <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 +0200253 </xsl:if>
254
Marc Kupietz815cc6c2024-04-19 12:44:44 +0200255 <xsl:if test="not(normalize-space($titel))">
Marc Kupietz0c246632024-04-29 07:08:23 +0200256 <xsl:message terminate="yes">ERROR: No title found for IDNO: <xsl:value-of select="$idno"/></xsl:message>
Marc Kupietz815cc6c2024-04-19 12:44:44 +0200257 </xsl:if>
258
Marc Kupietz2badfb12024-04-19 12:59:40 +0200259 <xsl:if test="not(normalize-space($autor))">
Marc Kupietz0c246632024-04-29 07:08:23 +0200260 <xsl:message terminate="yes">ERROR: No author found for IDNO: <xsl:value-of select="$idno"/></xsl:message>
Marc Kupietz2badfb12024-04-19 12:59:40 +0200261 </xsl:if>
262
Marc Kupietz52aa5052024-04-21 18:16:06 +0200263 <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 +0200264 <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 +0200265 </xsl:if>
266
Marc Kupietz1a422662024-03-16 09:34:10 +0100267 <idsDoc TEIform="TEI.2" type="text" version="1.0">
268 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="document" version="1.1">
269 <fileDesc>
270 <titleStmt>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100271 <dokumentSigle><xsl:value-of select="string-join(($corpus_sigle, $doc_sigle), '/')"/></dokumentSigle>
272 <d.title><xsl:value-of select="$short-reference"/></d.title>
Marc Kupietz1a422662024-03-16 09:34:10 +0100273 </titleStmt>
274 <publicationStmt>
275 <distributor/>
276 <pubAddress/>
Rebecca Wilme5f055a2024-05-10 15:07:50 +0200277 <xsl:for-each select="$dnbBookdata//dc:identifier">
278 <xsl:variable name="type" select="substring-after(@xsi:type, ':')"/>
279 <xsl:choose>
280 <xsl:when test="@xsi:type='tel:ISBN'">
281 <xsl:if test="matches(.,'(^([0-9]|-)+X?).*')">
282 <idno type="{$type}"><xsl:value-of select="replace(., '(([0-9]|-)+X?).*', '$1')"/></idno>
283 </xsl:if>
284 </xsl:when>
285 <xsl:otherwise><idno type="{$type}"><xsl:value-of select="."/></idno></xsl:otherwise>
286 </xsl:choose>
287 </xsl:for-each>
Marc Kupietz1a422662024-03-16 09:34:10 +0100288 <availability region="world" status="unknown">QAO-NC</availability>
289 <pubDate/>
290 </publicationStmt>
291 <sourceDesc>
292 <biblStruct>
293 <monogr>
294 <h.title type="main"/>
295 <imprint/>
296 </monogr>
297 </biblStruct>
298 </sourceDesc>
299 </fileDesc>
300 </idsHeader>
301 <idsText version="1.0">
302 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="text" version="1.1">
303 <fileDesc>
304 <titleStmt>
305 <textSigle><xsl:sequence select="$sigle"/></textSigle>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100306 <t.title assemblage="regular"><xsl:value-of select="$long-reference"/></t.title>
Marc Kupietz1a422662024-03-16 09:34:10 +0100307 </titleStmt>
308 <publicationStmt>
309 <distributor/>
310 <pubAddress/>
311 <availability region="world" status="unknown">QAO-NC</availability>
312 <pubDate/>
313 </publicationStmt>
314 <sourceDesc>
315 <biblStruct>
316 <monogr>
317 <h.title type="main"><xsl:value-of select="$titel"/></h.title>
318 <h.title type="sub"><xsl:value-of select="$untertitel"/></h.title>
319 <h.author><xsl:value-of select="$autor"/></h.author>
Marc Kupietzeaa90132024-04-26 18:14:40 +0200320 <xsl:if test="$translator">
321 <editor role="translator"><xsl:value-of select="$translator"/></editor>
322 </xsl:if>
Marc Kupietz15e7d612024-04-26 18:16:39 +0200323 <xsl:if test="$herausgeber">
324 <editor role="editor"><xsl:value-of select="$herausgeber"/></editor>
325 </xsl:if>
Marc Kupietz1a422662024-03-16 09:34:10 +0100326 <edition>
327 <further/>
328 <kind>E-Book-Ausgabe</kind>
329 <appearance>EPUB-Datei</appearance>
330 </edition>
331 <imprint>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100332 <publisher><xsl:value-of select="$verlag"/></publisher>
Marc Kupietz1a422662024-03-16 09:34:10 +0100333 <pubDate type="year"><xsl:value-of select="$j"/></pubDate>
334 <pubDate type="month"/>
335 <pubDate type="day"/>
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200336 <pubPlace key="{$erscheinungsland}"><xsl:value-of select="$erscheinungsort"/></pubPlace>
Marc Kupietz1a422662024-03-16 09:34:10 +0100337 </imprint>
338 <biblScope type="subsume"/>
339 <biblScope type="pp"/>
340 <biblScope type="vol"/>
341 <biblScope type="volume-title"/>
342 </monogr>
343 </biblStruct>
344 <reference assemblage="regular" type="complete"><xsl:value-of select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/></reference>
Marc Kupietz1a422662024-03-16 09:34:10 +0100345 </sourceDesc>
346 </fileDesc>
347 <profileDesc>
348 <creation>
349 <creatDate><xsl:value-of select="$j"/></creatDate>
350 </creation>
351 <textClass/>
352 <textDesc>
Marc Kupietz9d87e9d2024-05-05 15:56:50 +0200353 <textType><xsl:value-of select="$textFullGenre"/></textType>
354 <textTypeRef><xsl:value-of select="replace($textFullGenre, '.*: *', '')"/></textTypeRef>
Marc Kupietz1a422662024-03-16 09:34:10 +0100355 <textDomain/>
356 </textDesc>
357 </profileDesc>
358 </idsHeader>
359 <text>
360 <body>
361 <!-- Call the template for each link in the TOC
362 <xsl:apply-templates select="//xhtml:ol[@class='toc']/xhtml:li/xhtml:a" mode="collect"/> -->
Marc Kupietz8f727302024-04-10 16:31:19 +0200363 <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 +0100364 </body>
365 </text>
366 </idsText>
367 </idsDoc>
368 </xsl:template>
369
370 <xsl:template match="opf:item" mode="collect">
371 <xsl:variable name="href" select="@href"/>
372 <xsl:message>
Marc Kupietz0c246632024-04-29 07:08:23 +0200373 <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 +0100374 </xsl:message>
375 <xsl:apply-templates select="doc(resolve-uri($href, base-uri()))/xhtml:html/xhtml:body"/>
376 </xsl:template>
377
378 <xsl:template match="xhtml:body">
379 <div type="chapter">
380 <xsl:apply-templates/>
381 </div>
382 </xsl:template>
383
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000384 <xsl:template match="xhtml:body/text()">
385 <p>
386 <xsl:value-of select="."/>
387 </p>
388 </xsl:template>
389
Marc Kupietz1a422662024-03-16 09:34:10 +0100390 <xsl:template match="xhtml:title">
391 <head>
392 <xsl:apply-templates/>
393 </head>
394 </xsl:template>
395
396 <xsl:template match="xhtml:h1">
397 <head>
398 <xsl:apply-templates/>
399 </head>
400 </xsl:template>
401
Marc Kupietz3989c742024-04-21 17:33:49 +0200402 <xsl:template match="xhtml:h2|xhtml:h3|xhtml:h4|xhtml:h5|xhtml:h6">
Marc Kupietz1a422662024-03-16 09:34:10 +0100403 <head type="sub">
404 <xsl:apply-templates/>
405 </head>
406 </xsl:template>
407
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100408 <xsl:template match="xhtml:em">
409 <emph>
410 <xsl:apply-templates/>
411 </emph>
412 </xsl:template>
Marc Kupietz1a422662024-03-16 09:34:10 +0100413
Marc Kupietz30cc0802024-04-10 16:37:04 +0200414 <xsl:template match="xhtml:span[matches(@class, '(bold|italic|big|kursiv| )+')]">
415 <xsl:variable name="class" select="replace(@class, 'kursiv', 'italic')"/>
416 <hi rend="{$class}">
417 <xsl:apply-templates/>
418 </hi>
419 </xsl:template>
420
Marc Kupietzad4d4462024-04-26 17:43:08 +0200421 <xsl:template match="xhtml:span[matches(@class, '(regular|norm)')]">
Marc Kupietz5e873112024-04-15 06:51:08 +0200422 <xsl:apply-templates/>
423 </xsl:template>
424
Marc Kupietz3989c742024-04-21 17:33:49 +0200425 <xsl:template match="xhtml:b|xhtml:span[@class='b']|xhtml:strong">
Marc Kupietz30cc0802024-04-10 16:37:04 +0200426 <hi rend="bold">
Marc Kupietz1a422662024-03-16 09:34:10 +0100427 <xsl:apply-templates/>
428 </hi>
429 </xsl:template>
430
Marc Kupietzfb0f2c32024-04-26 17:43:18 +0200431 <xsl:template match="xhtml:i|xhtml:span[@class='i' or @class='it']">
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000432 <hi rend="italic">
433 <xsl:apply-templates/>
434 </hi>
435 </xsl:template>
436
437
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100438 <xsl:template match="xhtml:sub|xhtml:span[@class='sub']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100439 <hi rend="sub">
440 <xsl:apply-templates/>
441 </hi>
442 </xsl:template>
443
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100444 <xsl:template match="xhtml:sup|xhtml:span[@class='sup']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100445 <hi rend="sup">
446 <xsl:apply-templates/>
447 </hi>
448 </xsl:template>
449
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000450 <xsl:template match="xhtml:div[not(normalize-space(replace(., '&#160;', ' ')))]" priority="1.0"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100451
Marc Kupietzbf47ae72024-04-14 14:21:43 +0200452 <xsl:template match="xhtml:body/xhtml:div[./xhtml:h1|./xhtml:h2|./xhtml:h3]" priority="1.0">
453 <xsl:apply-templates/>
454 </xsl:template>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000455 <xsl:template match="xhtml:div/xhtml:div">
Marc Kupietz1a422662024-03-16 09:34:10 +0100456 <p>
457 <xsl:apply-templates/>
458 </p>
459 </xsl:template>
460
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000461 <xsl:template match="xhtml:body/xhtml:div[(descendant::xhtml:p|descendant::xhtml:div)]">
462 <div type="section">
463 <xsl:apply-templates/>
464 </div>
465 </xsl:template>
466
467 <xsl:template match="xhtml:body/xhtml:div[not(descendant::xhtml:p|descendant::xhtml:div)]">
468 <div type="section">
469 <p>
470 <xsl:apply-templates/>
471 </p>
472 </div>
473 </xsl:template>
474
475 <xsl:template match="xhtml:p[not(descendant::xhtml:p|descendant::xhtml:div)]">
476 <xsl:if test="normalize-space(.)">
477 <p>
478 <xsl:apply-templates/>
479 </p>
480 </xsl:if>
481 </xsl:template>
482
483 <xsl:template match="xhtml:p[descendant::xhtml:p|descendant::xhtml:div]">
484 <xsl:if test="normalize-space(.)">
485 <div type="section">
486 <xsl:apply-templates/>
487 </div>
488 </xsl:if>
489 </xsl:template>
490
Marc Kupietz09745e12024-04-21 12:54:10 +0200491 <xsl:template match="xhtml:ul">
492 <list type="unordered">
493 <xsl:apply-templates/>
494 </list>
495 </xsl:template>
496 <xsl:template match="xhtml:ol">
497 <list type="ordered">
498 <xsl:apply-templates/>
499 </list>
500 </xsl:template>
501 <xsl:template match="xhtml:li">
502 <item>
503 <xsl:apply-templates/>
504 </item>
505 </xsl:template>
506 <xsl:template match="xhtml:nav">
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200507 <!-- <gap reason="toc"/> -->
508 </xsl:template>
509
Marc Kupietz1a422662024-03-16 09:34:10 +0100510 <xsl:template match="xhtml:img">
511 <!-- <gap reason="image"/> -->
512 </xsl:template>
513
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200514 <xsl:template match="xhtml:audio">
515 <!-- <gap reason="audio"/> -->
516 </xsl:template>
517
Marc Kupietz09745e12024-04-21 12:54:10 +0200518 <xsl:template match="xhtml:table">
519 <!-- <gap reason="table"/> -->
520 </xsl:template>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000521 <xsl:template match="xhtml:body/xhtml:a">
Marc Kupietz164a2832024-04-14 21:00:48 +0200522 <xsl:if test="normalize-space(.)">
523 <p>
524 <ref target="{@href}">
525 <xsl:apply-templates />
526 </ref>
527 </p>
528 </xsl:if>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000529 </xsl:template>
530
531 <xsl:template match="xhtml:body/xhtml:span">
532 <xsl:message>
533 <xsl:text>unhandled span element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
534 </xsl:message>
535 <div type="section">
536 <p>
537 <xsl:value-of select="."/>
538 </p>
539 </div>
540 </xsl:template>
541 <xsl:template match="xhtml:span">
542 <xsl:message>
543 <xsl:text>unhandled span element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
544 </xsl:message>
545 <xsl:value-of select="."/>
546 </xsl:template>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100547 <xsl:template match="xhtml:a">
Marc Kupietz164a2832024-04-14 21:00:48 +0200548 <xsl:if test="normalize-space(.)">
549 <ref target="{@href}">
550 <xsl:apply-templates />
551 </ref>
552 </xsl:if>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100553 </xsl:template>
554
Marc Kupietz54ec28b2024-04-27 10:07:06 +0200555 <xsl:template match="xhtml:br">
556 <lb/><xsl:text>&#10;</xsl:text>
557 </xsl:template>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100558
Marc Kupietz1a422662024-03-16 09:34:10 +0100559 <xsl:template match="xhtml:*">
560 <xsl:message>
561 <xsl:text>unhandled element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
562 </xsl:message>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000563 <xsl:choose>
564 <xsl:when test="descendant::xhtml:div|descendant::xhtml:p|parent::xhtml:body">
565 <div type="section">
566 <xsl:apply-templates/>
567 </div>
568 </xsl:when>
569 <xsl:otherwise>
570 <xsl:apply-templates select="./*|node()"/>
571 </xsl:otherwise>
572 </xsl:choose>
Marc Kupietz1a422662024-03-16 09:34:10 +0100573 <xsl:apply-templates/>
574 </xsl:template>
575
576 <xsl:function name="ids:reversedAuthors">
577 <xsl:param name="s" />
578 <xsl:value-of
579 select="
580 if (matches($s, ';')) then
581 concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; ')))
582 else
583 replace($s, '(.+) (.+)', '$2, $1')"
584 />
585 </xsl:function>
586
587 <xsl:function name="hlu:reversedAuthors">
588 <xsl:param name="s"/>
589 <xsl:value-of
590 select="if (matches($s, ';')) then concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; '))) else replace($s, '(.+),(.+)', '$2, $1')"
591 />
592 </xsl:function>
593
Marc Kupietz10903f32024-04-14 14:21:18 +0200594 <xsl:variable name="city-country-map" as="map(xs:string, xs:string)">
595 <xsl:map>
596 <xsl:map-entry key="'Axams'" select="'AT'"/>
597 <xsl:map-entry key="'Vienna'" select="'AT'"/>
598 <xsl:map-entry key="'Klagenfurt'" select="'AT'"/>
599 <xsl:map-entry key="'Graz'" select="'AT'"/>
600 <xsl:map-entry key="'Innsbruck'" select="'AT'"/>
601 <xsl:map-entry key="'Salzburg'" select="'AT'"/>
602 <xsl:map-entry key="'Bern'" select="'CH'"/>
603 <xsl:map-entry key="'Biel/Bienne'" select="'CH'"/>
604 <xsl:map-entry key="'Zurich'" select="'CH'"/>
605 <xsl:map-entry key="'Basel'" select="'CH'"/>
606 <xsl:map-entry key="'Geneva'" select="'CH'"/>
607 <xsl:map-entry key="'Lucerne'" select="'CH'"/>
608 <xsl:map-entry key="'Lausanne'" select="'CH'"/>
609 <xsl:map-entry key="'Winterthur'" select="'CH'"/>
610 <xsl:map-entry key="'St. Gallen'" select="'CH'"/>
611 <xsl:map-entry key="'Interlaken'" select="'CH'"/>
612 <xsl:map-entry key="'Brussels'" select="'BE'"/>
613 <xsl:map-entry key="'Antwerp'" select="'BE'"/>
614 <xsl:map-entry key="'Ghent'" select="'BE'"/>
615 <xsl:map-entry key="'Bruges'" select="'BE'"/>
616 <xsl:map-entry key="'Leuven'" select="'BE'"/>
617 <xsl:map-entry key="'Liege'" select="'BE'"/>
618 <xsl:map-entry key="'Charleroi'" select="'BE'"/>
619 <xsl:map-entry key="'Namur'" select="'BE'"/>
620 <xsl:map-entry key="'Mons'" select="'BE'"/>
621 <xsl:map-entry key="'Bangkok'" select="'TH'"/>
622 <xsl:map-entry key="'Copenhagen'" select="'DK'"/>
623 <xsl:map-entry key="'colatina'" select="'BR'"/>
624 <xsl:map-entry key="'Oakland Park'" select="'US'"/>
625 <xsl:map-entry key="'Istanbul'" select="'TR'"/>
626 <xsl:map-entry key="'Luxemburg'" select="'LU'"/>
627 <xsl:map-entry key="'Palma de Mallorca'" select="'ES'"/>
628 <xsl:map-entry key="'Swakopmund'" select="'NA'"/>
629 <xsl:map-entry key="'Victoria'" select="'CA'"/>
630 <xsl:map-entry key="'Wien'" select="'AT'"/>
631 <xsl:map-entry key="'Windhoek'" select="'NA'"/>
632 <xsl:map-entry key="'Zuerich'" select="'CH'"/>
633 <xsl:map-entry key="'Zürich'" select="'CH'"/>
634 <xsl:map-entry key="'Zug'" select="'CH'"/>
635 <xsl:map-entry key="'ZÜRICH'" select="'CH'"/>
636 </xsl:map>
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200637
Marc Kupietz10903f32024-04-14 14:21:18 +0200638 </xsl:variable>
639
640 <!-- Define the function -->
641 <xsl:function name="ids:country-city" as="xs:string">
642 <xsl:param name="city" as="xs:string"/>
643 <xsl:sequence select="if (map:contains($city-country-map, $city)) then map:get($city-country-map, $city) else 'DE'"/>
644 </xsl:function>
Marc Kupietz1a422662024-03-16 09:34:10 +0100645</xsl:stylesheet>