forked from subugoe/pazpar2-etc
/
tmarc.xsl
1112 lines (1028 loc) · 41.1 KB
/
tmarc.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
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
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
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
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
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="UTF-8"?>
<!--
tmarc.xsl
Stylesheet to extract MARC21 fields from Index Data’s streamlined
TurboMarc XML format to an internal metadata model for pazpar2.
Mostly based on Index Data’s original tmarc.xsl from
http://git.indexdata.com/?p=pazpar2.git;a=blob_plain;f=etc/tmarc.xsl;hb=HEAD
In parts modified, extended and streamlined
2010-2014 Sven-S. Porst <ssp-web@earthlingsoft.net>
This version can be found in the repository at github:
https://github.com/ssp/pazpar2-etc/
-->
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:pz="http://www.indexdata.com/pazpar2/1.0"
xmlns:tmarc="http://www.indexdata.com/turbomarc" version="1.0">
<xsl:output indent="yes" method="xml" version="1.0" encoding="UTF-8"/>
<xsl:param name="medium"/>
<xsl:template name="record-hook"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="tmarc:collection">
<collection>
<xsl:apply-templates/>
</collection>
</xsl:template>
<xsl:template match="tmarc:r">
<!-- Assemble the parent’s title from 773 $a and $t. -->
<xsl:variable name="parent-title">
<xsl:value-of select="tmarc:d773/tmarc:sa"/>
<xsl:if test="tmarc:d773/tmarc:sa and tmarc:d773/tmarc:st">
<xsl:text>: </xsl:text>
</xsl:if>
<xsl:value-of select="tmarc:d773/tmarc:st"/>
</xsl:variable>
<xsl:variable name="fulltext_a" select="tmarc:d900/tmarc:sa"/>
<xsl:variable name="fulltext_b" select="tmarc:d900/tmarc:sb"/>
<xsl:variable name="typeofrec" select="substring(tmarc:l, 7, 1)"/>
<xsl:variable name="typeofvm" select="substring(tmarc:c008, 34, 1)"/>
<xsl:variable name="biblevel" select="substring(tmarc:l, 8, 1)"/>
<xsl:variable name="multipart" select="substring(tmarc:l, 20, 1)"/>
<xsl:variable name="form1" select="substring(tmarc:c008, 24, 1)"/>
<xsl:variable name="form2" select="substring(tmarc:c008, 30, 1)"/>
<xsl:variable name="language" select="substring(tmarc:c008, 36, 3)"/>
<xsl:variable name="oclca" select="substring(tmarc:c007, 1, 1)"/>
<xsl:variable name="oclcb" select="substring(tmarc:c007, 2, 1)"/>
<xsl:variable name="oclcd" select="substring(tmarc:c007, 4, 1)"/>
<xsl:variable name="oclce" select="substring(tmarc:c007, 5, 1)"/>
<xsl:variable name="typeofserial" select="substring(tmarc:c008, 22, 1)"/>
<xsl:variable name="electronic">
<xsl:choose>
<xsl:when test="$form1='s' or $form1='q' or $form1='o' or $form2='s' or $form2='q' or $form2='o'">
<xsl:text>yes</xsl:text>
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
</xsl:variable>
<xsl:variable name="vmedium">
<xsl:choose>
<xsl:when test="string-length($medium)"><xsl:value-of select="$medium"/></xsl:when>
<xsl:when test="$oclca='h' or $form1='a' or $form1='b' or $form1='c'">microform</xsl:when>
<xsl:when test="$multipart='a'">multivolume</xsl:when>
<xsl:when test="$typeofrec='j' or $typeofrec='i'">
<xsl:text>recording</xsl:text>
<xsl:choose>
<xsl:when test="$oclcb='d' and $oclcd='f'">-cd</xsl:when>
<xsl:when test="$oclcb='s'">-cassette</xsl:when>
<xsl:when test="$oclcb='d' and $oclcd='a' or $oclcd='b' or $oclcd='c' or $oclcd='d' or $oclcd='e'">-vinyl</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:when test="$typeofrec='g'">
<xsl:choose>
<xsl:when test="$typeofvm='m' or $typeofvm='v'">
<xsl:text>video</xsl:text>
<xsl:choose>
<xsl:when test="$oclca='v' and $oclcb='d' and $oclce='v'">-dvd</xsl:when>
<xsl:when test="$oclca='v' and $oclcb='d' and $oclce='s'">-blu-ray</xsl:when>
<xsl:when test="$oclca='v' and $oclcb='f' and $oclce='b'">-vhs</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:otherwise>audio-visual</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$typeofrec='a' and $biblevel='s'">
<xsl:choose>
<xsl:when test="$typeofserial='n'">newspaper</xsl:when>
<xsl:otherwise>journal</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$typeofrec='e' or $typeofrec='f'">map</xsl:when>
<xsl:when test="$typeofrec='c' or $typeofrec='d'">music-score</xsl:when>
<xsl:when test="$typeofrec='t'">manuscript</xsl:when>
<xsl:when test="string-length($parent-title) > 0">article</xsl:when>
<xsl:when test="($typeofrec='a' or $typeofrec='t') and ($biblevel='m' or $biblevel='a')">book</xsl:when>
<xsl:when test="($typeofrec='a' or $typeofrec='i') and ($typeofserial='d' or $typeofserial='w')">web</xsl:when>
<xsl:when test="$typeofrec='a' and $biblevel='b'">article</xsl:when>
<xsl:when test="$typeofrec='m'">electronic</xsl:when>
<xsl:when test="$typeofrec='o'">multiple</xsl:when>
<xsl:otherwise>
<xsl:text>other</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="has_fulltext">
<xsl:choose>
<xsl:when test="tmarc:d856/tmarc:sq">
<xsl:text>yes</xsl:text>
</xsl:when>
<xsl:when test="tmarc:d856/tmarc:si='TEXT*'">
<xsl:text>yes</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>no</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="oclc_number">
<xsl:choose>
<xsl:when test='contains(tmarc:c001,"ocn") or
contains(tmarc:c001,"ocm") or
contains(tmarc:c001,"OCoLC")'>
<xsl:value-of select="tmarc:c001"/>
</xsl:when>
<xsl:when test='contains(tmarc:d035/tmarc:sa,"ocn") or
contains(tmarc:d035/tmarc:sa,"ocm") or
contains(tmarc:d035/tmarc:sa,"OCoLC")'>
<xsl:value-of select="tmarc:d035/tmarc:sa"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="date_008">
<xsl:choose>
<xsl:when test="contains('cestpudikmr', substring(tmarc:c008, 7, 1))">
<xsl:value-of select="substring(tmarc:c008, 8, 4)"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="date_end_008">
<xsl:choose>
<xsl:when test="contains('dikmr', substring(tmarc:c008, 7, 1))">
<xsl:value-of select="substring(tmarc:c008, 12, 4)"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<pz:record>
<!-- extract language information from: 008[35-37] ($language variable) and 041 $a fields -->
<xsl:if test="$language!='und' and
$language!='zxx' and
$language!=' ' and
$language!='mul' and
$language!='|||'">
<pz:metadata type="language">
<xsl:value-of select="$language"/>
</pz:metadata>
</xsl:if>
<xsl:for-each select="tmarc:d041">
<!-- $a main, $b summary, $d audio, $e libretto, $f toc, $g additions, $j subtitles -->
<xsl:for-each select="tmarc:sa | tmarc:sb | tmarc:sd | tmarc:se | tmarc:sf | tmarc:sg | tmarc:sj">
<xsl:if test=". != $language and not(../@i2 = '7' and not(../tmarc:s2))">
<!-- only add language codes which do not duplicate the one in c008 and, if non-standard, which contain information about their type -->
<pz:metadata type="language">
<!-- for non-standard language codes transport their type in the language-code-scheme attribute -->
<xsl:if test="../@i2 = '7' and ../tmarc:s2">
<xsl:attribute name="language-code-scheme">
<xsl:value-of select="../tmarc:s2"/>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="."/>
</pz:metadata>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
<xsl:for-each select="tmarc:c001">
<pz:metadata type="id">
<xsl:value-of select="."/>
</pz:metadata>
</xsl:for-each>
<xsl:if test="string-length($oclc_number) > 0">
<pz:metadata type="oclc-number">
<xsl:value-of select="$oclc_number"/>
</pz:metadata>
</xsl:if>
<xsl:for-each select="tmarc:d010">
<xsl:for-each select="tmarc:sa">
<pz:metadata type="lccn">
<xsl:value-of select="."/>
</pz:metadata>
</xsl:for-each>
</xsl:for-each>
<xsl:for-each select="tmarc:d016">
<pz:metadata type="record-control-number">
<xsl:if test="@i1 = '7' and tmarc:s2">
<xsl:attribute name="source">
<xsl:value-of select="tmarc:s2"/>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="tmarc:sa"/>
</pz:metadata>
</xsl:for-each>
<xsl:for-each select="tmarc:d020">
<xsl:for-each select="tmarc:sa">
<pz:metadata type="isbn">
<xsl:value-of select="."/>
</pz:metadata>
</xsl:for-each>
</xsl:for-each>
<!-- ISSN should have the form »XXXX-XXXX« but some records
append a note »XXXX-XXXX (Note)« which does not conform to the standard.
Strip everything beyond the 9th character and normalise space to also
cope with records where the middle dash is missing.
-->
<xsl:for-each select="tmarc:d022">
<xsl:for-each select="tmarc:sa">
<pz:metadata type="issn">
<xsl:value-of select="normalize-space(substring(., 1, 9))"/>
</pz:metadata>
</xsl:for-each>
</xsl:for-each>
<xsl:for-each select="tmarc:d024">
<xsl:if test="(tmarc:sa) and (tmarc:s2='doi')">
<pz:metadata type="doi">
<xsl:value-of select="tmarc:sa"/>
</pz:metadata>
</xsl:if>
</xsl:for-each>
<xsl:for-each select="tmarc:d027">
<xsl:for-each select="tmarc:sa">
<pz:metadata type="tech-rep-nr">
<xsl:value-of select="."/>
</pz:metadata>
</xsl:for-each>
</xsl:for-each>
<xsl:for-each select="tmarc:d035">
<pz:metadata type="system-control-nr">
<xsl:choose>
<xsl:when test="tmarc:sa">
<xsl:value-of select="tmarc:sa"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="tmarc:sb"/>
</xsl:otherwise>
</xsl:choose>
</pz:metadata>
</xsl:for-each>
<!-- DDC -->
<xsl:for-each select="tmarc:d082">
<pz:metadata type="classification-ddc">
<xsl:value-of select="tmarc:sa"/>
</pz:metadata>
</xsl:for-each>
<!-- Marc 084 contains generic classification numbers with the
classification name in $2. Turn these into metadata fields with
name classification-XXX where XXX is the content of $2.
Create a new pazpar2 metadata field for each $a subfield.
-->
<xsl:for-each select="tmarc:d084">
<xsl:variable name="classification-name">
<xsl:value-of select="tmarc:s2"/>
</xsl:variable>
<xsl:for-each select="tmarc:sa">
<pz:metadata>
<xsl:attribute name="type">
<xsl:text>classification</xsl:text>
<xsl:if test="$classification-name">
<xsl:text>-</xsl:text>
<xsl:value-of select="translate($classification-name, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/>
</xsl:if>
</xsl:attribute>
<xsl:value-of select="."/>
</pz:metadata>
</xsl:for-each>
</xsl:for-each>
<xsl:for-each select="tmarc:d100 | tmarc:d700[tmarc:s4='aut']">
<xsl:for-each select="tmarc:sa">
<pz:metadata type="author">
<xsl:value-of select="."/>
</pz:metadata>
</xsl:for-each>
<xsl:for-each select="tmarc:sc">
<pz:metadata type="author-title">
<xsl:value-of select="."/>
</pz:metadata>
</xsl:for-each>
<xsl:for-each select="tmarc:sd">
<pz:metadata type="author-date">
<xsl:value-of select="."/>
</pz:metadata>
</xsl:for-each>
</xsl:for-each>
<xsl:for-each select="tmarc:d700">
<xsl:if test="not(tmarc:sa = ../tmarc:d100/tmarc:sa) and not(tmarc:s4='aut')">
<pz:metadata type="other-person">
<xsl:value-of select="tmarc:sa"/>
</pz:metadata>
</xsl:if>
</xsl:for-each>
<xsl:for-each select="tmarc:d110 | tmarc:d710 | tmarc:d111 | tmarc:d711">
<xsl:variable name="field">
<xsl:choose>
<xsl:when test="substring(local-name(.), 3, 2) = '10'">corporate</xsl:when>
<xsl:otherwise>meeting</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="level">
<xsl:choose>
<xsl:when test="substring(local-name(.), 2, 1) = '1'">main</xsl:when>
<xsl:otherwise>other</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="location">
<xsl:for-each select="tmarc:sc">
<xsl:if test="position() != 1">
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="date">
<xsl:for-each select="tmarc:sd">
<xsl:if test="position() != 1">
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:variable>
<xsl:for-each select="tmarc:sa">
<pz:metadata type="{$field}">
<xsl:attribute name="level">
<xsl:value-of select="$level"/>
</xsl:attribute>
<xsl:if test="string-length($location) > 0">
<xsl:attribute name="location">
<xsl:value-of select="$location"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="string-length($date) > 0">
<xsl:attribute name="date">
<xsl:value-of select="$date"/>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="."/>
<xsl:for-each select="../tmarc:sb">
<xsl:text>, </xsl:text>
<xsl:value-of select="."/>
</xsl:for-each>
</pz:metadata>
<pz:metadata type="{$field}-name">
<xsl:value-of select="."/>
</pz:metadata>
</xsl:for-each>
<xsl:if test="string-length($location) > 1">
<pz:metadata type="{$field}-location">
<xsl:value-of select="$location"/>
</pz:metadata>
</xsl:if>
<xsl:if test="string-length($date) > 1">
<pz:metadata type="{$field}-date">
<xsl:value-of select="$date"/>
</pz:metadata>
</xsl:if>
</xsl:for-each>
<xsl:for-each select="tmarc:d260">
<xsl:for-each select="tmarc:sc">
<pz:metadata type="date">
<xsl:value-of select="translate(., 'cp[].', '')"/>
</pz:metadata>
</xsl:for-each>
</xsl:for-each>
<xsl:if test="string-length($date_008) > 0 and not(tmarc:d260/tmarc:sc)">
<pz:metadata type="date">
<xsl:choose>
<xsl:when test="$date_end_008">
<xsl:value-of select="concat($date_008,'-',$date_end_008)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$date_008"/>
</xsl:otherwise>
</xsl:choose>
</pz:metadata>
</xsl:if>
<xsl:for-each select="tmarc:d130">
<xsl:for-each select="tmarc:sa">
<pz:metadata type="title-uniform">
<xsl:value-of select="." />
</pz:metadata>
</xsl:for-each>
<xsl:for-each select="tmarc:sm">
<pz:metadata type="title-uniform-media">
<xsl:value-of select="." />
</pz:metadata>
</xsl:for-each>
<xsl:for-each select="tmarc:sn">
<pz:metadata type="title-uniform-parts">
<xsl:value-of select="." />
</pz:metadata>
</xsl:for-each>
<xsl:for-each select="tmarc:sp">
<pz:metadata type="title-uniform-partname">
<xsl:value-of select="." />
</pz:metadata>
</xsl:for-each>
<xsl:for-each select="tmarc:sr">
<pz:metadata type="title-uniform-key">
<xsl:value-of select="." />
</pz:metadata>
</xsl:for-each>
</xsl:for-each>
<xsl:for-each select="tmarc:d245">
<xsl:for-each select="tmarc:sa">
<pz:metadata type="title">
<xsl:value-of select="." />
</pz:metadata>
</xsl:for-each>
<xsl:for-each select="tmarc:sb">
<pz:metadata type="title-remainder">
<xsl:value-of select="." />
</pz:metadata>
</xsl:for-each>
<xsl:for-each select="tmarc:sc">
<pz:metadata type="title-responsibility">
<xsl:value-of select="." />
</pz:metadata>
</xsl:for-each>
<xsl:for-each select="tmarc:sf">
<pz:metadata type="title-dates">
<xsl:value-of select="." />
</pz:metadata>
</xsl:for-each>
<xsl:for-each select="tmarc:sh">
<pz:metadata type="title-medium">
<xsl:value-of select="." />
</pz:metadata>
</xsl:for-each>
<xsl:variable name="number-info">
<xsl:for-each select="tmarc:sn|tmarc:sp">
<xsl:value-of select="."/>
<xsl:if test="not(contains(',.;:' ,substring(., string-length(.), 1)))">
<xsl:choose>
<xsl:when test="name(.)='sn' and name(following-sibling::*[1])='sp'">
<xsl:text>:</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>.</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:variable>
<pz:metadata type="title-number-section">
<xsl:value-of select="$number-info"/>
</pz:metadata>
<pz:metadata type="title-complete">
<xsl:value-of select="tmarc:sa"/>
<xsl:if test="tmarc:sn|tmarc:sp">
<xsl:value-of select="concat(' ', $number-info)"/>
</xsl:if>
<xsl:if test="tmarc:sb">
<xsl:value-of select="concat(': ', tmarc:sb)"/>
</xsl:if>
</pz:metadata>
</xsl:for-each>
<xsl:for-each select="tmarc:d250">
<xsl:for-each select="tmarc:sa">
<pz:metadata type="edition">
<xsl:value-of select="."/>
</pz:metadata>
</xsl:for-each>
</xsl:for-each>
<!-- Map information:
Create the mapscale field, add the scale as its text and
the projection/coordinates fields as attributes.
Delete the brackets and punctuation surrounding the
coordinates string.
-->
<xsl:for-each select="tmarc:d255">
<pz:metadata type="mapscale">
<xsl:if test="tmarc:sb">
<xsl:attribute name="projection">
<xsl:value-of select="tmarc:sb"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="tmarc:sc">
<xsl:attribute name="coordinates">
<xsl:value-of select="translate(tmarc:sc, '().', '')"/>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="tmarc:sa"/>
</pz:metadata>
</xsl:for-each>
<xsl:for-each select="tmarc:d260">
<xsl:for-each select="tmarc:sa">
<pz:metadata type="publication-place">
<xsl:value-of select="." />
</pz:metadata>
</xsl:for-each>
<xsl:for-each select="tmarc:sb">
<pz:metadata type="publication-name">
<xsl:value-of select="." />
</pz:metadata>
</xsl:for-each>
<xsl:for-each select="tmarc:sc">
<pz:metadata type="publication-date">
<xsl:value-of select="." />
</pz:metadata>
</xsl:for-each>
</xsl:for-each>
<xsl:for-each select="tmarc:d300">
<xsl:for-each select="tmarc:sa">
<pz:metadata type="physical-extent">
<xsl:value-of select="." />
</pz:metadata>
</xsl:for-each>
<xsl:for-each select="tmarc:sb">
<pz:metadata type="physical-format">
<xsl:value-of select="." />
</pz:metadata>
</xsl:for-each>
<xsl:for-each select="tmarc:sc">
<pz:metadata type="physical-dimensions">
<xsl:value-of select="." />
</pz:metadata>
</xsl:for-each>
<xsl:for-each select="tmarc:se">
<pz:metadata type="physical-accomp">
<xsl:value-of select="." />
</pz:metadata>
</xsl:for-each>
<xsl:for-each select="tmarc:sf">
<pz:metadata type="physical-unittype">
<xsl:value-of select="." />
</pz:metadata>
</xsl:for-each>
<xsl:for-each select="tmarc:sg">
<pz:metadata type="physical-unitsize">
<xsl:value-of select="." />
</pz:metadata>
</xsl:for-each>
<xsl:for-each select="tmarc:s3">
<pz:metadata type="physical-specified">
<xsl:value-of select="." />
</pz:metadata>
</xsl:for-each>
</xsl:for-each>
<xsl:for-each select="tmarc:d440">
<xsl:for-each select="tmarc:sa">
<pz:metadata type="series-title">
<xsl:value-of select="." />
</pz:metadata>
</xsl:for-each>
</xsl:for-each>
<!--
If the multipart variable (leader position 19) is b, the first Field 490
contains the multivolume work title. If the multivolume work is part of a series,
the series will be stated in the following 490 field.
-->
<xsl:for-each select="tmarc:d490">
<xsl:choose>
<xsl:when test="$multipart = 'b' and position() = 1">
<pz:metadata type="multivolume-title">
<xsl:value-of select="tmarc:sa"/>
<xsl:if test="tmarc:sv">
<xsl:text> </xsl:text>
<xsl:value-of select="tmarc:sv"/>
</xsl:if>
</pz:metadata>
</xsl:when>
<xsl:otherwise>
<pz:metadata type="series-title">
<xsl:value-of select="tmarc:sa"/>
<xsl:if test="tmarc:sv">
<xsl:text> </xsl:text>
<xsl:value-of select="tmarc:sv"/>
</xsl:if>
</pz:metadata>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<!-- Note fields
[general/500, with/501, dissertation/502, formatted contents/505,
event/518, summary/520, geographic coverage/522]
Concatenate all their subfields other than $0 with commas in between
and write a description field.
Ignore abstracts (520 with i1=3) which are treated separately below.
-->
<xsl:for-each select="tmarc:d500 | tmarc:d501 | tmarc:d502 | tmarc:d505 |
tmarc:d518 | tmarc:d520[@i1!='3'] | tmarc:d522">
<pz:metadata type="description">
<xsl:for-each select="./*[local-name()!='s0']">
<xsl:value-of select="text()"/>
<xsl:if test="position()!=last() and .!=''">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:for-each>
</pz:metadata>
</xsl:for-each>
<!-- Abstracts (520 with i1=3) get their own metadata field.
They are explicitly excluded from becoming descriptions above.
-->
<xsl:for-each select="tmarc:d520[@i1='3']">
<pz:metadata type="abstract">
<xsl:for-each select="./*">
<xsl:value-of select="text()"/>
<xsl:if test="position()!=last() and .!=''">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:for-each>
</pz:metadata>
</xsl:for-each>
<xsl:for-each select="tmarc:d911">
<pz:metadata type="description">
<xsl:for-each select="node()">
<xsl:value-of select="text()"/>
</xsl:for-each>
</pz:metadata>
</xsl:for-each>
<xsl:for-each select="tmarc:d600 | tmarc:d610 | tmarc:d611 | tmarc:d630 |
tmarc:d648 | tmarc:d650 | tmarc:d651 | tmarc:d653 |
tmarc:d654 | tmarc:d655 | tmarc:d656 | tmarc:d657 |
tmarc:d658 | tmarc:d662 | tmarc:d690 | tmarc:d691 |
tmarc:d692 | tmarc:d693 | tmarc:d694 | tmarc:d696 |
tmarc:d697 | tmarc:d698 | tmarc:d699 | tmarc:d69X">
<xsl:for-each select="tmarc:sa">
<pz:metadata type="subject">
<xsl:value-of select="."/>
</pz:metadata>
</xsl:for-each>
<pz:metadata type="subject-long">
<xsl:for-each select="node()/text()">
<xsl:if test="position() > 1">
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:variable name='value'>
<xsl:value-of select='normalize-space(.)'/>
</xsl:variable>
<xsl:choose>
<xsl:when test="substring($value, string-length($value)) = ','">
<xsl:value-of select="substring($value, 1, string-length($value)-1)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$value"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</pz:metadata>
</xsl:for-each>
<!--
Grab potential parent-id from 800/810/830 $w.
Parent links can occur in these fields (corresponding to the parent items mentioned
in 490 fields or 245) as well as in 773 $w.
There should be at most one parent-id.
-->
<xsl:for-each select="tmarc:d800 | tmarc:d810 | tmarc:d830">
<xsl:if test="tmarc:sw">
<pz:metadata type="parent-id">
<xsl:value-of select="tmarc:sw"/>
</pz:metadata>
</xsl:if>
</xsl:for-each>
<!-- Links: 856, with an attempt to try and isolate DOIs and URNs -->
<xsl:for-each select="tmarc:d856">
<xsl:choose>
<!-- Map DOI URLs to the doi field -->
<xsl:when test="substring(tmarc:su, 1, 18) = 'http://dx.doi.org/'">
<pz:metadata type="doi">
<xsl:value-of select="substring-after(tmarc:su, 'http://dx.doi.org/')"/>
</pz:metadata>
</xsl:when>
<!-- Map URNs to the urn field -->
<xsl:when test="substring(tmarc:su, 1, 4) = 'urn:'">
<pz:metadata type="urn">
<xsl:value-of select="tmarc:su"/>
</pz:metadata>
</xsl:when>
<!-- Generic URLs -->
<xsl:when test="tmarc:su">
<pz:metadata type="electronic-url">
<xsl:if test="tmarc:sy|tmarc:s3|tmarc:sa">
<xsl:variable name="name">
<!-- for the name: use the first available of $y, $3, $a -->
<xsl:choose>
<!-- $y Link text: repetitions separated by ; -->
<xsl:when test="tmarc:sy">
<xsl:variable name="name">
<xsl:for-each select="tmarc:sy">
<xsl:value-of select="."/>
<xsl:if test="position() != last()">; </xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:value-of select="$name"/>
</xsl:when>
<!-- $3 Materials Specified: not repeatable -->
<xsl:when test="tmarc:s3">
<xsl:value-of select="tmarc:s3"/>
</xsl:when>
<!-- $a Host Name: repetitions separated by ; -->
<xsl:when test="tmarc:sa">
<xsl:variable name="name">
<xsl:for-each select="tmarc:sa">
<xsl:value-of select="."/>
<xsl:if test="position() != last()">; </xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:value-of select="$name"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:if test="string-length($name) > 0">
<xsl:attribute name="name">
<xsl:value-of select="$name"/>
</xsl:attribute>
</xsl:if>
</xsl:if>
<!-- $z Public Note: repetitions separated by ; -->
<xsl:if test="tmarc:sz">
<xsl:variable name="note">
<xsl:for-each select="tmarc:sz">
<xsl:value-of select="."/>
<xsl:if test="position() != last()">; </xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:if test="string-length($note) > 0">
<xsl:attribute name="note">
<xsl:value-of select="$note"/>
</xsl:attribute>
</xsl:if>
</xsl:if>
<!-- $i Instruction: repetitions separated by ; -->
<xsl:if test="tmarc:si">
<xsl:variable name="instruction">
<xsl:for-each select="tmarc:si">
<xsl:value-of select="."/>
<xsl:if test="position() != last()">; </xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:if test="string-length($instruction) > 0">
<xsl:attribute name="format-instruction">
<xsl:value-of select="$instruction"/>
</xsl:attribute>
</xsl:if>
</xsl:if>
<!-- $q Electronic Format Type: not repeatable -->
<xsl:if test="tmarc:sq">
<xsl:attribute name="format-type">
<xsl:value-of select="tmarc:sq"/>
</xsl:attribute>
</xsl:if>
<!-- $u URL -->
<xsl:value-of select="tmarc:su"/>
</pz:metadata>
</xsl:when>
</xsl:choose>
</xsl:for-each>
<xsl:for-each select="tmarc:d773">
<!-- full citation -->
<pz:metadata type="citation">
<xsl:for-each select="*">
<xsl:value-of select="normalize-space(.)"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</pz:metadata>
<!-- ISSN -->
<xsl:if test="tmarc:sx">
<pz:metadata type="issn">
<xsl:value-of select="tmarc:sx"/>
</pz:metadata>
</xsl:if>
<!-- ISBN, can appear for essays in a book -->
<xsl:if test="tmarc:sz">
<pz:metadata type="isbn">
<xsl:value-of select="tmarc:sz"/>
</pz:metadata>
</xsl:if>
<!-- title: $parent-title combines $a and $t -->
<xsl:if test="$parent-title">
<pz:metadata type="journal-title">
<xsl:value-of select="$parent-title"/>
</pz:metadata>
</xsl:if>
<!-- short title -->
<xsl:if test="tmarc:sp">
<pz:metadata type="journal-title-abbrev">
<xsl:value-of select="tmarc:sp"/>
</pz:metadata>
</xsl:if>
<!-- parent ID -->
<xsl:if test="tmarc:sw">
<pz:metadata type="parent-id">
<xsl:value-of select="tmarc:sw"/>
</pz:metadata>
</xsl:if>
<!-- if necessary evaluate volume/pages information from $g -->
<xsl:if test="tmarc:sg">
<xsl:variable name="subpart">
<xsl:for-each select="tmarc:sg">
<xsl:value-of select="."/>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:variable>
<pz:metadata type="journal-subpart">
<xsl:value-of select="normalize-space($subpart)"/>
</pz:metadata>
<xsl:if test="not(tmarc:sq)">
<xsl:variable name="l">
<xsl:value-of select="translate($subpart,
'ABCDEFGHIJKLMNOPQRSTUVWXYZ.',
'abcdefghijklmnopqrstuvwxyz ')"/>
</xsl:variable>
<xsl:variable name="volume">
<xsl:choose>
<xsl:when test="string-length(substring-after($l,'vol ')) > 0">
<xsl:value-of select="substring-before(normalize-space(substring-after($l,'vol ')),' ')"/>
</xsl:when>
<xsl:when test="string-length(substring-after($l,'v ')) > 0">
<xsl:value-of select="substring-before(normalize-space(substring-after($l,'v ')),' ')"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="issue">
<xsl:value-of select="substring-before(translate(normalize-space(substring-after($l,'issue')), ',', ' '),' ')"/>
</xsl:variable>
<xsl:variable name="pages">
<xsl:choose>
<xsl:when test="string-length(substring-after($l,' p ')) > 0">
<xsl:value-of select="normalize-space(substring-after($l,' p '))"/>
</xsl:when>
<xsl:when test="string-length(substring-after($l,',p')) > 0">
<xsl:value-of select="normalize-space(substring-after($l,',p'))"/>
</xsl:when>
<xsl:when test="string-length(substring-after($l,' p')) > 0">
<xsl:value-of select="normalize-space(substring-after($l,' p'))"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<!-- volume -->
<xsl:if test="string-length($volume) > 0">
<pz:metadata type="volume-number">
<xsl:value-of select="$volume"/>
</pz:metadata>
</xsl:if>
<!-- issue -->
<xsl:if test="string-length($issue) > 0">
<pz:metadata type="issue-number">
<xsl:value-of select="$issue"/>
</pz:metadata>
</xsl:if>
<!-- pages -->
<xsl:if test="string-length($pages) > 0">
<pz:metadata type="pages-number">
<xsl:value-of select="$pages"/>
</pz:metadata>
</xsl:if>
</xsl:if> <!-- not(tmarc:sq) -->
</xsl:if> <!-- tmarc:sg -->
<!--
Evaluate Marc 773 $q for article page numbers.
The field contains a string of the form
volume:issue:subissue<pagenumber
..1...:......2.......<....3.....
where each component is potentially optional and the depth of the subissue
hierarchy can be extended as needed. Map the components to the pz:metadata fields:
1: volume-number
2: issue-number
3: pages
omitting blank fields if they occur.
-->
<xsl:if test="tmarc:sq">
<xsl:variable name="volumeIssue">
<xsl:choose>
<xsl:when test="contains(tmarc:sq, '<')">
<xsl:value-of select="substring-before(tmarc:sq, '<')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="tmarc:sq"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="volume">
<xsl:choose>
<xsl:when test="contains($volumeIssue, ':')">
<xsl:value-of select="normalize-space(substring-before($volumeIssue, ':'))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="normalize-space($volumeIssue)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="issue" select="normalize-space(substring-after($volumeIssue, ':'))"/>
<xsl:variable name="pages" select="normalize-space(substring-after(tmarc:sq, '<'))"/>
<!-- volume -->
<xsl:if test="string-length($volume) > 0">
<pz:metadata type="volume-number">
<xsl:value-of select="$volume"/>
</pz:metadata>
</xsl:if>
<!-- issue -->
<xsl:if test="string-length($issue) > 0">
<pz:metadata type="issue-number">
<xsl:value-of select="$issue"/>
</pz:metadata>
</xsl:if>
<!-- pages -->
<xsl:if test="string-length($pages) > 0">
<pz:metadata type="pages-number">
<xsl:value-of select="$pages"/>
</pz:metadata>
</xsl:if>
</xsl:if> <!-- tmarc:sq -->
</xsl:for-each> <!-- tmarc:d773 -->
<xsl:for-each select="tmarc:d852">
<xsl:for-each select="tmarc:sy">
<pz:metadata type="publicnote">
<xsl:value-of select="."/>
</pz:metadata>
</xsl:for-each>
<xsl:for-each select="tmarc:sh">
<pz:metadata type="callnumber">
<xsl:value-of select="."/>
</pz:metadata>
</xsl:for-each>
</xsl:for-each>
<xsl:for-each select="tmarc:d876">
<xsl:if test="tmarc:sf">
<pz:metadata type="loan-period">
<xsl:value-of select="concat(tmarc:s5,':',tmarc:sf)"/>
</pz:metadata>
</xsl:if>
</xsl:for-each>