-
Notifications
You must be signed in to change notification settings - Fork 0
/
mods_to_dc.xsl
554 lines (490 loc) · 16.9 KB
/
mods_to_dc.xsl
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
35
36
37
38
39
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
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
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
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
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
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mods="http://www.loc.gov/mods/v3" exclude-result-prefixes="mods" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:srw_dc="info:srw/schema/1/dc-schema" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--
Rewrote template for transformation of subjects. Instead of concatenating values into one dc:subject field, each type of subject is transformed to either dc:subject or dc:coverage. 2014-02-10. JME
Version 1.4 2013-12-13 [email protected]
Upgraded to MODS 3.5
Version 1.3 2013-12-09 [email protected]
Fixed date transformation for dates without start/end points
Version 1.2 2012-08-12 WS
Upgraded to MODS 3.4
Revision 1.1 2007-05-18 [email protected]
Added modsCollection conversion to DC SRU
Updated introductory documentation
Version 1.0 2007-05-04 [email protected]
This stylesheet transforms MODS version 3.4 records and collections of records to simple Dublin Core (DC) records,
based on the Library of Congress' MODS to simple DC mapping <http://www.loc.gov/standards/mods/mods-dcsimple.html>
The stylesheet will transform a collection of MODS 3.4 records into simple Dublin Core (DC)
as expressed by the SRU DC schema <http://www.loc.gov/standards/sru/dc-schema.xsd>
The stylesheet will transform a single MODS 3.4 record into simple Dublin Core (DC)
as expressed by the OAI DC schema <http://www.openarchives.org/OAI/2.0/oai_dc.xsd>
Because MODS is more granular than DC, transforming a given MODS element or subelement to a DC element frequently results in less precise tagging,
and local customizations of the stylesheet may be necessary to achieve desired results.
This stylesheet makes the following decisions in its interpretation of the MODS to simple DC mapping:
When the roleTerm value associated with a name is creator, then name maps to dc:creator
When there is no roleTerm value associated with name, or the roleTerm value associated with name is a value other than creator, then name maps to dc:contributor
Start and end dates are presented as span dates in dc:date and in dc:coverage
When the first subelement in a subject wrapper is topic, subject subelements are strung together in dc:subject with hyphens separating them
Some subject subelements, i.e., geographic, temporal, hierarchicalGeographic, and cartographics, are also parsed into dc:coverage
The subject subelement geographicCode is dropped in the transform
-->
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:choose>
<!-- WS: updated schema location -->
<xsl:when test="//mods:modsCollection">
<srw_dc:dcCollection xsi:schemaLocation="info:srw/schema/1/dc-schema http://www.loc.gov/standards/sru/resources/dc-schema.xsd">
<xsl:apply-templates/>
<xsl:for-each select="mods:modsCollection/mods:mods">
<srw_dc:dc xsi:schemaLocation="info:srw/schema/1/dc-schema http://www.loc.gov/standards/sru/resources/dc-schema.xsd">
<xsl:apply-templates/>
</srw_dc:dc>
</xsl:for-each>
</srw_dc:dcCollection>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="mods:mods">
<oai_dc:dc xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
<xsl:apply-templates/>
</oai_dc:dc>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="mods:titleInfo">
<dc:title>
<xsl:value-of select="mods:nonSort"/>
<xsl:if test="mods:nonSort">
<xsl:text> </xsl:text>
</xsl:if>
<xsl:value-of select="mods:title"/>
<xsl:if test="mods:subTitle">
<xsl:text>: </xsl:text>
<xsl:value-of select="mods:subTitle"/>
</xsl:if>
<xsl:if test="mods:partNumber">
<xsl:text>. </xsl:text>
<xsl:value-of select="mods:partNumber"/>
</xsl:if>
<xsl:if test="mods:partName">
<xsl:text>. </xsl:text>
<xsl:value-of select="mods:partName"/>
</xsl:if>
</dc:title>
</xsl:template>
<!-- tmee mods 3.5 -->
<xsl:template match="mods:name">
<xsl:choose>
<xsl:when test="mods:role/mods:roleTerm[@type='text']='creator' or mods:role/mods:roleTerm[@type='code']='cre' ">
<dc:creator>
<xsl:call-template name="name"/>
<xsl:choose>
<xsl:when test="mods:etal">
<xsl:value-of select="."/>
</xsl:when>
<xsl:otherwise>
<xsl:text>et al</xsl:text>
</xsl:otherwise>
</xsl:choose>
</dc:creator>
</xsl:when>
<xsl:otherwise>
<dc:creator>
<xsl:call-template name="name"/>
<xsl:if test="mods:etal">et al.</xsl:if>
</dc:creator>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="mods:classification">
<dc:subject>
<xsl:value-of select="."/>
</dc:subject>
</xsl:template>
<xsl:template match="mods:subject[ mods:topic | mods:name | mods:geographic | mods:cartographics | mods:hierarchicalGeographic | mods:temporal | mods:occupation | mods:titleInfo]">
<xsl:for-each select="mods:topic">
<dc:subject>
<xsl:value-of select="."/>
</dc:subject>
</xsl:for-each>
<xsl:for-each select="mods:name">
<dc:subject>
<xsl:call-template name="name"/>
</dc:subject>
</xsl:for-each>
<xsl:for-each select="mods:geographic">
<dc:coverage>
<xsl:value-of select="."/>
</dc:coverage>
</xsl:for-each>
<xsl:for-each select="mods:cartographics">
<dc:coverage>
<xsl:value-of select="."/>
</dc:coverage>
</xsl:for-each>
<xsl:for-each select="mods:hierarchicalGeographic">
<xsl:for-each select="mods:continent|mods:country|mods:provence|mods:region|mods:state|mods:territory|mods:county|mods:city|mods:island|mods:area">
<dc:coverage>
<xsl:value-of select="."/>
</dc:coverage>
</xsl:for-each>
</xsl:for-each>
<xsl:for-each select="mods:temporal">
<dc:coverage>
<xsl:value-of select="."/>
</dc:coverage>
</xsl:for-each>
<xsl:for-each select="mods:occupation">
<dc:subject>
<xsl:value-of select="."/>
</dc:subject>
</xsl:for-each>
<xsl:for-each select="mods:titleInfo">
<dc:subject>
<xsl:value-of select="mods:nonSort"/>
<xsl:if test="mods:nonSort">
<xsl:text> </xsl:text>
</xsl:if>
<xsl:value-of select="mods:title"/>
<xsl:if test="mods:subTitle">
<xsl:text>: </xsl:text>
<xsl:value-of select="mods:subTitle"/>
</xsl:if>
<xsl:if test="mods:partNumber">
<xsl:text>. </xsl:text>
<xsl:value-of select="mods:partNumber"/>
</xsl:if>
<xsl:if test="mods:partName">
<xsl:text>. </xsl:text>
<xsl:value-of select="mods:partName"/>
</xsl:if>
</dc:subject>
</xsl:for-each>
</xsl:template>
<!--
This entire section was commented out as it was duplicating subjects and concatenating subject names without any space. This was replaced with the code just above. 2014-02-10. JME
<xsl:template match="mods:subject[mods:topic | mods:name | mods:occupation | mods:geographic | mods:hierarchicalGeographic | mods:cartographics | mods:temporal] ">
<xsl:for-each select="mods:topic">
<dc:subject>
<xsl:value-of select="."/>
</dc:subject>
</xsl:for-each>
<xsl:for-each select="mods:name">
<dc:subject>
<xsl:call-template name="name"/>
</dc:subject>
</xsl:for-each>
<xsl:for-each select="mods:titleInfo/mods:title">
<dc:subject>
<xsl:value-of select="mods:titleInfo/mods:title"/>
</dc:subject>
</xsl:for-each>
<xsl:for-each select="mods:geographic">
<dc:coverage>
<xsl:value-of select="."/>
</dc:coverage>
</xsl:for-each>
<xsl:for-each select="mods:hierarchicalGeographic">
<xsl:for-each select="mods:continent|mods:country|mods:provence|mods:region|mods:state|mods:territory|mods:county|mods:city|mods:island|mods:area">
<dc:coverage>
<xsl:value-of select="."/>
</dc:coverage>
</xsl:for-each>
</xsl:for-each>
<xsl:for-each select="mods:cartographics/*">
<dc:coverage>
<xsl:value-of select="."/>
</dc:coverage>
</xsl:for-each>
<xsl:if test="mods:temporal">
<xsl:for-each select="mods:temporal">
<dc:coverage>
<xsl:value-of select="."/>
</dc:coverage>
</xsl:for-each>
</xsl:if>
<xsl:if test="*[1][local-name()='topic'] and *[local-name()!='topic']">
<xsl:for-each select="*[local-name()!='cartographics' and local-name()!='geographicCode' and local-name()!='hierarchicalGeographic'] ">
<dc:subject>
<xsl:value-of select="."/>
</dc:subject>
<xsl:if test="position()!=last()"> </xsl:if>
</xsl:for-each>
</xsl:if>
</xsl:template>-->
<xsl:template match="mods:abstract | mods:tableOfContents">
<dc:description>
<xsl:value-of select="."/>
</dc:description>
</xsl:template>
<xsl:template match="mods:note">
<xsl:choose>
<xsl:when test="contains(@type, 'preferred citation')">
<dc:description>
<xsl:text>Preferred Citation: </xsl:text>
<xsl:value-of select="."/>
</dc:description>
</xsl:when>
<xsl:when test="contains(@type, 'source note')">
<dc:relation>
<xsl:text>Source Note: </xsl:text>
<xsl:value-of select="."/>
</dc:relation>
</xsl:when>
<xsl:when test="contains(@type, 'ownership')">
<dc:publisher>
<xsl:text>Ownership Statement: </xsl:text>
<xsl:value-of select="."/>
</dc:publisher>
</xsl:when>
<xsl:when test="contains(@type, 'source identifier')">
<dc:description>
<xsl:text>Source Identifier: </xsl:text>
<xsl:value-of select="."/>
</dc:description>
</xsl:when>
<xsl:when test="contains(@type, 'historic/current address')">
<dc:description>
<xsl:text>Historic/Current Address: </xsl:text>
<xsl:value-of select="."/>
</dc:description>
</xsl:when>
<xsl:otherwise>
<dc:description>
<xsl:value-of select="."/>
</dc:description>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="mods:originInfo">
<xsl:apply-templates select="*[@point='start']"/>
<xsl:for-each select="mods:dateIssued[@point!='start' and @point!='end'] |mods:dateCreated[@point!='start' and @point!='end'] | mods:dateCaptured[@point!='start' and @point!='end'] | mods:dateOther[@point!='start' and @point!='end']">
<dc:date>
<xsl:value-of select="."/>
</dc:date>
</xsl:for-each>
<xsl:apply-templates select="*[not(@point)]"/>
<xsl:for-each select="mods:publisher">
<dc:publisher>
<xsl:value-of select="."/>
</dc:publisher>
</xsl:for-each>
</xsl:template>
<xsl:template match="mods:dateIssued | mods:dateCreated | mods:dateCaptured">
<dc:date>
<xsl:choose>
<xsl:when test="@point='start'">
<xsl:value-of select="."/>
<xsl:text> - </xsl:text>
</xsl:when>
<xsl:when test="@point='end'">
<xsl:value-of select="."/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</dc:date>
</xsl:template>
<xsl:template match="mods:dateIssued[@point='start'] | mods:dateCreated[@point='start'] | mods:dateCaptured[@point='start'] | mods:dateOther[@point='start'] ">
<xsl:variable name="dateName" select="local-name()"/>
<dc:date>
<xsl:value-of select="."/> - <xsl:value-of select="../*[local-name()=$dateName][@point='end']"/>
</dc:date>
</xsl:template>
<xsl:template match="mods:temporal[@point='start'] ">
<xsl:value-of select="."/>-<xsl:value-of select="../mods:temporal[@point='end']"/>
</xsl:template>
<xsl:template match="mods:temporal[@point!='start' and @point!='end'] ">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="mods:genre">
<xsl:choose>
<xsl:when test="@authority='dct'">
<dc:type>
<xsl:value-of select="."/>
</dc:type>
</xsl:when>
<xsl:otherwise>
<dc:type>
<xsl:value-of select="."/>
</dc:type>
<xsl:apply-templates select="mods:typeOfResource"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="mods:typeOfResource">
<xsl:if test="@collection='yes'">
<dc:type>Collection</dc:type>
</xsl:if>
<xsl:if test=". ='software' and ../mods:genre='database'">
<dc:type>Dataset</dc:type>
</xsl:if>
<xsl:if test=".='software' and ../mods:genre='online system or service'">
<dc:type>Service</dc:type>
</xsl:if>
<xsl:if test=".='software'">
<dc:type>Software</dc:type>
</xsl:if>
<xsl:if test=".='cartographic material'">
<dc:type>Image</dc:type>
</xsl:if>
<xsl:if test=".='multimedia'">
<dc:type>InteractiveResource</dc:type>
</xsl:if>
<xsl:if test=".='moving image'">
<dc:type>MovingImage</dc:type>
</xsl:if>
<xsl:if test=".='three dimensional object'">
<dc:type>PhysicalObject</dc:type>
</xsl:if>
<xsl:if test="starts-with(.,'sound recording')">
<dc:type>Sound</dc:type>
</xsl:if>
<xsl:if test=".='still image'">
<dc:type>StillImage</dc:type>
</xsl:if>
<xsl:if test=". ='text'">
<dc:type>Text</dc:type>
</xsl:if>
<xsl:if test=".='notated music'">
<dc:type>Text</dc:type>
</xsl:if>
</xsl:template>
<xsl:template match="mods:physicalDescription">
<xsl:for-each select="mods:extent">
<dc:format>
<!-- tmee mods 3.5 -->
<xsl:choose>
<xsl:when test="@unit">
<xsl:value-of select="."/>
<xsl:text> </xsl:text>
<xsl:value-of select="@unit"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</dc:format>
</xsl:for-each>
<xsl:for-each select="mods:form">
<dc:format>
<xsl:value-of select="."/>
</dc:format>
</xsl:for-each>
<xsl:for-each select="mods:internetMediaType">
<dc:format>
<xsl:value-of select="."/>
</dc:format>
</xsl:for-each>
</xsl:template>
<!--
<xsl:template match="mods:mimeType">
<dc:format>
<xsl:value-of select="."/>
</dc:format>
</xsl:template>
-->
<xsl:template match="mods:identifier">
<dc:identifier>
<xsl:variable name="type" select="translate(@type,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
<xsl:choose>
<!-- 2.0: added identifier type attribute to output, if it is present-->
<xsl:when test="contains(.,':')">
<xsl:value-of select="."/>
</xsl:when>
<xsl:when test="@type">
<xsl:value-of select="$type"/>: <xsl:value-of select="."/>
</xsl:when>
<xsl:when test="contains ('isbn issn uri doi lccn uri', $type)">
<xsl:value-of select="$type"/>: <xsl:value-of select="."/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</dc:identifier>
</xsl:template>
<xsl:template match="mods:location">
<xsl:for-each select="mods:url">
<dc:identifier>
<xsl:value-of select="."/>
</dc:identifier>
</xsl:for-each>
</xsl:template>
<xsl:template match="mods:language">
<dc:language>
<xsl:value-of select="child::*"/>
</dc:language>
</xsl:template>
<xsl:template match="mods:relatedItem[mods:titleInfo | mods:name | mods:identifier | mods:location]">
<xsl:choose>
<xsl:when test="@type='original'">
<dc:source>
<xsl:for-each select="mods:titleInfo/mods:title | mods:identifier | mods:location/mods:url">
<xsl:if test="normalize-space(.)!= ''">
<xsl:value-of select="."/>
<xsl:if test="position()!=last()">--</xsl:if>
</xsl:if>
</xsl:for-each>
</dc:source>
</xsl:when>
<xsl:when test="@type='series'"/>
<xsl:otherwise>
<dc:relation>
<xsl:for-each select="mods:titleInfo/mods:title | mods:identifier | mods:location/mods:url">
<xsl:if test="normalize-space(.)!= ''">
<xsl:value-of select="."/>
<xsl:if test="position()!=last()">--</xsl:if>
</xsl:if>
</xsl:for-each>
</dc:relation>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="mods:accessCondition">
<dc:rights>
<xsl:choose>
<xsl:when test="@displayLabel">
<xsl:value-of select="@displayLabel"/>
<xsl:text>: </xsl:text>
<xsl:value-of select="."/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</dc:rights>
</xsl:template>
<xsl:template name="name">
<xsl:variable name="name">
<xsl:for-each select="mods:namePart[not(@type)]">
<xsl:value-of select="."/>
<xsl:text> </xsl:text>
</xsl:for-each>
<xsl:value-of select="mods:namePart[@type='family']"/>
<xsl:if test="mods:namePart[@type='given']">
<xsl:text>, </xsl:text>
<xsl:value-of select="mods:namePart[@type='given']"/>
</xsl:if>
<xsl:if test="mods:namePart[@type='date']">
<xsl:text>, </xsl:text>
<xsl:value-of select="mods:namePart[@type='date']"/>
<xsl:text/>
</xsl:if>
<xsl:if test="mods:displayForm">
<xsl:text> (</xsl:text>
<xsl:value-of select="mods:displayForm"/>
<xsl:text>) </xsl:text>
</xsl:if>
<xsl:for-each select="mods:role[mods:roleTerm[@type='text']!='creator']">
<xsl:text> (</xsl:text>
<xsl:value-of select="normalize-space(child::*)"/>
<xsl:text>) </xsl:text>
</xsl:for-each>
</xsl:variable>
<xsl:value-of select="normalize-space($name)"/>
</xsl:template>
<!-- suppress all else:-->
<xsl:template match="*"/>
</xsl:stylesheet>