blob: aa5043de3b69e7ba5a8b60846ffb5f975e1518b8 [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"
9 exclude-result-prefixes="xs opf dc ids hlu saxon xhtml">
10
11 <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" saxon:line-length="1000"/>
12 <xsl:strip-space elements="*"/>
13
14 <xsl:variable name="ev"/>
15 <xsl:variable name="x"/>
16
17 <xsl:variable name="isbn" as="xs:string" select="replace(document-uri(), '.*([0-9]{13,}).*' , '$1')"/>
18
19
20 <xsl:variable name="dnbBookdata">
21 <xsl:copy-of select="doc(concat('https://services.dnb.de/sru/dnb?version=1.1&amp;operation=searchRetrieve&amp;query=NUM%3D', $isbn, '&amp;recordSchema=oai_dc'))"/>
22 </xsl:variable>
23
24 <xsl:variable name="autor"
Marc Kupietzea387372024-04-10 16:34:57 +020025 select="replace(string-join($dnbBookdata//dc:creator[not(matches(., '\[(Erzähler)\]'))], ' ; '), ' *\[[^\]]*\]', '')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010026
Marc Kupietzb660ed62024-03-16 11:45:53 +010027 <xsl:variable name="straight_autor" select="normalize-space(replace(hlu:reversedAuthors($autor), ',', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010028
29 <xsl:variable name="ina"/>
30 <xsl:variable name="_corpus"/>
31 <xsl:variable name="ent_known"/>
32
33
34 <!-- added HLU 2012-02-09: -->
35 <xsl:variable name="ent">
36 <xsl:choose>
37 <xsl:when test="$ent_known">
38 <xsl:value-of select="$ent_known"/>
39 </xsl:when>
40 <xsl:when test="$ev">
41 <xsl:value-of select="$ev"/>
42 </xsl:when>
43 <xsl:otherwise>
44 <xsl:value-of select="$j"/>
45 </xsl:otherwise>
46 </xsl:choose>
47 </xsl:variable>
48
49 <xsl:variable name="titel">
Marc Kupietz49124fa2024-04-10 16:50:01 +020050 <xsl:variable name="title-with-subtitles">
51 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +020052 <xsl:when test="contains(($dnbBookdata//dc:title)[1],':')">
53 <xsl:value-of select="normalize-space(substring-before(substring-before(($dnbBookdata//dc:title)[1], '/'), ':'))"
Marc Kupietz49124fa2024-04-10 16:50:01 +020054 />
55 </xsl:when>
56 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +020057 <xsl:value-of select="normalize-space(substring-before(($dnbBookdata//dc:title)[1], '/'))"/>
Marc Kupietz49124fa2024-04-10 16:50:01 +020058 </xsl:otherwise>
59 </xsl:choose>
60 </xsl:variable>
61 <xsl:value-of select="normalize-space(replace($title-with-subtitles, '\|.*', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010062 </xsl:variable>
63
64 <xsl:variable name="erscheinungsort">
65 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +020066 <xsl:when test="contains(($dnbBookdata//dc:publisher)[1], ':')">
67 <xsl:value-of select="normalize-space(substring-before(($dnbBookdata//dc:publisher)[1], ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010068 </xsl:when>
69 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +020070 <xsl:value-of select="normalize-space(($dnbBookdata//dc:publisher)[1])"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010071 </xsl:otherwise>
72 </xsl:choose>
73 </xsl:variable>
74
Marc Kupietz6cb52232024-04-13 12:28:44 +020075 <xsl:variable name="texttype" select="replace(($dnbBookdata//dc:subject[matches(., '^[A-Z] ')])[1], '^[A-Z] (.*)', '$1')"/>
Marc Kupietz7df4ccc2024-03-16 15:27:45 +010076
Marc Kupietz1a422662024-03-16 09:34:10 +010077 <xsl:variable name="verlag">
78 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +020079 <xsl:when test="contains(($dnbBookdata//dc:publisher)[1], ':')">
80 <xsl:value-of select="normalize-space(substring-after(($dnbBookdata//dc:publisher)[1], ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010081 </xsl:when>
82 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +020083 <xsl:value-of select="normalize-space(($dnbBookdata//dc:publisher)[1])"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010084 </xsl:otherwise>
85 </xsl:choose>
86 </xsl:variable>
87
88 <xsl:variable name="erscheinungsjahr">
89 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +020090 <xsl:when test="dnbBookdata//dc:date[matches(normalize-space(.), '^[0-9]{4}$')]">
91 <xsl:value-of select="$dnbBookdata//dc:date[matches(normalize-space(.), '^[0-9]{4}$')][1]"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010092 </xsl:when>
93 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +020094 <xsl:value-of select="substring-before(($dnbBookdata//dc:date)[1], '-')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010095 </xsl:otherwise>
96 </xsl:choose>
97 </xsl:variable>
98
99 <xsl:variable name="untertitel"
Marc Kupietz6cb52232024-04-13 12:28:44 +0200100 select="normalize-space(substring-after(substring-before(($dnbBookdata//dc:title)[1], '/'), ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100101
102 <xsl:variable name="herausgeber">
103 <xsl:choose>
104 <xsl:when test="$dnbBookdata//dc:creator[ends-with(.,'[Hrsg.]')]">
105 <xsl:value-of
Marc Kupietz6cb52232024-04-13 12:28:44 +0200106 select="replace(string-join($dnbBookdata//dc:creator[ends-with(.,'[Hrsg.]')][1], ' ; '),'\s?\[Hrsg.\]','')"
Marc Kupietz1a422662024-03-16 09:34:10 +0100107 />
108 </xsl:when>
109 <xsl:otherwise>.</xsl:otherwise>
110 </xsl:choose>
111 </xsl:variable>
112
113 <xsl:variable name="straight_herausgeber"
114 select="replace(hlu:reversedAuthors($herausgeber), ',', '')"/>
115
116 <xsl:variable name="j" select="$dnbBookdata//dc:date"/>
117
118 <!-- for BOT+s: -->
119 <xsl:variable name="seiten" select="replace($dnbBookdata//dc:format,'S\.','')"/>
120
121 <!-- fuer BOT+b: -->
122 <xsl:variable name="_b">
123 <xsl:variable name="regexp1" select="'(Band|Bd\.)\s*([0-9]?[0-9]?[0-9])'"/>
124 <xsl:choose>
125 <xsl:when test="matches($dnbBookdata, $regexp1)">
126 <xsl:analyze-string select="$dnbBookdata//dc:title" regex="{$regexp1}">
127 <xsl:matching-substring>
128 <xsl:value-of select="."/>
129 </xsl:matching-substring>
130 </xsl:analyze-string>
131 </xsl:when>
132 <xsl:otherwise>
133 <xsl:value-of select="'.'"/>
134 </xsl:otherwise>
135 </xsl:choose>
136 </xsl:variable>
137
138 <!-- for BOT+x: -->
139 <xsl:variable name="txtart">
140 <xsl:choose>
141 <xsl:when test="$x">
142 <xsl:value-of select="concat('[', $x, ']')"/>
143 </xsl:when>
144 <xsl:when
145 test="matches($untertitel, '([Rr]oman|[Ee]rzhlung(en)?|[Aa]nthologie|[Gg]eschichte(n)?|[Nn]ovelle)')">
146 <xsl:value-of
147 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'), ']')"
148 />
149 </xsl:when>
150 <xsl:otherwise>
151 <xsl:value-of>Roman</xsl:value-of>
152 </xsl:otherwise>
153 </xsl:choose>
154 </xsl:variable>
155
156
157
158 <!-- fuer BOTd: -->
159 <xsl:variable name="dok"
160 select="concat((if(string-length($autor) &gt; 0) then concat($straight_autor, ': ') else ''), $titel, ', ', $txtart, ', (', $j, ')')"/>
161
162 <!-- END variables derived from sru request to dnb archive -->
163
164
Marc Kupietz94bbe6b2024-04-10 20:35:48 +0200165 <xsl:variable name="corpus_sigle" select="concat('DNB', substring($erscheinungsjahr, 3, 2))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100166
167 <!-- for BOTD: -->
168 <!-- Dokumentsigle muss zusammen mit Korpussigle (z.B DIV fuer loz-div und loz-div-pub) eindeutig sein -->
169 <xsl:variable name="doc_sigle">
170 <xsl:variable name="firstContentWordTitleInitial">
171 <xsl:variable name="helper">
172 <xsl:analyze-string select="$titel" regex="\w+">
173 <xsl:matching-substring>
174 <xsl:choose>
175 <xsl:when
176 test="matches(.,'^[A-Z]') and not(matches(.,'^(Der|Die|Das|Des|Ein|Eine|Eines|Einmal|Von|Mit|Zu|Zurck)$'))">
177 <!-- TODO: Fktnswoerter nachtragen -->
178 <xsl:sequence select="."/>
179 </xsl:when>
180 <xsl:otherwise/>
181 </xsl:choose>
182 </xsl:matching-substring>
183 </xsl:analyze-string>
184 </xsl:variable>
185 <xsl:value-of
186 select="upper-case(substring(normalize-space(replace($helper,'\s+.+$','')),1,1))"/>
187 <!-- longest match of .+ -->
188 </xsl:variable>
189 <xsl:choose>
190 <xsl:when test="contains($autor,';')">
191 <xsl:variable name="lastname_aut1"
192 select="upper-case(substring(normalize-space(substring-before(substring-before($autor,';'),',')), 1, 1))"/>
193 <xsl:variable name="lastname_aut2"
194 select="upper-case(substring(normalize-space(substring-before(substring-before(substring-after($autor, ';'),';'),',')), 1, 1))"/>
195 <xsl:value-of select="concat($lastname_aut1, $lastname_aut2)"/>
196 </xsl:when>
197 <xsl:otherwise>
198 <xsl:variable name="lastname_aut1"
199 select="upper-case(substring(normalize-space(substring-before($autor,',')),1,1))"/>
200 <xsl:variable name="firstname_aut1"
201 select="upper-case(substring(normalize-space(substring-after($autor,',')),1,1))"/>
202 <xsl:value-of select="concat($lastname_aut1, $firstname_aut1)"/>
203 </xsl:otherwise>
204 </xsl:choose>
205 <xsl:value-of select="$firstContentWordTitleInitial"/>
206 </xsl:variable>
207
208
209 <xsl:variable name="text_sigle" select="substring($isbn, 8, 5)"/>
210 <xsl:variable name="sigle" select="concat($corpus_sigle, '/', $doc_sigle, '.', $text_sigle)"/>
211
212 <!-- fuer BOT+xy: (?) -->
213 <xsl:variable name="xyref">
214 <xsl:value-of select="document-uri(.)"/>
215 <xsl:text>; </xsl:text>
216 <xsl:text>ISBN:</xsl:text>
217 <xsl:value-of select="$isbn"/>
218 <xsl:text>; </xsl:text>
219 <xsl:value-of select="string-join($dnbBookdata//dc:identifier)"/>
220 </xsl:variable>
221
Marc Kupietzb660ed62024-03-16 11:45:53 +0100222 <xsl:variable name="long-reference"
223 select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/>
224
225 <xsl:variable name="short-reference"
226 select="concat($straight_autor, ': ', $titel, ' (', $erscheinungsjahr, ')')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100227
228 <xsl:template match="/">
229 <idsDoc TEIform="TEI.2" type="text" version="1.0">
230 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="document" version="1.1">
231 <fileDesc>
232 <titleStmt>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100233 <dokumentSigle><xsl:value-of select="string-join(($corpus_sigle, $doc_sigle), '/')"/></dokumentSigle>
234 <d.title><xsl:value-of select="$short-reference"/></d.title>
Marc Kupietz1a422662024-03-16 09:34:10 +0100235 </titleStmt>
236 <publicationStmt>
237 <distributor/>
238 <pubAddress/>
239 <availability region="world" status="unknown">QAO-NC</availability>
240 <pubDate/>
241 </publicationStmt>
242 <sourceDesc>
243 <biblStruct>
244 <monogr>
245 <h.title type="main"/>
246 <imprint/>
247 </monogr>
248 </biblStruct>
249 </sourceDesc>
250 </fileDesc>
251 </idsHeader>
252 <idsText version="1.0">
253 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="text" version="1.1">
254 <fileDesc>
255 <titleStmt>
256 <textSigle><xsl:sequence select="$sigle"/></textSigle>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100257 <t.title assemblage="regular"><xsl:value-of select="$long-reference"/></t.title>
Marc Kupietz1a422662024-03-16 09:34:10 +0100258 </titleStmt>
259 <publicationStmt>
260 <distributor/>
261 <pubAddress/>
262 <availability region="world" status="unknown">QAO-NC</availability>
263 <pubDate/>
264 </publicationStmt>
265 <sourceDesc>
266 <biblStruct>
267 <monogr>
268 <h.title type="main"><xsl:value-of select="$titel"/></h.title>
269 <h.title type="sub"><xsl:value-of select="$untertitel"/></h.title>
270 <h.author><xsl:value-of select="$autor"/></h.author>
271 <editor/>
272 <edition>
273 <further/>
274 <kind>E-Book-Ausgabe</kind>
275 <appearance>EPUB-Datei</appearance>
276 </edition>
277 <imprint>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100278 <publisher><xsl:value-of select="$verlag"/></publisher>
Marc Kupietz1a422662024-03-16 09:34:10 +0100279 <pubDate type="year"><xsl:value-of select="$j"/></pubDate>
280 <pubDate type="month"/>
281 <pubDate type="day"/>
282 <pubPlace key="DE"><xsl:value-of select="$erscheinungsort"/></pubPlace>
283 </imprint>
284 <biblScope type="subsume"/>
285 <biblScope type="pp"/>
286 <biblScope type="vol"/>
287 <biblScope type="volume-title"/>
288 </monogr>
289 </biblStruct>
290 <reference assemblage="regular" type="complete"><xsl:value-of select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/></reference>
Marc Kupietz1a422662024-03-16 09:34:10 +0100291 </sourceDesc>
292 </fileDesc>
293 <profileDesc>
294 <creation>
295 <creatDate><xsl:value-of select="$j"/></creatDate>
296 </creation>
297 <textClass/>
298 <textDesc>
Marc Kupietz7df4ccc2024-03-16 15:27:45 +0100299 <textType><xsl:value-of select="$texttype"/></textType>
300 <textTypeRef><xsl:value-of select="$texttype"/></textTypeRef>
Marc Kupietz1a422662024-03-16 09:34:10 +0100301 <textDomain/>
302 </textDesc>
303 </profileDesc>
304 </idsHeader>
305 <text>
306 <body>
307 <!-- Call the template for each link in the TOC
308 <xsl:apply-templates select="//xhtml:ol[@class='toc']/xhtml:li/xhtml:a" mode="collect"/> -->
Marc Kupietz8f727302024-04-10 16:31:19 +0200309 <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 +0100310 </body>
311 </text>
312 </idsText>
313 </idsDoc>
314 </xsl:template>
315
316 <xsl:template match="opf:item" mode="collect">
317 <xsl:variable name="href" select="@href"/>
318 <xsl:message>
319 <xsl:text>converting: </xsl:text><xsl:value-of select="$href"/><xsl:text> </xsl:text><xsl:value-of select="$isbn"/>
320 </xsl:message>
321 <xsl:apply-templates select="doc(resolve-uri($href, base-uri()))/xhtml:html/xhtml:body"/>
322 </xsl:template>
323
324 <xsl:template match="xhtml:body">
325 <div type="chapter">
326 <xsl:apply-templates/>
327 </div>
328 </xsl:template>
329
330 <xsl:template match="xhtml:title">
331 <head>
332 <xsl:apply-templates/>
333 </head>
334 </xsl:template>
335
336 <xsl:template match="xhtml:h1">
337 <head>
338 <xsl:apply-templates/>
339 </head>
340 </xsl:template>
341
342 <xsl:template match="xhtml:h2|xhtml:h3">
343 <head type="sub">
344 <xsl:apply-templates/>
345 </head>
346 </xsl:template>
347
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100348 <xsl:template match="xhtml:em">
349 <emph>
350 <xsl:apply-templates/>
351 </emph>
352 </xsl:template>
Marc Kupietz1a422662024-03-16 09:34:10 +0100353
Marc Kupietz30cc0802024-04-10 16:37:04 +0200354 <xsl:template match="xhtml:span[matches(@class, '(bold|italic|big|kursiv| )+')]">
355 <xsl:variable name="class" select="replace(@class, 'kursiv', 'italic')"/>
356 <hi rend="{$class}">
357 <xsl:apply-templates/>
358 </hi>
359 </xsl:template>
360
361 <xsl:template match="xhtml:b">
362 <hi rend="bold">
Marc Kupietz1a422662024-03-16 09:34:10 +0100363 <xsl:apply-templates/>
364 </hi>
365 </xsl:template>
366
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100367 <xsl:template match="xhtml:sub|xhtml:span[@class='sub']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100368 <hi rend="sub">
369 <xsl:apply-templates/>
370 </hi>
371 </xsl:template>
372
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100373 <xsl:template match="xhtml:sup|xhtml:span[@class='sup']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100374 <hi rend="sup">
375 <xsl:apply-templates/>
376 </hi>
377 </xsl:template>
378
379 <xsl:template match="xhtml:div">
380 <div type="section">
381 <xsl:apply-templates/>
382 </div>
383 </xsl:template>
384
385 <xsl:template match="xhtml:p">
386 <p>
387 <xsl:apply-templates/>
388 </p>
389 </xsl:template>
390
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200391 <xsl:template match="xhtml:nav">
392 <!-- <gap reason="toc"/> -->
393 </xsl:template>
394
Marc Kupietz1a422662024-03-16 09:34:10 +0100395 <xsl:template match="xhtml:img">
396 <!-- <gap reason="image"/> -->
397 </xsl:template>
398
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200399 <xsl:template match="xhtml:audio">
400 <!-- <gap reason="audio"/> -->
401 </xsl:template>
402
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100403 <xsl:template match="xhtml:a">
404 <ref target="{@href}">
405 <xsl:apply-templates />
406 </ref>
407 </xsl:template>
408
409 <xsl:template match="xhtml:br"/>
410
Marc Kupietz1a422662024-03-16 09:34:10 +0100411 <xsl:template match="xhtml:*">
412 <xsl:message>
413 <xsl:text>unhandled element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
414 </xsl:message>
415 <xsl:apply-templates/>
416 </xsl:template>
417
418 <xsl:function name="ids:reversedAuthors">
419 <xsl:param name="s" />
420 <xsl:value-of
421 select="
422 if (matches($s, ';')) then
423 concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; ')))
424 else
425 replace($s, '(.+) (.+)', '$2, $1')"
426 />
427 </xsl:function>
428
429 <xsl:function name="hlu:reversedAuthors">
430 <xsl:param name="s"/>
431 <xsl:value-of
432 select="if (matches($s, ';')) then concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; '))) else replace($s, '(.+),(.+)', '$2, $1')"
433 />
434 </xsl:function>
435
436</xsl:stylesheet>