| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 1 | <xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 2 | xmlns:xs="http://www.w3.org/2001/XMLSchema" |
| 3 | xmlns:opf="http://www.idpf.org/2007/opf" |
| 4 | xmlns:dc="http://purl.org/dc/elements/1.1/" |
| 5 | xmlns:ids="http://www.ids-mannheim.de/ids" |
| 6 | xmlns:hlu="http://www.ids-mannheim.de/hlu" |
| 7 | xmlns:saxon="http://saxon.sf.net/" |
| 8 | xmlns:xhtml="http://www.w3.org/1999/xhtml" |
| Marc Kupietz | 10903f3 | 2024-04-14 14:21:18 +0200 | [diff] [blame] | 9 | xmlns:map="http://www.w3.org/2005/xpath-functions/map" |
| 10 | exclude-result-prefixes="xs opf dc ids hlu map saxon xhtml"> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 11 | |
| 12 | <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" saxon:line-length="1000"/> |
| 13 | <xsl:strip-space elements="*"/> |
| 14 | |
| 15 | <xsl:variable name="ev"/> |
| 16 | <xsl:variable name="x"/> |
| 17 | |
| Marc Kupietz | ea684b8 | 2024-04-19 11:13:50 +0200 | [diff] [blame] | 18 | <xsl:variable name="isbn" as="xs:string" select="replace(document-uri(), '.*/([0-9]{9,13}X?).*' , '$1')"/> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 19 | |
| 20 | |
| 21 | <xsl:variable name="dnbBookdata"> |
| 22 | <xsl:copy-of select="doc(concat('https://services.dnb.de/sru/dnb?version=1.1&operation=searchRetrieve&query=NUM%3D', $isbn, '&recordSchema=oai_dc'))"/> |
| 23 | </xsl:variable> |
| 24 | |
| 25 | <xsl:variable name="autor" |
| Marc Kupietz | de2ca53 | 2024-04-26 16:50:53 +0200 | [diff] [blame] | 26 | select="replace(string-join($dnbBookdata//dc:creator[not(contains(., '[')) or matches(., '\[Verfasser\]')], ' ; '), ' *\[[^\]]*\]', '')"/> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 27 | |
| Marc Kupietz | b660ed6 | 2024-03-16 11:45:53 +0100 | [diff] [blame] | 28 | <xsl:variable name="straight_autor" select="normalize-space(replace(hlu:reversedAuthors($autor), ',', ''))"/> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 29 | |
| 30 | <xsl:variable name="ina"/> |
| 31 | <xsl:variable name="_corpus"/> |
| 32 | <xsl:variable name="ent_known"/> |
| 33 | |
| 34 | |
| 35 | <!-- added HLU 2012-02-09: --> |
| 36 | <xsl:variable name="ent"> |
| 37 | <xsl:choose> |
| 38 | <xsl:when test="$ent_known"> |
| 39 | <xsl:value-of select="$ent_known"/> |
| 40 | </xsl:when> |
| 41 | <xsl:when test="$ev"> |
| 42 | <xsl:value-of select="$ev"/> |
| 43 | </xsl:when> |
| 44 | <xsl:otherwise> |
| 45 | <xsl:value-of select="$j"/> |
| 46 | </xsl:otherwise> |
| 47 | </xsl:choose> |
| 48 | </xsl:variable> |
| 49 | |
| 50 | <xsl:variable name="titel"> |
| Marc Kupietz | 49124fa | 2024-04-10 16:50:01 +0200 | [diff] [blame] | 51 | <xsl:variable name="title-with-subtitles"> |
| 52 | <xsl:choose> |
| Marc Kupietz | 6cb5223 | 2024-04-13 12:28:44 +0200 | [diff] [blame] | 53 | <xsl:when test="contains(($dnbBookdata//dc:title)[1],':')"> |
| 54 | <xsl:value-of select="normalize-space(substring-before(substring-before(($dnbBookdata//dc:title)[1], '/'), ':'))" |
| Marc Kupietz | 49124fa | 2024-04-10 16:50:01 +0200 | [diff] [blame] | 55 | /> |
| 56 | </xsl:when> |
| 57 | <xsl:otherwise> |
| Marc Kupietz | 6cb5223 | 2024-04-13 12:28:44 +0200 | [diff] [blame] | 58 | <xsl:value-of select="normalize-space(substring-before(($dnbBookdata//dc:title)[1], '/'))"/> |
| Marc Kupietz | 49124fa | 2024-04-10 16:50:01 +0200 | [diff] [blame] | 59 | </xsl:otherwise> |
| 60 | </xsl:choose> |
| 61 | </xsl:variable> |
| 62 | <xsl:value-of select="normalize-space(replace($title-with-subtitles, '\|.*', ''))"/> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 63 | </xsl:variable> |
| 64 | |
| 65 | <xsl:variable name="erscheinungsort"> |
| 66 | <xsl:choose> |
| Marc Kupietz | 6cb5223 | 2024-04-13 12:28:44 +0200 | [diff] [blame] | 67 | <xsl:when test="contains(($dnbBookdata//dc:publisher)[1], ':')"> |
| 68 | <xsl:value-of select="normalize-space(substring-before(($dnbBookdata//dc:publisher)[1], ':'))"/> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 69 | </xsl:when> |
| 70 | <xsl:otherwise> |
| Marc Kupietz | 6cb5223 | 2024-04-13 12:28:44 +0200 | [diff] [blame] | 71 | <xsl:value-of select="normalize-space(($dnbBookdata//dc:publisher)[1])"/> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 72 | </xsl:otherwise> |
| 73 | </xsl:choose> |
| 74 | </xsl:variable> |
| 75 | |
| Marc Kupietz | d8599fc | 2024-04-14 13:16:56 +0200 | [diff] [blame] | 76 | <xsl:variable name="erscheinungsland" select="ids:country-city($erscheinungsort)"/> |
| 77 | |
| Marc Kupietz | 6cb5223 | 2024-04-13 12:28:44 +0200 | [diff] [blame] | 78 | <xsl:variable name="texttype" select="replace(($dnbBookdata//dc:subject[matches(., '^[A-Z] ')])[1], '^[A-Z] (.*)', '$1')"/> |
| Marc Kupietz | 7df4ccc | 2024-03-16 15:27:45 +0100 | [diff] [blame] | 79 | |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 80 | <xsl:variable name="verlag"> |
| 81 | <xsl:choose> |
| Marc Kupietz | 6cb5223 | 2024-04-13 12:28:44 +0200 | [diff] [blame] | 82 | <xsl:when test="contains(($dnbBookdata//dc:publisher)[1], ':')"> |
| 83 | <xsl:value-of select="normalize-space(substring-after(($dnbBookdata//dc:publisher)[1], ':'))"/> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 84 | </xsl:when> |
| 85 | <xsl:otherwise> |
| Marc Kupietz | 6cb5223 | 2024-04-13 12:28:44 +0200 | [diff] [blame] | 86 | <xsl:value-of select="normalize-space(($dnbBookdata//dc:publisher)[1])"/> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 87 | </xsl:otherwise> |
| 88 | </xsl:choose> |
| 89 | </xsl:variable> |
| 90 | |
| 91 | <xsl:variable name="erscheinungsjahr"> |
| Marc Kupietz | a5d0118 | 2024-04-14 12:24:02 +0200 | [diff] [blame] | 92 | <xsl:value-of select="replace(($dnbBookdata//dc:date)[1], '.*?((19|20)[0-9][0-9]).*', '$1')"/> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 93 | </xsl:variable> |
| 94 | |
| 95 | <xsl:variable name="untertitel" |
| Marc Kupietz | 6cb5223 | 2024-04-13 12:28:44 +0200 | [diff] [blame] | 96 | select="normalize-space(substring-after(substring-before(($dnbBookdata//dc:title)[1], '/'), ':'))"/> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 97 | |
| 98 | <xsl:variable name="herausgeber"> |
| 99 | <xsl:choose> |
| 100 | <xsl:when test="$dnbBookdata//dc:creator[ends-with(.,'[Hrsg.]')]"> |
| 101 | <xsl:value-of |
| Marc Kupietz | 6cb5223 | 2024-04-13 12:28:44 +0200 | [diff] [blame] | 102 | select="replace(string-join($dnbBookdata//dc:creator[ends-with(.,'[Hrsg.]')][1], ' ; '),'\s?\[Hrsg.\]','')" |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 103 | /> |
| 104 | </xsl:when> |
| 105 | <xsl:otherwise>.</xsl:otherwise> |
| 106 | </xsl:choose> |
| 107 | </xsl:variable> |
| 108 | |
| 109 | <xsl:variable name="straight_herausgeber" |
| 110 | select="replace(hlu:reversedAuthors($herausgeber), ',', '')"/> |
| 111 | |
| Marc Kupietz | a5d0118 | 2024-04-14 12:24:02 +0200 | [diff] [blame] | 112 | <xsl:variable name="j" select="$erscheinungsjahr"/> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 113 | |
| 114 | <!-- for BOT+s: --> |
| 115 | <xsl:variable name="seiten" select="replace($dnbBookdata//dc:format,'S\.','')"/> |
| 116 | |
| 117 | <!-- fuer BOT+b: --> |
| 118 | <xsl:variable name="_b"> |
| 119 | <xsl:variable name="regexp1" select="'(Band|Bd\.)\s*([0-9]?[0-9]?[0-9])'"/> |
| 120 | <xsl:choose> |
| 121 | <xsl:when test="matches($dnbBookdata, $regexp1)"> |
| 122 | <xsl:analyze-string select="$dnbBookdata//dc:title" regex="{$regexp1}"> |
| 123 | <xsl:matching-substring> |
| 124 | <xsl:value-of select="."/> |
| 125 | </xsl:matching-substring> |
| 126 | </xsl:analyze-string> |
| 127 | </xsl:when> |
| 128 | <xsl:otherwise> |
| 129 | <xsl:value-of select="'.'"/> |
| 130 | </xsl:otherwise> |
| 131 | </xsl:choose> |
| 132 | </xsl:variable> |
| 133 | |
| 134 | <!-- for BOT+x: --> |
| 135 | <xsl:variable name="txtart"> |
| 136 | <xsl:choose> |
| 137 | <xsl:when test="$x"> |
| 138 | <xsl:value-of select="concat('[', $x, ']')"/> |
| 139 | </xsl:when> |
| 140 | <xsl:when |
| 141 | test="matches($untertitel, '([Rr]oman|[Ee]rzhlung(en)?|[Aa]nthologie|[Gg]eschichte(n)?|[Nn]ovelle)')"> |
| 142 | <xsl:value-of |
| 143 | select="concat('[', replace(replace($untertitel, '.*?(((^|\P{L})\p{L}+)?([Rr]oman|[Ee]rzhlung(en)?|[Aa]nthologie|[Gg]eschichte(n)?|[Nn]ovelle)).*', '$1'), '\P{L}*(.+)', '$1'), ']')" |
| 144 | /> |
| 145 | </xsl:when> |
| 146 | <xsl:otherwise> |
| 147 | <xsl:value-of>Roman</xsl:value-of> |
| 148 | </xsl:otherwise> |
| 149 | </xsl:choose> |
| 150 | </xsl:variable> |
| 151 | |
| 152 | |
| 153 | |
| 154 | <!-- fuer BOTd: --> |
| 155 | <xsl:variable name="dok" |
| 156 | select="concat((if(string-length($autor) > 0) then concat($straight_autor, ': ') else ''), $titel, ', ', $txtart, ', (', $j, ')')"/> |
| 157 | |
| 158 | <!-- END variables derived from sru request to dnb archive --> |
| 159 | |
| 160 | |
| Marc Kupietz | 94bbe6b | 2024-04-10 20:35:48 +0200 | [diff] [blame] | 161 | <xsl:variable name="corpus_sigle" select="concat('DNB', substring($erscheinungsjahr, 3, 2))"/> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 162 | |
| 163 | <!-- for BOTD: --> |
| 164 | <!-- Dokumentsigle muss zusammen mit Korpussigle (z.B DIV fuer loz-div und loz-div-pub) eindeutig sein --> |
| 165 | <xsl:variable name="doc_sigle"> |
| 166 | <xsl:variable name="firstContentWordTitleInitial"> |
| 167 | <xsl:variable name="helper"> |
| 168 | <xsl:analyze-string select="$titel" regex="\w+"> |
| 169 | <xsl:matching-substring> |
| 170 | <xsl:choose> |
| 171 | <xsl:when |
| Marc Kupietz | ad1f3b8 | 2024-04-19 19:21:49 +0200 | [diff] [blame] | 172 | test="matches(.,'^[A-Z]') and not(matches(.,'^(Der|Die|Das|Des|Ein|Eine|Eines|Einmal|Von|Mit|Zu|Zur)$'))"> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 173 | <!-- TODO: Fktnswoerter nachtragen --> |
| 174 | <xsl:sequence select="."/> |
| 175 | </xsl:when> |
| 176 | <xsl:otherwise/> |
| 177 | </xsl:choose> |
| 178 | </xsl:matching-substring> |
| 179 | </xsl:analyze-string> |
| 180 | </xsl:variable> |
| 181 | <xsl:value-of |
| Marc Kupietz | 77b6aa9 | 2024-04-21 17:31:43 +0200 | [diff] [blame] | 182 | select="upper-case(substring(normalize-space(replace($helper,'\s+.+$','')),1,3))"/> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 183 | <!-- longest match of .+ --> |
| 184 | </xsl:variable> |
| Marc Kupietz | 77b6aa9 | 2024-04-21 17:31:43 +0200 | [diff] [blame] | 185 | <xsl:variable name="authorInitials"> |
| 186 | <xsl:choose> |
| 187 | <xsl:when test="contains($autor,';')"> |
| 188 | <xsl:variable name="lastname_aut1" |
| 189 | select="upper-case(substring(normalize-space($autor),1,1))"/> |
| 190 | <xsl:variable name="lastname_aut2" |
| 191 | select="replace($autor, '.*?;.*?([A-Z]).*', '$1')"/> |
| 192 | <xsl:value-of select="concat($lastname_aut1, $lastname_aut2)"/> |
| 193 | </xsl:when> |
| 194 | <xsl:otherwise> |
| 195 | <xsl:variable name="lastname_aut1" |
| 196 | select="upper-case(substring(normalize-space(substring-before($autor,',')),1,1))"/> |
| 197 | <xsl:variable name="firstname_aut1" |
| 198 | select="upper-case(substring(normalize-space(substring-after($autor,',')),1,1))"/> |
| 199 | <xsl:value-of select="concat($lastname_aut1, $firstname_aut1)"/> |
| 200 | </xsl:otherwise> |
| 201 | </xsl:choose> |
| 202 | </xsl:variable> |
| Marc Kupietz | 398b596 | 2024-04-21 17:51:34 +0200 | [diff] [blame] | 203 | <xsl:value-of select="substring(replace(normalize-unicode(concat($authorInitials,$firstContentWordTitleInitial), 'NFKD'),'[^A-Z]',''),1,3)"/> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 204 | </xsl:variable> |
| 205 | |
| 206 | |
| Marc Kupietz | 568240f | 2024-04-19 19:20:55 +0200 | [diff] [blame] | 207 | <xsl:variable name="text_sigle" select="replace($isbn, '.*([0-9]{5})[0-9X]$', '$1')"/> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 208 | <xsl:variable name="sigle" select="concat($corpus_sigle, '/', $doc_sigle, '.', $text_sigle)"/> |
| 209 | |
| 210 | <!-- fuer BOT+xy: (?) --> |
| 211 | <xsl:variable name="xyref"> |
| 212 | <xsl:value-of select="document-uri(.)"/> |
| 213 | <xsl:text>; </xsl:text> |
| 214 | <xsl:text>ISBN:</xsl:text> |
| 215 | <xsl:value-of select="$isbn"/> |
| 216 | <xsl:text>; </xsl:text> |
| 217 | <xsl:value-of select="string-join($dnbBookdata//dc:identifier)"/> |
| 218 | </xsl:variable> |
| 219 | |
| Marc Kupietz | b660ed6 | 2024-03-16 11:45:53 +0100 | [diff] [blame] | 220 | <xsl:variable name="long-reference" |
| 221 | select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/> |
| 222 | |
| 223 | <xsl:variable name="short-reference" |
| 224 | select="concat($straight_autor, ': ', $titel, ' (', $erscheinungsjahr, ')')"/> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 225 | |
| 226 | <xsl:template match="/"> |
| Marc Kupietz | b7a4f6c | 2024-04-19 11:35:25 +0200 | [diff] [blame] | 227 | <xsl:if test="not($j)"> |
| 228 | <xsl:message terminate="yes">ERROR: No dc:date found for ISBN: <xsl:value-of select="$isbn"/></xsl:message> |
| 229 | </xsl:if> |
| 230 | |
| Marc Kupietz | 815cc6c | 2024-04-19 12:44:44 +0200 | [diff] [blame] | 231 | <xsl:if test="not(normalize-space($titel))"> |
| 232 | <xsl:message terminate="yes">ERROR: No title found for ISBN: <xsl:value-of select="$isbn"/></xsl:message> |
| 233 | </xsl:if> |
| 234 | |
| Marc Kupietz | 2badfb1 | 2024-04-19 12:59:40 +0200 | [diff] [blame] | 235 | <xsl:if test="not(normalize-space($autor))"> |
| 236 | <xsl:message terminate="yes">ERROR: No author found for ISBN: <xsl:value-of select="$isbn"/></xsl:message> |
| 237 | </xsl:if> |
| 238 | |
| Marc Kupietz | 52aa505 | 2024-04-21 18:16:06 +0200 | [diff] [blame] | 239 | <xsl:if test="not(matches($sigle, '^[A-Z]{3}[0-9]{2}/[A-Z]{2,3}\.[0-9]{5}$'))"> |
| 240 | <xsl:message terminate="yes">ERROR: Invalid sigle »<xsl:value-of select="$sigle"/>« for ISBN: <xsl:value-of select="$isbn"/></xsl:message> |
| Marc Kupietz | 09745e1 | 2024-04-21 12:54:10 +0200 | [diff] [blame] | 241 | </xsl:if> |
| 242 | |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 243 | <idsDoc TEIform="TEI.2" type="text" version="1.0"> |
| 244 | <idsHeader TEIform="teiHeader" pattern="text" status="new" type="document" version="1.1"> |
| 245 | <fileDesc> |
| 246 | <titleStmt> |
| Marc Kupietz | b660ed6 | 2024-03-16 11:45:53 +0100 | [diff] [blame] | 247 | <dokumentSigle><xsl:value-of select="string-join(($corpus_sigle, $doc_sigle), '/')"/></dokumentSigle> |
| 248 | <d.title><xsl:value-of select="$short-reference"/></d.title> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 249 | </titleStmt> |
| 250 | <publicationStmt> |
| 251 | <distributor/> |
| 252 | <pubAddress/> |
| 253 | <availability region="world" status="unknown">QAO-NC</availability> |
| 254 | <pubDate/> |
| 255 | </publicationStmt> |
| 256 | <sourceDesc> |
| 257 | <biblStruct> |
| 258 | <monogr> |
| 259 | <h.title type="main"/> |
| 260 | <imprint/> |
| 261 | </monogr> |
| 262 | </biblStruct> |
| 263 | </sourceDesc> |
| 264 | </fileDesc> |
| 265 | </idsHeader> |
| 266 | <idsText version="1.0"> |
| 267 | <idsHeader TEIform="teiHeader" pattern="text" status="new" type="text" version="1.1"> |
| 268 | <fileDesc> |
| 269 | <titleStmt> |
| 270 | <textSigle><xsl:sequence select="$sigle"/></textSigle> |
| Marc Kupietz | b660ed6 | 2024-03-16 11:45:53 +0100 | [diff] [blame] | 271 | <t.title assemblage="regular"><xsl:value-of select="$long-reference"/></t.title> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 272 | </titleStmt> |
| 273 | <publicationStmt> |
| 274 | <distributor/> |
| 275 | <pubAddress/> |
| 276 | <availability region="world" status="unknown">QAO-NC</availability> |
| 277 | <pubDate/> |
| 278 | </publicationStmt> |
| 279 | <sourceDesc> |
| 280 | <biblStruct> |
| 281 | <monogr> |
| 282 | <h.title type="main"><xsl:value-of select="$titel"/></h.title> |
| 283 | <h.title type="sub"><xsl:value-of select="$untertitel"/></h.title> |
| 284 | <h.author><xsl:value-of select="$autor"/></h.author> |
| 285 | <editor/> |
| 286 | <edition> |
| 287 | <further/> |
| 288 | <kind>E-Book-Ausgabe</kind> |
| 289 | <appearance>EPUB-Datei</appearance> |
| 290 | </edition> |
| 291 | <imprint> |
| Marc Kupietz | b660ed6 | 2024-03-16 11:45:53 +0100 | [diff] [blame] | 292 | <publisher><xsl:value-of select="$verlag"/></publisher> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 293 | <pubDate type="year"><xsl:value-of select="$j"/></pubDate> |
| 294 | <pubDate type="month"/> |
| 295 | <pubDate type="day"/> |
| Marc Kupietz | d8599fc | 2024-04-14 13:16:56 +0200 | [diff] [blame] | 296 | <pubPlace key="{$erscheinungsland}"><xsl:value-of select="$erscheinungsort"/></pubPlace> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 297 | </imprint> |
| 298 | <biblScope type="subsume"/> |
| 299 | <biblScope type="pp"/> |
| 300 | <biblScope type="vol"/> |
| 301 | <biblScope type="volume-title"/> |
| 302 | </monogr> |
| 303 | </biblStruct> |
| 304 | <reference assemblage="regular" type="complete"><xsl:value-of select="concat($sigle, ' ', $autor, ': ', $titel, '. ', $erscheinungsort, ': ', $verlag, ', ', $erscheinungsjahr)"/></reference> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 305 | </sourceDesc> |
| 306 | </fileDesc> |
| 307 | <profileDesc> |
| 308 | <creation> |
| 309 | <creatDate><xsl:value-of select="$j"/></creatDate> |
| 310 | </creation> |
| 311 | <textClass/> |
| 312 | <textDesc> |
| Marc Kupietz | 7df4ccc | 2024-03-16 15:27:45 +0100 | [diff] [blame] | 313 | <textType><xsl:value-of select="$texttype"/></textType> |
| 314 | <textTypeRef><xsl:value-of select="$texttype"/></textTypeRef> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 315 | <textDomain/> |
| 316 | </textDesc> |
| 317 | </profileDesc> |
| 318 | </idsHeader> |
| 319 | <text> |
| 320 | <body> |
| 321 | <!-- Call the template for each link in the TOC |
| 322 | <xsl:apply-templates select="//xhtml:ol[@class='toc']/xhtml:li/xhtml:a" mode="collect"/> --> |
| Marc Kupietz | 8f72730 | 2024-04-10 16:31:19 +0200 | [diff] [blame] | 323 | <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 Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 324 | </body> |
| 325 | </text> |
| 326 | </idsText> |
| 327 | </idsDoc> |
| 328 | </xsl:template> |
| 329 | |
| 330 | <xsl:template match="opf:item" mode="collect"> |
| 331 | <xsl:variable name="href" select="@href"/> |
| 332 | <xsl:message> |
| 333 | <xsl:text>converting: </xsl:text><xsl:value-of select="$href"/><xsl:text> </xsl:text><xsl:value-of select="$isbn"/> |
| 334 | </xsl:message> |
| 335 | <xsl:apply-templates select="doc(resolve-uri($href, base-uri()))/xhtml:html/xhtml:body"/> |
| 336 | </xsl:template> |
| 337 | |
| 338 | <xsl:template match="xhtml:body"> |
| 339 | <div type="chapter"> |
| 340 | <xsl:apply-templates/> |
| 341 | </div> |
| 342 | </xsl:template> |
| 343 | |
| Marc Kupietz | 4b1f595 | 2024-04-13 20:04:56 +0000 | [diff] [blame] | 344 | <xsl:template match="xhtml:body/text()"> |
| 345 | <p> |
| 346 | <xsl:value-of select="."/> |
| 347 | </p> |
| 348 | </xsl:template> |
| 349 | |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 350 | <xsl:template match="xhtml:title"> |
| 351 | <head> |
| 352 | <xsl:apply-templates/> |
| 353 | </head> |
| 354 | </xsl:template> |
| 355 | |
| 356 | <xsl:template match="xhtml:h1"> |
| 357 | <head> |
| 358 | <xsl:apply-templates/> |
| 359 | </head> |
| 360 | </xsl:template> |
| 361 | |
| Marc Kupietz | 3989c74 | 2024-04-21 17:33:49 +0200 | [diff] [blame] | 362 | <xsl:template match="xhtml:h2|xhtml:h3|xhtml:h4|xhtml:h5|xhtml:h6"> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 363 | <head type="sub"> |
| 364 | <xsl:apply-templates/> |
| 365 | </head> |
| 366 | </xsl:template> |
| 367 | |
| Marc Kupietz | 99ec04b | 2024-03-16 11:30:03 +0100 | [diff] [blame] | 368 | <xsl:template match="xhtml:em"> |
| 369 | <emph> |
| 370 | <xsl:apply-templates/> |
| 371 | </emph> |
| 372 | </xsl:template> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 373 | |
| Marc Kupietz | 30cc080 | 2024-04-10 16:37:04 +0200 | [diff] [blame] | 374 | <xsl:template match="xhtml:span[matches(@class, '(bold|italic|big|kursiv| )+')]"> |
| 375 | <xsl:variable name="class" select="replace(@class, 'kursiv', 'italic')"/> |
| 376 | <hi rend="{$class}"> |
| 377 | <xsl:apply-templates/> |
| 378 | </hi> |
| 379 | </xsl:template> |
| 380 | |
| Marc Kupietz | ad4d446 | 2024-04-26 17:43:08 +0200 | [diff] [blame] | 381 | <xsl:template match="xhtml:span[matches(@class, '(regular|norm)')]"> |
| Marc Kupietz | 5e87311 | 2024-04-15 06:51:08 +0200 | [diff] [blame] | 382 | <xsl:apply-templates/> |
| 383 | </xsl:template> |
| 384 | |
| Marc Kupietz | 3989c74 | 2024-04-21 17:33:49 +0200 | [diff] [blame] | 385 | <xsl:template match="xhtml:b|xhtml:span[@class='b']|xhtml:strong"> |
| Marc Kupietz | 30cc080 | 2024-04-10 16:37:04 +0200 | [diff] [blame] | 386 | <hi rend="bold"> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 387 | <xsl:apply-templates/> |
| 388 | </hi> |
| 389 | </xsl:template> |
| 390 | |
| Marc Kupietz | fb0f2c3 | 2024-04-26 17:43:18 +0200 | [diff] [blame^] | 391 | <xsl:template match="xhtml:i|xhtml:span[@class='i' or @class='it']"> |
| Marc Kupietz | 4b1f595 | 2024-04-13 20:04:56 +0000 | [diff] [blame] | 392 | <hi rend="italic"> |
| 393 | <xsl:apply-templates/> |
| 394 | </hi> |
| 395 | </xsl:template> |
| 396 | |
| 397 | |
| Marc Kupietz | 99ec04b | 2024-03-16 11:30:03 +0100 | [diff] [blame] | 398 | <xsl:template match="xhtml:sub|xhtml:span[@class='sub']"> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 399 | <hi rend="sub"> |
| 400 | <xsl:apply-templates/> |
| 401 | </hi> |
| 402 | </xsl:template> |
| 403 | |
| Marc Kupietz | 99ec04b | 2024-03-16 11:30:03 +0100 | [diff] [blame] | 404 | <xsl:template match="xhtml:sup|xhtml:span[@class='sup']"> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 405 | <hi rend="sup"> |
| 406 | <xsl:apply-templates/> |
| 407 | </hi> |
| 408 | </xsl:template> |
| 409 | |
| Marc Kupietz | 4b1f595 | 2024-04-13 20:04:56 +0000 | [diff] [blame] | 410 | <xsl:template match="xhtml:div[not(normalize-space(replace(., ' ', ' ')))]" priority="1.0"/> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 411 | |
| Marc Kupietz | bf47ae7 | 2024-04-14 14:21:43 +0200 | [diff] [blame] | 412 | <xsl:template match="xhtml:body/xhtml:div[./xhtml:h1|./xhtml:h2|./xhtml:h3]" priority="1.0"> |
| 413 | <xsl:apply-templates/> |
| 414 | </xsl:template> |
| Marc Kupietz | 4b1f595 | 2024-04-13 20:04:56 +0000 | [diff] [blame] | 415 | <xsl:template match="xhtml:div/xhtml:div"> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 416 | <p> |
| 417 | <xsl:apply-templates/> |
| 418 | </p> |
| 419 | </xsl:template> |
| 420 | |
| Marc Kupietz | 4b1f595 | 2024-04-13 20:04:56 +0000 | [diff] [blame] | 421 | <xsl:template match="xhtml:body/xhtml:div[(descendant::xhtml:p|descendant::xhtml:div)]"> |
| 422 | <div type="section"> |
| 423 | <xsl:apply-templates/> |
| 424 | </div> |
| 425 | </xsl:template> |
| 426 | |
| 427 | <xsl:template match="xhtml:body/xhtml:div[not(descendant::xhtml:p|descendant::xhtml:div)]"> |
| 428 | <div type="section"> |
| 429 | <p> |
| 430 | <xsl:apply-templates/> |
| 431 | </p> |
| 432 | </div> |
| 433 | </xsl:template> |
| 434 | |
| 435 | <xsl:template match="xhtml:p[not(descendant::xhtml:p|descendant::xhtml:div)]"> |
| 436 | <xsl:if test="normalize-space(.)"> |
| 437 | <p> |
| 438 | <xsl:apply-templates/> |
| 439 | </p> |
| 440 | </xsl:if> |
| 441 | </xsl:template> |
| 442 | |
| 443 | <xsl:template match="xhtml:p[descendant::xhtml:p|descendant::xhtml:div]"> |
| 444 | <xsl:if test="normalize-space(.)"> |
| 445 | <div type="section"> |
| 446 | <xsl:apply-templates/> |
| 447 | </div> |
| 448 | </xsl:if> |
| 449 | </xsl:template> |
| 450 | |
| Marc Kupietz | 09745e1 | 2024-04-21 12:54:10 +0200 | [diff] [blame] | 451 | <xsl:template match="xhtml:ul"> |
| 452 | <list type="unordered"> |
| 453 | <xsl:apply-templates/> |
| 454 | </list> |
| 455 | </xsl:template> |
| 456 | <xsl:template match="xhtml:ol"> |
| 457 | <list type="ordered"> |
| 458 | <xsl:apply-templates/> |
| 459 | </list> |
| 460 | </xsl:template> |
| 461 | <xsl:template match="xhtml:li"> |
| 462 | <item> |
| 463 | <xsl:apply-templates/> |
| 464 | </item> |
| 465 | </xsl:template> |
| 466 | <xsl:template match="xhtml:nav"> |
| Marc Kupietz | 1e6bfd1 | 2024-04-10 16:33:20 +0200 | [diff] [blame] | 467 | <!-- <gap reason="toc"/> --> |
| 468 | </xsl:template> |
| 469 | |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 470 | <xsl:template match="xhtml:img"> |
| 471 | <!-- <gap reason="image"/> --> |
| 472 | </xsl:template> |
| 473 | |
| Marc Kupietz | 1e6bfd1 | 2024-04-10 16:33:20 +0200 | [diff] [blame] | 474 | <xsl:template match="xhtml:audio"> |
| 475 | <!-- <gap reason="audio"/> --> |
| 476 | </xsl:template> |
| 477 | |
| Marc Kupietz | 09745e1 | 2024-04-21 12:54:10 +0200 | [diff] [blame] | 478 | <xsl:template match="xhtml:table"> |
| 479 | <!-- <gap reason="table"/> --> |
| 480 | </xsl:template> |
| Marc Kupietz | 4b1f595 | 2024-04-13 20:04:56 +0000 | [diff] [blame] | 481 | <xsl:template match="xhtml:body/xhtml:a"> |
| Marc Kupietz | 164a283 | 2024-04-14 21:00:48 +0200 | [diff] [blame] | 482 | <xsl:if test="normalize-space(.)"> |
| 483 | <p> |
| 484 | <ref target="{@href}"> |
| 485 | <xsl:apply-templates /> |
| 486 | </ref> |
| 487 | </p> |
| 488 | </xsl:if> |
| Marc Kupietz | 4b1f595 | 2024-04-13 20:04:56 +0000 | [diff] [blame] | 489 | </xsl:template> |
| 490 | |
| 491 | <xsl:template match="xhtml:body/xhtml:span"> |
| 492 | <xsl:message> |
| 493 | <xsl:text>unhandled span element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/> |
| 494 | </xsl:message> |
| 495 | <div type="section"> |
| 496 | <p> |
| 497 | <xsl:value-of select="."/> |
| 498 | </p> |
| 499 | </div> |
| 500 | </xsl:template> |
| 501 | <xsl:template match="xhtml:span"> |
| 502 | <xsl:message> |
| 503 | <xsl:text>unhandled span element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/> |
| 504 | </xsl:message> |
| 505 | <xsl:value-of select="."/> |
| 506 | </xsl:template> |
| Marc Kupietz | 99ec04b | 2024-03-16 11:30:03 +0100 | [diff] [blame] | 507 | <xsl:template match="xhtml:a"> |
| Marc Kupietz | 164a283 | 2024-04-14 21:00:48 +0200 | [diff] [blame] | 508 | <xsl:if test="normalize-space(.)"> |
| 509 | <ref target="{@href}"> |
| 510 | <xsl:apply-templates /> |
| 511 | </ref> |
| 512 | </xsl:if> |
| Marc Kupietz | 99ec04b | 2024-03-16 11:30:03 +0100 | [diff] [blame] | 513 | </xsl:template> |
| 514 | |
| 515 | <xsl:template match="xhtml:br"/> |
| 516 | |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 517 | <xsl:template match="xhtml:*"> |
| 518 | <xsl:message> |
| 519 | <xsl:text>unhandled element: </xsl:text><xsl:value-of select="concat(name(), ' ', string-join(./@*[normalize-space(.) != '']/concat(name(), ':', ., ' '), '_'))"/> |
| 520 | </xsl:message> |
| Marc Kupietz | 4b1f595 | 2024-04-13 20:04:56 +0000 | [diff] [blame] | 521 | <xsl:choose> |
| 522 | <xsl:when test="descendant::xhtml:div|descendant::xhtml:p|parent::xhtml:body"> |
| 523 | <div type="section"> |
| 524 | <xsl:apply-templates/> |
| 525 | </div> |
| 526 | </xsl:when> |
| 527 | <xsl:otherwise> |
| 528 | <xsl:apply-templates select="./*|node()"/> |
| 529 | </xsl:otherwise> |
| 530 | </xsl:choose> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 531 | <xsl:apply-templates/> |
| 532 | </xsl:template> |
| 533 | |
| 534 | <xsl:function name="ids:reversedAuthors"> |
| 535 | <xsl:param name="s" /> |
| 536 | <xsl:value-of |
| 537 | select=" |
| 538 | if (matches($s, ';')) then |
| 539 | concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; '))) |
| 540 | else |
| 541 | replace($s, '(.+) (.+)', '$2, $1')" |
| 542 | /> |
| 543 | </xsl:function> |
| 544 | |
| 545 | <xsl:function name="hlu:reversedAuthors"> |
| 546 | <xsl:param name="s"/> |
| 547 | <xsl:value-of |
| 548 | select="if (matches($s, ';')) then concat(ids:reversedAuthors(substring-before($s, ' ; ')), ' ; ', ids:reversedAuthors(substring-after($s, ' ; '))) else replace($s, '(.+),(.+)', '$2, $1')" |
| 549 | /> |
| 550 | </xsl:function> |
| 551 | |
| Marc Kupietz | 10903f3 | 2024-04-14 14:21:18 +0200 | [diff] [blame] | 552 | <xsl:variable name="city-country-map" as="map(xs:string, xs:string)"> |
| 553 | <xsl:map> |
| 554 | <xsl:map-entry key="'Axams'" select="'AT'"/> |
| 555 | <xsl:map-entry key="'Vienna'" select="'AT'"/> |
| 556 | <xsl:map-entry key="'Klagenfurt'" select="'AT'"/> |
| 557 | <xsl:map-entry key="'Graz'" select="'AT'"/> |
| 558 | <xsl:map-entry key="'Innsbruck'" select="'AT'"/> |
| 559 | <xsl:map-entry key="'Salzburg'" select="'AT'"/> |
| 560 | <xsl:map-entry key="'Bern'" select="'CH'"/> |
| 561 | <xsl:map-entry key="'Biel/Bienne'" select="'CH'"/> |
| 562 | <xsl:map-entry key="'Zurich'" select="'CH'"/> |
| 563 | <xsl:map-entry key="'Basel'" select="'CH'"/> |
| 564 | <xsl:map-entry key="'Geneva'" select="'CH'"/> |
| 565 | <xsl:map-entry key="'Lucerne'" select="'CH'"/> |
| 566 | <xsl:map-entry key="'Lausanne'" select="'CH'"/> |
| 567 | <xsl:map-entry key="'Winterthur'" select="'CH'"/> |
| 568 | <xsl:map-entry key="'St. Gallen'" select="'CH'"/> |
| 569 | <xsl:map-entry key="'Interlaken'" select="'CH'"/> |
| 570 | <xsl:map-entry key="'Brussels'" select="'BE'"/> |
| 571 | <xsl:map-entry key="'Antwerp'" select="'BE'"/> |
| 572 | <xsl:map-entry key="'Ghent'" select="'BE'"/> |
| 573 | <xsl:map-entry key="'Bruges'" select="'BE'"/> |
| 574 | <xsl:map-entry key="'Leuven'" select="'BE'"/> |
| 575 | <xsl:map-entry key="'Liege'" select="'BE'"/> |
| 576 | <xsl:map-entry key="'Charleroi'" select="'BE'"/> |
| 577 | <xsl:map-entry key="'Namur'" select="'BE'"/> |
| 578 | <xsl:map-entry key="'Mons'" select="'BE'"/> |
| 579 | <xsl:map-entry key="'Bangkok'" select="'TH'"/> |
| 580 | <xsl:map-entry key="'Copenhagen'" select="'DK'"/> |
| 581 | <xsl:map-entry key="'colatina'" select="'BR'"/> |
| 582 | <xsl:map-entry key="'Oakland Park'" select="'US'"/> |
| 583 | <xsl:map-entry key="'Istanbul'" select="'TR'"/> |
| 584 | <xsl:map-entry key="'Luxemburg'" select="'LU'"/> |
| 585 | <xsl:map-entry key="'Palma de Mallorca'" select="'ES'"/> |
| 586 | <xsl:map-entry key="'Swakopmund'" select="'NA'"/> |
| 587 | <xsl:map-entry key="'Victoria'" select="'CA'"/> |
| 588 | <xsl:map-entry key="'Wien'" select="'AT'"/> |
| 589 | <xsl:map-entry key="'Windhoek'" select="'NA'"/> |
| 590 | <xsl:map-entry key="'Zuerich'" select="'CH'"/> |
| 591 | <xsl:map-entry key="'Zürich'" select="'CH'"/> |
| 592 | <xsl:map-entry key="'Zug'" select="'CH'"/> |
| 593 | <xsl:map-entry key="'ZÜRICH'" select="'CH'"/> |
| 594 | </xsl:map> |
| Marc Kupietz | d8599fc | 2024-04-14 13:16:56 +0200 | [diff] [blame] | 595 | |
| Marc Kupietz | 10903f3 | 2024-04-14 14:21:18 +0200 | [diff] [blame] | 596 | </xsl:variable> |
| 597 | |
| 598 | <!-- Define the function --> |
| 599 | <xsl:function name="ids:country-city" as="xs:string"> |
| 600 | <xsl:param name="city" as="xs:string"/> |
| 601 | <xsl:sequence select="if (map:contains($city-country-map, $city)) then map:get($city-country-map, $city) else 'DE'"/> |
| 602 | </xsl:function> |
| Marc Kupietz | 1a42266 | 2024-03-16 09:34:10 +0100 | [diff] [blame] | 603 | </xsl:stylesheet> |