blob: f2f2414da9bd555ccaa8c723c53ae33281240f81 [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 Kupietzcff63c02024-09-28 23:11:18 +020048 <xsl:copy-of select="if(starts-with($idno, '8')) then doc('static_metadata.xml')//oai:dc[dc:identifier=$idno] else doc($dnbBookdataQuery)"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010049 </xsl:variable>
50
51 <xsl:variable name="autor"
Marc Kupietzde2ca532024-04-26 16:50:53 +020052 select="replace(string-join($dnbBookdata//dc:creator[not(contains(., '[')) or matches(., '\[Verfasser\]')], ' ; '), ' *\[[^\]]*\]', '')"/>
Marc Kupietzeaa90132024-04-26 18:14:40 +020053 <xsl:variable name="straight_autor" select="normalize-space(replace(hlu:reversedAuthors($autor), ',', ''))"/>
54 <xsl:variable name="translator"
55 select="replace(string-join($dnbBookdata//dc:creator[matches(., '\[Übersetzer\]')], ' ; '), ' *\[[^\]]*\]', '')"/>
56 <xsl:variable name="straight_translator" select="normalize-space(replace(hlu:reversedAuthors($translator), ',', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010057
Marc Kupietz15e7d612024-04-26 18:16:39 +020058 <xsl:variable name="herausgeber"
59 select="replace(string-join($dnbBookdata//dc:creator[matches(., '\[(Herausgeber|Hrsg.)\]')], ' ; '), ' *\[[^\]]*\]', '')"/>
60 <xsl:variable name="straight_herausgeber" select="normalize-space(replace(hlu:reversedAuthors($herausgeber), ',', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010061
62 <xsl:variable name="ina"/>
63 <xsl:variable name="_corpus"/>
64 <xsl:variable name="ent_known"/>
65
66
67 <!-- added HLU 2012-02-09: -->
68 <xsl:variable name="ent">
69 <xsl:choose>
70 <xsl:when test="$ent_known">
71 <xsl:value-of select="$ent_known"/>
72 </xsl:when>
73 <xsl:when test="$ev">
74 <xsl:value-of select="$ev"/>
75 </xsl:when>
76 <xsl:otherwise>
77 <xsl:value-of select="$j"/>
78 </xsl:otherwise>
79 </xsl:choose>
80 </xsl:variable>
81
82 <xsl:variable name="titel">
Marc Kupietz49124fa2024-04-10 16:50:01 +020083 <xsl:variable name="title-with-subtitles">
Marc Kupietz2c7bc7e2024-09-30 14:09:25 +020084 <xsl:if test="$debug">
85 <xsl:message select="concat('title: ', ($dnbBookdata//dc:title)[1])"/>
86 </xsl:if>
Marc Kupietz49124fa2024-04-10 16:50:01 +020087 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +020088 <xsl:when test="contains(($dnbBookdata//dc:title)[1],':')">
Marc Kupietz744d30e2024-09-22 12:49:45 +020089 <xsl:choose>
90 <xsl:when test="matches(($dnbBookdata//dc:title)[1], '.*/.*:.*/')">
91 <xsl:value-of select="normalize-space(substring-before(($dnbBookdata//dc:title)[1], ':'))"/>
92 </xsl:when>
93 <xsl:otherwise>
94 <xsl:value-of select="normalize-space(substring-before(substring-before(($dnbBookdata//dc:title)[1], '/'), ':'))"/>
95 </xsl:otherwise>
96 </xsl:choose>
Marc Kupietz49124fa2024-04-10 16:50:01 +020097 </xsl:when>
Marc Kupietzb9903542024-09-30 14:02:18 +020098 <xsl:when test="contains(($dnbBookdata//dc:title)[1],'/')">
Marc Kupietz6cb52232024-04-13 12:28:44 +020099 <xsl:value-of select="normalize-space(substring-before(($dnbBookdata//dc:title)[1], '/'))"/>
Marc Kupietzb9903542024-09-30 14:02:18 +0200100 </xsl:when>
101 <xsl:otherwise>
102 <xsl:value-of select="normalize-space(($dnbBookdata//dc:title)[1])"/>
Marc Kupietz49124fa2024-04-10 16:50:01 +0200103 </xsl:otherwise>
104 </xsl:choose>
105 </xsl:variable>
106 <xsl:value-of select="normalize-space(replace($title-with-subtitles, '\|.*', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100107 </xsl:variable>
108
109 <xsl:variable name="erscheinungsort">
110 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +0200111 <xsl:when test="contains(($dnbBookdata//dc:publisher)[1], ':')">
112 <xsl:value-of select="normalize-space(substring-before(($dnbBookdata//dc:publisher)[1], ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100113 </xsl:when>
114 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +0200115 <xsl:value-of select="normalize-space(($dnbBookdata//dc:publisher)[1])"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100116 </xsl:otherwise>
117 </xsl:choose>
118 </xsl:variable>
119
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200120 <xsl:variable name="erscheinungsland" select="ids:country-city($erscheinungsort)"/>
121
Marc Kupietz6cb52232024-04-13 12:28:44 +0200122 <xsl:variable name="texttype" select="replace(($dnbBookdata//dc:subject[matches(., '^[A-Z] ')])[1], '^[A-Z] (.*)', '$1')"/>
Marc Kupietz7df4ccc2024-03-16 15:27:45 +0100123
Marc Kupietz9d87e9d2024-05-05 15:56:50 +0200124 <xsl:variable name="genretable">
125 <genres>
Nicolas Arnold32118802024-05-31 17:10:05 +0200126 <genre keyRegex="(krimi|thriller)" genre="Roman: Kriminalroman"/>
127 <genre keyRegex="arzt.?roman" genre="Roman: Arztroman"/>
128 <genre keyRegex="(liebes.*roman|dunja|romanze)" genre="Roman: Liebesroman"/>
Marc Kupietz9d87e9d2024-05-05 15:56:50 +0200129 <genre keyRegex="science.?fiction" genre="Roman: Science-Fiction-Roman"/>
130 <genre keyRegex="horror" genre="Roman: Horrorroman"/>
Marc Kupietzc214b4c2024-05-26 19:12:03 +0200131 <genre keyRegex="grusel" genre="Roman: Gruselroman"/>
132 <genre keyRegex="vampir.*roman" genre="Roman: Vampirroman"/>
Marc Kupietz9d87e9d2024-05-05 15:56:50 +0200133 <genre keyRegex="western" genre="Roman: Westernroman"/>
134 <genre keyRegex="fantasy" genre="Roman: Fantasyroman"/>
Marc Kupietzc214b4c2024-05-26 19:12:03 +0200135 <genre keyRegex="mystery" genre="Roman: Mysteryroman"/>
136 <genre keyRegex="heimat.*roman" genre="Roman: Heimatroman"/>
137 <genre keyRegex="familien.*roman" genre="Roman: Familienroman"/>
138 <genre keyRegex="(sex|erotik|erotische|versaute|fick|sm).*roman" genre="Roman: Erotikroman"/>
139 <genre keyRegex="gay" genre="Roman: Gay-Roman"/>
140 <genre keyRegex="(sex|erotik|erotische|versaute|fick|sm)" genre="Erzählung: Erotikerzählung"/>
Marc Kupietz9d87e9d2024-05-05 15:56:50 +0200141 <genre keyRegex="historischer roman" genre="Roman: Historischer Roman"/>
Nicolas Arnold32118802024-05-31 17:10:05 +0200142 <genre keyRegex="jugend" genre="Jugendliteratur: Jugendliteratur"/> <!-- wie in KJL -->
143 <genre keyRegex="(ein roman|der roman)" genre="Roman"/>
Marc Kupietz9d87e9d2024-05-05 15:56:50 +0200144 <genre keyRegex="erzählung" genre="Erzählung"/>
145 <genre keyRegex="novelle" genre="Novelle"/>
146 <genre keyRegex="anthologie" genre="Anthologie"/>
147 <genre keyRegex="kurzgeschichte" genre="Kurzgeschichte"/>
Marc Kupietzc214b4c2024-05-26 19:12:03 +0200148 <genre keyRegex="geschichte" genre="Erzählung"/>
149 <genre keyRegex="heftroman" genre="Roman: Heftroman"/>
Marc Kupietz9d87e9d2024-05-05 15:56:50 +0200150 <genre keyRegex="roman" genre="Roman"/>
151 <genre keyRegex="." genre="Roman"/>
152 </genres>
153 </xsl:variable>
154
155 <xsl:variable name="textFullGenre" select="$genretable/genres/genre[matches($dnbBookdata, ./@keyRegex, 'i')][1]/@genre"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100156 <xsl:variable name="verlag">
157 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +0200158 <xsl:when test="contains(($dnbBookdata//dc:publisher)[1], ':')">
159 <xsl:value-of select="normalize-space(substring-after(($dnbBookdata//dc:publisher)[1], ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100160 </xsl:when>
161 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +0200162 <xsl:value-of select="normalize-space(($dnbBookdata//dc:publisher)[1])"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100163 </xsl:otherwise>
164 </xsl:choose>
165 </xsl:variable>
166
167 <xsl:variable name="erscheinungsjahr">
Marc Kupietza5d01182024-04-14 12:24:02 +0200168 <xsl:value-of select="replace(($dnbBookdata//dc:date)[1], '.*?((19|20)[0-9][0-9]).*', '$1')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100169 </xsl:variable>
170
171 <xsl:variable name="untertitel"
Marc Kupietz6cb52232024-04-13 12:28:44 +0200172 select="normalize-space(substring-after(substring-before(($dnbBookdata//dc:title)[1], '/'), ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100173
Marc Kupietza5d01182024-04-14 12:24:02 +0200174 <xsl:variable name="j" select="$erscheinungsjahr"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100175
176 <!-- for BOT+s: -->
177 <xsl:variable name="seiten" select="replace($dnbBookdata//dc:format,'S\.','')"/>
178
179 <!-- fuer BOT+b: -->
180 <xsl:variable name="_b">
181 <xsl:variable name="regexp1" select="'(Band|Bd\.)\s*([0-9]?[0-9]?[0-9])'"/>
182 <xsl:choose>
183 <xsl:when test="matches($dnbBookdata, $regexp1)">
184 <xsl:analyze-string select="$dnbBookdata//dc:title" regex="{$regexp1}">
185 <xsl:matching-substring>
186 <xsl:value-of select="."/>
187 </xsl:matching-substring>
188 </xsl:analyze-string>
189 </xsl:when>
190 <xsl:otherwise>
191 <xsl:value-of select="'.'"/>
192 </xsl:otherwise>
193 </xsl:choose>
194 </xsl:variable>
195
196 <!-- for BOT+x: -->
197 <xsl:variable name="txtart">
198 <xsl:choose>
199 <xsl:when test="$x">
200 <xsl:value-of select="concat('[', $x, ']')"/>
201 </xsl:when>
202 <xsl:when
Nicolas Arnold26355632024-05-10 15:25:41 +0200203 test="matches($untertitel, '([Rr]oman|[Ee]rzählung(en)?|[Aa]nthologie|[Gg]eschichte(n)?|[Nn]ovelle)')">
Marc Kupietz1a422662024-03-16 09:34:10 +0100204 <xsl:value-of
Nicolas Arnold26355632024-05-10 15:25:41 +0200205 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 +0100206 />
207 </xsl:when>
208 <xsl:otherwise>
209 <xsl:value-of>Roman</xsl:value-of>
210 </xsl:otherwise>
211 </xsl:choose>
212 </xsl:variable>
213
214
215
216 <!-- fuer BOTd: -->
217 <xsl:variable name="dok"
218 select="concat((if(string-length($autor) &gt; 0) then concat($straight_autor, ': ') else ''), $titel, ', ', $txtart, ', (', $j, ')')"/>
219
220 <!-- END variables derived from sru request to dnb archive -->
221
222
Marc Kupietz94bbe6b2024-04-10 20:35:48 +0200223 <xsl:variable name="corpus_sigle" select="concat('DNB', substring($erscheinungsjahr, 3, 2))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100224
225 <!-- for BOTD: -->
226 <!-- Dokumentsigle muss zusammen mit Korpussigle (z.B DIV fuer loz-div und loz-div-pub) eindeutig sein -->
227 <xsl:variable name="doc_sigle">
228 <xsl:variable name="firstContentWordTitleInitial">
229 <xsl:variable name="helper">
230 <xsl:analyze-string select="$titel" regex="\w+">
231 <xsl:matching-substring>
232 <xsl:choose>
233 <xsl:when
Marc Kupietzad1f3b82024-04-19 19:21:49 +0200234 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 +0100235 <!-- TODO: Fktnswoerter nachtragen -->
236 <xsl:sequence select="."/>
237 </xsl:when>
238 <xsl:otherwise/>
239 </xsl:choose>
240 </xsl:matching-substring>
241 </xsl:analyze-string>
242 </xsl:variable>
243 <xsl:value-of
Marc Kupietz77b6aa92024-04-21 17:31:43 +0200244 select="upper-case(substring(normalize-space(replace($helper,'\s+.+$','')),1,3))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100245 <!-- longest match of .+ -->
246 </xsl:variable>
Marc Kupietz77b6aa92024-04-21 17:31:43 +0200247 <xsl:variable name="authorInitials">
248 <xsl:choose>
249 <xsl:when test="contains($autor,';')">
250 <xsl:variable name="lastname_aut1"
251 select="upper-case(substring(normalize-space($autor),1,1))"/>
252 <xsl:variable name="lastname_aut2"
253 select="replace($autor, '.*?;.*?([A-Z]).*', '$1')"/>
254 <xsl:value-of select="concat($lastname_aut1, $lastname_aut2)"/>
255 </xsl:when>
256 <xsl:otherwise>
257 <xsl:variable name="lastname_aut1"
258 select="upper-case(substring(normalize-space(substring-before($autor,',')),1,1))"/>
259 <xsl:variable name="firstname_aut1"
260 select="upper-case(substring(normalize-space(substring-after($autor,',')),1,1))"/>
261 <xsl:value-of select="concat($lastname_aut1, $firstname_aut1)"/>
262 </xsl:otherwise>
263 </xsl:choose>
264 </xsl:variable>
Marc Kupietz398b5962024-04-21 17:51:34 +0200265 <xsl:value-of select="substring(replace(normalize-unicode(concat($authorInitials,$firstContentWordTitleInitial), 'NFKD'),'[^A-Z]',''),1,3)"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100266 </xsl:variable>
267
268
Marc Kupietz0c246632024-04-29 07:08:23 +0200269 <xsl:variable name="text_sigle" select="replace($idno, '.*([0-9]{5})[0-9X]$', '$1')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100270 <xsl:variable name="sigle" select="concat($corpus_sigle, '/', $doc_sigle, '.', $text_sigle)"/>
271
272 <!-- fuer BOT+xy: (?) -->
273 <xsl:variable name="xyref">
Marc Kupietz0df2a572024-05-26 16:54:27 +0200274 <xsl:value-of select="base-uri(.)"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100275 <xsl:text>; </xsl:text>
Marc Kupietz0c246632024-04-29 07:08:23 +0200276 <xsl:text>IDNO:</xsl:text>
277 <xsl:value-of select="$idno"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100278 <xsl:text>; </xsl:text>
279 <xsl:value-of select="string-join($dnbBookdata//dc:identifier)"/>
280 </xsl:variable>
281
Marc Kupietzb660ed62024-03-16 11:45:53 +0100282 <xsl:variable name="long-reference"
283 select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/>
284
285 <xsl:variable name="short-reference"
286 select="concat($straight_autor, ': ', $titel, ' (', $erscheinungsjahr, ')')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100287
288 <xsl:template match="/">
Marc Kupietz98645242024-05-26 16:52:47 +0200289 <!-- for debugging purposes
290 <xsl:message select="concat('uri: ', base-uri())"/>
291 <xsl:message select="concat('idno: ', $idno)"/>
292
293 <xsl:message>
294 dnbBookdataQuery: <xsl:value-of select="$dnbBookdataQuery"/>
295 </xsl:message>
296
297 <xsl:message>
298 <xsl:copy-of select="$dnbBookdata"/>
299 </xsl:message>
300 -->
Marc Kupietz2c7bc7e2024-09-30 14:09:25 +0200301 <xsl:if test="not($dnbBookdata//oai:dc)">
302 <xsl:message terminate="yes" default-mode="text">ERROR: No metadata found for IDNO: <xsl:value-of select="$idno"/>
303 <xsl:text>&#10;Query was: </xsl:text>
304 <xsl:value-of disable-output-escaping="yes" select="replace($dnbBookdataQuery, '&amp;', '%38')"/>
305 <xsl:text>&#10;Retrieved response: </xsl:text>
306 <xsl:copy-of select="$dnbBookdata"/>
307 </xsl:message>
308 </xsl:if>
309
Marc Kupietzb7a4f6c2024-04-19 11:35:25 +0200310 <xsl:if test="not($j)">
Marc Kupietz0c246632024-04-29 07:08:23 +0200311 <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 +0200312 </xsl:if>
313
Marc Kupietz815cc6c2024-04-19 12:44:44 +0200314 <xsl:if test="not(normalize-space($titel))">
Marc Kupietz0c246632024-04-29 07:08:23 +0200315 <xsl:message terminate="yes">ERROR: No title found for IDNO: <xsl:value-of select="$idno"/></xsl:message>
Marc Kupietz815cc6c2024-04-19 12:44:44 +0200316 </xsl:if>
317
Marc Kupietz2badfb12024-04-19 12:59:40 +0200318 <xsl:if test="not(normalize-space($autor))">
Marc Kupietz0c246632024-04-29 07:08:23 +0200319 <xsl:message terminate="yes">ERROR: No author found for IDNO: <xsl:value-of select="$idno"/></xsl:message>
Marc Kupietz2badfb12024-04-19 12:59:40 +0200320 </xsl:if>
321
Nicolas Arnold1fbd37f2024-06-28 15:10:47 +0200322 <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 +0200323 <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 +0200324 </xsl:if>
325
Marc Kupietz1a422662024-03-16 09:34:10 +0100326 <idsDoc TEIform="TEI.2" type="text" version="1.0">
327 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="document" version="1.1">
328 <fileDesc>
329 <titleStmt>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100330 <dokumentSigle><xsl:value-of select="string-join(($corpus_sigle, $doc_sigle), '/')"/></dokumentSigle>
331 <d.title><xsl:value-of select="$short-reference"/></d.title>
Marc Kupietz1a422662024-03-16 09:34:10 +0100332 </titleStmt>
333 <publicationStmt>
334 <distributor/>
335 <pubAddress/>
336 <availability region="world" status="unknown">QAO-NC</availability>
337 <pubDate/>
338 </publicationStmt>
339 <sourceDesc>
340 <biblStruct>
341 <monogr>
342 <h.title type="main"/>
343 <imprint/>
344 </monogr>
345 </biblStruct>
346 </sourceDesc>
347 </fileDesc>
348 </idsHeader>
349 <idsText version="1.0">
350 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="text" version="1.1">
351 <fileDesc>
352 <titleStmt>
353 <textSigle><xsl:sequence select="$sigle"/></textSigle>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100354 <t.title assemblage="regular"><xsl:value-of select="$long-reference"/></t.title>
Marc Kupietz1a422662024-03-16 09:34:10 +0100355 </titleStmt>
356 <publicationStmt>
357 <distributor/>
358 <pubAddress/>
Rebecca Wilm7bb2b6f2024-06-17 10:34:47 +0200359 <xsl:for-each select="$dnbBookdata//dc:identifier">
360 <xsl:variable name="type" select="substring-after(@xsi:type, ':')"/>
361 <xsl:choose>
362 <xsl:when test="@xsi:type='tel:ISBN'">
363 <xsl:if test="matches(.,'(^([0-9]|-)+X?).*')">
364 <idno type="{$type}"><xsl:value-of select="replace(., '(([0-9]|-)+X?).*', '$1')"/></idno>
365 </xsl:if>
366 </xsl:when>
Marc Kupietz7582d572024-07-25 16:55:20 +0200367 <xsl:when test="$type='URL' and contains(., '/urn:nbn:de')">
368 <idno rend="URN;{tokenize(., '/')[last()]}" type="URL"><xsl:value-of select="."/></idno>
Marc Kupietzc4ea4092024-07-25 11:00:00 +0200369 </xsl:when>
Rebecca Wilm7bb2b6f2024-06-17 10:34:47 +0200370 <xsl:otherwise><idno type="{$type}"><xsl:value-of select="."/></idno></xsl:otherwise>
371 </xsl:choose>
372 </xsl:for-each>
Marc Kupietz1a422662024-03-16 09:34:10 +0100373 <availability region="world" status="unknown">QAO-NC</availability>
374 <pubDate/>
375 </publicationStmt>
376 <sourceDesc>
377 <biblStruct>
378 <monogr>
379 <h.title type="main"><xsl:value-of select="$titel"/></h.title>
380 <h.title type="sub"><xsl:value-of select="$untertitel"/></h.title>
381 <h.author><xsl:value-of select="$autor"/></h.author>
Marc Kupietzeaa90132024-04-26 18:14:40 +0200382 <xsl:if test="$translator">
383 <editor role="translator"><xsl:value-of select="$translator"/></editor>
384 </xsl:if>
Marc Kupietz15e7d612024-04-26 18:16:39 +0200385 <xsl:if test="$herausgeber">
386 <editor role="editor"><xsl:value-of select="$herausgeber"/></editor>
387 </xsl:if>
Marc Kupietz1a422662024-03-16 09:34:10 +0100388 <edition>
389 <further/>
390 <kind>E-Book-Ausgabe</kind>
391 <appearance>EPUB-Datei</appearance>
392 </edition>
393 <imprint>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100394 <publisher><xsl:value-of select="$verlag"/></publisher>
Marc Kupietz1a422662024-03-16 09:34:10 +0100395 <pubDate type="year"><xsl:value-of select="$j"/></pubDate>
396 <pubDate type="month"/>
397 <pubDate type="day"/>
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200398 <pubPlace key="{$erscheinungsland}"><xsl:value-of select="$erscheinungsort"/></pubPlace>
Marc Kupietz1a422662024-03-16 09:34:10 +0100399 </imprint>
400 <biblScope type="subsume"/>
401 <biblScope type="pp"/>
402 <biblScope type="vol"/>
403 <biblScope type="volume-title"/>
404 </monogr>
Marc Kupietz1c3ebca2024-09-22 13:49:28 +0200405 <xsl:if test="$buchpreis">
Rebecca Wilm2f345ff2024-07-30 16:58:25 +0200406 <xsl:element name="note">
407 <xsl:attribute name="type">award</xsl:attribute>
408 <xsl:attribute name="subtype">
Marc Kupietze43c7202024-09-22 12:53:41 +0200409 <xsl:value-of select="'Buchpreis deutscher_buchpreis'"/>
Rebecca Wilm2f345ff2024-07-30 16:58:25 +0200410 </xsl:attribute>
411 </xsl:element>
412 </xsl:if>
Marc Kupietz1a422662024-03-16 09:34:10 +0100413 </biblStruct>
414 <reference assemblage="regular" type="complete"><xsl:value-of select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/></reference>
Marc Kupietz1a422662024-03-16 09:34:10 +0100415 </sourceDesc>
416 </fileDesc>
417 <profileDesc>
418 <creation>
419 <creatDate><xsl:value-of select="$j"/></creatDate>
420 </creation>
421 <textClass/>
422 <textDesc>
Marc Kupietz9d87e9d2024-05-05 15:56:50 +0200423 <textType><xsl:value-of select="$textFullGenre"/></textType>
424 <textTypeRef><xsl:value-of select="replace($textFullGenre, '.*: *', '')"/></textTypeRef>
Marc Kupietz1a422662024-03-16 09:34:10 +0100425 <textDomain/>
426 </textDesc>
427 </profileDesc>
428 </idsHeader>
429 <text>
430 <body>
Marc Kupietz6b6d4702024-09-12 17:54:10 +0200431 <!-- Call the template for each idref the spine -->
432 <xsl:apply-templates select="//opf:spine/opf:itemref" mode="collect"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100433 </body>
434 </text>
435 </idsText>
436 </idsDoc>
437 </xsl:template>
438
Marc Kupietz6b6d4702024-09-12 17:54:10 +0200439 <xsl:template match="opf:itemref" mode="collect">
440 <xsl:variable name="id" select="@idref"/>
441 <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).*'))]"/>
442
443 <xsl:choose>
444 <xsl:when test = "$item">
445 <xsl:variable name="href" select="$item/@href"/>
446 <xsl:if test="$debug">
447 <xsl:message>
448 <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"/>
449 </xsl:message>
450 </xsl:if>
451 <xsl:apply-templates select="doc(resolve-uri($href, base-uri()))/xhtml:html/xhtml:body"/>
452 </xsl:when>
453 <xsl:otherwise>
454 <xsl:if test="$debug">
455 <xsl:message>
456 <xsl:text>skipping: </xsl:text><xsl:value-of select="$id"/><xsl:text> </xsl:text><xsl:value-of select="$idno"/>
457 </xsl:message>
458 </xsl:if>
459 </xsl:otherwise>
460 </xsl:choose>
461 </xsl:template>
Marc Kupietz1a422662024-03-16 09:34:10 +0100462
463 <xsl:template match="xhtml:body">
464 <div type="chapter">
465 <xsl:apply-templates/>
466 </div>
467 </xsl:template>
468
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000469 <xsl:template match="xhtml:body/text()">
470 <p>
471 <xsl:value-of select="."/>
472 </p>
473 </xsl:template>
474
Marc Kupietz1a422662024-03-16 09:34:10 +0100475 <xsl:template match="xhtml:title">
476 <head>
477 <xsl:apply-templates/>
478 </head>
479 </xsl:template>
480
481 <xsl:template match="xhtml:h1">
482 <head>
483 <xsl:apply-templates/>
484 </head>
485 </xsl:template>
486
Marc Kupietz3989c742024-04-21 17:33:49 +0200487 <xsl:template match="xhtml:h2|xhtml:h3|xhtml:h4|xhtml:h5|xhtml:h6">
Marc Kupietz1a422662024-03-16 09:34:10 +0100488 <head type="sub">
489 <xsl:apply-templates/>
490 </head>
491 </xsl:template>
492
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100493 <xsl:template match="xhtml:em">
494 <emph>
495 <xsl:apply-templates/>
496 </emph>
497 </xsl:template>
Marc Kupietz1a422662024-03-16 09:34:10 +0100498
Marc Kupietz30cc0802024-04-10 16:37:04 +0200499 <xsl:template match="xhtml:span[matches(@class, '(bold|italic|big|kursiv| )+')]">
500 <xsl:variable name="class" select="replace(@class, 'kursiv', 'italic')"/>
501 <hi rend="{$class}">
502 <xsl:apply-templates/>
503 </hi>
504 </xsl:template>
505
Marc Kupietzad4d4462024-04-26 17:43:08 +0200506 <xsl:template match="xhtml:span[matches(@class, '(regular|norm)')]">
Marc Kupietz5e873112024-04-15 06:51:08 +0200507 <xsl:apply-templates/>
508 </xsl:template>
509
Marc Kupietz3989c742024-04-21 17:33:49 +0200510 <xsl:template match="xhtml:b|xhtml:span[@class='b']|xhtml:strong">
Marc Kupietz30cc0802024-04-10 16:37:04 +0200511 <hi rend="bold">
Marc Kupietz1a422662024-03-16 09:34:10 +0100512 <xsl:apply-templates/>
513 </hi>
514 </xsl:template>
515
Nicolas Arnoldc169e832024-06-07 08:44:11 +0200516 <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 +0000517 <hi rend="italic">
518 <xsl:apply-templates/>
519 </hi>
520 </xsl:template>
521
522
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100523 <xsl:template match="xhtml:sub|xhtml:span[@class='sub']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100524 <hi rend="sub">
525 <xsl:apply-templates/>
526 </hi>
527 </xsl:template>
528
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100529 <xsl:template match="xhtml:sup|xhtml:span[@class='sup']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100530 <hi rend="sup">
531 <xsl:apply-templates/>
532 </hi>
533 </xsl:template>
534
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000535 <xsl:template match="xhtml:div[not(normalize-space(replace(., '&#160;', ' ')))]" priority="1.0"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100536
Marc Kupietzbf47ae72024-04-14 14:21:43 +0200537 <xsl:template match="xhtml:body/xhtml:div[./xhtml:h1|./xhtml:h2|./xhtml:h3]" priority="1.0">
538 <xsl:apply-templates/>
539 </xsl:template>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000540 <xsl:template match="xhtml:div/xhtml:div">
Marc Kupietz1a422662024-03-16 09:34:10 +0100541 <p>
542 <xsl:apply-templates/>
543 </p>
544 </xsl:template>
545
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000546 <xsl:template match="xhtml:body/xhtml:div[(descendant::xhtml:p|descendant::xhtml:div)]">
547 <div type="section">
548 <xsl:apply-templates/>
549 </div>
550 </xsl:template>
551
552 <xsl:template match="xhtml:body/xhtml:div[not(descendant::xhtml:p|descendant::xhtml:div)]">
553 <div type="section">
554 <p>
555 <xsl:apply-templates/>
556 </p>
557 </div>
558 </xsl:template>
559
560 <xsl:template match="xhtml:p[not(descendant::xhtml:p|descendant::xhtml:div)]">
561 <xsl:if test="normalize-space(.)">
562 <p>
563 <xsl:apply-templates/>
564 </p>
565 </xsl:if>
566 </xsl:template>
567
568 <xsl:template match="xhtml:p[descendant::xhtml:p|descendant::xhtml:div]">
569 <xsl:if test="normalize-space(.)">
570 <div type="section">
571 <xsl:apply-templates/>
572 </div>
573 </xsl:if>
574 </xsl:template>
575
Marc Kupietz09745e12024-04-21 12:54:10 +0200576 <xsl:template match="xhtml:ul">
577 <list type="unordered">
578 <xsl:apply-templates/>
579 </list>
580 </xsl:template>
581 <xsl:template match="xhtml:ol">
582 <list type="ordered">
583 <xsl:apply-templates/>
584 </list>
585 </xsl:template>
586 <xsl:template match="xhtml:li">
587 <item>
588 <xsl:apply-templates/>
589 </item>
590 </xsl:template>
591 <xsl:template match="xhtml:nav">
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200592 <!-- <gap reason="toc"/> -->
593 </xsl:template>
594
Marc Kupietz1a422662024-03-16 09:34:10 +0100595 <xsl:template match="xhtml:img">
596 <!-- <gap reason="image"/> -->
597 </xsl:template>
598
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200599 <xsl:template match="xhtml:audio">
600 <!-- <gap reason="audio"/> -->
601 </xsl:template>
602
Marc Kupietz09745e12024-04-21 12:54:10 +0200603 <xsl:template match="xhtml:table">
604 <!-- <gap reason="table"/> -->
605 </xsl:template>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000606 <xsl:template match="xhtml:body/xhtml:a">
Marc Kupietz164a2832024-04-14 21:00:48 +0200607 <xsl:if test="normalize-space(.)">
608 <p>
609 <ref target="{@href}">
610 <xsl:apply-templates />
611 </ref>
612 </p>
613 </xsl:if>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000614 </xsl:template>
615
616 <xsl:template match="xhtml:body/xhtml:span">
Marc Kupietz7f3fe792024-07-26 15:28:26 +0200617 <xsl:if test="$debug">
618 <xsl:message>
619 <xsl:text>unhandled span element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
620 </xsl:message>
621 </xsl:if>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000622 <div type="section">
623 <p>
624 <xsl:value-of select="."/>
625 </p>
626 </div>
627 </xsl:template>
628 <xsl:template match="xhtml:span">
Marc Kupietz7f3fe792024-07-26 15:28:26 +0200629 <xsl:if test="$debug">
630 <xsl:message>
631 <xsl:text>unhandled span element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
632 </xsl:message>
633 </xsl:if>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000634 <xsl:value-of select="."/>
635 </xsl:template>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100636 <xsl:template match="xhtml:a">
Marc Kupietz164a2832024-04-14 21:00:48 +0200637 <xsl:if test="normalize-space(.)">
638 <ref target="{@href}">
639 <xsl:apply-templates />
640 </ref>
641 </xsl:if>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100642 </xsl:template>
643
Marc Kupietz54ec28b2024-04-27 10:07:06 +0200644 <xsl:template match="xhtml:br">
645 <lb/><xsl:text>&#10;</xsl:text>
646 </xsl:template>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100647
Marc Kupietz1a422662024-03-16 09:34:10 +0100648 <xsl:template match="xhtml:*">
Marc Kupietz7f3fe792024-07-26 15:28:26 +0200649 <xsl:if test="$debug">
650 <xsl:message>
651 <xsl:text>unhandled element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
652 </xsl:message>
653 </xsl:if>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000654 <xsl:choose>
655 <xsl:when test="descendant::xhtml:div|descendant::xhtml:p|parent::xhtml:body">
656 <div type="section">
657 <xsl:apply-templates/>
658 </div>
659 </xsl:when>
660 <xsl:otherwise>
661 <xsl:apply-templates select="./*|node()"/>
662 </xsl:otherwise>
663 </xsl:choose>
Marc Kupietz1a422662024-03-16 09:34:10 +0100664 <xsl:apply-templates/>
665 </xsl:template>
666
667 <xsl:function name="ids:reversedAuthors">
668 <xsl:param name="s" />
669 <xsl:value-of
670 select="
671 if (matches($s, ';')) then
672 concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; ')))
673 else
674 replace($s, '(.+) (.+)', '$2, $1')"
675 />
676 </xsl:function>
677
678 <xsl:function name="hlu:reversedAuthors">
679 <xsl:param name="s"/>
680 <xsl:value-of
681 select="if (matches($s, ';')) then concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; '))) else replace($s, '(.+),(.+)', '$2, $1')"
682 />
683 </xsl:function>
684
Marc Kupietz10903f32024-04-14 14:21:18 +0200685 <xsl:variable name="city-country-map" as="map(xs:string, xs:string)">
686 <xsl:map>
687 <xsl:map-entry key="'Axams'" select="'AT'"/>
688 <xsl:map-entry key="'Vienna'" select="'AT'"/>
689 <xsl:map-entry key="'Klagenfurt'" select="'AT'"/>
690 <xsl:map-entry key="'Graz'" select="'AT'"/>
691 <xsl:map-entry key="'Innsbruck'" select="'AT'"/>
692 <xsl:map-entry key="'Salzburg'" select="'AT'"/>
693 <xsl:map-entry key="'Bern'" select="'CH'"/>
694 <xsl:map-entry key="'Biel/Bienne'" select="'CH'"/>
695 <xsl:map-entry key="'Zurich'" select="'CH'"/>
696 <xsl:map-entry key="'Basel'" select="'CH'"/>
697 <xsl:map-entry key="'Geneva'" select="'CH'"/>
698 <xsl:map-entry key="'Lucerne'" select="'CH'"/>
699 <xsl:map-entry key="'Lausanne'" select="'CH'"/>
700 <xsl:map-entry key="'Winterthur'" select="'CH'"/>
701 <xsl:map-entry key="'St. Gallen'" select="'CH'"/>
702 <xsl:map-entry key="'Interlaken'" select="'CH'"/>
703 <xsl:map-entry key="'Brussels'" select="'BE'"/>
704 <xsl:map-entry key="'Antwerp'" select="'BE'"/>
705 <xsl:map-entry key="'Ghent'" select="'BE'"/>
706 <xsl:map-entry key="'Bruges'" select="'BE'"/>
707 <xsl:map-entry key="'Leuven'" select="'BE'"/>
708 <xsl:map-entry key="'Liege'" select="'BE'"/>
709 <xsl:map-entry key="'Charleroi'" select="'BE'"/>
710 <xsl:map-entry key="'Namur'" select="'BE'"/>
711 <xsl:map-entry key="'Mons'" select="'BE'"/>
712 <xsl:map-entry key="'Bangkok'" select="'TH'"/>
713 <xsl:map-entry key="'Copenhagen'" select="'DK'"/>
714 <xsl:map-entry key="'colatina'" select="'BR'"/>
715 <xsl:map-entry key="'Oakland Park'" select="'US'"/>
716 <xsl:map-entry key="'Istanbul'" select="'TR'"/>
717 <xsl:map-entry key="'Luxemburg'" select="'LU'"/>
718 <xsl:map-entry key="'Palma de Mallorca'" select="'ES'"/>
719 <xsl:map-entry key="'Swakopmund'" select="'NA'"/>
720 <xsl:map-entry key="'Victoria'" select="'CA'"/>
721 <xsl:map-entry key="'Wien'" select="'AT'"/>
722 <xsl:map-entry key="'Windhoek'" select="'NA'"/>
723 <xsl:map-entry key="'Zuerich'" select="'CH'"/>
724 <xsl:map-entry key="'Zürich'" select="'CH'"/>
725 <xsl:map-entry key="'Zug'" select="'CH'"/>
726 <xsl:map-entry key="'ZÜRICH'" select="'CH'"/>
727 </xsl:map>
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200728
Marc Kupietz10903f32024-04-14 14:21:18 +0200729 </xsl:variable>
730
731 <!-- Define the function -->
732 <xsl:function name="ids:country-city" as="xs:string">
733 <xsl:param name="city" as="xs:string"/>
734 <xsl:sequence select="if (map:contains($city-country-map, $city)) then map:get($city-country-map, $city) else 'DE'"/>
735 </xsl:function>
Marc Kupietz1a422662024-03-16 09:34:10 +0100736</xsl:stylesheet>