wzb-oai_dc-2-xmlbundle.xslt 37.7 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
        <xsl:element name="bundle">
            <xsl:element name="metadata">
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
                <xsl:variable name="sets">
                    <xsl:for-each select="//oai:setSpec" >
                        <xsl:value-of select="text()"/>
                        <xsl:text> ; </xsl:text>
                    </xsl:for-each>
                </xsl:variable>
                <xsl:choose>
                    <xsl:when test="not(contains($sets, '10419_48639 ;'))" >
                        <xsl:value-of select="error(QName('','filteraway'), 'is not in set 10419_48639')" />
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:apply-templates select="oai:OAI-PMH/oai:GetRecord/oai:record/oai:metadata/oai_dc:dc" />
                    </xsl:otherwise>
                </xsl:choose>
                
                
Steinberg, Jan's avatar
Steinberg, Jan committed
53
54
            </xsl:element>
        </xsl:element>
Steinberg, Jan's avatar
Steinberg, Jan committed
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
    </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" />
97
        <xsl:apply-templates select="dc:description" />
Steinberg, Jan's avatar
Steinberg, Jan committed
98
99
        <xsl:apply-templates select="dc:language" />
        <xsl:apply-templates select="dc:source[@xml:lang='de-DE']" />
100
101
102
        <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.*')]" />
103
104
        <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
105
106
107
108
109
        <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" />
110
111
        <xsl:apply-templates select="dc:subject[starts-with(.,'ddc:')]" />
        <xsl:apply-templates select="dc:subject[not(starts-with(.,'ddc:'))]" />
112
        <xsl:apply-templates select="dc:rights" />
Steinberg, Jan's avatar
Steinberg, Jan committed
113
114
    </xsl:template>
    
115
116
    <xsl:template match="dc:description">
      <xsl:if test="position() = 1">
Steinberg, Jan's avatar
Steinberg, Jan committed
117
118
119
120
121
122
        <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>
123
124
125
126
127
128
129
130
      </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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
    </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: '), ' ;')"/>
154
        </xsl:call-template>            
Steinberg, Jan's avatar
Steinberg, Jan committed
155
156
157
158
        <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="''"/>
159
            <xsl:with-param name="value" select="normalize-space(replace(substring-after(., ' ; '), 'No.',''))"/>
Steinberg, Jan's avatar
Steinberg, Jan committed
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
          </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>
    
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
    <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
193
194
    </xsl:template>
    
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
    <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>
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
    </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>
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
271
272
273
274
275
276
277
278
    </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
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
305
306
307
308
309
310
311
312
    </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>
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
537
538
539
540
541
542
543
544
    </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
545
546
547
    </xsl:template>
    
    <xsl:template match="dc:type">
548
        <!--workingPaper, article, book, report, Dorctoral Thesis-->
Steinberg, Jan's avatar
Steinberg, Jan committed
549
550
551
552
553
554
555
556
557
558
559
560
561
562
      <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>
563
564
565
566
567
568
569
570
571
572
573
574
            <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>
575
576
577
578
579
580
            <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>
581
582
583
584
585
586
587
                <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>
588
            </xsl:if>
Steinberg, Jan's avatar
Steinberg, Jan committed
589
590
591
592
593
594
595
596
597
598
599
600
        </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">
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
      <xsl:if test="not(//dc:type/text() = 'doc-type:article')">
        <xsl:choose>
            <xsl:when test="contains(text(),'Wissenschaftszentrum Berlin')">
                <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: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="Berlin"/>
                </xsl:call-template>
            </xsl:when>
            <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="normalize-space(substring-after(text(), ': '))"/>
                  </xsl:call-template>
            </xsl:when>
        </xsl:choose>    
      </xsl:if>
Steinberg, Jan's avatar
Steinberg, Jan committed
630
631
  </xsl:template>
  
632
    <xsl:template match="dc:subject[starts-with(.,'ddc:')]">
Steinberg, Jan's avatar
Steinberg, Jan committed
633
634
    <xsl:if test="starts-with(.,'ddc:')">
      <xsl:call-template name="new-metadatum">
635
          <xsl:with-param name="key" select="'internal.identifier.ddc'"/>
Steinberg, Jan's avatar
Steinberg, Jan committed
636
637
638
639
640
        <xsl:with-param name="language" select="''"/>
        <xsl:with-param name="value" select="substring-after(., 'ddc:')"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>
641
642
643
644
645
646
647
648
649
    
    <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
650
651
  
    <xsl:template match="dc:title">
652
        <!--xsl:variable name="sanitizedLanguage" select="zoai:sanitizeLanguage( @xml:lang )" /-->
Steinberg, Jan's avatar
Steinberg, Jan committed
653
654
655
        <xsl:variable name="sanitizedMainLanguage" select="zoai:sanitizeLanguage( /oai:OAI-PMH/oai:GetRecord/oai:record/oai:metadata/oai_dc:dc/dc:language[1] )" />
        
        <xsl:choose>
656
            <xsl:when test="string-length($sanitizedMainLanguage) > 0 and position() = 1">
Steinberg, Jan's avatar
Steinberg, Jan committed
657
658
                <xsl:call-template name="new-metadatum">
                    <xsl:with-param name="key" select="'dc.title'"/>
659
660
                    <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
661
662
                </xsl:call-template>
            </xsl:when>
663
            <xsl:when test="$sanitizedMainLanguage = '' and position() = 1">
Steinberg, Jan's avatar
Steinberg, Jan committed
664
665
                <xsl:call-template name="new-metadatum">
                    <xsl:with-param name="key" select="'dc.title'"/>
666
667
668
669
670
671
672
673
674
                    <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
675
676
677
678
679
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="new-metadatum">
                    <xsl:with-param name="key" select="'dc.title.alternative'"/>
680
                    <xsl:with-param name="language" select="$sanitizedMainLanguage"/>
Steinberg, Jan's avatar
Steinberg, Jan committed
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
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
                    <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>