blob: d646af2a02d980404b5bdcd48105ebb09389f88b [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 Kupietz0df2a572024-05-26 16:54:27 +020022 <xsl:variable name="idno" as="xs:string" select="replace(base-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 Kupietz0df2a572024-05-26 16:54:27 +020035 <xsl:variable name="dnbBookdataQuery" as="xs:string">
36 <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')"/>
37 </xsl:variable>
Marc Kupietz1a422662024-03-16 09:34:10 +010038 <xsl:variable name="dnbBookdata">
Marc Kupietz0df2a572024-05-26 16:54:27 +020039 <xsl:copy-of select="doc($dnbBookdataQuery)"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010040 </xsl:variable>
41
42 <xsl:variable name="autor"
Marc Kupietzde2ca532024-04-26 16:50:53 +020043 select="replace(string-join($dnbBookdata//dc:creator[not(contains(., '[')) or matches(., '\[Verfasser\]')], ' ; '), ' *\[[^\]]*\]', '')"/>
Marc Kupietzeaa90132024-04-26 18:14:40 +020044 <xsl:variable name="straight_autor" select="normalize-space(replace(hlu:reversedAuthors($autor), ',', ''))"/>
45 <xsl:variable name="translator"
46 select="replace(string-join($dnbBookdata//dc:creator[matches(., '\[Übersetzer\]')], ' ; '), ' *\[[^\]]*\]', '')"/>
47 <xsl:variable name="straight_translator" select="normalize-space(replace(hlu:reversedAuthors($translator), ',', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010048
Marc Kupietz15e7d612024-04-26 18:16:39 +020049 <xsl:variable name="herausgeber"
50 select="replace(string-join($dnbBookdata//dc:creator[matches(., '\[(Herausgeber|Hrsg.)\]')], ' ; '), ' *\[[^\]]*\]', '')"/>
51 <xsl:variable name="straight_herausgeber" select="normalize-space(replace(hlu:reversedAuthors($herausgeber), ',', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010052
53 <xsl:variable name="ina"/>
54 <xsl:variable name="_corpus"/>
55 <xsl:variable name="ent_known"/>
56
57
58 <!-- added HLU 2012-02-09: -->
59 <xsl:variable name="ent">
60 <xsl:choose>
61 <xsl:when test="$ent_known">
62 <xsl:value-of select="$ent_known"/>
63 </xsl:when>
64 <xsl:when test="$ev">
65 <xsl:value-of select="$ev"/>
66 </xsl:when>
67 <xsl:otherwise>
68 <xsl:value-of select="$j"/>
69 </xsl:otherwise>
70 </xsl:choose>
71 </xsl:variable>
72
73 <xsl:variable name="titel">
Marc Kupietz49124fa2024-04-10 16:50:01 +020074 <xsl:variable name="title-with-subtitles">
75 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +020076 <xsl:when test="contains(($dnbBookdata//dc:title)[1],':')">
Rebecca Wilme5f055a2024-05-10 15:07:50 +020077 <xsl:value-of select="normalize-space(substring-before(substring-before(($dnbBookdata//dc:title)[1], '/'), ':'))"/>
Marc Kupietz49124fa2024-04-10 16:50:01 +020078 </xsl:when>
79 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +020080 <xsl:value-of select="normalize-space(substring-before(($dnbBookdata//dc:title)[1], '/'))"/>
Marc Kupietz49124fa2024-04-10 16:50:01 +020081 </xsl:otherwise>
82 </xsl:choose>
83 </xsl:variable>
84 <xsl:value-of select="normalize-space(replace($title-with-subtitles, '\|.*', ''))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010085 </xsl:variable>
86
87 <xsl:variable name="erscheinungsort">
88 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +020089 <xsl:when test="contains(($dnbBookdata//dc:publisher)[1], ':')">
90 <xsl:value-of select="normalize-space(substring-before(($dnbBookdata//dc:publisher)[1], ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010091 </xsl:when>
92 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +020093 <xsl:value-of select="normalize-space(($dnbBookdata//dc:publisher)[1])"/>
Marc Kupietz1a422662024-03-16 09:34:10 +010094 </xsl:otherwise>
95 </xsl:choose>
96 </xsl:variable>
97
Marc Kupietzd8599fc2024-04-14 13:16:56 +020098 <xsl:variable name="erscheinungsland" select="ids:country-city($erscheinungsort)"/>
99
Marc Kupietz6cb52232024-04-13 12:28:44 +0200100 <xsl:variable name="texttype" select="replace(($dnbBookdata//dc:subject[matches(., '^[A-Z] ')])[1], '^[A-Z] (.*)', '$1')"/>
Marc Kupietz7df4ccc2024-03-16 15:27:45 +0100101
Marc Kupietz9d87e9d2024-05-05 15:56:50 +0200102 <xsl:variable name="genretable">
103 <genres>
104 <genre keyRegex="krimi" genre="Roman: Kriminalroman"/>
105 <genre keyRegex="arztroman" genre="Roman: Arztroman"/>
106 <genre keyRegex="liebesroman" genre="Roman: Liebesroman"/>
107 <genre keyRegex="science.?fiction" genre="Roman: Science-Fiction-Roman"/>
108 <genre keyRegex="horror" genre="Roman: Horrorroman"/>
109 <genre keyRegex="western" genre="Roman: Westernroman"/>
110 <genre keyRegex="fantasy" genre="Roman: Fantasyroman"/>
111 <genre keyRegex="historischer roman" genre="Roman: Historischer Roman"/>
112 <genre keyRegex="erzählung" genre="Erzählung"/>
113 <genre keyRegex="novelle" genre="Novelle"/>
114 <genre keyRegex="anthologie" genre="Anthologie"/>
115 <genre keyRegex="kurzgeschichte" genre="Kurzgeschichte"/>
116 <genre keyRegex="roman" genre="Roman"/>
117 <genre keyRegex="." genre="Roman"/>
118 </genres>
119 </xsl:variable>
120
121 <xsl:variable name="textFullGenre" select="$genretable/genres/genre[matches($dnbBookdata, ./@keyRegex, 'i')][1]/@genre"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100122 <xsl:variable name="verlag">
123 <xsl:choose>
Marc Kupietz6cb52232024-04-13 12:28:44 +0200124 <xsl:when test="contains(($dnbBookdata//dc:publisher)[1], ':')">
125 <xsl:value-of select="normalize-space(substring-after(($dnbBookdata//dc:publisher)[1], ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100126 </xsl:when>
127 <xsl:otherwise>
Marc Kupietz6cb52232024-04-13 12:28:44 +0200128 <xsl:value-of select="normalize-space(($dnbBookdata//dc:publisher)[1])"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100129 </xsl:otherwise>
130 </xsl:choose>
131 </xsl:variable>
132
133 <xsl:variable name="erscheinungsjahr">
Marc Kupietza5d01182024-04-14 12:24:02 +0200134 <xsl:value-of select="replace(($dnbBookdata//dc:date)[1], '.*?((19|20)[0-9][0-9]).*', '$1')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100135 </xsl:variable>
136
137 <xsl:variable name="untertitel"
Marc Kupietz6cb52232024-04-13 12:28:44 +0200138 select="normalize-space(substring-after(substring-before(($dnbBookdata//dc:title)[1], '/'), ':'))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100139
Marc Kupietza5d01182024-04-14 12:24:02 +0200140 <xsl:variable name="j" select="$erscheinungsjahr"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100141
142 <!-- for BOT+s: -->
143 <xsl:variable name="seiten" select="replace($dnbBookdata//dc:format,'S\.','')"/>
144
145 <!-- fuer BOT+b: -->
146 <xsl:variable name="_b">
147 <xsl:variable name="regexp1" select="'(Band|Bd\.)\s*([0-9]?[0-9]?[0-9])'"/>
148 <xsl:choose>
149 <xsl:when test="matches($dnbBookdata, $regexp1)">
150 <xsl:analyze-string select="$dnbBookdata//dc:title" regex="{$regexp1}">
151 <xsl:matching-substring>
152 <xsl:value-of select="."/>
153 </xsl:matching-substring>
154 </xsl:analyze-string>
155 </xsl:when>
156 <xsl:otherwise>
157 <xsl:value-of select="'.'"/>
158 </xsl:otherwise>
159 </xsl:choose>
160 </xsl:variable>
161
162 <!-- for BOT+x: -->
163 <xsl:variable name="txtart">
164 <xsl:choose>
165 <xsl:when test="$x">
166 <xsl:value-of select="concat('[', $x, ']')"/>
167 </xsl:when>
168 <xsl:when
Nicolas Arnold26355632024-05-10 15:25:41 +0200169 test="matches($untertitel, '([Rr]oman|[Ee]rzählung(en)?|[Aa]nthologie|[Gg]eschichte(n)?|[Nn]ovelle)')">
Marc Kupietz1a422662024-03-16 09:34:10 +0100170 <xsl:value-of
Nicolas Arnold26355632024-05-10 15:25:41 +0200171 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 +0100172 />
173 </xsl:when>
174 <xsl:otherwise>
175 <xsl:value-of>Roman</xsl:value-of>
176 </xsl:otherwise>
177 </xsl:choose>
178 </xsl:variable>
179
180
181
182 <!-- fuer BOTd: -->
183 <xsl:variable name="dok"
184 select="concat((if(string-length($autor) &gt; 0) then concat($straight_autor, ': ') else ''), $titel, ', ', $txtart, ', (', $j, ')')"/>
185
186 <!-- END variables derived from sru request to dnb archive -->
187
188
Marc Kupietz94bbe6b2024-04-10 20:35:48 +0200189 <xsl:variable name="corpus_sigle" select="concat('DNB', substring($erscheinungsjahr, 3, 2))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100190
191 <!-- for BOTD: -->
192 <!-- Dokumentsigle muss zusammen mit Korpussigle (z.B DIV fuer loz-div und loz-div-pub) eindeutig sein -->
193 <xsl:variable name="doc_sigle">
194 <xsl:variable name="firstContentWordTitleInitial">
195 <xsl:variable name="helper">
196 <xsl:analyze-string select="$titel" regex="\w+">
197 <xsl:matching-substring>
198 <xsl:choose>
199 <xsl:when
Marc Kupietzad1f3b82024-04-19 19:21:49 +0200200 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 +0100201 <!-- TODO: Fktnswoerter nachtragen -->
202 <xsl:sequence select="."/>
203 </xsl:when>
204 <xsl:otherwise/>
205 </xsl:choose>
206 </xsl:matching-substring>
207 </xsl:analyze-string>
208 </xsl:variable>
209 <xsl:value-of
Marc Kupietz77b6aa92024-04-21 17:31:43 +0200210 select="upper-case(substring(normalize-space(replace($helper,'\s+.+$','')),1,3))"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100211 <!-- longest match of .+ -->
212 </xsl:variable>
Marc Kupietz77b6aa92024-04-21 17:31:43 +0200213 <xsl:variable name="authorInitials">
214 <xsl:choose>
215 <xsl:when test="contains($autor,';')">
216 <xsl:variable name="lastname_aut1"
217 select="upper-case(substring(normalize-space($autor),1,1))"/>
218 <xsl:variable name="lastname_aut2"
219 select="replace($autor, '.*?;.*?([A-Z]).*', '$1')"/>
220 <xsl:value-of select="concat($lastname_aut1, $lastname_aut2)"/>
221 </xsl:when>
222 <xsl:otherwise>
223 <xsl:variable name="lastname_aut1"
224 select="upper-case(substring(normalize-space(substring-before($autor,',')),1,1))"/>
225 <xsl:variable name="firstname_aut1"
226 select="upper-case(substring(normalize-space(substring-after($autor,',')),1,1))"/>
227 <xsl:value-of select="concat($lastname_aut1, $firstname_aut1)"/>
228 </xsl:otherwise>
229 </xsl:choose>
230 </xsl:variable>
Marc Kupietz398b5962024-04-21 17:51:34 +0200231 <xsl:value-of select="substring(replace(normalize-unicode(concat($authorInitials,$firstContentWordTitleInitial), 'NFKD'),'[^A-Z]',''),1,3)"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100232 </xsl:variable>
233
234
Marc Kupietz0c246632024-04-29 07:08:23 +0200235 <xsl:variable name="text_sigle" select="replace($idno, '.*([0-9]{5})[0-9X]$', '$1')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100236 <xsl:variable name="sigle" select="concat($corpus_sigle, '/', $doc_sigle, '.', $text_sigle)"/>
237
238 <!-- fuer BOT+xy: (?) -->
239 <xsl:variable name="xyref">
Marc Kupietz0df2a572024-05-26 16:54:27 +0200240 <xsl:value-of select="base-uri(.)"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100241 <xsl:text>; </xsl:text>
Marc Kupietz0c246632024-04-29 07:08:23 +0200242 <xsl:text>IDNO:</xsl:text>
243 <xsl:value-of select="$idno"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100244 <xsl:text>; </xsl:text>
245 <xsl:value-of select="string-join($dnbBookdata//dc:identifier)"/>
246 </xsl:variable>
247
Marc Kupietzb660ed62024-03-16 11:45:53 +0100248 <xsl:variable name="long-reference"
249 select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/>
250
251 <xsl:variable name="short-reference"
252 select="concat($straight_autor, ': ', $titel, ' (', $erscheinungsjahr, ')')"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100253
254 <xsl:template match="/">
Marc Kupietz98645242024-05-26 16:52:47 +0200255 <!-- for debugging purposes
256 <xsl:message select="concat('uri: ', base-uri())"/>
257 <xsl:message select="concat('idno: ', $idno)"/>
258
259 <xsl:message>
260 dnbBookdataQuery: <xsl:value-of select="$dnbBookdataQuery"/>
261 </xsl:message>
262
263 <xsl:message>
264 <xsl:copy-of select="$dnbBookdata"/>
265 </xsl:message>
266 -->
Marc Kupietzb7a4f6c2024-04-19 11:35:25 +0200267 <xsl:if test="not($j)">
Marc Kupietz0c246632024-04-29 07:08:23 +0200268 <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 +0200269 </xsl:if>
270
Marc Kupietz815cc6c2024-04-19 12:44:44 +0200271 <xsl:if test="not(normalize-space($titel))">
Marc Kupietz0c246632024-04-29 07:08:23 +0200272 <xsl:message terminate="yes">ERROR: No title found for IDNO: <xsl:value-of select="$idno"/></xsl:message>
Marc Kupietz815cc6c2024-04-19 12:44:44 +0200273 </xsl:if>
274
Marc Kupietz2badfb12024-04-19 12:59:40 +0200275 <xsl:if test="not(normalize-space($autor))">
Marc Kupietz0c246632024-04-29 07:08:23 +0200276 <xsl:message terminate="yes">ERROR: No author found for IDNO: <xsl:value-of select="$idno"/></xsl:message>
Marc Kupietz2badfb12024-04-19 12:59:40 +0200277 </xsl:if>
278
Marc Kupietz52aa5052024-04-21 18:16:06 +0200279 <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 +0200280 <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 +0200281 </xsl:if>
282
Marc Kupietz1a422662024-03-16 09:34:10 +0100283 <idsDoc TEIform="TEI.2" type="text" version="1.0">
284 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="document" version="1.1">
285 <fileDesc>
286 <titleStmt>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100287 <dokumentSigle><xsl:value-of select="string-join(($corpus_sigle, $doc_sigle), '/')"/></dokumentSigle>
288 <d.title><xsl:value-of select="$short-reference"/></d.title>
Marc Kupietz1a422662024-03-16 09:34:10 +0100289 </titleStmt>
290 <publicationStmt>
291 <distributor/>
292 <pubAddress/>
Rebecca Wilme5f055a2024-05-10 15:07:50 +0200293 <xsl:for-each select="$dnbBookdata//dc:identifier">
294 <xsl:variable name="type" select="substring-after(@xsi:type, ':')"/>
295 <xsl:choose>
296 <xsl:when test="@xsi:type='tel:ISBN'">
297 <xsl:if test="matches(.,'(^([0-9]|-)+X?).*')">
298 <idno type="{$type}"><xsl:value-of select="replace(., '(([0-9]|-)+X?).*', '$1')"/></idno>
299 </xsl:if>
300 </xsl:when>
301 <xsl:otherwise><idno type="{$type}"><xsl:value-of select="."/></idno></xsl:otherwise>
302 </xsl:choose>
303 </xsl:for-each>
Marc Kupietz1a422662024-03-16 09:34:10 +0100304 <availability region="world" status="unknown">QAO-NC</availability>
305 <pubDate/>
306 </publicationStmt>
307 <sourceDesc>
308 <biblStruct>
309 <monogr>
310 <h.title type="main"/>
311 <imprint/>
312 </monogr>
313 </biblStruct>
314 </sourceDesc>
315 </fileDesc>
316 </idsHeader>
317 <idsText version="1.0">
318 <idsHeader TEIform="teiHeader" pattern="text" status="new" type="text" version="1.1">
319 <fileDesc>
320 <titleStmt>
321 <textSigle><xsl:sequence select="$sigle"/></textSigle>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100322 <t.title assemblage="regular"><xsl:value-of select="$long-reference"/></t.title>
Marc Kupietz1a422662024-03-16 09:34:10 +0100323 </titleStmt>
324 <publicationStmt>
325 <distributor/>
326 <pubAddress/>
327 <availability region="world" status="unknown">QAO-NC</availability>
328 <pubDate/>
329 </publicationStmt>
330 <sourceDesc>
331 <biblStruct>
332 <monogr>
333 <h.title type="main"><xsl:value-of select="$titel"/></h.title>
334 <h.title type="sub"><xsl:value-of select="$untertitel"/></h.title>
335 <h.author><xsl:value-of select="$autor"/></h.author>
Marc Kupietzeaa90132024-04-26 18:14:40 +0200336 <xsl:if test="$translator">
337 <editor role="translator"><xsl:value-of select="$translator"/></editor>
338 </xsl:if>
Marc Kupietz15e7d612024-04-26 18:16:39 +0200339 <xsl:if test="$herausgeber">
340 <editor role="editor"><xsl:value-of select="$herausgeber"/></editor>
341 </xsl:if>
Marc Kupietz1a422662024-03-16 09:34:10 +0100342 <edition>
343 <further/>
344 <kind>E-Book-Ausgabe</kind>
345 <appearance>EPUB-Datei</appearance>
346 </edition>
347 <imprint>
Marc Kupietzb660ed62024-03-16 11:45:53 +0100348 <publisher><xsl:value-of select="$verlag"/></publisher>
Marc Kupietz1a422662024-03-16 09:34:10 +0100349 <pubDate type="year"><xsl:value-of select="$j"/></pubDate>
350 <pubDate type="month"/>
351 <pubDate type="day"/>
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200352 <pubPlace key="{$erscheinungsland}"><xsl:value-of select="$erscheinungsort"/></pubPlace>
Marc Kupietz1a422662024-03-16 09:34:10 +0100353 </imprint>
354 <biblScope type="subsume"/>
355 <biblScope type="pp"/>
356 <biblScope type="vol"/>
357 <biblScope type="volume-title"/>
358 </monogr>
359 </biblStruct>
360 <reference assemblage="regular" type="complete"><xsl:value-of select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/></reference>
Marc Kupietz1a422662024-03-16 09:34:10 +0100361 </sourceDesc>
362 </fileDesc>
363 <profileDesc>
364 <creation>
365 <creatDate><xsl:value-of select="$j"/></creatDate>
366 </creation>
367 <textClass/>
368 <textDesc>
Marc Kupietz9d87e9d2024-05-05 15:56:50 +0200369 <textType><xsl:value-of select="$textFullGenre"/></textType>
370 <textTypeRef><xsl:value-of select="replace($textFullGenre, '.*: *', '')"/></textTypeRef>
Marc Kupietz1a422662024-03-16 09:34:10 +0100371 <textDomain/>
372 </textDesc>
373 </profileDesc>
374 </idsHeader>
375 <text>
376 <body>
377 <!-- Call the template for each link in the TOC
378 <xsl:apply-templates select="//xhtml:ol[@class='toc']/xhtml:li/xhtml:a" mode="collect"/> -->
Marc Kupietz8f727302024-04-10 16:31:19 +0200379 <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 +0100380 </body>
381 </text>
382 </idsText>
383 </idsDoc>
384 </xsl:template>
385
386 <xsl:template match="opf:item" mode="collect">
387 <xsl:variable name="href" select="@href"/>
388 <xsl:message>
Marc Kupietz0c246632024-04-29 07:08:23 +0200389 <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 +0100390 </xsl:message>
391 <xsl:apply-templates select="doc(resolve-uri($href, base-uri()))/xhtml:html/xhtml:body"/>
392 </xsl:template>
393
394 <xsl:template match="xhtml:body">
395 <div type="chapter">
396 <xsl:apply-templates/>
397 </div>
398 </xsl:template>
399
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000400 <xsl:template match="xhtml:body/text()">
401 <p>
402 <xsl:value-of select="."/>
403 </p>
404 </xsl:template>
405
Marc Kupietz1a422662024-03-16 09:34:10 +0100406 <xsl:template match="xhtml:title">
407 <head>
408 <xsl:apply-templates/>
409 </head>
410 </xsl:template>
411
412 <xsl:template match="xhtml:h1">
413 <head>
414 <xsl:apply-templates/>
415 </head>
416 </xsl:template>
417
Marc Kupietz3989c742024-04-21 17:33:49 +0200418 <xsl:template match="xhtml:h2|xhtml:h3|xhtml:h4|xhtml:h5|xhtml:h6">
Marc Kupietz1a422662024-03-16 09:34:10 +0100419 <head type="sub">
420 <xsl:apply-templates/>
421 </head>
422 </xsl:template>
423
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100424 <xsl:template match="xhtml:em">
425 <emph>
426 <xsl:apply-templates/>
427 </emph>
428 </xsl:template>
Marc Kupietz1a422662024-03-16 09:34:10 +0100429
Marc Kupietz30cc0802024-04-10 16:37:04 +0200430 <xsl:template match="xhtml:span[matches(@class, '(bold|italic|big|kursiv| )+')]">
431 <xsl:variable name="class" select="replace(@class, 'kursiv', 'italic')"/>
432 <hi rend="{$class}">
433 <xsl:apply-templates/>
434 </hi>
435 </xsl:template>
436
Marc Kupietzad4d4462024-04-26 17:43:08 +0200437 <xsl:template match="xhtml:span[matches(@class, '(regular|norm)')]">
Marc Kupietz5e873112024-04-15 06:51:08 +0200438 <xsl:apply-templates/>
439 </xsl:template>
440
Marc Kupietz3989c742024-04-21 17:33:49 +0200441 <xsl:template match="xhtml:b|xhtml:span[@class='b']|xhtml:strong">
Marc Kupietz30cc0802024-04-10 16:37:04 +0200442 <hi rend="bold">
Marc Kupietz1a422662024-03-16 09:34:10 +0100443 <xsl:apply-templates/>
444 </hi>
445 </xsl:template>
446
Marc Kupietzfb0f2c32024-04-26 17:43:18 +0200447 <xsl:template match="xhtml:i|xhtml:span[@class='i' or @class='it']">
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000448 <hi rend="italic">
449 <xsl:apply-templates/>
450 </hi>
451 </xsl:template>
452
453
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100454 <xsl:template match="xhtml:sub|xhtml:span[@class='sub']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100455 <hi rend="sub">
456 <xsl:apply-templates/>
457 </hi>
458 </xsl:template>
459
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100460 <xsl:template match="xhtml:sup|xhtml:span[@class='sup']">
Marc Kupietz1a422662024-03-16 09:34:10 +0100461 <hi rend="sup">
462 <xsl:apply-templates/>
463 </hi>
464 </xsl:template>
465
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000466 <xsl:template match="xhtml:div[not(normalize-space(replace(., '&#160;', ' ')))]" priority="1.0"/>
Marc Kupietz1a422662024-03-16 09:34:10 +0100467
Marc Kupietzbf47ae72024-04-14 14:21:43 +0200468 <xsl:template match="xhtml:body/xhtml:div[./xhtml:h1|./xhtml:h2|./xhtml:h3]" priority="1.0">
469 <xsl:apply-templates/>
470 </xsl:template>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000471 <xsl:template match="xhtml:div/xhtml:div">
Marc Kupietz1a422662024-03-16 09:34:10 +0100472 <p>
473 <xsl:apply-templates/>
474 </p>
475 </xsl:template>
476
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000477 <xsl:template match="xhtml:body/xhtml:div[(descendant::xhtml:p|descendant::xhtml:div)]">
478 <div type="section">
479 <xsl:apply-templates/>
480 </div>
481 </xsl:template>
482
483 <xsl:template match="xhtml:body/xhtml:div[not(descendant::xhtml:p|descendant::xhtml:div)]">
484 <div type="section">
485 <p>
486 <xsl:apply-templates/>
487 </p>
488 </div>
489 </xsl:template>
490
491 <xsl:template match="xhtml:p[not(descendant::xhtml:p|descendant::xhtml:div)]">
492 <xsl:if test="normalize-space(.)">
493 <p>
494 <xsl:apply-templates/>
495 </p>
496 </xsl:if>
497 </xsl:template>
498
499 <xsl:template match="xhtml:p[descendant::xhtml:p|descendant::xhtml:div]">
500 <xsl:if test="normalize-space(.)">
501 <div type="section">
502 <xsl:apply-templates/>
503 </div>
504 </xsl:if>
505 </xsl:template>
506
Marc Kupietz09745e12024-04-21 12:54:10 +0200507 <xsl:template match="xhtml:ul">
508 <list type="unordered">
509 <xsl:apply-templates/>
510 </list>
511 </xsl:template>
512 <xsl:template match="xhtml:ol">
513 <list type="ordered">
514 <xsl:apply-templates/>
515 </list>
516 </xsl:template>
517 <xsl:template match="xhtml:li">
518 <item>
519 <xsl:apply-templates/>
520 </item>
521 </xsl:template>
522 <xsl:template match="xhtml:nav">
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200523 <!-- <gap reason="toc"/> -->
524 </xsl:template>
525
Marc Kupietz1a422662024-03-16 09:34:10 +0100526 <xsl:template match="xhtml:img">
527 <!-- <gap reason="image"/> -->
528 </xsl:template>
529
Marc Kupietz1e6bfd12024-04-10 16:33:20 +0200530 <xsl:template match="xhtml:audio">
531 <!-- <gap reason="audio"/> -->
532 </xsl:template>
533
Marc Kupietz09745e12024-04-21 12:54:10 +0200534 <xsl:template match="xhtml:table">
535 <!-- <gap reason="table"/> -->
536 </xsl:template>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000537 <xsl:template match="xhtml:body/xhtml:a">
Marc Kupietz164a2832024-04-14 21:00:48 +0200538 <xsl:if test="normalize-space(.)">
539 <p>
540 <ref target="{@href}">
541 <xsl:apply-templates />
542 </ref>
543 </p>
544 </xsl:if>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000545 </xsl:template>
546
547 <xsl:template match="xhtml:body/xhtml:span">
548 <xsl:message>
549 <xsl:text>unhandled span element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
550 </xsl:message>
551 <div type="section">
552 <p>
553 <xsl:value-of select="."/>
554 </p>
555 </div>
556 </xsl:template>
557 <xsl:template match="xhtml:span">
558 <xsl:message>
559 <xsl:text>unhandled span element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
560 </xsl:message>
561 <xsl:value-of select="."/>
562 </xsl:template>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100563 <xsl:template match="xhtml:a">
Marc Kupietz164a2832024-04-14 21:00:48 +0200564 <xsl:if test="normalize-space(.)">
565 <ref target="{@href}">
566 <xsl:apply-templates />
567 </ref>
568 </xsl:if>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100569 </xsl:template>
570
Marc Kupietz54ec28b2024-04-27 10:07:06 +0200571 <xsl:template match="xhtml:br">
572 <lb/><xsl:text>&#10;</xsl:text>
573 </xsl:template>
Marc Kupietz99ec04b2024-03-16 11:30:03 +0100574
Marc Kupietz1a422662024-03-16 09:34:10 +0100575 <xsl:template match="xhtml:*">
576 <xsl:message>
577 <xsl:text>unhandled element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/>
578 </xsl:message>
Marc Kupietz4b1f5952024-04-13 20:04:56 +0000579 <xsl:choose>
580 <xsl:when test="descendant::xhtml:div|descendant::xhtml:p|parent::xhtml:body">
581 <div type="section">
582 <xsl:apply-templates/>
583 </div>
584 </xsl:when>
585 <xsl:otherwise>
586 <xsl:apply-templates select="./*|node()"/>
587 </xsl:otherwise>
588 </xsl:choose>
Marc Kupietz1a422662024-03-16 09:34:10 +0100589 <xsl:apply-templates/>
590 </xsl:template>
591
592 <xsl:function name="ids:reversedAuthors">
593 <xsl:param name="s" />
594 <xsl:value-of
595 select="
596 if (matches($s, ';')) then
597 concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; ')))
598 else
599 replace($s, '(.+) (.+)', '$2, $1')"
600 />
601 </xsl:function>
602
603 <xsl:function name="hlu:reversedAuthors">
604 <xsl:param name="s"/>
605 <xsl:value-of
606 select="if (matches($s, ';')) then concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; '))) else replace($s, '(.+),(.+)', '$2, $1')"
607 />
608 </xsl:function>
609
Marc Kupietz10903f32024-04-14 14:21:18 +0200610 <xsl:variable name="city-country-map" as="map(xs:string, xs:string)">
611 <xsl:map>
612 <xsl:map-entry key="'Axams'" select="'AT'"/>
613 <xsl:map-entry key="'Vienna'" select="'AT'"/>
614 <xsl:map-entry key="'Klagenfurt'" select="'AT'"/>
615 <xsl:map-entry key="'Graz'" select="'AT'"/>
616 <xsl:map-entry key="'Innsbruck'" select="'AT'"/>
617 <xsl:map-entry key="'Salzburg'" select="'AT'"/>
618 <xsl:map-entry key="'Bern'" select="'CH'"/>
619 <xsl:map-entry key="'Biel/Bienne'" select="'CH'"/>
620 <xsl:map-entry key="'Zurich'" select="'CH'"/>
621 <xsl:map-entry key="'Basel'" select="'CH'"/>
622 <xsl:map-entry key="'Geneva'" select="'CH'"/>
623 <xsl:map-entry key="'Lucerne'" select="'CH'"/>
624 <xsl:map-entry key="'Lausanne'" select="'CH'"/>
625 <xsl:map-entry key="'Winterthur'" select="'CH'"/>
626 <xsl:map-entry key="'St. Gallen'" select="'CH'"/>
627 <xsl:map-entry key="'Interlaken'" select="'CH'"/>
628 <xsl:map-entry key="'Brussels'" select="'BE'"/>
629 <xsl:map-entry key="'Antwerp'" select="'BE'"/>
630 <xsl:map-entry key="'Ghent'" select="'BE'"/>
631 <xsl:map-entry key="'Bruges'" select="'BE'"/>
632 <xsl:map-entry key="'Leuven'" select="'BE'"/>
633 <xsl:map-entry key="'Liege'" select="'BE'"/>
634 <xsl:map-entry key="'Charleroi'" select="'BE'"/>
635 <xsl:map-entry key="'Namur'" select="'BE'"/>
636 <xsl:map-entry key="'Mons'" select="'BE'"/>
637 <xsl:map-entry key="'Bangkok'" select="'TH'"/>
638 <xsl:map-entry key="'Copenhagen'" select="'DK'"/>
639 <xsl:map-entry key="'colatina'" select="'BR'"/>
640 <xsl:map-entry key="'Oakland Park'" select="'US'"/>
641 <xsl:map-entry key="'Istanbul'" select="'TR'"/>
642 <xsl:map-entry key="'Luxemburg'" select="'LU'"/>
643 <xsl:map-entry key="'Palma de Mallorca'" select="'ES'"/>
644 <xsl:map-entry key="'Swakopmund'" select="'NA'"/>
645 <xsl:map-entry key="'Victoria'" select="'CA'"/>
646 <xsl:map-entry key="'Wien'" select="'AT'"/>
647 <xsl:map-entry key="'Windhoek'" select="'NA'"/>
648 <xsl:map-entry key="'Zuerich'" select="'CH'"/>
649 <xsl:map-entry key="'Zürich'" select="'CH'"/>
650 <xsl:map-entry key="'Zug'" select="'CH'"/>
651 <xsl:map-entry key="'ZÜRICH'" select="'CH'"/>
652 </xsl:map>
Marc Kupietzd8599fc2024-04-14 13:16:56 +0200653
Marc Kupietz10903f32024-04-14 14:21:18 +0200654 </xsl:variable>
655
656 <!-- Define the function -->
657 <xsl:function name="ids:country-city" as="xs:string">
658 <xsl:param name="city" as="xs:string"/>
659 <xsl:sequence select="if (map:contains($city-country-map, $city)) then map:get($city-country-map, $city) else 'DE'"/>
660 </xsl:function>
Marc Kupietz1a422662024-03-16 09:34:10 +0100661</xsl:stylesheet>