blob: 2847b81c32d70f68e2e58b66d56d44e69ff41de4 [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
Marc Kupietz7f3fe792024-07-26 15:28:26 +020019 <xsl:param name="debug"/>
20
Marc Kupietz1a422662024-03-16 09:34:10 +010021 <xsl:variable name="ev"/>
22 <xsl:variable name="x"/>
Rebecca Wilm2f345ff2024-07-30 16:58:25 +020023
Marc Kupietz0df2a572024-05-26 16:54:27 +020024 <xsl:variable name="idno" as="xs:string" select="replace(base-uri(), '.*/([0-9]{9,13}X?).*' , '$1')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010025
Rebecca Wilmf614a4b2024-05-07 10:19:43 +020026 <xsl:variable name="idno_type">
Rebecca Wilme5f055a2024-05-10 15:07:50 +020027 <xsl:choose>
28 <xsl:when test="starts-with($idno,'1')">
29 <xsl:value-of select="'IDN'"/>
30 </xsl:when>
31 <xsl:otherwise>
32 <xsl:value-of select="'ISBN'"/>
33 </xsl:otherwise>
34 </xsl:choose>
Rebecca Wilmf614a4b2024-05-07 10:19:43 +020035 </xsl:variable>
Rebecca Wilm2f345ff2024-07-30 16:58:25 +020036
Marc Kupietz1c3ebca2024-09-22 13:49:28 +020037 <xsl:param name="buchpreis"/>
Rebecca Wilmf614a4b2024-05-07 10:19:43 +020038
Marc Kupietz0df2a572024-05-26 16:54:27 +020039 <xsl:variable name="dnbBookdataQuery" as="xs:string">
40 <xsl:value-of disable-output-escaping="yes" select="concat('https://services.dnb.de/sru/dnb?version=1.1&amp;operation=searchRetrieve&amp;query=', $idno_type, '%3D', $idno, '&amp;recordSchema=oai_dc')"/>
41 </xsl:variable>
Marc Kupietz1a422662024-03-16 09:34:10 +010042 <xsl:variable name="dnbBookdata">
Marc Kupietz2c7bc7e2024-09-30 14:09:25 +020043 <xsl:if test="$debug">
44 <xsl:message select="concat('debug message dnbBookdataQuery: ', $dnbBookdataQuery)"/>
45 <xsl:message select="concat('debug message idno: ', $idno)"/>
46 <xsl:message select="concat('debug message original title from static metadata: ', if(starts-with($idno, '8')) then doc('static_metadata.xml')//oai:dc[dc:identifier=$idno]//dc:title else '')"/>
47 </xsl:if>
Marc Kupietzf475f222024-09-30 15:01:06 +020048 <xsl:variable name="tmp" select="if(starts-with($idno, '8')) then doc('static_metadata.xml')//oai:dc[dc:identifier=$idno] else doc($dnbBookdataQuery)"/>
49 <xsl:copy-of select="if($tmp//dc:title) then $tmp else doc('static_metadata.xml')//oai:dc[replace(dc:identifier[@xsi:type='tel:ISBN'][1], '-', '')=$idno]"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010050 </xsl:variable>
51
52 <xsl:variable name="autor"
Marc Kupietzde2ca532024-04-26 16:50:53 +020053 select="replace(string-join($dnbBookdata//dc:creator[not(contains(., '[')) or matches(., '\[Verfasser\]')], ' ; '), ' *\[[^\]]*\]', '')"/>
Marc Kupietzeaa90132024-04-26 18:14:40 +020054 <xsl:variable name="straight_autor" select="normalize-space(replace(hlu:reversedAuthors($autor), ',', ''))"/>
55 <xsl:variable name="translator"
56 select="replace(string-join($dnbBookdata//dc:creator[matches(., '\[Übersetzer\]')], ' ; '), ' *\[[^\]]*\]', '')"/>
57 <xsl:variable name="straight_translator" select="normalize-space(replace(hlu:reversedAuthors($translator), ',', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010058
Marc Kupietz15e7d612024-04-26 18:16:39 +020059 <xsl:variable name="herausgeber"
60 select="replace(string-join($dnbBookdata//dc:creator[matches(., '\[(Herausgeber|Hrsg.)\]')], ' ; '), ' *\[[^\]]*\]', '')"/>
61 <xsl:variable name="straight_herausgeber" select="normalize-space(replace(hlu:reversedAuthors($herausgeber), ',', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010062
63 <xsl:variable name="ina"/>
64 <xsl:variable name="_corpus"/>
65 <xsl:variable name="ent_known"/>
66
67
68 <!-- added HLU 2012-02-09: -->
69 <xsl:variable name="ent">
70 <xsl:choose>
71 <xsl:when test="$ent_known">
72 <xsl:value-of select="$ent_known"/>
73 </xsl:when>
74 <xsl:when test="$ev">
75 <xsl:value-of select="$ev"/>
76 </xsl:when>
77 <xsl:otherwise>
78 <xsl:value-of select="$j"/>
79 </xsl:otherwise>
80 </xsl:choose>
81 </xsl:variable>
82
83 <xsl:variable name="titel">
Marc Kupietz49124fa2024-04-10 16:50:01 +020084 <xsl:variable name="title-with-subtitles">
Marc Kupietz2c7bc7e2024-09-30 14:09:25 +020085 <xsl:if test="$debug">
86 <xsl:message select="concat('title: ', ($dnbBookdata//dc:title)[1])"/>
87 </xsl:if>
Marc Kupietz49124fa2024-04-10 16:50:01 +020088 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +020089 <xsl:when test="contains(($dnbBookdata//dc:title)[1],':')">
Marc Kupietz744d30e2024-09-22 12:49:45 +020090 <xsl:choose>
91 <xsl:when test="matches(($dnbBookdata//dc:title)[1], '.*/.*:.*/')">
92 <xsl:value-of select="normalize-space(substring-before(($dnbBookdata//dc:title)[1], ':'))"/>
93 </xsl:when>
94 <xsl:otherwise>
95 <xsl:value-of select="normalize-space(substring-before(substring-before(($dnbBookdata//dc:title)[1], '/'), ':'))"/>
96 </xsl:otherwise>
97 </xsl:choose>
Marc Kupietz49124fa2024-04-10 16:50:01 +020098 </xsl:when>
Marc Kupietzb9903542024-09-30 14:02:18 +020099 <xsl:when test="contains(($dnbBookdata//dc:title)[1],'/')">
Marc Kupietz6cb52232024-04-13 12:28:44 +0200100 <xsl:value-of select="normalize-space(substring-before(($dnbBookdata//dc:title)[1], '/'))"/>
Marc Kupietzb9903542024-09-30 14:02:18 +0200101 </xsl:when>
102 <xsl:otherwise>
103 <xsl:value-of select="normalize-space(($dnbBookdata//dc:title)[1])"/>
Marc Kupietz49124fa2024-04-10 16:50:01 +0200104 </xsl:otherwise>
105 </xsl:choose>
106 </xsl:variable>
107 <xsl:value-of select="normalize-space(replace($title-with-subtitles, '\|.*', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100108 </xsl:variable>
109
110 <xsl:variable name="erscheinungsort">
111 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +0200112 <xsl:when test="contains(($dnbBookdata//dc:publisher)[1], ':')">
113 <xsl:value-of select="normalize-space(substring-before(($dnbBookdata//dc:publisher)[1], ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100114 </xsl:when>
115 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +0200116 <xsl:value-of select="normalize-space(($dnbBookdata//dc:publisher)[1])"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100117 </xsl:otherwise>
118 </xsl:choose>
119 </xsl:variable>
120
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200121 <xsl:variable name="erscheinungsland" select="ids:country-city($erscheinungsort)"/>
122
Marc Kupietz6cb52232024-04-13 12:28:44 +0200123 <xsl:variable name="texttype" select="replace(($dnbBookdata//dc:subject[matches(., '^[A-Z] ')])[1], '^[A-Z] (.*)', '$1')"/>
Marc Kupietz7df4ccc2024-03-16 15:27:45 +0100124
Marc Kupietz9d87e9d2024-05-05 15:56:50 +0200125 <xsl:variable name="genretable">
126 <genres>
Nicolas Arnold32118802024-05-31 17:10:05 +0200127 <genre keyRegex="(krimi|thriller)" genre="Roman: Kriminalroman"/>
128 <genre keyRegex="arzt.?roman" genre="Roman: Arztroman"/>
129 <genre keyRegex="(liebes.*roman|dunja|romanze)" genre="Roman: Liebesroman"/>
Marc Kupietz9d87e9d2024-05-05 15:56:50 +0200130 <genre keyRegex="science.?fiction" genre="Roman: Science-Fiction-Roman"/>
131 <genre keyRegex="horror" genre="Roman: Horrorroman"/>
Marc Kupietzc214b4c2024-05-26 19:12:03 +0200132 <genre keyRegex="grusel" genre="Roman: Gruselroman"/>
133 <genre keyRegex="vampir.*roman" genre="Roman: Vampirroman"/>
Marc Kupietz9d87e9d2024-05-05 15:56:50 +0200134 <genre keyRegex="western" genre="Roman: Westernroman"/>
135 <genre keyRegex="fantasy" genre="Roman: Fantasyroman"/>
Marc Kupietzc214b4c2024-05-26 19:12:03 +0200136 <genre keyRegex="mystery" genre="Roman: Mysteryroman"/>
137 <genre keyRegex="heimat.*roman" genre="Roman: Heimatroman"/>
138 <genre keyRegex="familien.*roman" genre="Roman: Familienroman"/>
139 <genre keyRegex="(sex|erotik|erotische|versaute|fick|sm).*roman" genre="Roman: Erotikroman"/>
140 <genre keyRegex="gay" genre="Roman: Gay-Roman"/>
141 <genre keyRegex="(sex|erotik|erotische|versaute|fick|sm)" genre="Erzählung: Erotikerzählung"/>
Marc Kupietz9d87e9d2024-05-05 15:56:50 +0200142 <genre keyRegex="historischer roman" genre="Roman: Historischer Roman"/>
Nicolas Arnold32118802024-05-31 17:10:05 +0200143 <genre keyRegex="jugend" genre="Jugendliteratur: Jugendliteratur"/> <!-- wie in KJL -->
144 <genre keyRegex="(ein roman|der roman)" genre="Roman"/>
Marc Kupietz9d87e9d2024-05-05 15:56:50 +0200145 <genre keyRegex="erzählung" genre="Erzählung"/>
146 <genre keyRegex="novelle" genre="Novelle"/>
147 <genre keyRegex="anthologie" genre="Anthologie"/>
148 <genre keyRegex="kurzgeschichte" genre="Kurzgeschichte"/>
Marc Kupietzc214b4c2024-05-26 19:12:03 +0200149 <genre keyRegex="geschichte" genre="Erzählung"/>
150 <genre keyRegex="heftroman" genre="Roman: Heftroman"/>
Marc Kupietz9d87e9d2024-05-05 15:56:50 +0200151 <genre keyRegex="roman" genre="Roman"/>
152 <genre keyRegex="." genre="Roman"/>
153 </genres>
154 </xsl:variable>
155
156 <xsl:variable name="textFullGenre" select="$genretable/genres/genre[matches($dnbBookdata, ./@keyRegex, 'i')][1]/@genre"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100157 <xsl:variable name="verlag">
158 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +0200159 <xsl:when test="contains(($dnbBookdata//dc:publisher)[1], ':')">
160 <xsl:value-of select="normalize-space(substring-after(($dnbBookdata//dc:publisher)[1], ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100161 </xsl:when>
162 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +0200163 <xsl:value-of select="normalize-space(($dnbBookdata//dc:publisher)[1])"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100164 </xsl:otherwise>
165 </xsl:choose>
166 </xsl:variable>
167
168 <xsl:variable name="erscheinungsjahr">
Marc Kupietza5d01182024-04-14 12:24:02 +0200169 <xsl:value-of select="replace(($dnbBookdata//dc:date)[1], '.*?((19|20)[0-9][0-9]).*', '$1')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100170 </xsl:variable>
171
172 <xsl:variable name="untertitel"
Marc Kupietz6cb52232024-04-13 12:28:44 +0200173 select="normalize-space(substring-after(substring-before(($dnbBookdata//dc:title)[1], '/'), ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100174
Marc Kupietza5d01182024-04-14 12:24:02 +0200175 <xsl:variable name="j" select="$erscheinungsjahr"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100176
177 <!-- for BOT+s: -->
178 <xsl:variable name="seiten" select="replace($dnbBookdata//dc:format,'S\.','')"/>
179
180 <!-- fuer BOT+b: -->
181 <xsl:variable name="_b">
182 <xsl:variable name="regexp1" select="'(Band|Bd\.)\s*([0-9]?[0-9]?[0-9])'"/>
183 <xsl:choose>
184 <xsl:when test="matches($dnbBookdata, $regexp1)">
185 <xsl:analyze-string select="$dnbBookdata//dc:title" regex="{$regexp1}">
186 <xsl:matching-substring>
187 <xsl:value-of select="."/>
188 </xsl:matching-substring>
189 </xsl:analyze-string>
190 </xsl:when>
191 <xsl:otherwise>
192 <xsl:value-of select="'.'"/>
193 </xsl:otherwise>
194 </xsl:choose>
195 </xsl:variable>
196
197 <!-- for BOT+x: -->
198 <xsl:variable name="txtart">
199 <xsl:choose>
200 <xsl:when test="$x">
201 <xsl:value-of select="concat('[', $x, ']')"/>
202 </xsl:when>
203 <xsl:when
Nicolas Arnold26355632024-05-10 15:25:41 +0200204 test="matches($untertitel, '([Rr]oman|[Ee]rzählung(en)?|[Aa]nthologie|[Gg]eschichte(n)?|[Nn]ovelle)')">
Marc Kupietz1a422662024-03-16 09:34:10 +0100205 <xsl:value-of
Nicolas Arnold26355632024-05-10 15:25:41 +0200206 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 +0100207 />
208 </xsl:when>
209 <xsl:otherwise>
210 <xsl:value-of>Roman</xsl:value-of>
211 </xsl:otherwise>
212 </xsl:choose>
213 </xsl:variable>
214
215
216
217 <!-- fuer BOTd: -->
218 <xsl:variable name="dok"
219 select="concat((if(string-length($autor) &gt; 0) then concat($straight_autor, ': ') else ''), $titel, ', ', $txtart, ', (', $j, ')')"/>
220
221 <!-- END variables derived from sru request to dnb archive -->
222
223
Marc Kupietz94bbe6b2024-04-10 20:35:48 +0200224 <xsl:variable name="corpus_sigle" select="concat('DNB', substring($erscheinungsjahr, 3, 2))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100225
226 <!-- for BOTD: -->
227 <!-- Dokumentsigle muss zusammen mit Korpussigle (z.B DIV fuer loz-div und loz-div-pub) eindeutig sein -->
228 <xsl:variable name="doc_sigle">
229 <xsl:variable name="firstContentWordTitleInitial">
230 <xsl:variable name="helper">
231 <xsl:analyze-string select="$titel" regex="\w+">
232 <xsl:matching-substring>
233 <xsl:choose>
234 <xsl:when
Marc Kupietzad1f3b82024-04-19 19:21:49 +0200235 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 +0100236 <!-- TODO: Fktnswoerter nachtragen -->
237 <xsl:sequence select="."/>
238 </xsl:when>
239 <xsl:otherwise/>
240 </xsl:choose>
241 </xsl:matching-substring>
242 </xsl:analyze-string>
243 </xsl:variable>
244 <xsl:value-of
Marc Kupietz77b6aa92024-04-21 17:31:43 +0200245 select="upper-case(substring(normalize-space(replace($helper,'\s+.+$','')),1,3))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100246 <!-- longest match of .+ -->
247 </xsl:variable>
Marc Kupietz77b6aa92024-04-21 17:31:43 +0200248 <xsl:variable name="authorInitials">
249 <xsl:choose>
250 <xsl:when test="contains($autor,';')">
251 <xsl:variable name="lastname_aut1"
252 select="upper-case(substring(normalize-space($autor),1,1))"/>
253 <xsl:variable name="lastname_aut2"
254 select="replace($autor, '.*?;.*?([A-Z]).*', '$1')"/>
255 <xsl:value-of select="concat($lastname_aut1, $lastname_aut2)"/>
256 </xsl:when>
257 <xsl:otherwise>
258 <xsl:variable name="lastname_aut1"
259 select="upper-case(substring(normalize-space(substring-before($autor,',')),1,1))"/>
260 <xsl:variable name="firstname_aut1"
261 select="upper-case(substring(normalize-space(substring-after($autor,',')),1,1))"/>
262 <xsl:value-of select="concat($lastname_aut1, $firstname_aut1)"/>
263 </xsl:otherwise>
264 </xsl:choose>
265 </xsl:variable>
Marc Kupietz398b5962024-04-21 17:51:34 +0200266 <xsl:value-of select="substring(replace(normalize-unicode(concat($authorInitials,$firstContentWordTitleInitial), 'NFKD'),'[^A-Z]',''),1,3)"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100267 </xsl:variable>
268
269
Marc Kupietz0c246632024-04-29 07:08:23 +0200270 <xsl:variable name="text_sigle" select="replace($idno, '.*([0-9]{5})[0-9X]$', '$1')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100271 <xsl:variable name="sigle" select="concat($corpus_sigle, '/', $doc_sigle, '.', $text_sigle)"/>
272
273 <!-- fuer BOT+xy: (?) -->
274 <xsl:variable name="xyref">
Marc Kupietz0df2a572024-05-26 16:54:27 +0200275 <xsl:value-of select="base-uri(.)"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100276 <xsl:text>; </xsl:text>
Marc Kupietz0c246632024-04-29 07:08:23 +0200277 <xsl:text>IDNO:</xsl:text>
278 <xsl:value-of select="$idno"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100279 <xsl:text>; </xsl:text>
280 <xsl:value-of select="string-join($dnbBookdata//dc:identifier)"/>
281 </xsl:variable>
282
Marc Kupietzb660ed62024-03-16 11:45:53 +0100283 <xsl:variable name="long-reference"
284 select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/>
285
286 <xsl:variable name="short-reference"
287 select="concat($straight_autor, ': ', $titel, ' (', $erscheinungsjahr, ')')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100288
289 <xsl:template match="/">
Marc Kupietz98645242024-05-26 16:52:47 +0200290 <!-- for debugging purposes
291 <xsl:message select="concat('uri: ', base-uri())"/>
292 <xsl:message select="concat('idno: ', $idno)"/>
293
294 <xsl:message>
295 dnbBookdataQuery: <xsl:value-of select="$dnbBookdataQuery"/>
296 </xsl:message>
297
298 <xsl:message>
299 <xsl:copy-of select="$dnbBookdata"/>
300 </xsl:message>
301 -->
Marc Kupietz2c7bc7e2024-09-30 14:09:25 +0200302 <xsl:if test="not($dnbBookdata//oai:dc)">
303 <xsl:message terminate="yes" default-mode="text">ERROR: No metadata found for IDNO: <xsl:value-of select="$idno"/>
304 <xsl:text>&#10;Query was: </xsl:text>
305 <xsl:value-of disable-output-escaping="yes" select="replace($dnbBookdataQuery, '&amp;', '%38')"/>
306 <xsl:text>&#10;Retrieved response: </xsl:text>
307 <xsl:copy-of select="$dnbBookdata"/>
308 </xsl:message>
309 </xsl:if>
310
Marc Kupietzb7a4f6c2024-04-19 11:35:25 +0200311 <xsl:if test="not($j)">
Marc Kupietz0c246632024-04-29 07:08:23 +0200312 <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 +0200313 </xsl:if>
314
Marc Kupietz815cc6c2024-04-19 12:44:44 +0200315 <xsl:if test="not(normalize-space($titel))">
Marc Kupietz0c246632024-04-29 07:08:23 +0200316 <xsl:message terminate="yes">ERROR: No title found for IDNO: <xsl:value-of select="$idno"/></xsl:message>
Marc Kupietz815cc6c2024-04-19 12:44:44 +0200317 </xsl:if>
318
Marc Kupietz2badfb12024-04-19 12:59:40 +0200319 <xsl:if test="not(normalize-space($autor))">
Marc Kupietz0c246632024-04-29 07:08:23 +0200320 <xsl:message terminate="yes">ERROR: No author found for IDNO: <xsl:value-of select="$idno"/></xsl:message>
Marc Kupietz2badfb12024-04-19 12:59:40 +0200321 </xsl:if>
322
Nicolas Arnold1fbd37f2024-06-28 15:10:47 +0200323 <xsl:if test="not(matches($sigle, '^[A-Z]{2,3}[0-9]{2}/[A-Z]{2,3}\.[0-9]{5}$'))">
Marc Kupietz0c246632024-04-29 07:08:23 +0200324 <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 +0200325 </xsl:if>
326
Marc Kupietz1a422662024-03-16 09:34:10 +0100327 <idsDoc TEIform="TEI.2" type="text" version="1.0">
328 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="document" version="1.1">
329 <fileDesc>
330 <titleStmt>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100331 <dokumentSigle><xsl:value-of select="string-join(($corpus_sigle, $doc_sigle), '/')"/></dokumentSigle>
332 <d.title><xsl:value-of select="$short-reference"/></d.title>
Marc Kupietz1a422662024-03-16 09:34:10 +0100333 </titleStmt>
334 <publicationStmt>
335 <distributor/>
336 <pubAddress/>
337 <availability region="world" status="unknown">QAO-NC</availability>
338 <pubDate/>
339 </publicationStmt>
340 <sourceDesc>
341 <biblStruct>
342 <monogr>
343 <h.title type="main"/>
344 <imprint/>
345 </monogr>
346 </biblStruct>
347 </sourceDesc>
348 </fileDesc>
349 </idsHeader>
350 <idsText version="1.0">
351 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="text" version="1.1">
352 <fileDesc>
353 <titleStmt>
354 <textSigle><xsl:sequence select="$sigle"/></textSigle>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100355 <t.title assemblage="regular"><xsl:value-of select="$long-reference"/></t.title>
Marc Kupietz1a422662024-03-16 09:34:10 +0100356 </titleStmt>
357 <publicationStmt>
358 <distributor/>
359 <pubAddress/>
Rebecca Wilm7bb2b6f2024-06-17 10:34:47 +0200360 <xsl:for-each select="$dnbBookdata//dc:identifier">
361 <xsl:variable name="type" select="substring-after(@xsi:type, ':')"/>
362 <xsl:choose>
363 <xsl:when test="@xsi:type='tel:ISBN'">
364 <xsl:if test="matches(.,'(^([0-9]|-)+X?).*')">
365 <idno type="{$type}"><xsl:value-of select="replace(., '(([0-9]|-)+X?).*', '$1')"/></idno>
366 </xsl:if>
367 </xsl:when>
Marc Kupietz7582d572024-07-25 16:55:20 +0200368 <xsl:when test="$type='URL' and contains(., '/urn:nbn:de')">
369 <idno rend="URN;{tokenize(., '/')[last()]}" type="URL"><xsl:value-of select="."/></idno>
Marc Kupietzc4ea4092024-07-25 11:00:00 +0200370 </xsl:when>
Rebecca Wilm7bb2b6f2024-06-17 10:34:47 +0200371 <xsl:otherwise><idno type="{$type}"><xsl:value-of select="."/></idno></xsl:otherwise>
372 </xsl:choose>
373 </xsl:for-each>
Marc Kupietz1a422662024-03-16 09:34:10 +0100374 <availability region="world" status="unknown">QAO-NC</availability>
375 <pubDate/>
376 </publicationStmt>
377 <sourceDesc>
378 <biblStruct>
379 <monogr>
380 <h.title type="main"><xsl:value-of select="$titel"/></h.title>
381 <h.title type="sub"><xsl:value-of select="$untertitel"/></h.title>
382 <h.author><xsl:value-of select="$autor"/></h.author>
Marc Kupietzeaa90132024-04-26 18:14:40 +0200383 <xsl:if test="$translator">
384 <editor role="translator"><xsl:value-of select="$translator"/></editor>
385 </xsl:if>
Marc Kupietz15e7d612024-04-26 18:16:39 +0200386 <xsl:if test="$herausgeber">
387 <editor role="editor"><xsl:value-of select="$herausgeber"/></editor>
388 </xsl:if>
Marc Kupietz1a422662024-03-16 09:34:10 +0100389 <edition>
390 <further/>
391 <kind>E-Book-Ausgabe</kind>
392 <appearance>EPUB-Datei</appearance>
393 </edition>
394 <imprint>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100395 <publisher><xsl:value-of select="$verlag"/></publisher>
Marc Kupietz1a422662024-03-16 09:34:10 +0100396 <pubDate type="year"><xsl:value-of select="$j"/></pubDate>
397 <pubDate type="month"/>
398 <pubDate type="day"/>
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200399 <pubPlace key="{$erscheinungsland}"><xsl:value-of select="$erscheinungsort"/></pubPlace>
Marc Kupietz1a422662024-03-16 09:34:10 +0100400 </imprint>
401 <biblScope type="subsume"/>
402 <biblScope type="pp"/>
403 <biblScope type="vol"/>
404 <biblScope type="volume-title"/>
405 </monogr>
Marc Kupietz1c3ebca2024-09-22 13:49:28 +0200406 <xsl:if test="$buchpreis">
Rebecca Wilm2f345ff2024-07-30 16:58:25 +0200407 <xsl:element name="note">
408 <xsl:attribute name="type">award</xsl:attribute>
409 <xsl:attribute name="subtype">
Marc Kupietze43c7202024-09-22 12:53:41 +0200410 <xsl:value-of select="'Buchpreis deutscher_buchpreis'"/>
Rebecca Wilm2f345ff2024-07-30 16:58:25 +0200411 </xsl:attribute>
412 </xsl:element>
413 </xsl:if>
Marc Kupietz1a422662024-03-16 09:34:10 +0100414 </biblStruct>
415 <reference assemblage="regular" type="complete"><xsl:value-of select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/></reference>
Marc Kupietz1a422662024-03-16 09:34:10 +0100416 </sourceDesc>
417 </fileDesc>
418 <profileDesc>
419 <creation>
420 <creatDate><xsl:value-of select="$j"/></creatDate>
421 </creation>
422 <textClass/>
423 <textDesc>
Marc Kupietz9d87e9d2024-05-05 15:56:50 +0200424 <textType><xsl:value-of select="$textFullGenre"/></textType>
425 <textTypeRef><xsl:value-of select="replace($textFullGenre, '.*: *', '')"/></textTypeRef>
Marc Kupietz1a422662024-03-16 09:34:10 +0100426 <textDomain/>
427 </textDesc>
428 </profileDesc>
429 </idsHeader>
430 <text>
431 <body>
Marc Kupietz6b6d4702024-09-12 17:54:10 +0200432 <!-- Call the template for each idref the spine -->
433 <xsl:apply-templates select="//opf:spine/opf:itemref" mode="collect"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100434 </body>
435 </text>
436 </idsText>
437 </idsDoc>
438 </xsl:template>
439
Marc Kupietz6b6d4702024-09-12 17:54:10 +0200440 <xsl:template match="opf:itemref" mode="collect">
441 <xsl:variable name="id" select="@idref"/>
442 <xsl:variable name="item" select="//opf:manifest/opf:item[@id=$id and matches(@href, '\.x?html?$') and not(matches(@href, '(cover|toc|copyright|feedback|inhalt|nav|titlepage).*'))]"/>
443
444 <xsl:choose>
445 <xsl:when test = "$item">
446 <xsl:variable name="href" select="$item/@href"/>
447 <xsl:if test="$debug">
448 <xsl:message>
449 <xsl:text>converting: </xsl:text><xsl:value-of select="$id"/><xsl:text> </xsl:text><xsl:value-of select="$href"/><xsl:text> </xsl:text><xsl:value-of select="$idno"/>
450 </xsl:message>
451 </xsl:if>
452 <xsl:apply-templates select="doc(resolve-uri($href, base-uri()))/xhtml:html/xhtml:body"/>
453 </xsl:when>
454 <xsl:otherwise>
455 <xsl:if test="$debug">
456 <xsl:message>
457 <xsl:text>skipping: </xsl:text><xsl:value-of select="$id"/><xsl:text> </xsl:text><xsl:value-of select="$idno"/>
458 </xsl:message>
459 </xsl:if>
460 </xsl:otherwise>
461 </xsl:choose>
462 </xsl:template>
Marc Kupietz1a422662024-03-16 09:34:10 +0100463
464 <xsl:template match="xhtml:body">
465 <div type="chapter">
466 <xsl:apply-templates/>
467 </div>
468 </xsl:template>
469
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000470 <xsl:template match="xhtml:body/text()">
471 <p>
472 <xsl:value-of select="."/>
473 </p>
474 </xsl:template>
475
Marc Kupietz1a422662024-03-16 09:34:10 +0100476 <xsl:template match="xhtml:title">
477 <head>
478 <xsl:apply-templates/>
479 </head>
480 </xsl:template>
481
482 <xsl:template match="xhtml:h1">
483 <head>
484 <xsl:apply-templates/>
485 </head>
486 </xsl:template>
487
Marc Kupietz3989c742024-04-21 17:33:49 +0200488 <xsl:template match="xhtml:h2|xhtml:h3|xhtml:h4|xhtml:h5|xhtml:h6">
Marc Kupietz1a422662024-03-16 09:34:10 +0100489 <head type="sub">
490 <xsl:apply-templates/>
491 </head>
492 </xsl:template>
493
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100494 <xsl:template match="xhtml:em">
495 <emph>
496 <xsl:apply-templates/>
497 </emph>
498 </xsl:template>
Marc Kupietz1a422662024-03-16 09:34:10 +0100499
Marc Kupietz30cc0802024-04-10 16:37:04 +0200500 <xsl:template match="xhtml:span[matches(@class, '(bold|italic|big|kursiv| )+')]">
501 <xsl:variable name="class" select="replace(@class, 'kursiv', 'italic')"/>
502 <hi rend="{$class}">
503 <xsl:apply-templates/>
504 </hi>
505 </xsl:template>
506
Marc Kupietzad4d4462024-04-26 17:43:08 +0200507 <xsl:template match="xhtml:span[matches(@class, '(regular|norm)')]">
Marc Kupietz5e873112024-04-15 06:51:08 +0200508 <xsl:apply-templates/>
509 </xsl:template>
510
Marc Kupietz3989c742024-04-21 17:33:49 +0200511 <xsl:template match="xhtml:b|xhtml:span[@class='b']|xhtml:strong">
Marc Kupietz30cc0802024-04-10 16:37:04 +0200512 <hi rend="bold">
Marc Kupietz1a422662024-03-16 09:34:10 +0100513 <xsl:apply-templates/>
514 </hi>
515 </xsl:template>
516
Nicolas Arnoldc169e832024-06-07 08:44:11 +0200517 <xsl:template match="xhtml:i|xhtml:span[@class='i' or @class='it' or @class='Italic']|xhtml:span[@style='font-style:italic' or @style='font-style:italic;']">
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000518 <hi rend="italic">
519 <xsl:apply-templates/>
520 </hi>
521 </xsl:template>
522
523
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100524 <xsl:template match="xhtml:sub|xhtml:span[@class='sub']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100525 <hi rend="sub">
526 <xsl:apply-templates/>
527 </hi>
528 </xsl:template>
529
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100530 <xsl:template match="xhtml:sup|xhtml:span[@class='sup']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100531 <hi rend="sup">
532 <xsl:apply-templates/>
533 </hi>
534 </xsl:template>
535
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000536 <xsl:template match="xhtml:div[not(normalize-space(replace(., '&#160;', ' ')))]" priority="1.0"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100537
Marc Kupietzbf47ae72024-04-14 14:21:43 +0200538 <xsl:template match="xhtml:body/xhtml:div[./xhtml:h1|./xhtml:h2|./xhtml:h3]" priority="1.0">
539 <xsl:apply-templates/>
540 </xsl:template>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000541 <xsl:template match="xhtml:div/xhtml:div">
Marc Kupietz1a422662024-03-16 09:34:10 +0100542 <p>
543 <xsl:apply-templates/>
544 </p>
545 </xsl:template>
546
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000547 <xsl:template match="xhtml:body/xhtml:div[(descendant::xhtml:p|descendant::xhtml:div)]">
548 <div type="section">
549 <xsl:apply-templates/>
550 </div>
551 </xsl:template>
552
553 <xsl:template match="xhtml:body/xhtml:div[not(descendant::xhtml:p|descendant::xhtml:div)]">
554 <div type="section">
555 <p>
556 <xsl:apply-templates/>
557 </p>
558 </div>
559 </xsl:template>
560
561 <xsl:template match="xhtml:p[not(descendant::xhtml:p|descendant::xhtml:div)]">
562 <xsl:if test="normalize-space(.)">
563 <p>
564 <xsl:apply-templates/>
565 </p>
566 </xsl:if>
567 </xsl:template>
568
569 <xsl:template match="xhtml:p[descendant::xhtml:p|descendant::xhtml:div]">
570 <xsl:if test="normalize-space(.)">
571 <div type="section">
572 <xsl:apply-templates/>
573 </div>
574 </xsl:if>
575 </xsl:template>
576
Marc Kupietz09745e12024-04-21 12:54:10 +0200577 <xsl:template match="xhtml:ul">
578 <list type="unordered">
579 <xsl:apply-templates/>
580 </list>
581 </xsl:template>
582 <xsl:template match="xhtml:ol">
583 <list type="ordered">
584 <xsl:apply-templates/>
585 </list>
586 </xsl:template>
587 <xsl:template match="xhtml:li">
588 <item>
589 <xsl:apply-templates/>
590 </item>
591 </xsl:template>
592 <xsl:template match="xhtml:nav">
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200593 <!-- <gap reason="toc"/> -->
594 </xsl:template>
595
Marc Kupietz1a422662024-03-16 09:34:10 +0100596 <xsl:template match="xhtml:img">
597 <!-- <gap reason="image"/> -->
598 </xsl:template>
599
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200600 <xsl:template match="xhtml:audio">
601 <!-- <gap reason="audio"/> -->
602 </xsl:template>
603
Marc Kupietz09745e12024-04-21 12:54:10 +0200604 <xsl:template match="xhtml:table">
605 <!-- <gap reason="table"/> -->
606 </xsl:template>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000607 <xsl:template match="xhtml:body/xhtml:a">
Marc Kupietz164a2832024-04-14 21:00:48 +0200608 <xsl:if test="normalize-space(.)">
609 <p>
610 <ref target="{@href}">
611 <xsl:apply-templates />
612 </ref>
613 </p>
614 </xsl:if>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000615 </xsl:template>
616
617 <xsl:template match="xhtml:body/xhtml:span">
Marc Kupietz7f3fe792024-07-26 15:28:26 +0200618 <xsl:if test="$debug">
619 <xsl:message>
620 <xsl:text>unhandled span element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
621 </xsl:message>
622 </xsl:if>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000623 <div type="section">
624 <p>
625 <xsl:value-of select="."/>
626 </p>
627 </div>
628 </xsl:template>
629 <xsl:template match="xhtml:span">
Marc Kupietz7f3fe792024-07-26 15:28:26 +0200630 <xsl:if test="$debug">
631 <xsl:message>
632 <xsl:text>unhandled span element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
633 </xsl:message>
634 </xsl:if>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000635 <xsl:value-of select="."/>
636 </xsl:template>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100637 <xsl:template match="xhtml:a">
Marc Kupietz164a2832024-04-14 21:00:48 +0200638 <xsl:if test="normalize-space(.)">
639 <ref target="{@href}">
640 <xsl:apply-templates />
641 </ref>
642 </xsl:if>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100643 </xsl:template>
644
Marc Kupietz54ec28b2024-04-27 10:07:06 +0200645 <xsl:template match="xhtml:br">
646 <lb/><xsl:text>&#10;</xsl:text>
647 </xsl:template>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100648
Marc Kupietz1a422662024-03-16 09:34:10 +0100649 <xsl:template match="xhtml:*">
Marc Kupietz7f3fe792024-07-26 15:28:26 +0200650 <xsl:if test="$debug">
651 <xsl:message>
652 <xsl:text>unhandled element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
653 </xsl:message>
654 </xsl:if>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000655 <xsl:choose>
656 <xsl:when test="descendant::xhtml:div|descendant::xhtml:p|parent::xhtml:body">
657 <div type="section">
658 <xsl:apply-templates/>
659 </div>
660 </xsl:when>
661 <xsl:otherwise>
662 <xsl:apply-templates select="./*|node()"/>
663 </xsl:otherwise>
664 </xsl:choose>
Marc Kupietz1a422662024-03-16 09:34:10 +0100665 <xsl:apply-templates/>
666 </xsl:template>
667
668 <xsl:function name="ids:reversedAuthors">
669 <xsl:param name="s" />
670 <xsl:value-of
671 select="
672 if (matches($s, ';')) then
673 concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; ')))
674 else
675 replace($s, '(.+) (.+)', '$2, $1')"
676 />
677 </xsl:function>
678
679 <xsl:function name="hlu:reversedAuthors">
680 <xsl:param name="s"/>
681 <xsl:value-of
682 select="if (matches($s, ';')) then concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; '))) else replace($s, '(.+),(.+)', '$2, $1')"
683 />
684 </xsl:function>
685
Marc Kupietz10903f32024-04-14 14:21:18 +0200686 <xsl:variable name="city-country-map" as="map(xs:string, xs:string)">
687 <xsl:map>
688 <xsl:map-entry key="'Axams'" select="'AT'"/>
689 <xsl:map-entry key="'Vienna'" select="'AT'"/>
690 <xsl:map-entry key="'Klagenfurt'" select="'AT'"/>
691 <xsl:map-entry key="'Graz'" select="'AT'"/>
692 <xsl:map-entry key="'Innsbruck'" select="'AT'"/>
693 <xsl:map-entry key="'Salzburg'" select="'AT'"/>
694 <xsl:map-entry key="'Bern'" select="'CH'"/>
695 <xsl:map-entry key="'Biel/Bienne'" select="'CH'"/>
696 <xsl:map-entry key="'Zurich'" select="'CH'"/>
697 <xsl:map-entry key="'Basel'" select="'CH'"/>
698 <xsl:map-entry key="'Geneva'" select="'CH'"/>
699 <xsl:map-entry key="'Lucerne'" select="'CH'"/>
700 <xsl:map-entry key="'Lausanne'" select="'CH'"/>
701 <xsl:map-entry key="'Winterthur'" select="'CH'"/>
702 <xsl:map-entry key="'St. Gallen'" select="'CH'"/>
703 <xsl:map-entry key="'Interlaken'" select="'CH'"/>
704 <xsl:map-entry key="'Brussels'" select="'BE'"/>
705 <xsl:map-entry key="'Antwerp'" select="'BE'"/>
706 <xsl:map-entry key="'Ghent'" select="'BE'"/>
707 <xsl:map-entry key="'Bruges'" select="'BE'"/>
708 <xsl:map-entry key="'Leuven'" select="'BE'"/>
709 <xsl:map-entry key="'Liege'" select="'BE'"/>
710 <xsl:map-entry key="'Charleroi'" select="'BE'"/>
711 <xsl:map-entry key="'Namur'" select="'BE'"/>
712 <xsl:map-entry key="'Mons'" select="'BE'"/>
713 <xsl:map-entry key="'Bangkok'" select="'TH'"/>
714 <xsl:map-entry key="'Copenhagen'" select="'DK'"/>
715 <xsl:map-entry key="'colatina'" select="'BR'"/>
716 <xsl:map-entry key="'Oakland Park'" select="'US'"/>
717 <xsl:map-entry key="'Istanbul'" select="'TR'"/>
718 <xsl:map-entry key="'Luxemburg'" select="'LU'"/>
719 <xsl:map-entry key="'Palma de Mallorca'" select="'ES'"/>
720 <xsl:map-entry key="'Swakopmund'" select="'NA'"/>
721 <xsl:map-entry key="'Victoria'" select="'CA'"/>
722 <xsl:map-entry key="'Wien'" select="'AT'"/>
723 <xsl:map-entry key="'Windhoek'" select="'NA'"/>
724 <xsl:map-entry key="'Zuerich'" select="'CH'"/>
725 <xsl:map-entry key="'Zürich'" select="'CH'"/>
726 <xsl:map-entry key="'Zug'" select="'CH'"/>
727 <xsl:map-entry key="'ZÜRICH'" select="'CH'"/>
728 </xsl:map>
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200729
Marc Kupietz10903f32024-04-14 14:21:18 +0200730 </xsl:variable>
731
732 <!-- Define the function -->
733 <xsl:function name="ids:country-city" as="xs:string">
734 <xsl:param name="city" as="xs:string"/>
735 <xsl:sequence select="if (map:contains($city-country-map, $city)) then map:get($city-country-map, $city) else 'DE'"/>
736 </xsl:function>
Marc Kupietz1a422662024-03-16 09:34:10 +0100737</xsl:stylesheet>