blob: c5f5c953c964748c206d5584e2850f9fcc0780f1 [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"
25 select="string-join(replace($dnbBookdata//dc:creator, ' *\[[^\]]*\]', ''), ' ; ')"/>
26
27 <xsl:variable name="straight_autor" select="replace(hlu:reversedAuthors($autor), ',', '')"/>
28
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">
50 <xsl:choose>
51 <xsl:when test="contains($dnbBookdata//dc:title,':')">
52 <xsl:value-of select="normalize-space(substring-before(substring-before($dnbBookdata//dc:title, '/'), ':'))"
53 />
54 </xsl:when>
55 <xsl:otherwise>
56 <xsl:value-of select="normalize-space(substring-before($dnbBookdata//dc:title, '/'))"/>
57 </xsl:otherwise>
58 </xsl:choose>
59 </xsl:variable>
60
61 <xsl:variable name="erscheinungsort">
62 <xsl:choose>
63 <xsl:when test="contains($dnbBookdata//dc:publisher,':')">
64 <xsl:value-of select="normalize-space(substring-before($dnbBookdata//dc:publisher, ':'))"/>
65 </xsl:when>
66 <xsl:otherwise>
67 <xsl:value-of select="normalize-space($dnbBookdata//dc:publisher)"/>
68 </xsl:otherwise>
69 </xsl:choose>
70 </xsl:variable>
71
72 <xsl:variable name="verlag">
73 <xsl:choose>
74 <xsl:when test="contains($dnbBookdata//dc:publisher,':')">
75 <xsl:value-of select="normalize-space(substring-after($dnbBookdata//dc:publisher, ':'))"/>
76 </xsl:when>
77 <xsl:otherwise>
78 <xsl:value-of select="normalize-space($dnbBookdata//dc:publisher)"/>
79 </xsl:otherwise>
80 </xsl:choose>
81 </xsl:variable>
82
83 <xsl:variable name="erscheinungsjahr">
84 <xsl:choose>
85 <xsl:when test="matches($dnbBookdata//dc:date, '^[0-9]{4}$')">
86 <xsl:value-of select="$dnbBookdata//dc:date"/>
87 </xsl:when>
88 <xsl:otherwise>
89 <xsl:value-of select="substring-before($dnbBookdata//dc:date, '-')"/>
90 </xsl:otherwise>
91 </xsl:choose>
92 </xsl:variable>
93
94 <xsl:variable name="untertitel"
95 select="normalize-space(substring-after(substring-before($dnbBookdata//dc:title, '/'), ':'))"/>
96
97 <xsl:variable name="herausgeber">
98 <xsl:choose>
99 <xsl:when test="$dnbBookdata//dc:creator[ends-with(.,'[Hrsg.]')]">
100 <xsl:value-of
101 select="replace(string-join($dnbBookdata//dc:creator[ends-with(.,'[Hrsg.]')], ' ; '),'\s?\[Hrsg.\]','')"
102 />
103 </xsl:when>
104 <xsl:otherwise>.</xsl:otherwise>
105 </xsl:choose>
106 </xsl:variable>
107
108 <xsl:variable name="straight_herausgeber"
109 select="replace(hlu:reversedAuthors($herausgeber), ',', '')"/>
110
111 <xsl:variable name="j" select="$dnbBookdata//dc:date"/>
112
113 <!-- for BOT+s: -->
114 <xsl:variable name="seiten" select="replace($dnbBookdata//dc:format,'S\.','')"/>
115
116 <!-- fuer BOT+b: -->
117 <xsl:variable name="_b">
118 <xsl:variable name="regexp1" select="'(Band|Bd\.)\s*([0-9]?[0-9]?[0-9])'"/>
119 <xsl:choose>
120 <xsl:when test="matches($dnbBookdata, $regexp1)">
121 <xsl:analyze-string select="$dnbBookdata//dc:title" regex="{$regexp1}">
122 <xsl:matching-substring>
123 <xsl:value-of select="."/>
124 </xsl:matching-substring>
125 </xsl:analyze-string>
126 </xsl:when>
127 <xsl:otherwise>
128 <xsl:value-of select="'.'"/>
129 </xsl:otherwise>
130 </xsl:choose>
131 </xsl:variable>
132
133 <!-- for BOT+x: -->
134 <xsl:variable name="txtart">
135 <xsl:choose>
136 <xsl:when test="$x">
137 <xsl:value-of select="concat('[', $x, ']')"/>
138 </xsl:when>
139 <xsl:when
140 test="matches($untertitel, '([Rr]oman|[Ee]rzhlung(en)?|[Aa]nthologie|[Gg]eschichte(n)?|[Nn]ovelle)')">
141 <xsl:value-of
142 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'), ']')"
143 />
144 </xsl:when>
145 <xsl:otherwise>
146 <xsl:value-of>Roman</xsl:value-of>
147 </xsl:otherwise>
148 </xsl:choose>
149 </xsl:variable>
150
151
152
153 <!-- fuer BOTd: -->
154 <xsl:variable name="dok"
155 select="concat((if(string-length($autor) &gt; 0) then concat($straight_autor, ': ') else ''), $titel, ', ', $txtart, ', (', $j, ')')"/>
156
157 <!-- END variables derived from sru request to dnb archive -->
158
159
160 <xsl:variable name="corpus_sigle" select="'DNB'"/>
161
162 <!-- for BOTD: -->
163 <!-- Dokumentsigle muss zusammen mit Korpussigle (z.B DIV fuer loz-div und loz-div-pub) eindeutig sein -->
164 <xsl:variable name="doc_sigle">
165 <xsl:variable name="firstContentWordTitleInitial">
166 <xsl:variable name="helper">
167 <xsl:analyze-string select="$titel" regex="\w+">
168 <xsl:matching-substring>
169 <xsl:choose>
170 <xsl:when
171 test="matches(.,'^[A-Z]') and not(matches(.,'^(Der|Die|Das|Des|Ein|Eine|Eines|Einmal|Von|Mit|Zu|Zurck)$'))">
172 <!-- TODO: Fktnswoerter nachtragen -->
173 <xsl:sequence select="."/>
174 </xsl:when>
175 <xsl:otherwise/>
176 </xsl:choose>
177 </xsl:matching-substring>
178 </xsl:analyze-string>
179 </xsl:variable>
180 <xsl:value-of
181 select="upper-case(substring(normalize-space(replace($helper,'\s+.+$','')),1,1))"/>
182 <!-- longest match of .+ -->
183 </xsl:variable>
184 <xsl:choose>
185 <xsl:when test="contains($autor,';')">
186 <xsl:variable name="lastname_aut1"
187 select="upper-case(substring(normalize-space(substring-before(substring-before($autor,';'),',')), 1, 1))"/>
188 <xsl:variable name="lastname_aut2"
189 select="upper-case(substring(normalize-space(substring-before(substring-before(substring-after($autor, ';'),';'),',')), 1, 1))"/>
190 <xsl:value-of select="concat($lastname_aut1, $lastname_aut2)"/>
191 </xsl:when>
192 <xsl:otherwise>
193 <xsl:variable name="lastname_aut1"
194 select="upper-case(substring(normalize-space(substring-before($autor,',')),1,1))"/>
195 <xsl:variable name="firstname_aut1"
196 select="upper-case(substring(normalize-space(substring-after($autor,',')),1,1))"/>
197 <xsl:value-of select="concat($lastname_aut1, $firstname_aut1)"/>
198 </xsl:otherwise>
199 </xsl:choose>
200 <xsl:value-of select="$firstContentWordTitleInitial"/>
201 </xsl:variable>
202
203
204 <xsl:variable name="text_sigle" select="substring($isbn, 8, 5)"/>
205 <xsl:variable name="sigle" select="concat($corpus_sigle, '/', $doc_sigle, '.', $text_sigle)"/>
206
207 <!-- fuer BOT+xy: (?) -->
208 <xsl:variable name="xyref">
209 <xsl:value-of select="document-uri(.)"/>
210 <xsl:text>; </xsl:text>
211 <xsl:text>ISBN:</xsl:text>
212 <xsl:value-of select="$isbn"/>
213 <xsl:text>; </xsl:text>
214 <xsl:value-of select="string-join($dnbBookdata//dc:identifier)"/>
215 </xsl:variable>
216
217
218 <xsl:template match="/">
219 <idsDoc TEIform="TEI.2" type="text" version="1.0">
220 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="document" version="1.1">
221 <fileDesc>
222 <titleStmt>
223 <dokumentSigle>KJL/HRK</dokumentSigle>
224 <d.title>Christiane F. ; Kai Hermann ; Horst Rieck: Wir Kinder vom Bahnhof Zoo , [Jugendliteratur], (2011)</d.title>
225 </titleStmt>
226 <publicationStmt>
227 <distributor/>
228 <pubAddress/>
229 <availability region="world" status="unknown">QAO-NC</availability>
230 <pubDate/>
231 </publicationStmt>
232 <sourceDesc>
233 <biblStruct>
234 <monogr>
235 <h.title type="main"/>
236 <imprint/>
237 </monogr>
238 </biblStruct>
239 </sourceDesc>
240 </fileDesc>
241 </idsHeader>
242 <idsText version="1.0">
243 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="text" version="1.1">
244 <fileDesc>
245 <titleStmt>
246 <textSigle><xsl:sequence select="$sigle"/></textSigle>
247 <t.title assemblage="regular">KJL/HRK.00001 F., Christiane ; Hermann, Kai ; Rieck, Horst: Wir Kinder vom Bahnhof Zoo, [Jugendliteratur], Erstv. 1978. - Hamburg, 2011</t.title>
248 </titleStmt>
249 <publicationStmt>
250 <distributor/>
251 <pubAddress/>
252 <availability region="world" status="unknown">QAO-NC</availability>
253 <pubDate/>
254 </publicationStmt>
255 <sourceDesc>
256 <biblStruct>
257 <monogr>
258 <h.title type="main"><xsl:value-of select="$titel"/></h.title>
259 <h.title type="sub"><xsl:value-of select="$untertitel"/></h.title>
260 <h.author><xsl:value-of select="$autor"/></h.author>
261 <editor/>
262 <edition>
263 <further/>
264 <kind>E-Book-Ausgabe</kind>
265 <appearance>EPUB-Datei</appearance>
266 </edition>
267 <imprint>
268 <publisher><xsl:value-of select="$herausgeber"/></publisher>
269 <pubDate type="year"><xsl:value-of select="$j"/></pubDate>
270 <pubDate type="month"/>
271 <pubDate type="day"/>
272 <pubPlace key="DE"><xsl:value-of select="$erscheinungsort"/></pubPlace>
273 </imprint>
274 <biblScope type="subsume"/>
275 <biblScope type="pp"/>
276 <biblScope type="vol"/>
277 <biblScope type="volume-title"/>
278 </monogr>
279 </biblStruct>
280 <reference assemblage="regular" type="complete"><xsl:value-of select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/></reference>
281 <reference assemblage="regular" type="short">KJL/HRK.00001 F. ; Hermann ; Rieck: Wir Kinder vom Bahnhof Zoo, Erstv. 1978, 2011</reference>
282 </sourceDesc>
283 </fileDesc>
284 <profileDesc>
285 <creation>
286 <creatDate><xsl:value-of select="$j"/></creatDate>
287 </creation>
288 <textClass/>
289 <textDesc>
290 <textType>Jugendliteratur</textType>
291 <textTypeRef>Jugendliteratur</textTypeRef>
292 <textDomain/>
293 </textDesc>
294 </profileDesc>
295 </idsHeader>
296 <text>
297 <body>
298 <!-- Call the template for each link in the TOC
299 <xsl:apply-templates select="//xhtml:ol[@class='toc']/xhtml:li/xhtml:a" mode="collect"/> -->
300 <xsl:apply-templates select="//opf:package/opf:manifest/opf:item[matches(@href, '\.x?html$') and not(matches(@href, '(cover|toc|copyright|feedback).*'))]" mode="collect"/>
301 </body>
302 </text>
303 </idsText>
304 </idsDoc>
305 </xsl:template>
306
307 <xsl:template match="opf:item" mode="collect">
308 <xsl:variable name="href" select="@href"/>
309 <xsl:message>
310 <xsl:text>converting: </xsl:text><xsl:value-of select="$href"/><xsl:text> </xsl:text><xsl:value-of select="$isbn"/>
311 </xsl:message>
312 <xsl:apply-templates select="doc(resolve-uri($href, base-uri()))/xhtml:html/xhtml:body"/>
313 </xsl:template>
314
315 <xsl:template match="xhtml:body">
316 <div type="chapter">
317 <xsl:apply-templates/>
318 </div>
319 </xsl:template>
320
321 <xsl:template match="xhtml:title">
322 <head>
323 <xsl:apply-templates/>
324 </head>
325 </xsl:template>
326
327 <xsl:template match="xhtml:h1">
328 <head>
329 <xsl:apply-templates/>
330 </head>
331 </xsl:template>
332
333 <xsl:template match="xhtml:h2|xhtml:h3">
334 <head type="sub">
335 <xsl:apply-templates/>
336 </head>
337 </xsl:template>
338
339
340 <xsl:template match="xhtml:span[@class='italic']">
341 <hi rend="italic">
342 <xsl:apply-templates/>
343 </hi>
344 </xsl:template>
345
346 <xsl:template match="xhtml:span[@class='bold']">
347 <hi rend="bold">
348 <xsl:apply-templates/>
349 </hi>
350 </xsl:template>
351
352 <xsl:template match="xhtml:span[@class='sub']">
353 <hi rend="sub">
354 <xsl:apply-templates/>
355 </hi>
356 </xsl:template>
357
358 <xsl:template match="xhtml:span[@class='sup']">
359 <hi rend="sup">
360 <xsl:apply-templates/>
361 </hi>
362 </xsl:template>
363
364 <xsl:template match="xhtml:div">
365 <div type="section">
366 <xsl:apply-templates/>
367 </div>
368 </xsl:template>
369
370 <xsl:template match="xhtml:p">
371 <p>
372 <xsl:apply-templates/>
373 </p>
374 </xsl:template>
375
376 <xsl:template match="xhtml:img">
377 <!-- <gap reason="image"/> -->
378 </xsl:template>
379
380 <xsl:template match="xhtml:*">
381 <xsl:message>
382 <xsl:text>unhandled element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
383 </xsl:message>
384 <xsl:apply-templates/>
385 </xsl:template>
386
387 <xsl:function name="ids:reversedAuthors">
388 <xsl:param name="s" />
389 <xsl:value-of
390 select="
391 if (matches($s, ';')) then
392 concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; ')))
393 else
394 replace($s, '(.+) (.+)', '$2, $1')"
395 />
396 </xsl:function>
397
398 <xsl:function name="hlu:reversedAuthors">
399 <xsl:param name="s"/>
400 <xsl:value-of
401 select="if (matches($s, ';')) then concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; '))) else replace($s, '(.+),(.+)', '$2, $1')"
402 />
403 </xsl:function>
404
405</xsl:stylesheet>