blob: 2eff8cd8ce89e80ae8b29ac38fcc28385b987857 [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
37 <xsl:variable name="original_path" select="document(resolve-uri('../originalPath.xml', base-uri(/)))/originalPath"/>
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 Kupietz0df2a572024-05-26 16:54:27 +020043 <xsl:copy-of select="doc($dnbBookdataQuery)"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010044 </xsl:variable>
45
46 <xsl:variable name="autor"
Marc Kupietzde2ca532024-04-26 16:50:53 +020047 select="replace(string-join($dnbBookdata//dc:creator[not(contains(., '[')) or matches(., '\[Verfasser\]')], ' ; '), ' *\[[^\]]*\]', '')"/>
Marc Kupietzeaa90132024-04-26 18:14:40 +020048 <xsl:variable name="straight_autor" select="normalize-space(replace(hlu:reversedAuthors($autor), ',', ''))"/>
49 <xsl:variable name="translator"
50 select="replace(string-join($dnbBookdata//dc:creator[matches(., '\[Übersetzer\]')], ' ; '), ' *\[[^\]]*\]', '')"/>
51 <xsl:variable name="straight_translator" select="normalize-space(replace(hlu:reversedAuthors($translator), ',', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010052
Marc Kupietz15e7d612024-04-26 18:16:39 +020053 <xsl:variable name="herausgeber"
54 select="replace(string-join($dnbBookdata//dc:creator[matches(., '\[(Herausgeber|Hrsg.)\]')], ' ; '), ' *\[[^\]]*\]', '')"/>
55 <xsl:variable name="straight_herausgeber" select="normalize-space(replace(hlu:reversedAuthors($herausgeber), ',', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010056
57 <xsl:variable name="ina"/>
58 <xsl:variable name="_corpus"/>
59 <xsl:variable name="ent_known"/>
60
61
62 <!-- added HLU 2012-02-09: -->
63 <xsl:variable name="ent">
64 <xsl:choose>
65 <xsl:when test="$ent_known">
66 <xsl:value-of select="$ent_known"/>
67 </xsl:when>
68 <xsl:when test="$ev">
69 <xsl:value-of select="$ev"/>
70 </xsl:when>
71 <xsl:otherwise>
72 <xsl:value-of select="$j"/>
73 </xsl:otherwise>
74 </xsl:choose>
75 </xsl:variable>
76
77 <xsl:variable name="titel">
Marc Kupietz49124fa2024-04-10 16:50:01 +020078 <xsl:variable name="title-with-subtitles">
79 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +020080 <xsl:when test="contains(($dnbBookdata//dc:title)[1],':')">
Rebecca Wilme5f055a2024-05-10 15:07:50 +020081 <xsl:value-of select="normalize-space(substring-before(substring-before(($dnbBookdata//dc:title)[1], '/'), ':'))"/>
Marc Kupietz49124fa2024-04-10 16:50:01 +020082 </xsl:when>
83 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +020084 <xsl:value-of select="normalize-space(substring-before(($dnbBookdata//dc:title)[1], '/'))"/>
Marc Kupietz49124fa2024-04-10 16:50:01 +020085 </xsl:otherwise>
86 </xsl:choose>
87 </xsl:variable>
88 <xsl:value-of select="normalize-space(replace($title-with-subtitles, '\|.*', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010089 </xsl:variable>
90
91 <xsl:variable name="erscheinungsort">
92 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +020093 <xsl:when test="contains(($dnbBookdata//dc:publisher)[1], ':')">
94 <xsl:value-of select="normalize-space(substring-before(($dnbBookdata//dc:publisher)[1], ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010095 </xsl:when>
96 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +020097 <xsl:value-of select="normalize-space(($dnbBookdata//dc:publisher)[1])"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010098 </xsl:otherwise>
99 </xsl:choose>
100 </xsl:variable>
101
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200102 <xsl:variable name="erscheinungsland" select="ids:country-city($erscheinungsort)"/>
103
Marc Kupietz6cb52232024-04-13 12:28:44 +0200104 <xsl:variable name="texttype" select="replace(($dnbBookdata//dc:subject[matches(., '^[A-Z] ')])[1], '^[A-Z] (.*)', '$1')"/>
Marc Kupietz7df4ccc2024-03-16 15:27:45 +0100105
Marc Kupietz9d87e9d2024-05-05 15:56:50 +0200106 <xsl:variable name="genretable">
107 <genres>
Nicolas Arnold32118802024-05-31 17:10:05 +0200108 <genre keyRegex="(krimi|thriller)" genre="Roman: Kriminalroman"/>
109 <genre keyRegex="arzt.?roman" genre="Roman: Arztroman"/>
110 <genre keyRegex="(liebes.*roman|dunja|romanze)" genre="Roman: Liebesroman"/>
Marc Kupietz9d87e9d2024-05-05 15:56:50 +0200111 <genre keyRegex="science.?fiction" genre="Roman: Science-Fiction-Roman"/>
112 <genre keyRegex="horror" genre="Roman: Horrorroman"/>
Marc Kupietzc214b4c2024-05-26 19:12:03 +0200113 <genre keyRegex="grusel" genre="Roman: Gruselroman"/>
114 <genre keyRegex="vampir.*roman" genre="Roman: Vampirroman"/>
Marc Kupietz9d87e9d2024-05-05 15:56:50 +0200115 <genre keyRegex="western" genre="Roman: Westernroman"/>
116 <genre keyRegex="fantasy" genre="Roman: Fantasyroman"/>
Marc Kupietzc214b4c2024-05-26 19:12:03 +0200117 <genre keyRegex="mystery" genre="Roman: Mysteryroman"/>
118 <genre keyRegex="heimat.*roman" genre="Roman: Heimatroman"/>
119 <genre keyRegex="familien.*roman" genre="Roman: Familienroman"/>
120 <genre keyRegex="(sex|erotik|erotische|versaute|fick|sm).*roman" genre="Roman: Erotikroman"/>
121 <genre keyRegex="gay" genre="Roman: Gay-Roman"/>
122 <genre keyRegex="(sex|erotik|erotische|versaute|fick|sm)" genre="Erzählung: Erotikerzählung"/>
Marc Kupietz9d87e9d2024-05-05 15:56:50 +0200123 <genre keyRegex="historischer roman" genre="Roman: Historischer Roman"/>
Nicolas Arnold32118802024-05-31 17:10:05 +0200124 <genre keyRegex="jugend" genre="Jugendliteratur: Jugendliteratur"/> <!-- wie in KJL -->
125 <genre keyRegex="(ein roman|der roman)" genre="Roman"/>
Marc Kupietz9d87e9d2024-05-05 15:56:50 +0200126 <genre keyRegex="erzählung" genre="Erzählung"/>
127 <genre keyRegex="novelle" genre="Novelle"/>
128 <genre keyRegex="anthologie" genre="Anthologie"/>
129 <genre keyRegex="kurzgeschichte" genre="Kurzgeschichte"/>
Marc Kupietzc214b4c2024-05-26 19:12:03 +0200130 <genre keyRegex="geschichte" genre="Erzählung"/>
131 <genre keyRegex="heftroman" genre="Roman: Heftroman"/>
Marc Kupietz9d87e9d2024-05-05 15:56:50 +0200132 <genre keyRegex="roman" genre="Roman"/>
133 <genre keyRegex="." genre="Roman"/>
134 </genres>
135 </xsl:variable>
136
137 <xsl:variable name="textFullGenre" select="$genretable/genres/genre[matches($dnbBookdata, ./@keyRegex, 'i')][1]/@genre"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100138 <xsl:variable name="verlag">
139 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +0200140 <xsl:when test="contains(($dnbBookdata//dc:publisher)[1], ':')">
141 <xsl:value-of select="normalize-space(substring-after(($dnbBookdata//dc:publisher)[1], ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100142 </xsl:when>
143 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +0200144 <xsl:value-of select="normalize-space(($dnbBookdata//dc:publisher)[1])"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100145 </xsl:otherwise>
146 </xsl:choose>
147 </xsl:variable>
148
149 <xsl:variable name="erscheinungsjahr">
Marc Kupietza5d01182024-04-14 12:24:02 +0200150 <xsl:value-of select="replace(($dnbBookdata//dc:date)[1], '.*?((19|20)[0-9][0-9]).*', '$1')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100151 </xsl:variable>
152
153 <xsl:variable name="untertitel"
Marc Kupietz6cb52232024-04-13 12:28:44 +0200154 select="normalize-space(substring-after(substring-before(($dnbBookdata//dc:title)[1], '/'), ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100155
Marc Kupietza5d01182024-04-14 12:24:02 +0200156 <xsl:variable name="j" select="$erscheinungsjahr"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100157
158 <!-- for BOT+s: -->
159 <xsl:variable name="seiten" select="replace($dnbBookdata//dc:format,'S\.','')"/>
160
161 <!-- fuer BOT+b: -->
162 <xsl:variable name="_b">
163 <xsl:variable name="regexp1" select="'(Band|Bd\.)\s*([0-9]?[0-9]?[0-9])'"/>
164 <xsl:choose>
165 <xsl:when test="matches($dnbBookdata, $regexp1)">
166 <xsl:analyze-string select="$dnbBookdata//dc:title" regex="{$regexp1}">
167 <xsl:matching-substring>
168 <xsl:value-of select="."/>
169 </xsl:matching-substring>
170 </xsl:analyze-string>
171 </xsl:when>
172 <xsl:otherwise>
173 <xsl:value-of select="'.'"/>
174 </xsl:otherwise>
175 </xsl:choose>
176 </xsl:variable>
177
178 <!-- for BOT+x: -->
179 <xsl:variable name="txtart">
180 <xsl:choose>
181 <xsl:when test="$x">
182 <xsl:value-of select="concat('[', $x, ']')"/>
183 </xsl:when>
184 <xsl:when
Nicolas Arnold26355632024-05-10 15:25:41 +0200185 test="matches($untertitel, '([Rr]oman|[Ee]rzählung(en)?|[Aa]nthologie|[Gg]eschichte(n)?|[Nn]ovelle)')">
Marc Kupietz1a422662024-03-16 09:34:10 +0100186 <xsl:value-of
Nicolas Arnold26355632024-05-10 15:25:41 +0200187 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 +0100188 />
189 </xsl:when>
190 <xsl:otherwise>
191 <xsl:value-of>Roman</xsl:value-of>
192 </xsl:otherwise>
193 </xsl:choose>
194 </xsl:variable>
195
196
197
198 <!-- fuer BOTd: -->
199 <xsl:variable name="dok"
200 select="concat((if(string-length($autor) &gt; 0) then concat($straight_autor, ': ') else ''), $titel, ', ', $txtart, ', (', $j, ')')"/>
201
202 <!-- END variables derived from sru request to dnb archive -->
203
204
Marc Kupietz94bbe6b2024-04-10 20:35:48 +0200205 <xsl:variable name="corpus_sigle" select="concat('DNB', substring($erscheinungsjahr, 3, 2))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100206
207 <!-- for BOTD: -->
208 <!-- Dokumentsigle muss zusammen mit Korpussigle (z.B DIV fuer loz-div und loz-div-pub) eindeutig sein -->
209 <xsl:variable name="doc_sigle">
210 <xsl:variable name="firstContentWordTitleInitial">
211 <xsl:variable name="helper">
212 <xsl:analyze-string select="$titel" regex="\w+">
213 <xsl:matching-substring>
214 <xsl:choose>
215 <xsl:when
Marc Kupietzad1f3b82024-04-19 19:21:49 +0200216 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 +0100217 <!-- TODO: Fktnswoerter nachtragen -->
218 <xsl:sequence select="."/>
219 </xsl:when>
220 <xsl:otherwise/>
221 </xsl:choose>
222 </xsl:matching-substring>
223 </xsl:analyze-string>
224 </xsl:variable>
225 <xsl:value-of
Marc Kupietz77b6aa92024-04-21 17:31:43 +0200226 select="upper-case(substring(normalize-space(replace($helper,'\s+.+$','')),1,3))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100227 <!-- longest match of .+ -->
228 </xsl:variable>
Marc Kupietz77b6aa92024-04-21 17:31:43 +0200229 <xsl:variable name="authorInitials">
230 <xsl:choose>
231 <xsl:when test="contains($autor,';')">
232 <xsl:variable name="lastname_aut1"
233 select="upper-case(substring(normalize-space($autor),1,1))"/>
234 <xsl:variable name="lastname_aut2"
235 select="replace($autor, '.*?;.*?([A-Z]).*', '$1')"/>
236 <xsl:value-of select="concat($lastname_aut1, $lastname_aut2)"/>
237 </xsl:when>
238 <xsl:otherwise>
239 <xsl:variable name="lastname_aut1"
240 select="upper-case(substring(normalize-space(substring-before($autor,',')),1,1))"/>
241 <xsl:variable name="firstname_aut1"
242 select="upper-case(substring(normalize-space(substring-after($autor,',')),1,1))"/>
243 <xsl:value-of select="concat($lastname_aut1, $firstname_aut1)"/>
244 </xsl:otherwise>
245 </xsl:choose>
246 </xsl:variable>
Marc Kupietz398b5962024-04-21 17:51:34 +0200247 <xsl:value-of select="substring(replace(normalize-unicode(concat($authorInitials,$firstContentWordTitleInitial), 'NFKD'),'[^A-Z]',''),1,3)"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100248 </xsl:variable>
249
250
Marc Kupietz0c246632024-04-29 07:08:23 +0200251 <xsl:variable name="text_sigle" select="replace($idno, '.*([0-9]{5})[0-9X]$', '$1')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100252 <xsl:variable name="sigle" select="concat($corpus_sigle, '/', $doc_sigle, '.', $text_sigle)"/>
253
254 <!-- fuer BOT+xy: (?) -->
255 <xsl:variable name="xyref">
Marc Kupietz0df2a572024-05-26 16:54:27 +0200256 <xsl:value-of select="base-uri(.)"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100257 <xsl:text>; </xsl:text>
Marc Kupietz0c246632024-04-29 07:08:23 +0200258 <xsl:text>IDNO:</xsl:text>
259 <xsl:value-of select="$idno"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100260 <xsl:text>; </xsl:text>
261 <xsl:value-of select="string-join($dnbBookdata//dc:identifier)"/>
262 </xsl:variable>
263
Marc Kupietzb660ed62024-03-16 11:45:53 +0100264 <xsl:variable name="long-reference"
265 select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/>
266
267 <xsl:variable name="short-reference"
268 select="concat($straight_autor, ': ', $titel, ' (', $erscheinungsjahr, ')')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100269
270 <xsl:template match="/">
Marc Kupietz98645242024-05-26 16:52:47 +0200271 <!-- for debugging purposes
272 <xsl:message select="concat('uri: ', base-uri())"/>
273 <xsl:message select="concat('idno: ', $idno)"/>
274
275 <xsl:message>
276 dnbBookdataQuery: <xsl:value-of select="$dnbBookdataQuery"/>
277 </xsl:message>
278
279 <xsl:message>
280 <xsl:copy-of select="$dnbBookdata"/>
281 </xsl:message>
282 -->
Marc Kupietzb7a4f6c2024-04-19 11:35:25 +0200283 <xsl:if test="not($j)">
Marc Kupietz0c246632024-04-29 07:08:23 +0200284 <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 +0200285 </xsl:if>
286
Marc Kupietz815cc6c2024-04-19 12:44:44 +0200287 <xsl:if test="not(normalize-space($titel))">
Marc Kupietz0c246632024-04-29 07:08:23 +0200288 <xsl:message terminate="yes">ERROR: No title found for IDNO: <xsl:value-of select="$idno"/></xsl:message>
Marc Kupietz815cc6c2024-04-19 12:44:44 +0200289 </xsl:if>
290
Marc Kupietz2badfb12024-04-19 12:59:40 +0200291 <xsl:if test="not(normalize-space($autor))">
Marc Kupietz0c246632024-04-29 07:08:23 +0200292 <xsl:message terminate="yes">ERROR: No author found for IDNO: <xsl:value-of select="$idno"/></xsl:message>
Marc Kupietz2badfb12024-04-19 12:59:40 +0200293 </xsl:if>
294
Nicolas Arnold1fbd37f2024-06-28 15:10:47 +0200295 <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 +0200296 <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 +0200297 </xsl:if>
298
Marc Kupietz1a422662024-03-16 09:34:10 +0100299 <idsDoc TEIform="TEI.2" type="text" version="1.0">
300 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="document" version="1.1">
301 <fileDesc>
302 <titleStmt>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100303 <dokumentSigle><xsl:value-of select="string-join(($corpus_sigle, $doc_sigle), '/')"/></dokumentSigle>
304 <d.title><xsl:value-of select="$short-reference"/></d.title>
Marc Kupietz1a422662024-03-16 09:34:10 +0100305 </titleStmt>
306 <publicationStmt>
307 <distributor/>
308 <pubAddress/>
309 <availability region="world" status="unknown">QAO-NC</availability>
310 <pubDate/>
311 </publicationStmt>
312 <sourceDesc>
313 <biblStruct>
314 <monogr>
315 <h.title type="main"/>
316 <imprint/>
317 </monogr>
318 </biblStruct>
319 </sourceDesc>
320 </fileDesc>
321 </idsHeader>
322 <idsText version="1.0">
323 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="text" version="1.1">
324 <fileDesc>
325 <titleStmt>
326 <textSigle><xsl:sequence select="$sigle"/></textSigle>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100327 <t.title assemblage="regular"><xsl:value-of select="$long-reference"/></t.title>
Marc Kupietz1a422662024-03-16 09:34:10 +0100328 </titleStmt>
329 <publicationStmt>
330 <distributor/>
331 <pubAddress/>
Rebecca Wilm7bb2b6f2024-06-17 10:34:47 +0200332 <xsl:for-each select="$dnbBookdata//dc:identifier">
333 <xsl:variable name="type" select="substring-after(@xsi:type, ':')"/>
334 <xsl:choose>
335 <xsl:when test="@xsi:type='tel:ISBN'">
336 <xsl:if test="matches(.,'(^([0-9]|-)+X?).*')">
337 <idno type="{$type}"><xsl:value-of select="replace(., '(([0-9]|-)+X?).*', '$1')"/></idno>
338 </xsl:if>
339 </xsl:when>
Marc Kupietz7582d572024-07-25 16:55:20 +0200340 <xsl:when test="$type='URL' and contains(., '/urn:nbn:de')">
341 <idno rend="URN;{tokenize(., '/')[last()]}" type="URL"><xsl:value-of select="."/></idno>
Marc Kupietzc4ea4092024-07-25 11:00:00 +0200342 </xsl:when>
Rebecca Wilm7bb2b6f2024-06-17 10:34:47 +0200343 <xsl:otherwise><idno type="{$type}"><xsl:value-of select="."/></idno></xsl:otherwise>
344 </xsl:choose>
345 </xsl:for-each>
Marc Kupietz1a422662024-03-16 09:34:10 +0100346 <availability region="world" status="unknown">QAO-NC</availability>
347 <pubDate/>
348 </publicationStmt>
349 <sourceDesc>
350 <biblStruct>
351 <monogr>
352 <h.title type="main"><xsl:value-of select="$titel"/></h.title>
353 <h.title type="sub"><xsl:value-of select="$untertitel"/></h.title>
354 <h.author><xsl:value-of select="$autor"/></h.author>
Marc Kupietzeaa90132024-04-26 18:14:40 +0200355 <xsl:if test="$translator">
356 <editor role="translator"><xsl:value-of select="$translator"/></editor>
357 </xsl:if>
Marc Kupietz15e7d612024-04-26 18:16:39 +0200358 <xsl:if test="$herausgeber">
359 <editor role="editor"><xsl:value-of select="$herausgeber"/></editor>
360 </xsl:if>
Marc Kupietz1a422662024-03-16 09:34:10 +0100361 <edition>
362 <further/>
363 <kind>E-Book-Ausgabe</kind>
364 <appearance>EPUB-Datei</appearance>
365 </edition>
366 <imprint>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100367 <publisher><xsl:value-of select="$verlag"/></publisher>
Marc Kupietz1a422662024-03-16 09:34:10 +0100368 <pubDate type="year"><xsl:value-of select="$j"/></pubDate>
369 <pubDate type="month"/>
370 <pubDate type="day"/>
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200371 <pubPlace key="{$erscheinungsland}"><xsl:value-of select="$erscheinungsort"/></pubPlace>
Marc Kupietz1a422662024-03-16 09:34:10 +0100372 </imprint>
373 <biblScope type="subsume"/>
374 <biblScope type="pp"/>
375 <biblScope type="vol"/>
376 <biblScope type="volume-title"/>
377 </monogr>
Rebecca Wilm2f345ff2024-07-30 16:58:25 +0200378 <xsl:if test="matches($original_path, 'Buchpreis', 'i')">
379 <xsl:variable name="bookprize_year" as="xs:string" select="replace($original_path, '.*Buchpreis_?([0-9]{4}).*' , '$1')"/>
380 <xsl:element name="note">
381 <xsl:attribute name="type">award</xsl:attribute>
382 <xsl:attribute name="subtype">
383 <xsl:value-of select="concat('Deutscher Buchpreis ', $bookprize_year)"/>
384 </xsl:attribute>
385 </xsl:element>
386 </xsl:if>
Marc Kupietz1a422662024-03-16 09:34:10 +0100387 </biblStruct>
388 <reference assemblage="regular" type="complete"><xsl:value-of select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/></reference>
Marc Kupietz1a422662024-03-16 09:34:10 +0100389 </sourceDesc>
390 </fileDesc>
391 <profileDesc>
392 <creation>
393 <creatDate><xsl:value-of select="$j"/></creatDate>
394 </creation>
395 <textClass/>
396 <textDesc>
Marc Kupietz9d87e9d2024-05-05 15:56:50 +0200397 <textType><xsl:value-of select="$textFullGenre"/></textType>
398 <textTypeRef><xsl:value-of select="replace($textFullGenre, '.*: *', '')"/></textTypeRef>
Marc Kupietz1a422662024-03-16 09:34:10 +0100399 <textDomain/>
400 </textDesc>
401 </profileDesc>
402 </idsHeader>
403 <text>
404 <body>
Marc Kupietz6b6d4702024-09-12 17:54:10 +0200405 <!-- Call the template for each idref the spine -->
406 <xsl:apply-templates select="//opf:spine/opf:itemref" mode="collect"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100407 </body>
408 </text>
409 </idsText>
410 </idsDoc>
411 </xsl:template>
412
Marc Kupietz6b6d4702024-09-12 17:54:10 +0200413 <xsl:template match="opf:itemref" mode="collect">
414 <xsl:variable name="id" select="@idref"/>
415 <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).*'))]"/>
416
417 <xsl:choose>
418 <xsl:when test = "$item">
419 <xsl:variable name="href" select="$item/@href"/>
420 <xsl:if test="$debug">
421 <xsl:message>
422 <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"/>
423 </xsl:message>
424 </xsl:if>
425 <xsl:apply-templates select="doc(resolve-uri($href, base-uri()))/xhtml:html/xhtml:body"/>
426 </xsl:when>
427 <xsl:otherwise>
428 <xsl:if test="$debug">
429 <xsl:message>
430 <xsl:text>skipping: </xsl:text><xsl:value-of select="$id"/><xsl:text> </xsl:text><xsl:value-of select="$idno"/>
431 </xsl:message>
432 </xsl:if>
433 </xsl:otherwise>
434 </xsl:choose>
435 </xsl:template>
Marc Kupietz1a422662024-03-16 09:34:10 +0100436
437 <xsl:template match="xhtml:body">
438 <div type="chapter">
439 <xsl:apply-templates/>
440 </div>
441 </xsl:template>
442
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000443 <xsl:template match="xhtml:body/text()">
444 <p>
445 <xsl:value-of select="."/>
446 </p>
447 </xsl:template>
448
Marc Kupietz1a422662024-03-16 09:34:10 +0100449 <xsl:template match="xhtml:title">
450 <head>
451 <xsl:apply-templates/>
452 </head>
453 </xsl:template>
454
455 <xsl:template match="xhtml:h1">
456 <head>
457 <xsl:apply-templates/>
458 </head>
459 </xsl:template>
460
Marc Kupietz3989c742024-04-21 17:33:49 +0200461 <xsl:template match="xhtml:h2|xhtml:h3|xhtml:h4|xhtml:h5|xhtml:h6">
Marc Kupietz1a422662024-03-16 09:34:10 +0100462 <head type="sub">
463 <xsl:apply-templates/>
464 </head>
465 </xsl:template>
466
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100467 <xsl:template match="xhtml:em">
468 <emph>
469 <xsl:apply-templates/>
470 </emph>
471 </xsl:template>
Marc Kupietz1a422662024-03-16 09:34:10 +0100472
Marc Kupietz30cc0802024-04-10 16:37:04 +0200473 <xsl:template match="xhtml:span[matches(@class, '(bold|italic|big|kursiv| )+')]">
474 <xsl:variable name="class" select="replace(@class, 'kursiv', 'italic')"/>
475 <hi rend="{$class}">
476 <xsl:apply-templates/>
477 </hi>
478 </xsl:template>
479
Marc Kupietzad4d4462024-04-26 17:43:08 +0200480 <xsl:template match="xhtml:span[matches(@class, '(regular|norm)')]">
Marc Kupietz5e873112024-04-15 06:51:08 +0200481 <xsl:apply-templates/>
482 </xsl:template>
483
Marc Kupietz3989c742024-04-21 17:33:49 +0200484 <xsl:template match="xhtml:b|xhtml:span[@class='b']|xhtml:strong">
Marc Kupietz30cc0802024-04-10 16:37:04 +0200485 <hi rend="bold">
Marc Kupietz1a422662024-03-16 09:34:10 +0100486 <xsl:apply-templates/>
487 </hi>
488 </xsl:template>
489
Nicolas Arnoldc169e832024-06-07 08:44:11 +0200490 <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 +0000491 <hi rend="italic">
492 <xsl:apply-templates/>
493 </hi>
494 </xsl:template>
495
496
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100497 <xsl:template match="xhtml:sub|xhtml:span[@class='sub']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100498 <hi rend="sub">
499 <xsl:apply-templates/>
500 </hi>
501 </xsl:template>
502
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100503 <xsl:template match="xhtml:sup|xhtml:span[@class='sup']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100504 <hi rend="sup">
505 <xsl:apply-templates/>
506 </hi>
507 </xsl:template>
508
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000509 <xsl:template match="xhtml:div[not(normalize-space(replace(., '&#160;', ' ')))]" priority="1.0"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100510
Marc Kupietzbf47ae72024-04-14 14:21:43 +0200511 <xsl:template match="xhtml:body/xhtml:div[./xhtml:h1|./xhtml:h2|./xhtml:h3]" priority="1.0">
512 <xsl:apply-templates/>
513 </xsl:template>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000514 <xsl:template match="xhtml:div/xhtml:div">
Marc Kupietz1a422662024-03-16 09:34:10 +0100515 <p>
516 <xsl:apply-templates/>
517 </p>
518 </xsl:template>
519
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000520 <xsl:template match="xhtml:body/xhtml:div[(descendant::xhtml:p|descendant::xhtml:div)]">
521 <div type="section">
522 <xsl:apply-templates/>
523 </div>
524 </xsl:template>
525
526 <xsl:template match="xhtml:body/xhtml:div[not(descendant::xhtml:p|descendant::xhtml:div)]">
527 <div type="section">
528 <p>
529 <xsl:apply-templates/>
530 </p>
531 </div>
532 </xsl:template>
533
534 <xsl:template match="xhtml:p[not(descendant::xhtml:p|descendant::xhtml:div)]">
535 <xsl:if test="normalize-space(.)">
536 <p>
537 <xsl:apply-templates/>
538 </p>
539 </xsl:if>
540 </xsl:template>
541
542 <xsl:template match="xhtml:p[descendant::xhtml:p|descendant::xhtml:div]">
543 <xsl:if test="normalize-space(.)">
544 <div type="section">
545 <xsl:apply-templates/>
546 </div>
547 </xsl:if>
548 </xsl:template>
549
Marc Kupietz09745e12024-04-21 12:54:10 +0200550 <xsl:template match="xhtml:ul">
551 <list type="unordered">
552 <xsl:apply-templates/>
553 </list>
554 </xsl:template>
555 <xsl:template match="xhtml:ol">
556 <list type="ordered">
557 <xsl:apply-templates/>
558 </list>
559 </xsl:template>
560 <xsl:template match="xhtml:li">
561 <item>
562 <xsl:apply-templates/>
563 </item>
564 </xsl:template>
565 <xsl:template match="xhtml:nav">
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200566 <!-- <gap reason="toc"/> -->
567 </xsl:template>
568
Marc Kupietz1a422662024-03-16 09:34:10 +0100569 <xsl:template match="xhtml:img">
570 <!-- <gap reason="image"/> -->
571 </xsl:template>
572
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200573 <xsl:template match="xhtml:audio">
574 <!-- <gap reason="audio"/> -->
575 </xsl:template>
576
Marc Kupietz09745e12024-04-21 12:54:10 +0200577 <xsl:template match="xhtml:table">
578 <!-- <gap reason="table"/> -->
579 </xsl:template>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000580 <xsl:template match="xhtml:body/xhtml:a">
Marc Kupietz164a2832024-04-14 21:00:48 +0200581 <xsl:if test="normalize-space(.)">
582 <p>
583 <ref target="{@href}">
584 <xsl:apply-templates />
585 </ref>
586 </p>
587 </xsl:if>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000588 </xsl:template>
589
590 <xsl:template match="xhtml:body/xhtml:span">
Marc Kupietz7f3fe792024-07-26 15:28:26 +0200591 <xsl:if test="$debug">
592 <xsl:message>
593 <xsl:text>unhandled span element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
594 </xsl:message>
595 </xsl:if>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000596 <div type="section">
597 <p>
598 <xsl:value-of select="."/>
599 </p>
600 </div>
601 </xsl:template>
602 <xsl:template match="xhtml:span">
Marc Kupietz7f3fe792024-07-26 15:28:26 +0200603 <xsl:if test="$debug">
604 <xsl:message>
605 <xsl:text>unhandled span element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
606 </xsl:message>
607 </xsl:if>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000608 <xsl:value-of select="."/>
609 </xsl:template>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100610 <xsl:template match="xhtml:a">
Marc Kupietz164a2832024-04-14 21:00:48 +0200611 <xsl:if test="normalize-space(.)">
612 <ref target="{@href}">
613 <xsl:apply-templates />
614 </ref>
615 </xsl:if>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100616 </xsl:template>
617
Marc Kupietz54ec28b2024-04-27 10:07:06 +0200618 <xsl:template match="xhtml:br">
619 <lb/><xsl:text>&#10;</xsl:text>
620 </xsl:template>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100621
Marc Kupietz1a422662024-03-16 09:34:10 +0100622 <xsl:template match="xhtml:*">
Marc Kupietz7f3fe792024-07-26 15:28:26 +0200623 <xsl:if test="$debug">
624 <xsl:message>
625 <xsl:text>unhandled element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
626 </xsl:message>
627 </xsl:if>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000628 <xsl:choose>
629 <xsl:when test="descendant::xhtml:div|descendant::xhtml:p|parent::xhtml:body">
630 <div type="section">
631 <xsl:apply-templates/>
632 </div>
633 </xsl:when>
634 <xsl:otherwise>
635 <xsl:apply-templates select="./*|node()"/>
636 </xsl:otherwise>
637 </xsl:choose>
Marc Kupietz1a422662024-03-16 09:34:10 +0100638 <xsl:apply-templates/>
639 </xsl:template>
640
641 <xsl:function name="ids:reversedAuthors">
642 <xsl:param name="s" />
643 <xsl:value-of
644 select="
645 if (matches($s, ';')) then
646 concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; ')))
647 else
648 replace($s, '(.+) (.+)', '$2, $1')"
649 />
650 </xsl:function>
651
652 <xsl:function name="hlu:reversedAuthors">
653 <xsl:param name="s"/>
654 <xsl:value-of
655 select="if (matches($s, ';')) then concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; '))) else replace($s, '(.+),(.+)', '$2, $1')"
656 />
657 </xsl:function>
658
Marc Kupietz10903f32024-04-14 14:21:18 +0200659 <xsl:variable name="city-country-map" as="map(xs:string, xs:string)">
660 <xsl:map>
661 <xsl:map-entry key="'Axams'" select="'AT'"/>
662 <xsl:map-entry key="'Vienna'" select="'AT'"/>
663 <xsl:map-entry key="'Klagenfurt'" select="'AT'"/>
664 <xsl:map-entry key="'Graz'" select="'AT'"/>
665 <xsl:map-entry key="'Innsbruck'" select="'AT'"/>
666 <xsl:map-entry key="'Salzburg'" select="'AT'"/>
667 <xsl:map-entry key="'Bern'" select="'CH'"/>
668 <xsl:map-entry key="'Biel/Bienne'" select="'CH'"/>
669 <xsl:map-entry key="'Zurich'" select="'CH'"/>
670 <xsl:map-entry key="'Basel'" select="'CH'"/>
671 <xsl:map-entry key="'Geneva'" select="'CH'"/>
672 <xsl:map-entry key="'Lucerne'" select="'CH'"/>
673 <xsl:map-entry key="'Lausanne'" select="'CH'"/>
674 <xsl:map-entry key="'Winterthur'" select="'CH'"/>
675 <xsl:map-entry key="'St. Gallen'" select="'CH'"/>
676 <xsl:map-entry key="'Interlaken'" select="'CH'"/>
677 <xsl:map-entry key="'Brussels'" select="'BE'"/>
678 <xsl:map-entry key="'Antwerp'" select="'BE'"/>
679 <xsl:map-entry key="'Ghent'" select="'BE'"/>
680 <xsl:map-entry key="'Bruges'" select="'BE'"/>
681 <xsl:map-entry key="'Leuven'" select="'BE'"/>
682 <xsl:map-entry key="'Liege'" select="'BE'"/>
683 <xsl:map-entry key="'Charleroi'" select="'BE'"/>
684 <xsl:map-entry key="'Namur'" select="'BE'"/>
685 <xsl:map-entry key="'Mons'" select="'BE'"/>
686 <xsl:map-entry key="'Bangkok'" select="'TH'"/>
687 <xsl:map-entry key="'Copenhagen'" select="'DK'"/>
688 <xsl:map-entry key="'colatina'" select="'BR'"/>
689 <xsl:map-entry key="'Oakland Park'" select="'US'"/>
690 <xsl:map-entry key="'Istanbul'" select="'TR'"/>
691 <xsl:map-entry key="'Luxemburg'" select="'LU'"/>
692 <xsl:map-entry key="'Palma de Mallorca'" select="'ES'"/>
693 <xsl:map-entry key="'Swakopmund'" select="'NA'"/>
694 <xsl:map-entry key="'Victoria'" select="'CA'"/>
695 <xsl:map-entry key="'Wien'" select="'AT'"/>
696 <xsl:map-entry key="'Windhoek'" select="'NA'"/>
697 <xsl:map-entry key="'Zuerich'" select="'CH'"/>
698 <xsl:map-entry key="'Zürich'" select="'CH'"/>
699 <xsl:map-entry key="'Zug'" select="'CH'"/>
700 <xsl:map-entry key="'ZÜRICH'" select="'CH'"/>
701 </xsl:map>
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200702
Marc Kupietz10903f32024-04-14 14:21:18 +0200703 </xsl:variable>
704
705 <!-- Define the function -->
706 <xsl:function name="ids:country-city" as="xs:string">
707 <xsl:param name="city" as="xs:string"/>
708 <xsl:sequence select="if (map:contains($city-country-map, $city)) then map:get($city-country-map, $city) else 'DE'"/>
709 </xsl:function>
Marc Kupietz1a422662024-03-16 09:34:10 +0100710</xsl:stylesheet>