blob: 80c6a356fc9170f3eed2bbc6088d31593fe3a97e [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
19 <xsl:variable name="ev"/>
20 <xsl:variable name="x"/>
21
Marc Kupietz0c246632024-04-29 07:08:23 +020022 <xsl:variable name="idno" as="xs:string" select="replace(document-uri(), '.*/([0-9]{9,13}X?).*' , '$1')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010023
Rebecca Wilmf614a4b2024-05-07 10:19:43 +020024 <xsl:variable name="idno_type">
Rebecca Wilme5f055a2024-05-10 15:07:50 +020025 <xsl:choose>
26 <xsl:when test="starts-with($idno,'1')">
27 <xsl:value-of select="'IDN'"/>
28 </xsl:when>
29 <xsl:otherwise>
30 <xsl:value-of select="'ISBN'"/>
31 </xsl:otherwise>
32 </xsl:choose>
Rebecca Wilmf614a4b2024-05-07 10:19:43 +020033 </xsl:variable>
34
Marc Kupietz1a422662024-03-16 09:34:10 +010035 <xsl:variable name="dnbBookdata">
Rebecca Wilmf614a4b2024-05-07 10:19:43 +020036 <xsl:copy-of select="doc(concat('https://services.dnb.de/sru/dnb?version=1.1&amp;operation=searchRetrieve&amp;query=', $idno_type, '%3D', $idno, '&amp;recordSchema=oai_dc'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010037 </xsl:variable>
38
39 <xsl:variable name="autor"
Marc Kupietzde2ca532024-04-26 16:50:53 +020040 select="replace(string-join($dnbBookdata//dc:creator[not(contains(., '[')) or matches(., '\[Verfasser\]')], ' ; '), ' *\[[^\]]*\]', '')"/>
Marc Kupietzeaa90132024-04-26 18:14:40 +020041 <xsl:variable name="straight_autor" select="normalize-space(replace(hlu:reversedAuthors($autor), ',', ''))"/>
42 <xsl:variable name="translator"
43 select="replace(string-join($dnbBookdata//dc:creator[matches(., '\[Übersetzer\]')], ' ; '), ' *\[[^\]]*\]', '')"/>
44 <xsl:variable name="straight_translator" select="normalize-space(replace(hlu:reversedAuthors($translator), ',', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010045
Marc Kupietz15e7d612024-04-26 18:16:39 +020046 <xsl:variable name="herausgeber"
47 select="replace(string-join($dnbBookdata//dc:creator[matches(., '\[(Herausgeber|Hrsg.)\]')], ' ; '), ' *\[[^\]]*\]', '')"/>
48 <xsl:variable name="straight_herausgeber" select="normalize-space(replace(hlu:reversedAuthors($herausgeber), ',', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010049
50 <xsl:variable name="ina"/>
51 <xsl:variable name="_corpus"/>
52 <xsl:variable name="ent_known"/>
53
54
55 <!-- added HLU 2012-02-09: -->
56 <xsl:variable name="ent">
57 <xsl:choose>
58 <xsl:when test="$ent_known">
59 <xsl:value-of select="$ent_known"/>
60 </xsl:when>
61 <xsl:when test="$ev">
62 <xsl:value-of select="$ev"/>
63 </xsl:when>
64 <xsl:otherwise>
65 <xsl:value-of select="$j"/>
66 </xsl:otherwise>
67 </xsl:choose>
68 </xsl:variable>
69
70 <xsl:variable name="titel">
Marc Kupietz49124fa2024-04-10 16:50:01 +020071 <xsl:variable name="title-with-subtitles">
72 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +020073 <xsl:when test="contains(($dnbBookdata//dc:title)[1],':')">
Rebecca Wilme5f055a2024-05-10 15:07:50 +020074 <xsl:value-of select="normalize-space(substring-before(substring-before(($dnbBookdata//dc:title)[1], '/'), ':'))"/>
Marc Kupietz49124fa2024-04-10 16:50:01 +020075 </xsl:when>
76 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +020077 <xsl:value-of select="normalize-space(substring-before(($dnbBookdata//dc:title)[1], '/'))"/>
Marc Kupietz49124fa2024-04-10 16:50:01 +020078 </xsl:otherwise>
79 </xsl:choose>
80 </xsl:variable>
81 <xsl:value-of select="normalize-space(replace($title-with-subtitles, '\|.*', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010082 </xsl:variable>
83
84 <xsl:variable name="erscheinungsort">
85 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +020086 <xsl:when test="contains(($dnbBookdata//dc:publisher)[1], ':')">
87 <xsl:value-of select="normalize-space(substring-before(($dnbBookdata//dc:publisher)[1], ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010088 </xsl:when>
89 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +020090 <xsl:value-of select="normalize-space(($dnbBookdata//dc:publisher)[1])"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010091 </xsl:otherwise>
92 </xsl:choose>
93 </xsl:variable>
94
Marc Kupietzd8599fc2024-04-14 13:16:56 +020095 <xsl:variable name="erscheinungsland" select="ids:country-city($erscheinungsort)"/>
96
Marc Kupietz6cb52232024-04-13 12:28:44 +020097 <xsl:variable name="texttype" select="replace(($dnbBookdata//dc:subject[matches(., '^[A-Z] ')])[1], '^[A-Z] (.*)', '$1')"/>
Marc Kupietz7df4ccc2024-03-16 15:27:45 +010098
Marc Kupietz9d87e9d2024-05-05 15:56:50 +020099 <xsl:variable name="genretable">
100 <genres>
101 <genre keyRegex="krimi" genre="Roman: Kriminalroman"/>
102 <genre keyRegex="arztroman" genre="Roman: Arztroman"/>
103 <genre keyRegex="liebesroman" genre="Roman: Liebesroman"/>
104 <genre keyRegex="science.?fiction" genre="Roman: Science-Fiction-Roman"/>
105 <genre keyRegex="horror" genre="Roman: Horrorroman"/>
106 <genre keyRegex="western" genre="Roman: Westernroman"/>
107 <genre keyRegex="fantasy" genre="Roman: Fantasyroman"/>
108 <genre keyRegex="historischer roman" genre="Roman: Historischer Roman"/>
109 <genre keyRegex="erzählung" genre="Erzählung"/>
110 <genre keyRegex="novelle" genre="Novelle"/>
111 <genre keyRegex="anthologie" genre="Anthologie"/>
112 <genre keyRegex="kurzgeschichte" genre="Kurzgeschichte"/>
113 <genre keyRegex="roman" genre="Roman"/>
114 <genre keyRegex="." genre="Roman"/>
115 </genres>
116 </xsl:variable>
117
118 <xsl:variable name="textFullGenre" select="$genretable/genres/genre[matches($dnbBookdata, ./@keyRegex, 'i')][1]/@genre"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100119 <xsl:variable name="verlag">
120 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +0200121 <xsl:when test="contains(($dnbBookdata//dc:publisher)[1], ':')">
122 <xsl:value-of select="normalize-space(substring-after(($dnbBookdata//dc:publisher)[1], ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100123 </xsl:when>
124 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +0200125 <xsl:value-of select="normalize-space(($dnbBookdata//dc:publisher)[1])"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100126 </xsl:otherwise>
127 </xsl:choose>
128 </xsl:variable>
129
130 <xsl:variable name="erscheinungsjahr">
Marc Kupietza5d01182024-04-14 12:24:02 +0200131 <xsl:value-of select="replace(($dnbBookdata//dc:date)[1], '.*?((19|20)[0-9][0-9]).*', '$1')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100132 </xsl:variable>
133
134 <xsl:variable name="untertitel"
Marc Kupietz6cb52232024-04-13 12:28:44 +0200135 select="normalize-space(substring-after(substring-before(($dnbBookdata//dc:title)[1], '/'), ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100136
Marc Kupietza5d01182024-04-14 12:24:02 +0200137 <xsl:variable name="j" select="$erscheinungsjahr"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100138
139 <!-- for BOT+s: -->
140 <xsl:variable name="seiten" select="replace($dnbBookdata//dc:format,'S\.','')"/>
141
142 <!-- fuer BOT+b: -->
143 <xsl:variable name="_b">
144 <xsl:variable name="regexp1" select="'(Band|Bd\.)\s*([0-9]?[0-9]?[0-9])'"/>
145 <xsl:choose>
146 <xsl:when test="matches($dnbBookdata, $regexp1)">
147 <xsl:analyze-string select="$dnbBookdata//dc:title" regex="{$regexp1}">
148 <xsl:matching-substring>
149 <xsl:value-of select="."/>
150 </xsl:matching-substring>
151 </xsl:analyze-string>
152 </xsl:when>
153 <xsl:otherwise>
154 <xsl:value-of select="'.'"/>
155 </xsl:otherwise>
156 </xsl:choose>
157 </xsl:variable>
158
159 <!-- for BOT+x: -->
160 <xsl:variable name="txtart">
161 <xsl:choose>
162 <xsl:when test="$x">
163 <xsl:value-of select="concat('[', $x, ']')"/>
164 </xsl:when>
165 <xsl:when
Nicolas Arnold26355632024-05-10 15:25:41 +0200166 test="matches($untertitel, '([Rr]oman|[Ee]rzählung(en)?|[Aa]nthologie|[Gg]eschichte(n)?|[Nn]ovelle)')">
Marc Kupietz1a422662024-03-16 09:34:10 +0100167 <xsl:value-of
Nicolas Arnold26355632024-05-10 15:25:41 +0200168 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 +0100169 />
170 </xsl:when>
171 <xsl:otherwise>
172 <xsl:value-of>Roman</xsl:value-of>
173 </xsl:otherwise>
174 </xsl:choose>
175 </xsl:variable>
176
177
178
179 <!-- fuer BOTd: -->
180 <xsl:variable name="dok"
181 select="concat((if(string-length($autor) &gt; 0) then concat($straight_autor, ': ') else ''), $titel, ', ', $txtart, ', (', $j, ')')"/>
182
183 <!-- END variables derived from sru request to dnb archive -->
184
185
Marc Kupietz94bbe6b2024-04-10 20:35:48 +0200186 <xsl:variable name="corpus_sigle" select="concat('DNB', substring($erscheinungsjahr, 3, 2))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100187
188 <!-- for BOTD: -->
189 <!-- Dokumentsigle muss zusammen mit Korpussigle (z.B DIV fuer loz-div und loz-div-pub) eindeutig sein -->
190 <xsl:variable name="doc_sigle">
191 <xsl:variable name="firstContentWordTitleInitial">
192 <xsl:variable name="helper">
193 <xsl:analyze-string select="$titel" regex="\w+">
194 <xsl:matching-substring>
195 <xsl:choose>
196 <xsl:when
Marc Kupietzad1f3b82024-04-19 19:21:49 +0200197 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 +0100198 <!-- TODO: Fktnswoerter nachtragen -->
199 <xsl:sequence select="."/>
200 </xsl:when>
201 <xsl:otherwise/>
202 </xsl:choose>
203 </xsl:matching-substring>
204 </xsl:analyze-string>
205 </xsl:variable>
206 <xsl:value-of
Marc Kupietz77b6aa92024-04-21 17:31:43 +0200207 select="upper-case(substring(normalize-space(replace($helper,'\s+.+$','')),1,3))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100208 <!-- longest match of .+ -->
209 </xsl:variable>
Marc Kupietz77b6aa92024-04-21 17:31:43 +0200210 <xsl:variable name="authorInitials">
211 <xsl:choose>
212 <xsl:when test="contains($autor,';')">
213 <xsl:variable name="lastname_aut1"
214 select="upper-case(substring(normalize-space($autor),1,1))"/>
215 <xsl:variable name="lastname_aut2"
216 select="replace($autor, '.*?;.*?([A-Z]).*', '$1')"/>
217 <xsl:value-of select="concat($lastname_aut1, $lastname_aut2)"/>
218 </xsl:when>
219 <xsl:otherwise>
220 <xsl:variable name="lastname_aut1"
221 select="upper-case(substring(normalize-space(substring-before($autor,',')),1,1))"/>
222 <xsl:variable name="firstname_aut1"
223 select="upper-case(substring(normalize-space(substring-after($autor,',')),1,1))"/>
224 <xsl:value-of select="concat($lastname_aut1, $firstname_aut1)"/>
225 </xsl:otherwise>
226 </xsl:choose>
227 </xsl:variable>
Marc Kupietz398b5962024-04-21 17:51:34 +0200228 <xsl:value-of select="substring(replace(normalize-unicode(concat($authorInitials,$firstContentWordTitleInitial), 'NFKD'),'[^A-Z]',''),1,3)"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100229 </xsl:variable>
230
231
Marc Kupietz0c246632024-04-29 07:08:23 +0200232 <xsl:variable name="text_sigle" select="replace($idno, '.*([0-9]{5})[0-9X]$', '$1')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100233 <xsl:variable name="sigle" select="concat($corpus_sigle, '/', $doc_sigle, '.', $text_sigle)"/>
234
235 <!-- fuer BOT+xy: (?) -->
236 <xsl:variable name="xyref">
237 <xsl:value-of select="document-uri(.)"/>
238 <xsl:text>; </xsl:text>
Marc Kupietz0c246632024-04-29 07:08:23 +0200239 <xsl:text>IDNO:</xsl:text>
240 <xsl:value-of select="$idno"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100241 <xsl:text>; </xsl:text>
242 <xsl:value-of select="string-join($dnbBookdata//dc:identifier)"/>
243 </xsl:variable>
244
Marc Kupietzb660ed62024-03-16 11:45:53 +0100245 <xsl:variable name="long-reference"
246 select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/>
247
248 <xsl:variable name="short-reference"
249 select="concat($straight_autor, ': ', $titel, ' (', $erscheinungsjahr, ')')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100250
251 <xsl:template match="/">
Marc Kupietz98645242024-05-26 16:52:47 +0200252 <!-- for debugging purposes
253 <xsl:message select="concat('uri: ', base-uri())"/>
254 <xsl:message select="concat('idno: ', $idno)"/>
255
256 <xsl:message>
257 dnbBookdataQuery: <xsl:value-of select="$dnbBookdataQuery"/>
258 </xsl:message>
259
260 <xsl:message>
261 <xsl:copy-of select="$dnbBookdata"/>
262 </xsl:message>
263 -->
Marc Kupietzb7a4f6c2024-04-19 11:35:25 +0200264 <xsl:if test="not($j)">
Marc Kupietz0c246632024-04-29 07:08:23 +0200265 <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 +0200266 </xsl:if>
267
Marc Kupietz815cc6c2024-04-19 12:44:44 +0200268 <xsl:if test="not(normalize-space($titel))">
Marc Kupietz0c246632024-04-29 07:08:23 +0200269 <xsl:message terminate="yes">ERROR: No title found for IDNO: <xsl:value-of select="$idno"/></xsl:message>
Marc Kupietz815cc6c2024-04-19 12:44:44 +0200270 </xsl:if>
271
Marc Kupietz2badfb12024-04-19 12:59:40 +0200272 <xsl:if test="not(normalize-space($autor))">
Marc Kupietz0c246632024-04-29 07:08:23 +0200273 <xsl:message terminate="yes">ERROR: No author found for IDNO: <xsl:value-of select="$idno"/></xsl:message>
Marc Kupietz2badfb12024-04-19 12:59:40 +0200274 </xsl:if>
275
Marc Kupietz52aa5052024-04-21 18:16:06 +0200276 <xsl:if test="not(matches($sigle, '^[A-Z]{3}[0-9]{2}/[A-Z]{2,3}\.[0-9]{5}$'))">
Marc Kupietz0c246632024-04-29 07:08:23 +0200277 <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 +0200278 </xsl:if>
279
Marc Kupietz1a422662024-03-16 09:34:10 +0100280 <idsDoc TEIform="TEI.2" type="text" version="1.0">
281 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="document" version="1.1">
282 <fileDesc>
283 <titleStmt>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100284 <dokumentSigle><xsl:value-of select="string-join(($corpus_sigle, $doc_sigle), '/')"/></dokumentSigle>
285 <d.title><xsl:value-of select="$short-reference"/></d.title>
Marc Kupietz1a422662024-03-16 09:34:10 +0100286 </titleStmt>
287 <publicationStmt>
288 <distributor/>
289 <pubAddress/>
Rebecca Wilme5f055a2024-05-10 15:07:50 +0200290 <xsl:for-each select="$dnbBookdata//dc:identifier">
291 <xsl:variable name="type" select="substring-after(@xsi:type, ':')"/>
292 <xsl:choose>
293 <xsl:when test="@xsi:type='tel:ISBN'">
294 <xsl:if test="matches(.,'(^([0-9]|-)+X?).*')">
295 <idno type="{$type}"><xsl:value-of select="replace(., '(([0-9]|-)+X?).*', '$1')"/></idno>
296 </xsl:if>
297 </xsl:when>
298 <xsl:otherwise><idno type="{$type}"><xsl:value-of select="."/></idno></xsl:otherwise>
299 </xsl:choose>
300 </xsl:for-each>
Marc Kupietz1a422662024-03-16 09:34:10 +0100301 <availability region="world" status="unknown">QAO-NC</availability>
302 <pubDate/>
303 </publicationStmt>
304 <sourceDesc>
305 <biblStruct>
306 <monogr>
307 <h.title type="main"/>
308 <imprint/>
309 </monogr>
310 </biblStruct>
311 </sourceDesc>
312 </fileDesc>
313 </idsHeader>
314 <idsText version="1.0">
315 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="text" version="1.1">
316 <fileDesc>
317 <titleStmt>
318 <textSigle><xsl:sequence select="$sigle"/></textSigle>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100319 <t.title assemblage="regular"><xsl:value-of select="$long-reference"/></t.title>
Marc Kupietz1a422662024-03-16 09:34:10 +0100320 </titleStmt>
321 <publicationStmt>
322 <distributor/>
323 <pubAddress/>
324 <availability region="world" status="unknown">QAO-NC</availability>
325 <pubDate/>
326 </publicationStmt>
327 <sourceDesc>
328 <biblStruct>
329 <monogr>
330 <h.title type="main"><xsl:value-of select="$titel"/></h.title>
331 <h.title type="sub"><xsl:value-of select="$untertitel"/></h.title>
332 <h.author><xsl:value-of select="$autor"/></h.author>
Marc Kupietzeaa90132024-04-26 18:14:40 +0200333 <xsl:if test="$translator">
334 <editor role="translator"><xsl:value-of select="$translator"/></editor>
335 </xsl:if>
Marc Kupietz15e7d612024-04-26 18:16:39 +0200336 <xsl:if test="$herausgeber">
337 <editor role="editor"><xsl:value-of select="$herausgeber"/></editor>
338 </xsl:if>
Marc Kupietz1a422662024-03-16 09:34:10 +0100339 <edition>
340 <further/>
341 <kind>E-Book-Ausgabe</kind>
342 <appearance>EPUB-Datei</appearance>
343 </edition>
344 <imprint>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100345 <publisher><xsl:value-of select="$verlag"/></publisher>
Marc Kupietz1a422662024-03-16 09:34:10 +0100346 <pubDate type="year"><xsl:value-of select="$j"/></pubDate>
347 <pubDate type="month"/>
348 <pubDate type="day"/>
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200349 <pubPlace key="{$erscheinungsland}"><xsl:value-of select="$erscheinungsort"/></pubPlace>
Marc Kupietz1a422662024-03-16 09:34:10 +0100350 </imprint>
351 <biblScope type="subsume"/>
352 <biblScope type="pp"/>
353 <biblScope type="vol"/>
354 <biblScope type="volume-title"/>
355 </monogr>
356 </biblStruct>
357 <reference assemblage="regular" type="complete"><xsl:value-of select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/></reference>
Marc Kupietz1a422662024-03-16 09:34:10 +0100358 </sourceDesc>
359 </fileDesc>
360 <profileDesc>
361 <creation>
362 <creatDate><xsl:value-of select="$j"/></creatDate>
363 </creation>
364 <textClass/>
365 <textDesc>
Marc Kupietz9d87e9d2024-05-05 15:56:50 +0200366 <textType><xsl:value-of select="$textFullGenre"/></textType>
367 <textTypeRef><xsl:value-of select="replace($textFullGenre, '.*: *', '')"/></textTypeRef>
Marc Kupietz1a422662024-03-16 09:34:10 +0100368 <textDomain/>
369 </textDesc>
370 </profileDesc>
371 </idsHeader>
372 <text>
373 <body>
374 <!-- Call the template for each link in the TOC
375 <xsl:apply-templates select="//xhtml:ol[@class='toc']/xhtml:li/xhtml:a" mode="collect"/> -->
Marc Kupietz8f727302024-04-10 16:31:19 +0200376 <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 +0100377 </body>
378 </text>
379 </idsText>
380 </idsDoc>
381 </xsl:template>
382
383 <xsl:template match="opf:item" mode="collect">
384 <xsl:variable name="href" select="@href"/>
385 <xsl:message>
Marc Kupietz0c246632024-04-29 07:08:23 +0200386 <xsl:text>converting: </xsl:text><xsl:value-of select="$href"/><xsl:text> </xsl:text><xsl:value-of select="$idno"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100387 </xsl:message>
388 <xsl:apply-templates select="doc(resolve-uri($href, base-uri()))/xhtml:html/xhtml:body"/>
389 </xsl:template>
390
391 <xsl:template match="xhtml:body">
392 <div type="chapter">
393 <xsl:apply-templates/>
394 </div>
395 </xsl:template>
396
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000397 <xsl:template match="xhtml:body/text()">
398 <p>
399 <xsl:value-of select="."/>
400 </p>
401 </xsl:template>
402
Marc Kupietz1a422662024-03-16 09:34:10 +0100403 <xsl:template match="xhtml:title">
404 <head>
405 <xsl:apply-templates/>
406 </head>
407 </xsl:template>
408
409 <xsl:template match="xhtml:h1">
410 <head>
411 <xsl:apply-templates/>
412 </head>
413 </xsl:template>
414
Marc Kupietz3989c742024-04-21 17:33:49 +0200415 <xsl:template match="xhtml:h2|xhtml:h3|xhtml:h4|xhtml:h5|xhtml:h6">
Marc Kupietz1a422662024-03-16 09:34:10 +0100416 <head type="sub">
417 <xsl:apply-templates/>
418 </head>
419 </xsl:template>
420
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100421 <xsl:template match="xhtml:em">
422 <emph>
423 <xsl:apply-templates/>
424 </emph>
425 </xsl:template>
Marc Kupietz1a422662024-03-16 09:34:10 +0100426
Marc Kupietz30cc0802024-04-10 16:37:04 +0200427 <xsl:template match="xhtml:span[matches(@class, '(bold|italic|big|kursiv| )+')]">
428 <xsl:variable name="class" select="replace(@class, 'kursiv', 'italic')"/>
429 <hi rend="{$class}">
430 <xsl:apply-templates/>
431 </hi>
432 </xsl:template>
433
Marc Kupietzad4d4462024-04-26 17:43:08 +0200434 <xsl:template match="xhtml:span[matches(@class, '(regular|norm)')]">
Marc Kupietz5e873112024-04-15 06:51:08 +0200435 <xsl:apply-templates/>
436 </xsl:template>
437
Marc Kupietz3989c742024-04-21 17:33:49 +0200438 <xsl:template match="xhtml:b|xhtml:span[@class='b']|xhtml:strong">
Marc Kupietz30cc0802024-04-10 16:37:04 +0200439 <hi rend="bold">
Marc Kupietz1a422662024-03-16 09:34:10 +0100440 <xsl:apply-templates/>
441 </hi>
442 </xsl:template>
443
Marc Kupietzfb0f2c32024-04-26 17:43:18 +0200444 <xsl:template match="xhtml:i|xhtml:span[@class='i' or @class='it']">
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000445 <hi rend="italic">
446 <xsl:apply-templates/>
447 </hi>
448 </xsl:template>
449
450
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100451 <xsl:template match="xhtml:sub|xhtml:span[@class='sub']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100452 <hi rend="sub">
453 <xsl:apply-templates/>
454 </hi>
455 </xsl:template>
456
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100457 <xsl:template match="xhtml:sup|xhtml:span[@class='sup']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100458 <hi rend="sup">
459 <xsl:apply-templates/>
460 </hi>
461 </xsl:template>
462
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000463 <xsl:template match="xhtml:div[not(normalize-space(replace(., '&#160;', ' ')))]" priority="1.0"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100464
Marc Kupietzbf47ae72024-04-14 14:21:43 +0200465 <xsl:template match="xhtml:body/xhtml:div[./xhtml:h1|./xhtml:h2|./xhtml:h3]" priority="1.0">
466 <xsl:apply-templates/>
467 </xsl:template>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000468 <xsl:template match="xhtml:div/xhtml:div">
Marc Kupietz1a422662024-03-16 09:34:10 +0100469 <p>
470 <xsl:apply-templates/>
471 </p>
472 </xsl:template>
473
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000474 <xsl:template match="xhtml:body/xhtml:div[(descendant::xhtml:p|descendant::xhtml:div)]">
475 <div type="section">
476 <xsl:apply-templates/>
477 </div>
478 </xsl:template>
479
480 <xsl:template match="xhtml:body/xhtml:div[not(descendant::xhtml:p|descendant::xhtml:div)]">
481 <div type="section">
482 <p>
483 <xsl:apply-templates/>
484 </p>
485 </div>
486 </xsl:template>
487
488 <xsl:template match="xhtml:p[not(descendant::xhtml:p|descendant::xhtml:div)]">
489 <xsl:if test="normalize-space(.)">
490 <p>
491 <xsl:apply-templates/>
492 </p>
493 </xsl:if>
494 </xsl:template>
495
496 <xsl:template match="xhtml:p[descendant::xhtml:p|descendant::xhtml:div]">
497 <xsl:if test="normalize-space(.)">
498 <div type="section">
499 <xsl:apply-templates/>
500 </div>
501 </xsl:if>
502 </xsl:template>
503
Marc Kupietz09745e12024-04-21 12:54:10 +0200504 <xsl:template match="xhtml:ul">
505 <list type="unordered">
506 <xsl:apply-templates/>
507 </list>
508 </xsl:template>
509 <xsl:template match="xhtml:ol">
510 <list type="ordered">
511 <xsl:apply-templates/>
512 </list>
513 </xsl:template>
514 <xsl:template match="xhtml:li">
515 <item>
516 <xsl:apply-templates/>
517 </item>
518 </xsl:template>
519 <xsl:template match="xhtml:nav">
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200520 <!-- <gap reason="toc"/> -->
521 </xsl:template>
522
Marc Kupietz1a422662024-03-16 09:34:10 +0100523 <xsl:template match="xhtml:img">
524 <!-- <gap reason="image"/> -->
525 </xsl:template>
526
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200527 <xsl:template match="xhtml:audio">
528 <!-- <gap reason="audio"/> -->
529 </xsl:template>
530
Marc Kupietz09745e12024-04-21 12:54:10 +0200531 <xsl:template match="xhtml:table">
532 <!-- <gap reason="table"/> -->
533 </xsl:template>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000534 <xsl:template match="xhtml:body/xhtml:a">
Marc Kupietz164a2832024-04-14 21:00:48 +0200535 <xsl:if test="normalize-space(.)">
536 <p>
537 <ref target="{@href}">
538 <xsl:apply-templates />
539 </ref>
540 </p>
541 </xsl:if>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000542 </xsl:template>
543
544 <xsl:template match="xhtml:body/xhtml:span">
545 <xsl:message>
546 <xsl:text>unhandled span element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
547 </xsl:message>
548 <div type="section">
549 <p>
550 <xsl:value-of select="."/>
551 </p>
552 </div>
553 </xsl:template>
554 <xsl:template match="xhtml:span">
555 <xsl:message>
556 <xsl:text>unhandled span element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
557 </xsl:message>
558 <xsl:value-of select="."/>
559 </xsl:template>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100560 <xsl:template match="xhtml:a">
Marc Kupietz164a2832024-04-14 21:00:48 +0200561 <xsl:if test="normalize-space(.)">
562 <ref target="{@href}">
563 <xsl:apply-templates />
564 </ref>
565 </xsl:if>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100566 </xsl:template>
567
Marc Kupietz54ec28b2024-04-27 10:07:06 +0200568 <xsl:template match="xhtml:br">
569 <lb/><xsl:text>&#10;</xsl:text>
570 </xsl:template>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100571
Marc Kupietz1a422662024-03-16 09:34:10 +0100572 <xsl:template match="xhtml:*">
573 <xsl:message>
574 <xsl:text>unhandled element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
575 </xsl:message>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000576 <xsl:choose>
577 <xsl:when test="descendant::xhtml:div|descendant::xhtml:p|parent::xhtml:body">
578 <div type="section">
579 <xsl:apply-templates/>
580 </div>
581 </xsl:when>
582 <xsl:otherwise>
583 <xsl:apply-templates select="./*|node()"/>
584 </xsl:otherwise>
585 </xsl:choose>
Marc Kupietz1a422662024-03-16 09:34:10 +0100586 <xsl:apply-templates/>
587 </xsl:template>
588
589 <xsl:function name="ids:reversedAuthors">
590 <xsl:param name="s" />
591 <xsl:value-of
592 select="
593 if (matches($s, ';')) then
594 concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; ')))
595 else
596 replace($s, '(.+) (.+)', '$2, $1')"
597 />
598 </xsl:function>
599
600 <xsl:function name="hlu:reversedAuthors">
601 <xsl:param name="s"/>
602 <xsl:value-of
603 select="if (matches($s, ';')) then concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; '))) else replace($s, '(.+),(.+)', '$2, $1')"
604 />
605 </xsl:function>
606
Marc Kupietz10903f32024-04-14 14:21:18 +0200607 <xsl:variable name="city-country-map" as="map(xs:string, xs:string)">
608 <xsl:map>
609 <xsl:map-entry key="'Axams'" select="'AT'"/>
610 <xsl:map-entry key="'Vienna'" select="'AT'"/>
611 <xsl:map-entry key="'Klagenfurt'" select="'AT'"/>
612 <xsl:map-entry key="'Graz'" select="'AT'"/>
613 <xsl:map-entry key="'Innsbruck'" select="'AT'"/>
614 <xsl:map-entry key="'Salzburg'" select="'AT'"/>
615 <xsl:map-entry key="'Bern'" select="'CH'"/>
616 <xsl:map-entry key="'Biel/Bienne'" select="'CH'"/>
617 <xsl:map-entry key="'Zurich'" select="'CH'"/>
618 <xsl:map-entry key="'Basel'" select="'CH'"/>
619 <xsl:map-entry key="'Geneva'" select="'CH'"/>
620 <xsl:map-entry key="'Lucerne'" select="'CH'"/>
621 <xsl:map-entry key="'Lausanne'" select="'CH'"/>
622 <xsl:map-entry key="'Winterthur'" select="'CH'"/>
623 <xsl:map-entry key="'St. Gallen'" select="'CH'"/>
624 <xsl:map-entry key="'Interlaken'" select="'CH'"/>
625 <xsl:map-entry key="'Brussels'" select="'BE'"/>
626 <xsl:map-entry key="'Antwerp'" select="'BE'"/>
627 <xsl:map-entry key="'Ghent'" select="'BE'"/>
628 <xsl:map-entry key="'Bruges'" select="'BE'"/>
629 <xsl:map-entry key="'Leuven'" select="'BE'"/>
630 <xsl:map-entry key="'Liege'" select="'BE'"/>
631 <xsl:map-entry key="'Charleroi'" select="'BE'"/>
632 <xsl:map-entry key="'Namur'" select="'BE'"/>
633 <xsl:map-entry key="'Mons'" select="'BE'"/>
634 <xsl:map-entry key="'Bangkok'" select="'TH'"/>
635 <xsl:map-entry key="'Copenhagen'" select="'DK'"/>
636 <xsl:map-entry key="'colatina'" select="'BR'"/>
637 <xsl:map-entry key="'Oakland Park'" select="'US'"/>
638 <xsl:map-entry key="'Istanbul'" select="'TR'"/>
639 <xsl:map-entry key="'Luxemburg'" select="'LU'"/>
640 <xsl:map-entry key="'Palma de Mallorca'" select="'ES'"/>
641 <xsl:map-entry key="'Swakopmund'" select="'NA'"/>
642 <xsl:map-entry key="'Victoria'" select="'CA'"/>
643 <xsl:map-entry key="'Wien'" select="'AT'"/>
644 <xsl:map-entry key="'Windhoek'" select="'NA'"/>
645 <xsl:map-entry key="'Zuerich'" select="'CH'"/>
646 <xsl:map-entry key="'Zürich'" select="'CH'"/>
647 <xsl:map-entry key="'Zug'" select="'CH'"/>
648 <xsl:map-entry key="'ZÜRICH'" select="'CH'"/>
649 </xsl:map>
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200650
Marc Kupietz10903f32024-04-14 14:21:18 +0200651 </xsl:variable>
652
653 <!-- Define the function -->
654 <xsl:function name="ids:country-city" as="xs:string">
655 <xsl:param name="city" as="xs:string"/>
656 <xsl:sequence select="if (map:contains($city-country-map, $city)) then map:get($city-country-map, $city) else 'DE'"/>
657 </xsl:function>
Marc Kupietz1a422662024-03-16 09:34:10 +0100658</xsl:stylesheet>