wzb-oai_dc-2-xmlbundle.xslt 37 KB
Newer Older
Steinberg, Jan's avatar
Steinberg, Jan committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
    xmlns:cc="http://www.d-nb.de/standards/cc/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:dcmitype="http://purl.org/dc/dcmitype/"
    xmlns:dcterms="http://purl.org/dc/terms/"
    xmlns:ddb="http://www.d-nb.de/standards/ddb/"
    xmlns:dini="http://www.d-nb.de/standards/xmetadissplus/type/"
    xmlns:doi="http://www.d-nb.de/standards/doi/"
    xmlns:hdl="http://www.d-nb.de/standards/hdl/"
    xmlns:mml="http://www.w3.org/1998/Math/MathML"
    xmlns:nlm="http://dtd.nlm.nih.gov/publishing/2.3"
    xmlns:oai="http://www.openarchives.org/OAI/2.0/"
    xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
    xmlns:pc="http://www.d-nb.de/standards/pc/"
    xmlns:thesis="http://www.ndltd.org/standards/metadata/etdms/1.0/"
    xmlns:urn="http://www.d-nb.de/standards/urn/"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns:xMetaDiss="http://www.d-nb.de/standards/xmetadissplus/"
    xmlns:xoai="http://www.lyncode.com/xoai"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:zoai="http://git.gesis.org/dda/zoai">
    
    <xsl:output indent="yes"/>
    <xsl:strip-space elements="*"/>
    <!-- <xsl:copy-of select="."/>  -->
    <!-- <xsl:message terminate="no">here is some message for stderr, e.g. <xsl:value-of select='text()' /> </xsl:message> -->
    
    
    <!-- override default template -->
    <xsl:template match="*" />
    
    <xsl:template match="/">
Steinberg, Jan's avatar
Steinberg, Jan committed
35
36
37
38
39
        <xsl:element name="bundle">
            <xsl:element name="metadata">
                <xsl:apply-templates select="oai:OAI-PMH/oai:GetRecord/oai:record/oai:metadata/oai_dc:dc" />
            </xsl:element>
        </xsl:element>
Steinberg, Jan's avatar
Steinberg, Jan committed
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
    </xsl:template>
    
    <xsl:template match="oai:OAI-PMH/oai:GetRecord/oai:record/oai:metadata/oai_dc:dc">
        <xsl:call-template name="new-metadatum">
            <xsl:with-param name="key" select="'dc.description.pubstatus'"/>
            <xsl:with-param name="language" select="''"/>
            <xsl:with-param name="value" select="'1'"/>
        </xsl:call-template>
        
        <xsl:call-template name="new-metadatum">
            <xsl:with-param name="key" select="'dc.publisher.country'"/>
            <xsl:with-param name="language" select="''"/>
            <xsl:with-param name="value" select="'DEU'"/>
        </xsl:call-template>
      
      <xsl:call-template name="new-metadatum">
        <xsl:with-param name="key" select="'ssoar.contributor.institution'"/>
        <xsl:with-param name="language" select="''"/>
        <xsl:with-param name="value" select="'WZB'"/>
      </xsl:call-template>
        
        <!-- <xsl:call-template name="new-metadatum">
            <xsl:with-param name="key" select="'ssoar.urn.registration'"/>
            <xsl:with-param name="language" select="''"/>
            <xsl:with-param name="value" select="'false'"/>
        </xsl:call-template>-->
        
        <xsl:call-template name="new-metadatum">
            <xsl:with-param name="key" select="'dc.description.review'"/>
            <xsl:with-param name="language" select="''"/>
            <xsl:with-param name="value" select="'4'"/>
        </xsl:call-template>
  
        <xsl:call-template name="new-metadatum">
            <xsl:with-param name="key" select="'internal.status'"/>
            <xsl:with-param name="language" select="''"/>
            <xsl:with-param name="value" select="'formal und inhaltlich fertig erschlossen'"/>
        </xsl:call-template>
        
        
        <!--xsl:apply-templates select="dc:type[@xml:lang='en-US']" /-->
        <xsl:apply-templates select="dc:title" />
82
        <xsl:apply-templates select="dc:description" />
Steinberg, Jan's avatar
Steinberg, Jan committed
83
84
        <xsl:apply-templates select="dc:language" />
        <xsl:apply-templates select="dc:source[@xml:lang='de-DE']" />
85
86
87
        <xsl:apply-templates select="dc:identifier[matches(text(), '^http.*')]" />
        <xsl:apply-templates select="dc:identifier[matches(text(), '^Journal.*')]" />
        <xsl:apply-templates select="dc:identifier[matches(text(), '^doi.*')]" />
88
89
        <xsl:apply-templates select="dc:identifier[matches(text(), '^urn.*') and not(matches(text(), '^.*isbn:\d+.*'))]" />
        <xsl:apply-templates select="dc:identifier[matches(text(), '^.*isbn:\d+.*')]" />
Steinberg, Jan's avatar
Steinberg, Jan committed
90
91
92
93
94
        <xsl:apply-templates select="dc:type" />
        <xsl:apply-templates select="dc:relation" />
        <xsl:apply-templates select="dc:creator" />
        <xsl:apply-templates select="dc:date" />
        <xsl:apply-templates select="dc:publisher" />
95
96
        <xsl:apply-templates select="dc:subject[starts-with(.,'ddc:')]" />
        <xsl:apply-templates select="dc:subject[not(starts-with(.,'ddc:'))]" />
97
        <xsl:apply-templates select="dc:rights" />
Steinberg, Jan's avatar
Steinberg, Jan committed
98
99
    </xsl:template>
    
100
101
    <xsl:template match="dc:description">
      <xsl:if test="position() = 1">
Steinberg, Jan's avatar
Steinberg, Jan committed
102
103
104
105
106
107
        <xsl:variable name="sanitizedLanguage" select="zoai:sanitizeLanguage( ../dc:language/text() )" />
        <xsl:call-template name="new-metadatum">
          <xsl:with-param name="key" select="'dc.description.abstract'"/>
          <xsl:with-param name="language" select="$sanitizedLanguage"/>
          <xsl:with-param name="value" select="normalize-space(replace(text(),'[‹›»«]','&quot;'))"/>
        </xsl:call-template>
108
109
110
111
112
113
114
115
      </xsl:if>
        <xsl:if test="starts-with(text(), 'Zugl.: ') or starts-with(text(), 'Dissertationsschrift ')or starts-with(text(), 'PhD Thesis')">
            <xsl:call-template name="new-metadatum">
                <xsl:with-param name="key" select="'dc.type.document'"/>
                <xsl:with-param name="language" select="''"/>
                <xsl:with-param name="value" select="'9'"/>
            </xsl:call-template>
        </xsl:if>
Steinberg, Jan's avatar
Steinberg, Jan committed
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
    </xsl:template>
    <xsl:template match="dc:date">
        <xsl:call-template name="new-metadatum">
            <xsl:with-param name="key" select="'dc.date.issued'"/>
            <xsl:with-param name="language" select="''"/>
            <xsl:with-param name="value" select="substring(text(),1,4)"/>
        </xsl:call-template>
    </xsl:template>
    
    <xsl:template match="dc:creator">
        <xsl:call-template name="new-metadatum">
            <xsl:with-param name="key" select="'dc.contributor.author'"/>
            <xsl:with-param name="language" select="''"/>
            <xsl:with-param name="value" select="text()"/>
        </xsl:call-template>
    </xsl:template>
    
    <xsl:template match="dc:relation">
      <xsl:if test="starts-with(., 'Series: ')">
        <xsl:call-template name="new-metadatum">
          <xsl:with-param name="key" select="'dc.source.series'"/>
          <xsl:with-param name="language" select="''"/>
          <xsl:with-param name="value" select="substring-before(substring-after(., 'Series: '), ' ;')"/>
        </xsl:call-template>
140
141
142
143
144
145
146
          <xsl:if test="/OAI-PMH/GetRecord/record/metadata/oai_dc:dc/dc:type[starts-with(.,'doc-type')] != 'doc-type:book'">
            <xsl:call-template name="new-metadatum">
                <xsl:with-param name="key" select="'dc.contributor.corporateeditor'"/>
                <xsl:with-param name="language" select="''"/>
                <xsl:with-param name="value" select="'381'"/>
            </xsl:call-template>
          </xsl:if>              
Steinberg, Jan's avatar
Steinberg, Jan committed
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
        <xsl:if test="contains(., ' ; ')">
          <xsl:call-template name="new-metadatum">
            <xsl:with-param name="key" select="'dc.source.volume'"/>
            <xsl:with-param name="language" select="''"/>
            <xsl:with-param name="value" select="replace(substring-after(., ' ; '), 'No.','')"/>
          </xsl:call-template>
        </xsl:if>
      </xsl:if>
      
       
    </xsl:template>
    
    <xsl:template match="dc:language">
        <xsl:if test="position()=1">
        <xsl:variable name="sanitizedLanguage" select="zoai:sanitizeLanguage( text() )" />
            <xsl:call-template name="new-metadatum">
                <xsl:with-param name="key" select="'dc.language'"/>
                <xsl:with-param name="language" select="''"/>
                <xsl:with-param name="value" select="$sanitizedLanguage"/>
            </xsl:call-template>
        </xsl:if>
    </xsl:template>
    
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
    <xsl:template match="dc:identifier[matches(text(), '^http.*')]">
        <xsl:if test="not(contains(text(), 'handle'))">
            <xsl:call-template name="new-metadatum">
                <xsl:with-param name="key" select="'dc.identifier.url'"/>
                <xsl:with-param name="language" select="''"/>
                <xsl:with-param name="value" select="text()"/>
            </xsl:call-template>
        </xsl:if>
        <xsl:if test="contains(text(), 'handle')">
            <xsl:call-template name="new-metadatum">
                <xsl:with-param name="key" select="'dc.identifier.handle'"/>
                <xsl:with-param name="language" select="''"/>
                <xsl:with-param name="value" select="text()"/>
            </xsl:call-template>
        </xsl:if>
Steinberg, Jan's avatar
Steinberg, Jan committed
185
186
    </xsl:template>
    
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
    <xsl:template match="dc:identifier[matches(text(), '^doi.*')]">
        <xsl:choose>
            <xsl:when test="contains(.,'doi.org')">
                <xsl:call-template name="new-metadatum">
                    <xsl:with-param name="key" select="'dc.identifier.doi'"/>
                    <xsl:with-param name="language" select="''"/>
                    <xsl:with-param name="value" select="text()"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="new-metadatum">
                    <xsl:with-param name="key" select="'dc.identifier.doi'"/>
                    <xsl:with-param name="language" select="''"/>
                    <xsl:with-param name="value" select="concat('https://doi.org/', substring-after(text(), 'doi:'))"/>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
    </xsl:template>
    
    <xsl:template match="dc:identifier[matches(text(), '^urn.*') and not(matches(text(), '^.*isbn:\d+.*'))]">
        <xsl:choose>
            <xsl:when test="contains(.,'https://nbn-resolving.org')">
                <xsl:call-template name="new-metadatum">
                    <xsl:with-param name="key" select="'dc.identifier.urn'"/>
                    <xsl:with-param name="language" select="''"/>
                    <xsl:with-param name="value" select="substring-after(text(),'nbn-resolving.org/')"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="new-metadatum">
                    <xsl:with-param name="key" select="'dc.identifier.urn'"/>
                    <xsl:with-param name="language" select="''"/>
                    <xsl:with-param name="value" select="text()"/>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    
    <xsl:template match="dc:identifier[matches(text(), '^.*isbn:\d+.*')]">
        <xsl:call-template name="new-metadatum">
            <xsl:with-param name="key" select="'dc.identifier.isbn'"/>
            <xsl:with-param name="language" select="''"/>
            <xsl:with-param name="value" select="substring-after(text(), 'isbn:')"/>
        </xsl:call-template>
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
    </xsl:template>
    
    <xsl:template match="dc:identifier[matches(text(), '^Journal.*')]">
        <xsl:for-each select="tokenize(text(), ' ; ')">
            <xsl:if test="starts-with(., 'Journal: ')">
                <xsl:call-template name="new-metadatum">
                    <xsl:with-param name="key" select="'dc.source.journal'"/>
                    <xsl:with-param name="language" select="''"/>
                    <xsl:with-param name="value" select="normalize-space(substring-after(.,'Journal:'))"/>
                </xsl:call-template>
            </xsl:if>
            <xsl:if test="starts-with(., 'ISSN: ')">
                <xsl:call-template name="new-metadatum">
                    <xsl:with-param name="key" select="'dc.identifier.issn'"/>
                    <xsl:with-param name="language" select="''"/>
                    <xsl:with-param name="value" select="normalize-space(substring-after(.,'ISSN:'))"/>
                </xsl:call-template>
            </xsl:if>
            <xsl:if test="starts-with(., 'Volume: ')">
                <xsl:call-template name="new-metadatum">
                    <xsl:with-param name="key" select="'dc.source.volume'"/>
                    <xsl:with-param name="language" select="''"/>
                    <xsl:with-param name="value" select="normalize-space(substring-after(.,'Volume:'))"/>
                </xsl:call-template>
            </xsl:if>
            <xsl:if test="starts-with(., 'Issue: ')">
                <xsl:call-template name="new-metadatum">
                    <xsl:with-param name="key" select="'dc.source.issue'"/>
                    <xsl:with-param name="language" select="''"/>
                    <xsl:with-param name="value" select="normalize-space(substring-after(.,'Issue:'))"/>
                </xsl:call-template>
            </xsl:if>
            <xsl:if test="starts-with(., 'Pages: ')">
                <xsl:call-template name="new-metadatum">
                    <xsl:with-param name="key" select="'dc.source.pageinfo'"/>
                    <xsl:with-param name="language" select="''"/>
                    <xsl:with-param name="value" select="normalize-space(substring-after(.,'Pages:'))"/>
                </xsl:call-template>
            </xsl:if>
        </xsl:for-each>
Steinberg, Jan's avatar
Steinberg, Jan committed
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
    </xsl:template>
    
    <xsl:template match="dc:source[@xml:lang='de-DE']">
        <xsl:variable name="pageinfo" select="tokenize( text(),'; ' )[last()]" />
        <xsl:if test="$pageinfo != '' and matches($pageinfo, '^\d+(-\d+)?')">
            <xsl:call-template name="new-metadatum">
                <xsl:with-param name="key" select="'dc.source.pageinfo'"/>
                <xsl:with-param name="language" select="''"/>
                <xsl:with-param name="value" select="$pageinfo"/>
            </xsl:call-template>
        </xsl:if>
        <xsl:if test="$pageinfo != '' and matches($pageinfo, '^\w\d+(-\w\d+)?')">
            <xsl:call-template name="new-metadatum">
                <xsl:with-param name="key" select="'dc.source.pageinfo'"/>
                <xsl:with-param name="language" select="''"/>
                <xsl:with-param name="value" select="$pageinfo"/>
            </xsl:call-template>
        </xsl:if>
        <xsl:variable name="issue" select="substring-before(substring-after(text(),'Nr. '),' ')" />
        <xsl:if test="$issue != '' and matches ($issue, '\d+')">
            <xsl:call-template name="new-metadatum">
                <xsl:with-param name="key" select="'dc.source.issue'"/>
                <xsl:with-param name="language" select="''"/>
                <xsl:with-param name="value" select="$issue"/>
            </xsl:call-template>
        </xsl:if>
        <xsl:variable name="issuetopic" select="substring-before(substring-after(text(),'): '),'; ')" />
        <xsl:if test="$issuetopic != ''">
            <xsl:call-template name="new-metadatum">
                <xsl:with-param name="key" select="'dc.source.issuetopic'"/>
                <xsl:with-param name="language" select="''"/>
                <xsl:with-param name="value" select="replace($issuetopic,'•',':')"/>
            </xsl:call-template>
        </xsl:if>
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
    </xsl:template>
    
    <xsl:template match="dc:rights">
        <xsl:if test="matches(text(), '^.*creativecommons.org.*')">
            
            <xsl:choose>
                <xsl:when test="contains(text(), '/by-sa/1.0')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="21"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/by-sa/2.0')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="22"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/by-sa/3.0')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="23"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/by-sa/4.0')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="24"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/by-sa/')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="8"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/by-nc-nd/1.0')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="17"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/by-nc-nd/2.0')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="18"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/by-nc-nd/3.0')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="19"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/by-nc-nd/4.0')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="20"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/by-nc-nd/')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="20"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/by-nc-sa/1.0')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="33"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/by-nc-sa/2.0')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="34"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/by-nc-sa/3.0')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="35"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/by-nc-sa/4.0')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="36"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/by-nc-sa/')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="11"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/by/1.0')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="13"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/by/2.0')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="14"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/by/3.0')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="15"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/by/4.0')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="16"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/by/')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="1"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/by-nc/1.0')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="29"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/by-nc/2.0')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="30"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/by-nc/3.0')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="31"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/by-nc/4.0')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="32"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/by-nc/')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="10"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/by-nd/1.0')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="25"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/by-nd/2.0')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="26"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/by-nd/3.0')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="27"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/by-nd/4.0')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="28"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/by-nd/')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="29"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:when test="contains(text(), '/cc0/')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.rights.licence'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="13"/>
                    </xsl:call-template>
                </xsl:when>
            </xsl:choose>
        </xsl:if>
        <xsl:if test="not(matches(text(), '^.*creativecommons.org.*')) and not(matches(text(), 'http://www.econstor.eu/dspace/Nutzungsbedingungen'))">
            <xsl:call-template name="new-metadatum">
                <xsl:with-param name="key" select="'dc.rights.licence'"/>
                <xsl:with-param name="language" select="''"/>
                <xsl:with-param name="value" select="3"/>
            </xsl:call-template>
        </xsl:if>
Steinberg, Jan's avatar
Steinberg, Jan committed
537
538
539
    </xsl:template>
    
    <xsl:template match="dc:type">
540
        <!--workingPaper, article, book, report, Dorctoral Thesis-->
Steinberg, Jan's avatar
Steinberg, Jan committed
541
542
543
544
545
546
547
548
549
550
551
552
553
554
      <xsl:choose>
        <xsl:when test="starts-with(., 'doc-type')">
          <xsl:if test="contains(., 'workingPaper')">
            <xsl:call-template name="new-metadatum">
                <xsl:with-param name="key" select="'dc.type.stock'"/>
                <xsl:with-param name="language" select="''"/>
                <xsl:with-param name="value" select="'monograph'"/>
            </xsl:call-template>
            <xsl:call-template name="new-metadatum">
              <xsl:with-param name="key" select="'dc.type.document'"/>
              <xsl:with-param name="language" select="''"/>
              <xsl:with-param name="value" select="'3'"/>
            </xsl:call-template>
          </xsl:if>
555
556
557
558
559
560
561
562
563
564
565
566
            <xsl:if test="contains(., 'article')">
                <xsl:call-template name="new-metadatum">
                    <xsl:with-param name="key" select="'dc.type.stock'"/>
                    <xsl:with-param name="language" select="''"/>
                    <xsl:with-param name="value" select="'article'"/>
                </xsl:call-template>
                <xsl:call-template name="new-metadatum">
                    <xsl:with-param name="key" select="'dc.type.document'"/>
                    <xsl:with-param name="language" select="''"/>
                    <xsl:with-param name="value" select="'32'"/>
                </xsl:call-template>
            </xsl:if>
567
568
569
570
571
572
            <xsl:if test="contains(., 'book') or contains(., 'report') or contains(., 'doctoralThesis')">
                <xsl:call-template name="new-metadatum">
                    <xsl:with-param name="key" select="'dc.type.stock'"/>
                    <xsl:with-param name="language" select="''"/>
                    <xsl:with-param name="value" select="'monograph'"/>
                </xsl:call-template>
573
574
575
576
577
578
579
                <xsl:if test="contains(., 'report')">
                    <xsl:call-template name="new-metadatum">
                        <xsl:with-param name="key" select="'dc.type.document'"/>
                        <xsl:with-param name="language" select="''"/>
                        <xsl:with-param name="value" select="'12'"/>
                    </xsl:call-template>
                </xsl:if>
580
            </xsl:if>
Steinberg, Jan's avatar
Steinberg, Jan committed
581
582
583
584
585
586
587
588
589
590
591
592
        </xsl:when>
        <xsl:otherwise>
          <xsl:call-template name="new-metadatum">
            <xsl:with-param name="key" select="'dc.type.stock'"/>
            <xsl:with-param name="language" select="''"/>
            <xsl:with-param name="value" select="'monograph'"/>
          </xsl:call-template>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:template>
  
  <xsl:template match="dc:publisher">
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
      <xsl:choose>
          <xsl:when test="contains(text(), ': ')">
              <xsl:call-template name="new-metadatum">
                  <xsl:with-param name="key" select="'dc.publisher.city'"/>
                  <xsl:with-param name="language" select="''"/>
                  <xsl:with-param name="value" select="substring-before(text(), ': ')"/>
              </xsl:call-template>
              <xsl:call-template name="new-metadatum">
                  <xsl:with-param name="key" select="'dc.publisher'"/>
                  <xsl:with-param name="language" select="''"/>
                  <xsl:with-param name="value" select="substring-after(text(), ': ')"/>
              </xsl:call-template>
          </xsl:when>
          <xsl:otherwise>
              <xsl:call-template name="new-metadatum">
                  <xsl:with-param name="key" select="'dc.publisher'"/>
                  <xsl:with-param name="language" select="''"/>
                  <xsl:with-param name="value" select="text()"/>
              </xsl:call-template>
          </xsl:otherwise>
      </xsl:choose>
Steinberg, Jan's avatar
Steinberg, Jan committed
614
615
  </xsl:template>
  
616
    <xsl:template match="dc:subject[starts-with(.,'ddc:')]">
Steinberg, Jan's avatar
Steinberg, Jan committed
617
618
    <xsl:if test="starts-with(.,'ddc:')">
      <xsl:call-template name="new-metadatum">
619
          <xsl:with-param name="key" select="'internal.identifier.ddc'"/>
Steinberg, Jan's avatar
Steinberg, Jan committed
620
621
622
623
624
        <xsl:with-param name="language" select="''"/>
        <xsl:with-param name="value" select="substring-after(., 'ddc:')"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>
625
626
627
628
629
630
631
632
633
    
    <xsl:template match="dc:subject[not(starts-with(.,'ddc:'))]">
        <xsl:variable name="sanitizedMainLanguage" select="zoai:sanitizeLanguage( /oai:OAI-PMH/oai:GetRecord/oai:record/oai:metadata/oai_dc:dc/dc:language[1] )" />
        <xsl:call-template name="new-metadatum">
            <xsl:with-param name="key" select="'dc.subject.other'"/>
            <xsl:with-param name="language" select="$sanitizedMainLanguage"/>
            <xsl:with-param name="value" select="text()"/>
        </xsl:call-template>
    </xsl:template>
Steinberg, Jan's avatar
Steinberg, Jan committed
634
635
  
    <xsl:template match="dc:title">
636
        <!--xsl:variable name="sanitizedLanguage" select="zoai:sanitizeLanguage( @xml:lang )" /-->
Steinberg, Jan's avatar
Steinberg, Jan committed
637
638
639
        <xsl:variable name="sanitizedMainLanguage" select="zoai:sanitizeLanguage( /oai:OAI-PMH/oai:GetRecord/oai:record/oai:metadata/oai_dc:dc/dc:language[1] )" />
        
        <xsl:choose>
640
            <xsl:when test="string-length($sanitizedMainLanguage) > 0 and position() = 1">
Steinberg, Jan's avatar
Steinberg, Jan committed
641
642
                <xsl:call-template name="new-metadatum">
                    <xsl:with-param name="key" select="'dc.title'"/>
643
644
                    <xsl:with-param name="language" select="$sanitizedMainLanguage"/>
                    <xsl:with-param name="value" select="normalize-space(replace(text(),'[‹›»«]','&quot;'))"/>
Steinberg, Jan's avatar
Steinberg, Jan committed
645
646
                </xsl:call-template>
            </xsl:when>
647
            <xsl:when test="$sanitizedMainLanguage = '' and position() = 1">
Steinberg, Jan's avatar
Steinberg, Jan committed
648
649
                <xsl:call-template name="new-metadatum">
                    <xsl:with-param name="key" select="'dc.title'"/>
650
651
652
653
654
655
656
657
658
                    <xsl:with-param name="language" select="'de'"/>
                    <xsl:with-param name="value" select="normalize-space(replace(text(),'[‹›»«]','&quot;'))"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:when test="$sanitizedMainLanguage = '' and position() > 1">
                <xsl:call-template name="new-metadatum">
                    <xsl:with-param name="key" select="'dc.title.alternative'"/>
                    <xsl:with-param name="language" select="'de'"/>
                    <xsl:with-param name="value" select="normalize-space(replace(text(),'[‹›»«]','&quot;'))"/>
Steinberg, Jan's avatar
Steinberg, Jan committed
659
660
661
662
663
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="new-metadatum">
                    <xsl:with-param name="key" select="'dc.title.alternative'"/>
664
                    <xsl:with-param name="language" select="$sanitizedMainLanguage"/>
Steinberg, Jan's avatar
Steinberg, Jan committed
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
                    <xsl:with-param name="value" select="normalize-space(replace(text(),'[‹›»«]','&quot;'))"/>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
        
    </xsl:template>
    
    
    <xsl:template name="new-metadatum">
        <xsl:param name="key" />
        <xsl:param name="language" />
        <xsl:param name="value" />
        <xsl:element name="metadatum">
            
            <xsl:element name="key">
                <xsl:value-of select="$key" />
            </xsl:element>
            
            <xsl:if test="$language != ''">
                <xsl:variable name="sanitizedLanguage" select="zoai:sanitizeLanguage($language)" />
                
                <xsl:element name="language">
                    <xsl:value-of select="$sanitizedLanguage" />
                </xsl:element>
            </xsl:if>
            
            <xsl:element name="value">
                <xsl:value-of select="$value" />
            </xsl:element>
            
        </xsl:element>
    </xsl:template>
    
    <xsl:function name="zoai:sanitizeLanguage">
        <xsl:param name="inputLanguage" />
        <xsl:choose>
            <xsl:when test="$inputLanguage = 'ger' or $inputLanguage = 'DE' or $inputLanguage = 'de-DE' or $inputLanguage = 'deu'">
                <xsl:value-of select="'de'" />
            </xsl:when>
            <xsl:when test="$inputLanguage = 'eng' or $inputLanguage = 'EN' or $inputLanguage = 'en-US' or $inputLanguage = 'en-GB'">
                <xsl:value-of select="'en'" />
            </xsl:when>
            <xsl:when test="$inputLanguage = 'ukr' or $inputLanguage = 'uk-UA'">
                <xsl:value-of select="'uk'" />
            </xsl:when>
            <xsl:when test="$inputLanguage = 'rus' or $inputLanguage = 'ru-RU'">
                <xsl:value-of select="'ru'" />
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$inputLanguage" />
            </xsl:otherwise>
        </xsl:choose>
    </xsl:function>
</xsl:stylesheet>