blob: 4659dc4ec3f1ff9300fdf707f853de2415e420ea [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>
405 <!-- Call the template for each link in the TOC
406 <xsl:apply-templates select="//xhtml:ol[@class='toc']/xhtml:li/xhtml:a" mode="collect"/> -->
Nicolas Arnoldc1c30832024-06-19 12:22:39 +0200407 <xsl:apply-templates select="//opf:package/opf:manifest/opf:item[matches(@href, '\.x?html?$') and not(matches(@href, '(cover|toc|copyright|feedback|inhalt|nav|titlepage).*'))]" mode="collect"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100408 </body>
409 </text>
410 </idsText>
411 </idsDoc>
412 </xsl:template>
413
414 <xsl:template match="opf:item" mode="collect">
415 <xsl:variable name="href" select="@href"/>
Marc Kupietz20ee0e52024-07-27 12:28:58 +0200416 <xsl:if test="$debug">
417 <xsl:message>
418 <xsl:text>converting: </xsl:text><xsl:value-of select="$href"/><xsl:text> </xsl:text><xsl:value-of select="$idno"/>
419 </xsl:message>
420 </xsl:if>
Marc Kupietz1a422662024-03-16 09:34:10 +0100421 <xsl:apply-templates select="doc(resolve-uri($href, base-uri()))/xhtml:html/xhtml:body"/>
422 </xsl:template>
423
424 <xsl:template match="xhtml:body">
425 <div type="chapter">
426 <xsl:apply-templates/>
427 </div>
428 </xsl:template>
429
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000430 <xsl:template match="xhtml:body/text()">
431 <p>
432 <xsl:value-of select="."/>
433 </p>
434 </xsl:template>
435
Marc Kupietz1a422662024-03-16 09:34:10 +0100436 <xsl:template match="xhtml:title">
437 <head>
438 <xsl:apply-templates/>
439 </head>
440 </xsl:template>
441
442 <xsl:template match="xhtml:h1">
443 <head>
444 <xsl:apply-templates/>
445 </head>
446 </xsl:template>
447
Marc Kupietz3989c742024-04-21 17:33:49 +0200448 <xsl:template match="xhtml:h2|xhtml:h3|xhtml:h4|xhtml:h5|xhtml:h6">
Marc Kupietz1a422662024-03-16 09:34:10 +0100449 <head type="sub">
450 <xsl:apply-templates/>
451 </head>
452 </xsl:template>
453
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100454 <xsl:template match="xhtml:em">
455 <emph>
456 <xsl:apply-templates/>
457 </emph>
458 </xsl:template>
Marc Kupietz1a422662024-03-16 09:34:10 +0100459
Marc Kupietz30cc0802024-04-10 16:37:04 +0200460 <xsl:template match="xhtml:span[matches(@class, '(bold|italic|big|kursiv| )+')]">
461 <xsl:variable name="class" select="replace(@class, 'kursiv', 'italic')"/>
462 <hi rend="{$class}">
463 <xsl:apply-templates/>
464 </hi>
465 </xsl:template>
466
Marc Kupietzad4d4462024-04-26 17:43:08 +0200467 <xsl:template match="xhtml:span[matches(@class, '(regular|norm)')]">
Marc Kupietz5e873112024-04-15 06:51:08 +0200468 <xsl:apply-templates/>
469 </xsl:template>
470
Marc Kupietz3989c742024-04-21 17:33:49 +0200471 <xsl:template match="xhtml:b|xhtml:span[@class='b']|xhtml:strong">
Marc Kupietz30cc0802024-04-10 16:37:04 +0200472 <hi rend="bold">
Marc Kupietz1a422662024-03-16 09:34:10 +0100473 <xsl:apply-templates/>
474 </hi>
475 </xsl:template>
476
Nicolas Arnoldc169e832024-06-07 08:44:11 +0200477 <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 +0000478 <hi rend="italic">
479 <xsl:apply-templates/>
480 </hi>
481 </xsl:template>
482
483
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100484 <xsl:template match="xhtml:sub|xhtml:span[@class='sub']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100485 <hi rend="sub">
486 <xsl:apply-templates/>
487 </hi>
488 </xsl:template>
489
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100490 <xsl:template match="xhtml:sup|xhtml:span[@class='sup']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100491 <hi rend="sup">
492 <xsl:apply-templates/>
493 </hi>
494 </xsl:template>
495
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000496 <xsl:template match="xhtml:div[not(normalize-space(replace(., '&#160;', ' ')))]" priority="1.0"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100497
Marc Kupietzbf47ae72024-04-14 14:21:43 +0200498 <xsl:template match="xhtml:body/xhtml:div[./xhtml:h1|./xhtml:h2|./xhtml:h3]" priority="1.0">
499 <xsl:apply-templates/>
500 </xsl:template>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000501 <xsl:template match="xhtml:div/xhtml:div">
Marc Kupietz1a422662024-03-16 09:34:10 +0100502 <p>
503 <xsl:apply-templates/>
504 </p>
505 </xsl:template>
506
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000507 <xsl:template match="xhtml:body/xhtml:div[(descendant::xhtml:p|descendant::xhtml:div)]">
508 <div type="section">
509 <xsl:apply-templates/>
510 </div>
511 </xsl:template>
512
513 <xsl:template match="xhtml:body/xhtml:div[not(descendant::xhtml:p|descendant::xhtml:div)]">
514 <div type="section">
515 <p>
516 <xsl:apply-templates/>
517 </p>
518 </div>
519 </xsl:template>
520
521 <xsl:template match="xhtml:p[not(descendant::xhtml:p|descendant::xhtml:div)]">
522 <xsl:if test="normalize-space(.)">
523 <p>
524 <xsl:apply-templates/>
525 </p>
526 </xsl:if>
527 </xsl:template>
528
529 <xsl:template match="xhtml:p[descendant::xhtml:p|descendant::xhtml:div]">
530 <xsl:if test="normalize-space(.)">
531 <div type="section">
532 <xsl:apply-templates/>
533 </div>
534 </xsl:if>
535 </xsl:template>
536
Marc Kupietz09745e12024-04-21 12:54:10 +0200537 <xsl:template match="xhtml:ul">
538 <list type="unordered">
539 <xsl:apply-templates/>
540 </list>
541 </xsl:template>
542 <xsl:template match="xhtml:ol">
543 <list type="ordered">
544 <xsl:apply-templates/>
545 </list>
546 </xsl:template>
547 <xsl:template match="xhtml:li">
548 <item>
549 <xsl:apply-templates/>
550 </item>
551 </xsl:template>
552 <xsl:template match="xhtml:nav">
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200553 <!-- <gap reason="toc"/> -->
554 </xsl:template>
555
Marc Kupietz1a422662024-03-16 09:34:10 +0100556 <xsl:template match="xhtml:img">
557 <!-- <gap reason="image"/> -->
558 </xsl:template>
559
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200560 <xsl:template match="xhtml:audio">
561 <!-- <gap reason="audio"/> -->
562 </xsl:template>
563
Marc Kupietz09745e12024-04-21 12:54:10 +0200564 <xsl:template match="xhtml:table">
565 <!-- <gap reason="table"/> -->
566 </xsl:template>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000567 <xsl:template match="xhtml:body/xhtml:a">
Marc Kupietz164a2832024-04-14 21:00:48 +0200568 <xsl:if test="normalize-space(.)">
569 <p>
570 <ref target="{@href}">
571 <xsl:apply-templates />
572 </ref>
573 </p>
574 </xsl:if>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000575 </xsl:template>
576
577 <xsl:template match="xhtml:body/xhtml:span">
Marc Kupietz7f3fe792024-07-26 15:28:26 +0200578 <xsl:if test="$debug">
579 <xsl:message>
580 <xsl:text>unhandled span element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
581 </xsl:message>
582 </xsl:if>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000583 <div type="section">
584 <p>
585 <xsl:value-of select="."/>
586 </p>
587 </div>
588 </xsl:template>
589 <xsl:template match="xhtml:span">
Marc Kupietz7f3fe792024-07-26 15:28:26 +0200590 <xsl:if test="$debug">
591 <xsl:message>
592 <xsl:text>unhandled span element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
593 </xsl:message>
594 </xsl:if>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000595 <xsl:value-of select="."/>
596 </xsl:template>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100597 <xsl:template match="xhtml:a">
Marc Kupietz164a2832024-04-14 21:00:48 +0200598 <xsl:if test="normalize-space(.)">
599 <ref target="{@href}">
600 <xsl:apply-templates />
601 </ref>
602 </xsl:if>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100603 </xsl:template>
604
Marc Kupietz54ec28b2024-04-27 10:07:06 +0200605 <xsl:template match="xhtml:br">
606 <lb/><xsl:text>&#10;</xsl:text>
607 </xsl:template>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100608
Marc Kupietz1a422662024-03-16 09:34:10 +0100609 <xsl:template match="xhtml:*">
Marc Kupietz7f3fe792024-07-26 15:28:26 +0200610 <xsl:if test="$debug">
611 <xsl:message>
612 <xsl:text>unhandled element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
613 </xsl:message>
614 </xsl:if>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000615 <xsl:choose>
616 <xsl:when test="descendant::xhtml:div|descendant::xhtml:p|parent::xhtml:body">
617 <div type="section">
618 <xsl:apply-templates/>
619 </div>
620 </xsl:when>
621 <xsl:otherwise>
622 <xsl:apply-templates select="./*|node()"/>
623 </xsl:otherwise>
624 </xsl:choose>
Marc Kupietz1a422662024-03-16 09:34:10 +0100625 <xsl:apply-templates/>
626 </xsl:template>
627
628 <xsl:function name="ids:reversedAuthors">
629 <xsl:param name="s" />
630 <xsl:value-of
631 select="
632 if (matches($s, ';')) then
633 concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; ')))
634 else
635 replace($s, '(.+) (.+)', '$2, $1')"
636 />
637 </xsl:function>
638
639 <xsl:function name="hlu:reversedAuthors">
640 <xsl:param name="s"/>
641 <xsl:value-of
642 select="if (matches($s, ';')) then concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; '))) else replace($s, '(.+),(.+)', '$2, $1')"
643 />
644 </xsl:function>
645
Marc Kupietz10903f32024-04-14 14:21:18 +0200646 <xsl:variable name="city-country-map" as="map(xs:string, xs:string)">
647 <xsl:map>
648 <xsl:map-entry key="'Axams'" select="'AT'"/>
649 <xsl:map-entry key="'Vienna'" select="'AT'"/>
650 <xsl:map-entry key="'Klagenfurt'" select="'AT'"/>
651 <xsl:map-entry key="'Graz'" select="'AT'"/>
652 <xsl:map-entry key="'Innsbruck'" select="'AT'"/>
653 <xsl:map-entry key="'Salzburg'" select="'AT'"/>
654 <xsl:map-entry key="'Bern'" select="'CH'"/>
655 <xsl:map-entry key="'Biel/Bienne'" select="'CH'"/>
656 <xsl:map-entry key="'Zurich'" select="'CH'"/>
657 <xsl:map-entry key="'Basel'" select="'CH'"/>
658 <xsl:map-entry key="'Geneva'" select="'CH'"/>
659 <xsl:map-entry key="'Lucerne'" select="'CH'"/>
660 <xsl:map-entry key="'Lausanne'" select="'CH'"/>
661 <xsl:map-entry key="'Winterthur'" select="'CH'"/>
662 <xsl:map-entry key="'St. Gallen'" select="'CH'"/>
663 <xsl:map-entry key="'Interlaken'" select="'CH'"/>
664 <xsl:map-entry key="'Brussels'" select="'BE'"/>
665 <xsl:map-entry key="'Antwerp'" select="'BE'"/>
666 <xsl:map-entry key="'Ghent'" select="'BE'"/>
667 <xsl:map-entry key="'Bruges'" select="'BE'"/>
668 <xsl:map-entry key="'Leuven'" select="'BE'"/>
669 <xsl:map-entry key="'Liege'" select="'BE'"/>
670 <xsl:map-entry key="'Charleroi'" select="'BE'"/>
671 <xsl:map-entry key="'Namur'" select="'BE'"/>
672 <xsl:map-entry key="'Mons'" select="'BE'"/>
673 <xsl:map-entry key="'Bangkok'" select="'TH'"/>
674 <xsl:map-entry key="'Copenhagen'" select="'DK'"/>
675 <xsl:map-entry key="'colatina'" select="'BR'"/>
676 <xsl:map-entry key="'Oakland Park'" select="'US'"/>
677 <xsl:map-entry key="'Istanbul'" select="'TR'"/>
678 <xsl:map-entry key="'Luxemburg'" select="'LU'"/>
679 <xsl:map-entry key="'Palma de Mallorca'" select="'ES'"/>
680 <xsl:map-entry key="'Swakopmund'" select="'NA'"/>
681 <xsl:map-entry key="'Victoria'" select="'CA'"/>
682 <xsl:map-entry key="'Wien'" select="'AT'"/>
683 <xsl:map-entry key="'Windhoek'" select="'NA'"/>
684 <xsl:map-entry key="'Zuerich'" select="'CH'"/>
685 <xsl:map-entry key="'Zürich'" select="'CH'"/>
686 <xsl:map-entry key="'Zug'" select="'CH'"/>
687 <xsl:map-entry key="'ZÜRICH'" select="'CH'"/>
688 </xsl:map>
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200689
Marc Kupietz10903f32024-04-14 14:21:18 +0200690 </xsl:variable>
691
692 <!-- Define the function -->
693 <xsl:function name="ids:country-city" as="xs:string">
694 <xsl:param name="city" as="xs:string"/>
695 <xsl:sequence select="if (map:contains($city-country-map, $city)) then map:get($city-country-map, $city) else 'DE'"/>
696 </xsl:function>
Marc Kupietz1a422662024-03-16 09:34:10 +0100697</xsl:stylesheet>