1 <?xml version="1.0" encoding="UTF-8"?>
2 <xsl:stylesheet version="1.0"
3 xmlns="http://www.indexdata.com/turbomarc"
4 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5 xmlns:pz="http://www.indexdata.com/pazpar2/1.0"
6 xmlns:tmarc="http://www.indexdata.com/turbomarc">
8 <xsl:output indent="yes" method="xml" version="1.0"
10 <xsl:param name="medium"/>
12 <!-- Extract metadata from MARC21/USMARC from streamlined marcxml format
13 http://www.loc.gov/marc/bibliographic/ecbdhome.html -->
14 <xsl:template name="record-hook" />
17 <xsl:template match="/">
18 <xsl:apply-templates />
21 <xsl:template match="tmarc:collection">
23 <xsl:apply-templates />
27 <xsl:template match="tmarc:r">
28 <xsl:variable name="title_medium" select="tmarc:d245/tmarc:sh" />
29 <xsl:variable name="journal_title" select="tmarc:d773/tmarc:st" />
30 <xsl:variable name="electronic_location_url" select="tmarc:d856/tmarc:su" />
31 <xsl:variable name="fulltext_a" select="tmarc:d900/tmarc:sa" />
32 <xsl:variable name="fulltext_b" select="tmarc:d900/tmarc:sb" />
33 <!-- Does not always hit the right substring. The field is not always fixed-width? -->
34 <xsl:variable name="control_lang" select="substring(tmarc:c008, 36, 3)" />
35 <xsl:variable name="contains110" select="tmarc:d110" />
36 <xsl:variable name="hasAuthorFields" select="tmarc:d100 or tmarc:d111" />
37 <xsl:variable name="typeofrec" select="substring(tmarc:l, 7, 1)"/>
38 <xsl:variable name="typeofvm" select="substring(tmarc:c008, 34, 1)"/>
39 <xsl:variable name="biblevel" select="substring(tmarc:l, 8, 1)"/>
40 <xsl:variable name="physdes" select="substring(tmarc:c007, 1, 1)"/>
41 <xsl:variable name="form1" select="substring(tmarc:c008, 24, 1)"/>
42 <xsl:variable name="form2" select="substring(tmarc:c008, 30, 1)"/>
43 <xsl:variable name="oclca" select="substring(tmarc:c007, 1, 1)"/>
44 <xsl:variable name="oclcb" select="substring(tmarc:c007, 2, 1)"/>
45 <xsl:variable name="oclcd" select="substring(tmarc:c007, 4, 1)"/>
46 <xsl:variable name="oclce" select="substring(tmarc:c007, 5, 1)"/>
47 <xsl:variable name="typeofserial" select="substring(tmarc:c008, 22, 1)"/>
49 <xsl:variable name="electronic">
51 <xsl:when test="$form1='s' or $form1='q' or $form1='o' or
52 $form2='s' or $form2='q' or $form2='o'">
53 <xsl:text>yes</xsl:text>
59 <xsl:variable name="vmedium">
61 <xsl:when test="string-length($medium)"><xsl:value-of select="$medium" /></xsl:when>
62 <xsl:when test="($typeofrec='a' or $typeofrec='t') and $biblevel='m'">book</xsl:when>
63 <xsl:when test="$typeofrec='j' or $typeofrec='i'">
64 <xsl:text>recording</xsl:text>
66 <xsl:when test="$oclcb='d' and $oclcd='f'">-cd</xsl:when>
67 <xsl:when test="$oclcb='s'">-cassette</xsl:when>
68 <xsl:when test="$oclcb='d' and $oclcd='a' or $oclcd='b' or
69 $oclcd='c' or $oclcd='d' or $oclcd='e'">-vinyl</xsl:when>
72 <xsl:when test="$typeofrec='g'">
74 <xsl:when test="$typeofvm='m' or $typeofvm='v'">
75 <xsl:text>video</xsl:text>
77 <xsl:when test="$oclca='v' and $oclcb='d' and $oclce='v'">-dvd</xsl:when>
78 <xsl:when test="$oclca='v' and $oclcb='d' and $oclce='s'">-blu-ray</xsl:when>
79 <xsl:when test="$oclca='v' and $oclcb='f' and $oclce='b'">-vhs</xsl:when>
82 <xsl:otherwise>audio-visual</xsl:otherwise>
85 <xsl:when test="$typeofrec='a' and $biblevel='s'">
87 <xsl:when test="$typeofserial='n'">newspaper</xsl:when>
88 <xsl:otherwise>journal</xsl:otherwise>
91 <xsl:when test="$typeofrec='e' or $typeofrec='f'">map</xsl:when>
92 <xsl:when test="$typeofrec='c' or $typeofrec='d'">music-score</xsl:when>
93 <xsl:when test="$form1='a' or $form1='b' or $form1='c'">microform</xsl:when>
94 <xsl:when test="$typeofrec='t'">thesis</xsl:when>
95 <!-- <xsl:when test="$journal_title">article</xsl:when> -->
96 <xsl:when test="$typeofrec='a' or $typeofrec='i' and
97 ($typeofserial='d' or $typeofserial='w')">web</xsl:when>
98 <xsl:when test="$typeofrec='a' and $biblevel='b'">article</xsl:when>
99 <xsl:when test="$typeofrec='m'">electronic</xsl:when>
101 <xsl:text>other</xsl:text>
106 <xsl:variable name="has_fulltext">
108 <xsl:when test="tmarc:d856/tmarc:sq">
109 <xsl:text>yes</xsl:text>
111 <xsl:when test="tmarc:d856/tmarc:si='TEXT*'">
112 <xsl:text>yes</xsl:text>
115 <xsl:text>no</xsl:text>
120 <xsl:variable name="oclc_number">
122 <xsl:when test='contains(tmarc:c001,"ocn") or
123 contains(tmarc:c001,"ocm") or
124 contains(tmarc:c001,"OCoLC") '>
125 <xsl:value-of select="tmarc:c001"/>
127 <xsl:when test='contains(tmarc:d035/tmarc:sa,"ocn") or
128 contains(tmarc:d035/tmarc:sa,"ocm") or
129 contains(tmarc:d035/tmarc:sa,"OCoLC") '>
130 <xsl:value-of select="tmarc:d035/tmarc:sa"/>
135 <xsl:variable name="date_008">
137 <xsl:when test="contains('cestpudikmr', substring(tmarc:c008, 7, 1))">
138 <xsl:value-of select="substring(tmarc:c008, 8, 4)" />
143 <xsl:variable name="date_end_008">
145 <xsl:when test="contains('dikmr', substring(tmarc:c008, 7, 1))">
146 <xsl:value-of select="substring(tmarc:c008, 12, 4)" />
153 <xsl:attribute name="mergekey">
154 <xsl:text>title </xsl:text>
155 <xsl:value-of select="tmarc:d245/tmarc:sa" />
156 <xsl:text> author </xsl:text>
157 <xsl:value-of select="tmarc:d100/tmarc:sa" />
158 <xsl:text> medium </xsl:text>
159 <xsl:value-of select="$medium" />
163 <xsl:for-each select="tmarc:c001">
164 <pz:metadata type="id">
165 <xsl:value-of select="." />
169 <xsl:if test="string-length($oclc_number) > 0">
170 <pz:metadata type="oclc-number">
171 <xsl:value-of select="$oclc_number" />
175 <xsl:for-each select="tmarc:d010">
176 <xsl:for-each select="tmarc:sa">
177 <pz:metadata type="lccn">
178 <xsl:value-of select="." />
183 <xsl:for-each select="tmarc:d020">
184 <xsl:for-each select="tmarc:sa">
185 <pz:metadata type="isbn">
186 <xsl:value-of select="." />
191 <xsl:for-each select="tmarc:d022">
192 <xsl:for-each select="tmarc:sa">
193 <pz:metadata type="issn">
194 <xsl:value-of select="." />
199 <xsl:for-each select="tmarc:d027">
200 <xsl:for-each select="tmarc:sa">
201 <pz:metadata type="tech-rep-nr">
202 <xsl:value-of select="tmarc:sa" />
207 <xsl:for-each select="tmarc:d035">
208 <pz:metadata type="system-control-nr">
210 <xsl:when test="tmarc:sa">
211 <xsl:value-of select="tmarc:sa"/>
214 <xsl:value-of select="tmarc:sb"/>
220 <xsl:for-each select="tmarc:d100">
221 <xsl:for-each select="tmarc:sa">
222 <pz:metadata type="author">
223 <xsl:value-of select="." />
226 <xsl:for-each select="tmarc:sc">
227 <pz:metadata type="author-title">
228 <xsl:value-of select="." />
231 <xsl:for-each select="tmarc:sd">
232 <pz:metadata type="author-date">
233 <xsl:value-of select="." />
238 <xsl:for-each select="tmarc:d110">
239 <xsl:for-each select="tmarc:sa">
240 <pz:metadata type="corporate-name">
241 <xsl:value-of select="." />
244 <xsl:for-each select="tmarc:sc">
245 <pz:metadata type="corporate-location">
246 <xsl:value-of select="." />
249 <xsl:for-each select="tmarc:sd">
250 <pz:metadata type="corporate-date">
251 <xsl:value-of select="." />
256 <xsl:for-each select="tmarc:d111">
257 <xsl:for-each select="tmarc:sa">
258 <pz:metadata type="meeting-name">
259 <xsl:value-of select="." />
262 <xsl:for-each select="tmarc:sc">
263 <pz:metadata type="meeting-location">
264 <xsl:value-of select="." />
267 <xsl:for-each select="tmarc:sd">
268 <pz:metadata type="meeting-date">
269 <xsl:value-of select="." />
274 <xsl:for-each select="tmarc:d260">
275 <xsl:for-each select="tmarc:sc">
276 <pz:metadata type="date">
277 <xsl:value-of select="translate(., 'cp[].', '')" />
282 <xsl:if test="string-length($date_008) > 0 and not(tmarc:d260)">
283 <pz:metadata type="date">
285 <xsl:when test="$date_end_008">
286 <xsl:value-of select="concat($date_008,'-',$date_end_008)" />
289 <xsl:value-of select="$date_008" />
295 <xsl:for-each select="tmarc:d130">
296 <xsl:for-each select="tmarc:sa">
297 <pz:metadata type="title-uniform">
298 <xsl:value-of select="." />
301 <xsl:for-each select="tmarc:sm">
302 <pz:metadata type="title-uniform-media">
303 <xsl:value-of select="." />
306 <xsl:for-each select="tmarc:sn">
307 <pz:metadata type="title-uniform-parts">
308 <xsl:value-of select="." />
311 <xsl:for-each select="tmarc:sp">
312 <pz:metadata type="title-uniform-partname">
313 <xsl:value-of select="." />
316 <xsl:for-each select="tmarc:sr">
317 <pz:metadata type="title-uniform-key">
318 <xsl:value-of select="." />
323 <xsl:for-each select="tmarc:d245">
324 <xsl:for-each select="tmarc:sa">
325 <pz:metadata type="title">
326 <xsl:value-of select="." />
329 <xsl:for-each select="tmarc:sb">
330 <pz:metadata type="title-remainder">
331 <xsl:value-of select="." />
334 <xsl:for-each select="tmarc:sc">
335 <pz:metadata type="title-responsibility">
336 <xsl:value-of select="." />
339 <xsl:for-each select="tmarc:sf">
340 <pz:metadata type="title-dates">
341 <xsl:value-of select="." />
344 <xsl:for-each select="tmarc:sh">
345 <pz:metadata type="title-medium">
346 <xsl:value-of select="." />
349 <xsl:for-each select="tmarc:sn">
350 <pz:metadata type="title-number-section">
351 <xsl:value-of select="." />
354 <xsl:if test="tmarc:sa">
355 <pz:metadata type="title-complete">
356 <xsl:value-of select="tmarc:sa" />
357 <xsl:if test="tmarc:sb" ><xsl:value-of select="concat(' ', tmarc:sb)" /></xsl:if>
362 <xsl:for-each select="tmarc:d250">
363 <xsl:for-each select="tmarc:sa">
364 <pz:metadata type="edition">
365 <xsl:value-of select="." />
370 <xsl:for-each select="tmarc:d260">
371 <xsl:for-each select="tmarc:sa">
372 <pz:metadata type="publication-place">
373 <xsl:value-of select="." />
376 <xsl:for-each select="tmarc:sb">
377 <pz:metadata type="publication-name">
378 <xsl:value-of select="." />
381 <xsl:for-each select="tmarc:sc">
382 <pz:metadata type="publication-date">
383 <xsl:value-of select="." />
388 <xsl:for-each select="tmarc:d300">
389 <xsl:for-each select="tmarc:sa">
390 <pz:metadata type="physical-extent">
391 <xsl:value-of select="." />
394 <xsl:for-each select="tmarc:sb">
395 <pz:metadata type="physical-format">
396 <xsl:value-of select="." />
399 <xsl:for-each select="tmarc:sc">
400 <pz:metadata type="physical-dimensions">
401 <xsl:value-of select="." />
404 <xsl:for-each select="tmarc:se">
405 <pz:metadata type="physical-accomp">
406 <xsl:value-of select="." />
409 <xsl:for-each select="tmarc:sf">
410 <pz:metadata type="physical-unittype">
411 <xsl:value-of select="." />
414 <xsl:for-each select="tmarc:sg">
415 <pz:metadata type="physical-unitsize">
416 <xsl:value-of select="." />
419 <xsl:for-each select="tmarc:s3">
420 <pz:metadata type="physical-specified">
421 <xsl:value-of select="." />
426 <xsl:for-each select="tmarc:d440">
427 <xsl:for-each select="tmarc:sa">
428 <pz:metadata type="series-title">
429 <xsl:value-of select="." />
434 <xsl:for-each select="tmarc:d500">
435 <pz:metadata type="description">
436 <xsl:for-each select="node()">
437 <xsl:value-of select="text()" />
442 <xsl:for-each select="tmarc:d505">
443 <pz:metadata type="description">
444 <xsl:for-each select="node()">
445 <xsl:value-of select="text()" />
450 <xsl:for-each select="tmarc:d518">
451 <pz:metadata type="description">
452 <xsl:for-each select="node()">
453 <xsl:value-of select="text()" />
458 <xsl:for-each select="tmarc:d520">
459 <pz:metadata type="description">
460 <xsl:for-each select="node()">
461 <xsl:value-of select="text()" />
466 <xsl:for-each select="tmarc:d522">
467 <pz:metadata type="description">
468 <xsl:for-each select="node()">
469 <xsl:value-of select="text()" />
474 <xsl:for-each select="tmarc:d911">
475 <pz:metadata type="description">
476 <xsl:for-each select="node()">
477 <xsl:value-of select="text()" />
482 <xsl:for-each select="tmarc:d600 | tmarc:d610 | tmarc:d611 | tmarc:d630 |
483 tmarc:d648 | tmarc:d650 | tmarc:d651 | tmarc:d653 |
484 tmarc:d654 | tmarc:d655 | tmarc:d656 | tmarc:d657 |
485 tmarc:d658 | tmarc:d662 | tmarc:d69X">
486 <xsl:for-each select="tmarc:sa">
487 <pz:metadata type="subject">
488 <xsl:value-of select="."/>
491 <pz:metadata type="subject-long">
492 <xsl:for-each select="node()/text()">
493 <xsl:if test="position() > 1">
494 <xsl:text>, </xsl:text>
496 <xsl:variable name='value'>
497 <xsl:value-of select='normalize-space(.)'/>
500 <xsl:when test="substring($value, string-length($value)) = ','">
501 <xsl:value-of select="substring($value, 1, string-length($value)-1)"/>
504 <xsl:value-of select="$value"/>
511 <xsl:for-each select="tmarc:d856">
512 <xsl:for-each select="tmarc:su">
513 <pz:metadata type="electronic-url">
514 <xsl:value-of select="." />
517 <pz:metadata type="electronic-text">
519 <xsl:when test="tmarc:sy">
520 <xsl:value-of select="tmarc:sy/text()" />
522 <xsl:when test="tmarc:s3">
523 <xsl:value-of select="tmarc:s3/text()" />
525 <xsl:when test="tmarc:sa">
526 <xsl:value-of select="tmarc:sa/text()" />
528 <xsl:otherwise>Get resource</xsl:otherwise>
531 <xsl:for-each select="tmarc:sz">
532 <pz:metadata type="electronic-note">
533 <xsl:value-of select="." />
536 <xsl:for-each select="tmarc:si">
537 <pz:metadata type="electronic-format-instruction">
538 <xsl:value-of select="." />
541 <xsl:for-each select="tmarc:sq">
542 <pz:metadata type="electronic-format-type">
543 <xsl:value-of select="." />
548 <xsl:for-each select="tmarc:d773">
549 <pz:metadata type="citation">
550 <xsl:for-each select="*">
551 <xsl:value-of select="normalize-space(.)" />
552 <xsl:text> </xsl:text>
555 <xsl:for-each select="tmarc:st">
556 <pz:metadata type="journal-title">
557 <xsl:value-of select="."/>
560 <xsl:if test="tmarc:sg">
561 <xsl:variable name="value">
562 <xsl:for-each select="tmarc:sg">
563 <xsl:value-of select="."/>
566 <pz:metadata type="journal-subpart">
567 <xsl:value-of select="$value"/>
569 <xsl:variable name="l">
570 <xsl:value-of select="translate($value,
571 'ABCDEFGHIJKLMNOPQRSTUVWXYZ.',
572 'abcdefghijklmnopqrstuvwxyz ') "/>
574 <xsl:variable name="volume">
576 <xsl:when test="string-length(substring-after($l,'vol ')) > 0">
577 <xsl:value-of select="substring-before(normalize-space(substring-after($l,'vol ')),' ')"/>
579 <xsl:when test="string-length(substring-after($l,'v ')) > 0">
580 <xsl:value-of select="substring-before(normalize-space(substring-after($l,'v ')),' ')"/>
584 <xsl:variable name="issue">
585 <xsl:value-of select="substring-before(translate(normalize-space(substring-after($l,'issue')), ',', ' '),' ')"/>
587 <xsl:variable name="pages">
589 <xsl:when test="string-length(substring-after($l,' p ')) > 0">
590 <xsl:value-of select="normalize-space(substring-after($l,' p '))"/>
592 <xsl:when test="string-length(substring-after($l,',p')) > 0">
593 <xsl:value-of select="normalize-space(substring-after($l,',p'))"/>
595 <xsl:when test="string-length(substring-after($l,' p')) > 0">
596 <xsl:value-of select="normalize-space(substring-after($l,' p'))"/>
602 <xsl:if test="string-length($volume) > 0">
603 <pz:metadata type="volume-number">
604 <xsl:value-of select="$volume"/>
608 <xsl:if test="string-length($issue) > 0">
609 <pz:metadata type="issue-number">
610 <xsl:value-of select="$issue"/>
614 <xsl:if test="string-length($pages) > 0">
615 <pz:metadata type="pages-number">
616 <xsl:value-of select="$pages"/>
622 <xsl:if test="tmarc:sp">
623 <pz:metadata type="journal-title-abbrev">
624 <xsl:value-of select="tmarc:sp"/>
629 <xsl:for-each select="tmarc:d852">
630 <xsl:for-each select="tmarc:sy">
631 <pz:metadata type="publicnote">
632 <xsl:value-of select="." />
635 <xsl:for-each select="tmarc:sh">
636 <pz:metadata type="callnumber">
637 <xsl:value-of select="." />
642 <xsl:for-each select="tmarc:d876">
643 <xsl:if test="tmarc:sf">
644 <pz:metadata type="loan-period">
645 <xsl:value-of select="concat(tmarc:s5,':',tmarc:sf)" />
650 <pz:metadata type="medium">
651 <xsl:value-of select="$vmedium" />
652 <xsl:if test="string-length($electronic) and $vmedium != 'electronic'">
653 <xsl:text> (electronic)</xsl:text>
657 <xsl:for-each select="tmarc:d900/tmarc:sa">
658 <pz:metadata type="fulltext">
659 <xsl:value-of select="." />
663 <!-- <xsl:if test="$fulltext_a"> <pz:metadata type="fulltext"> <xsl:value-of
664 select="$fulltext_a"/> </pz:metadata> </xsl:if> -->
666 <xsl:for-each select="tmarc:d900/tmarc:sb">
667 <pz:metadata type="fulltext">
668 <xsl:value-of select="." />
672 <xsl:for-each select="tmarc:d900/tmarc:se">
673 <pz:metadata type="fulltext">
674 <xsl:value-of select="." />
678 <xsl:for-each select="tmarc:d900/tmarc:sf">
679 <pz:metadata type="fulltext">
680 <xsl:value-of select="." />
684 <xsl:for-each select="tmarc:d900/tmarc:si">
685 <pz:metadata type="fulltext">
686 <xsl:value-of select="." />
690 <xsl:for-each select="tmarc:d900/tmarc:sk">
691 <pz:metadata type="fulltext">
692 <xsl:value-of select="." />
696 <xsl:for-each select="tmarc:d900/tmarc:sq">
697 <pz:metadata type="fulltext">
698 <xsl:value-of select="." />
702 <xsl:for-each select="tmarc:d900/tmarc:ss">
703 <pz:metadata type="fulltext">
704 <xsl:value-of select="." />
708 <xsl:for-each select="tmarc:d900/tmarc:su">
709 <pz:metadata type="fulltext">
710 <xsl:value-of select="." />
714 <xsl:for-each select="tmarc:d900/tmarc:sy">
715 <pz:metadata type="fulltext">
716 <xsl:value-of select="." />
720 <xsl:for-each select="tmarc:d903">
721 <xsl:if test="tmarc:sa">
722 <pz:metadata type="publication-date">
723 <xsl:value-of select="substring(tmarc:sa,1,4)"/>
725 <pz:metadata type="date">
726 <xsl:value-of select="substring(tmarc:sa,1,4)"/>
731 <!-- <xsl:if test="$fulltext_b"> <pz:metadata type="fulltext"> <xsl:value-of
732 select="$fulltext_b"/> </pz:metadata> </xsl:if> -->
734 <pz:metadata type="has-fulltext">
735 <xsl:value-of select="$has_fulltext"/>
738 <xsl:for-each select="tmarc:d907 | tmarc:d901">
739 <pz:metadata type="iii-id">
740 <xsl:value-of select="tmarc:sa" />
744 <xsl:for-each select="tmarc:d926">
745 <pz:metadata type="locallocation" empty="PAZPAR2_NULL_VALUE">
746 <xsl:value-of select="tmarc:sa"/>
748 <pz:metadata type="callnumber" empty="PAZPAR2_NULL_VALUE">
749 <xsl:value-of select="tmarc:sc"/>
751 <pz:metadata type="available" empty="PAZPAR2_NULL_VALUE">
752 <xsl:value-of select="tmarc:se"/>
756 <!-- OhioLINK holdings -->
757 <xsl:for-each select="tmarc:d945">
758 <pz:metadata type="locallocation" empty="PAZPAR2_NULL_VALUE">
759 <xsl:value-of select="tmarc:sa"/>
761 <pz:metadata type="callnumber" empty="PAZPAR2_NULL_VALUE">
762 <xsl:value-of select="tmarc:sb"/>
764 <pz:metadata type="publicnote" empty="PAZPAR2_NULL_VALUE">
765 <xsl:value-of select="tmarc:sc"/>
767 <pz:metadata type="available" empty="PAZPAR2_NULL_VALUE">
769 <xsl:when test="tmarc:ss = 'N'">Available</xsl:when>
771 <xsl:value-of select="tmarc:sd"/>
777 <xsl:for-each select="tmarc:d948">
778 <pz:metadata type="holding">
779 <xsl:for-each select="tmarc:s">
780 <xsl:if test="position() > 1">
781 <xsl:text> </xsl:text>
783 <xsl:value-of select="." />
788 <xsl:for-each select="tmarc:d991">
789 <pz:metadata type="holding">
790 <xsl:for-each select="tmarc:s">
791 <xsl:if test="position() > 1">
792 <xsl:text> </xsl:text>
794 <xsl:value-of select="." />
799 <xsl:for-each select="tmarc:d999">
800 <pz:metadata type="localid">
802 <xsl:when test="tmarc:sa">
803 <xsl:value-of select="tmarc:sa"/>
805 <xsl:when test="tmarc:sc">
806 <xsl:value-of select="tmarc:sc"/>
809 <xsl:value-of select="tmarc:sd"/>
816 <!-- passthrough id data -->
817 <xsl:for-each select="pz:metadata">
818 <xsl:copy-of select="." />
821 <!-- other stylesheets importing this might want to define this -->
822 <xsl:call-template name="record-hook" />
827 <xsl:template match="text()" />