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>
100 <xsl:when test="$title_medium">
101 <xsl:value-of select="translate($title_medium, ' []/:', '')" />
104 <xsl:text>other</xsl:text>
109 <xsl:variable name="has_fulltext">
111 <xsl:when test="tmarc:d856/tmarc:sq">
112 <xsl:text>yes</xsl:text>
114 <xsl:when test="tmarc:d856/tmarc:si='TEXT*'">
115 <xsl:text>yes</xsl:text>
118 <xsl:text>no</xsl:text>
123 <xsl:variable name="oclc_number">
125 <xsl:when test='contains(tmarc:c001,"ocn") or
126 contains(tmarc:c001,"ocm") or
127 contains(tmarc:c001,"OCoLC") '>
128 <xsl:value-of select="tmarc:c001"/>
130 <xsl:when test='contains(tmarc:d035/tmarc:sa,"ocn") or
131 contains(tmarc:d035/tmarc:sa,"ocm") or
132 contains(tmarc:d035/tmarc:sa,"OCoLC") '>
133 <xsl:value-of select="tmarc:d035/tmarc:sa"/>
138 <xsl:variable name="date_008">
140 <xsl:when test="contains('cestpudikmr', substring(tmarc:c008, 7, 1))">
141 <xsl:value-of select="substring(tmarc:c008, 8, 4)" />
146 <xsl:variable name="date_end_008">
148 <xsl:when test="contains('dikmr', substring(tmarc:c008, 7, 1))">
149 <xsl:value-of select="substring(tmarc:c008, 12, 4)" />
156 <xsl:attribute name="mergekey">
157 <xsl:text>title </xsl:text>
158 <xsl:value-of select="tmarc:d245/tmarc:sa" />
159 <xsl:text> author </xsl:text>
160 <xsl:value-of select="tmarc:d100/tmarc:sa" />
161 <xsl:text> medium </xsl:text>
162 <xsl:value-of select="$medium" />
166 <xsl:for-each select="tmarc:c001">
167 <pz:metadata type="id">
168 <xsl:value-of select="." />
172 <xsl:if test="string-length($oclc_number) > 0">
173 <pz:metadata type="oclc-number">
174 <xsl:value-of select="$oclc_number" />
178 <xsl:for-each select="tmarc:d010">
179 <xsl:for-each select="tmarc:sa">
180 <pz:metadata type="lccn">
181 <xsl:value-of select="." />
186 <xsl:for-each select="tmarc:d020">
187 <xsl:for-each select="tmarc:sa">
188 <pz:metadata type="isbn">
189 <xsl:value-of select="." />
194 <xsl:for-each select="tmarc:d022">
195 <xsl:for-each select="tmarc:sa">
196 <pz:metadata type="issn">
197 <xsl:value-of select="." />
202 <xsl:for-each select="tmarc:d027">
203 <xsl:for-each select="tmarc:sa">
204 <pz:metadata type="tech-rep-nr">
205 <xsl:value-of select="tmarc:sa" />
210 <xsl:for-each select="tmarc:d035">
211 <pz:metadata type="system-control-nr">
213 <xsl:when test="tmarc:sa">
214 <xsl:value-of select="tmarc:sa"/>
217 <xsl:value-of select="tmarc:sb"/>
223 <xsl:for-each select="tmarc:d100">
224 <xsl:for-each select="tmarc:sa">
225 <pz:metadata type="author">
226 <xsl:value-of select="." />
229 <xsl:for-each select="tmarc:sc">
230 <pz:metadata type="author-title">
231 <xsl:value-of select="." />
234 <xsl:for-each select="tmarc:sd">
235 <pz:metadata type="author-date">
236 <xsl:value-of select="." />
241 <xsl:for-each select="tmarc:d110">
242 <xsl:for-each select="tmarc:sa">
243 <pz:metadata type="corporate-name">
244 <xsl:value-of select="." />
247 <xsl:for-each select="tmarc:sc">
248 <pz:metadata type="corporate-location">
249 <xsl:value-of select="." />
252 <xsl:for-each select="tmarc:sd">
253 <pz:metadata type="corporate-date">
254 <xsl:value-of select="." />
259 <xsl:for-each select="tmarc:d111">
260 <xsl:for-each select="tmarc:sa">
261 <pz:metadata type="meeting-name">
262 <xsl:value-of select="." />
265 <xsl:for-each select="tmarc:sc">
266 <pz:metadata type="meeting-location">
267 <xsl:value-of select="." />
270 <xsl:for-each select="tmarc:sd">
271 <pz:metadata type="meeting-date">
272 <xsl:value-of select="." />
277 <xsl:for-each select="tmarc:d260">
278 <xsl:for-each select="tmarc:sc">
279 <pz:metadata type="date">
280 <xsl:value-of select="translate(., 'cp[].', '')" />
285 <xsl:if test="string-length($date_008) > 0 and not(tmarc:d260)">
286 <pz:metadata type="date">
288 <xsl:when test="$date_end_008">
289 <xsl:value-of select="concat($date_008,'-',$date_end_008)" />
292 <xsl:value-of select="$date_008" />
298 <xsl:for-each select="tmarc:d130">
299 <xsl:for-each select="tmarc:sa">
300 <pz:metadata type="title-uniform">
301 <xsl:value-of select="." />
304 <xsl:for-each select="tmarc:sm">
305 <pz:metadata type="title-uniform-media">
306 <xsl:value-of select="." />
309 <xsl:for-each select="tmarc:sn">
310 <pz:metadata type="title-uniform-parts">
311 <xsl:value-of select="." />
314 <xsl:for-each select="tmarc:sp">
315 <pz:metadata type="title-uniform-partname">
316 <xsl:value-of select="." />
319 <xsl:for-each select="tmarc:sr">
320 <pz:metadata type="title-uniform-key">
321 <xsl:value-of select="." />
326 <xsl:for-each select="tmarc:d245">
327 <xsl:for-each select="tmarc:sa">
328 <pz:metadata type="title">
329 <xsl:value-of select="." />
332 <xsl:for-each select="tmarc:sb">
333 <pz:metadata type="title-remainder">
334 <xsl:value-of select="." />
337 <xsl:for-each select="tmarc:sc">
338 <pz:metadata type="title-responsibility">
339 <xsl:value-of select="." />
342 <xsl:for-each select="tmarc:sf">
343 <pz:metadata type="title-dates">
344 <xsl:value-of select="." />
347 <xsl:for-each select="tmarc:sh">
348 <pz:metadata type="title-medium">
349 <xsl:value-of select="." />
352 <xsl:for-each select="tmarc:sn">
353 <pz:metadata type="title-number-section">
354 <xsl:value-of select="." />
357 <xsl:if test="tmarc:sa">
358 <pz:metadata type="title-complete">
359 <xsl:value-of select="tmarc:sa" />
360 <xsl:if test="tmarc:sb" ><xsl:value-of select="concat(' ', tmarc:sb)" /></xsl:if>
365 <xsl:for-each select="tmarc:d250">
366 <xsl:for-each select="tmarc:sa">
367 <pz:metadata type="edition">
368 <xsl:value-of select="." />
373 <xsl:for-each select="tmarc:d260">
374 <xsl:for-each select="tmarc:sa">
375 <pz:metadata type="publication-place">
376 <xsl:value-of select="." />
379 <xsl:for-each select="tmarc:sb">
380 <pz:metadata type="publication-name">
381 <xsl:value-of select="." />
384 <xsl:for-each select="tmarc:sc">
385 <pz:metadata type="publication-date">
386 <xsl:value-of select="." />
391 <xsl:for-each select="tmarc:d300">
392 <xsl:for-each select="tmarc:sa">
393 <pz:metadata type="physical-extent">
394 <xsl:value-of select="." />
397 <xsl:for-each select="tmarc:sb">
398 <pz:metadata type="physical-format">
399 <xsl:value-of select="." />
402 <xsl:for-each select="tmarc:sc">
403 <pz:metadata type="physical-dimensions">
404 <xsl:value-of select="." />
407 <xsl:for-each select="tmarc:se">
408 <pz:metadata type="physical-accomp">
409 <xsl:value-of select="." />
412 <xsl:for-each select="tmarc:sf">
413 <pz:metadata type="physical-unittype">
414 <xsl:value-of select="." />
417 <xsl:for-each select="tmarc:sg">
418 <pz:metadata type="physical-unitsize">
419 <xsl:value-of select="." />
422 <xsl:for-each select="tmarc:s3">
423 <pz:metadata type="physical-specified">
424 <xsl:value-of select="." />
429 <xsl:for-each select="tmarc:d440">
430 <xsl:for-each select="tmarc:sa">
431 <pz:metadata type="series-title">
432 <xsl:value-of select="." />
437 <xsl:for-each select="tmarc:d500">
438 <pz:metadata type="description">
439 <xsl:for-each select="node()">
440 <xsl:value-of select="text()" />
445 <xsl:for-each select="tmarc:d505">
446 <pz:metadata type="description">
447 <xsl:for-each select="node()">
448 <xsl:value-of select="text()" />
453 <xsl:for-each select="tmarc:d518">
454 <pz:metadata type="description">
455 <xsl:for-each select="node()">
456 <xsl:value-of select="text()" />
461 <xsl:for-each select="tmarc:d520">
462 <pz:metadata type="description">
463 <xsl:for-each select="node()">
464 <xsl:value-of select="text()" />
469 <xsl:for-each select="tmarc:d522">
470 <pz:metadata type="description">
471 <xsl:for-each select="node()">
472 <xsl:value-of select="text()" />
477 <xsl:for-each select="tmarc:d911">
478 <pz:metadata type="description">
479 <xsl:for-each select="node()">
480 <xsl:value-of select="text()" />
485 <xsl:for-each select="tmarc:d600 | tmarc:d610 | tmarc:d611 | tmarc:d630 |
486 tmarc:d648 | tmarc:d650 | tmarc:d651 | tmarc:d653 |
487 tmarc:d654 | tmarc:d655 | tmarc:d656 | tmarc:d657 |
488 tmarc:d658 | tmarc:d662 | tmarc:d69X">
489 <xsl:for-each select="tmarc:sa">
490 <pz:metadata type="subject">
491 <xsl:value-of select="."/>
494 <pz:metadata type="subject-long">
495 <xsl:for-each select="node()/text()">
496 <xsl:if test="position() > 1">
497 <xsl:text>, </xsl:text>
499 <xsl:variable name='value'>
500 <xsl:value-of select='normalize-space(.)'/>
503 <xsl:when test="substring($value, string-length($value)) = ','">
504 <xsl:value-of select="substring($value, 1, string-length($value)-1)"/>
507 <xsl:value-of select="$value"/>
514 <xsl:for-each select="tmarc:d856">
515 <xsl:for-each select="tmarc:su">
516 <pz:metadata type="electronic-url">
517 <xsl:value-of select="." />
520 <pz:metadata type="electronic-text">
522 <xsl:when test="tmarc:sy">
523 <xsl:value-of select="tmarc:sy/text()" />
525 <xsl:when test="tmarc:s3">
526 <xsl:value-of select="tmarc:s3/text()" />
528 <xsl:when test="tmarc:sa">
529 <xsl:value-of select="tmarc:sa/text()" />
531 <xsl:otherwise>Get resource</xsl:otherwise>
534 <xsl:for-each select="tmarc:sz">
535 <pz:metadata type="electronic-note">
536 <xsl:value-of select="." />
539 <xsl:for-each select="tmarc:si">
540 <pz:metadata type="electronic-format-instruction">
541 <xsl:value-of select="." />
544 <xsl:for-each select="tmarc:sq">
545 <pz:metadata type="electronic-format-type">
546 <xsl:value-of select="." />
551 <xsl:for-each select="tmarc:d773">
552 <pz:metadata type="citation">
553 <xsl:for-each select="*">
554 <xsl:value-of select="normalize-space(.)" />
555 <xsl:text> </xsl:text>
558 <xsl:for-each select="tmarc:st">
559 <pz:metadata type="journal-title">
560 <xsl:value-of select="."/>
563 <xsl:if test="tmarc:sg">
564 <xsl:variable name="value">
565 <xsl:for-each select="tmarc:sg">
566 <xsl:value-of select="."/>
569 <pz:metadata type="journal-subpart">
570 <xsl:value-of select="$value"/>
572 <xsl:variable name="l">
573 <xsl:value-of select="translate($value,
574 'ABCDEFGHIJKLMNOPQRSTUVWXYZ.',
575 'abcdefghijklmnopqrstuvwxyz ') "/>
577 <xsl:variable name="volume">
579 <xsl:when test="string-length(substring-after($l,'vol ')) > 0">
580 <xsl:value-of select="substring-before(normalize-space(substring-after($l,'vol ')),' ')"/>
582 <xsl:when test="string-length(substring-after($l,'v ')) > 0">
583 <xsl:value-of select="substring-before(normalize-space(substring-after($l,'v ')),' ')"/>
587 <xsl:variable name="issue">
588 <xsl:value-of select="substring-before(translate(normalize-space(substring-after($l,'issue')), ',', ' '),' ')"/>
590 <xsl:variable name="pages">
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'))"/>
598 <xsl:when test="string-length(substring-after($l,' p')) > 0">
599 <xsl:value-of select="normalize-space(substring-after($l,' p'))"/>
605 <xsl:if test="string-length($volume) > 0">
606 <pz:metadata type="volume-number">
607 <xsl:value-of select="$volume"/>
611 <xsl:if test="string-length($issue) > 0">
612 <pz:metadata type="issue-number">
613 <xsl:value-of select="$issue"/>
617 <xsl:if test="string-length($pages) > 0">
618 <pz:metadata type="pages-number">
619 <xsl:value-of select="$pages"/>
625 <xsl:if test="tmarc:sp">
626 <pz:metadata type="journal-title-abbrev">
627 <xsl:value-of select="tmarc:sp"/>
632 <xsl:for-each select="tmarc:d852">
633 <xsl:for-each select="tmarc:sy">
634 <pz:metadata type="publicnote">
635 <xsl:value-of select="." />
638 <xsl:for-each select="tmarc:sh">
639 <pz:metadata type="callnumber">
640 <xsl:value-of select="." />
645 <xsl:for-each select="tmarc:d876">
646 <xsl:if test="tmarc:sf">
647 <pz:metadata type="loan-period">
648 <xsl:value-of select="concat(tmarc:s5,':',tmarc:sf)" />
653 <pz:metadata type="medium">
654 <xsl:value-of select="$vmedium" />
655 <xsl:if test="string-length($electronic) and $vmedium != 'electronic'">
656 <xsl:text> (electronic)</xsl:text>
660 <xsl:for-each select="tmarc:d900/tmarc:sa">
661 <pz:metadata type="fulltext">
662 <xsl:value-of select="." />
666 <!-- <xsl:if test="$fulltext_a"> <pz:metadata type="fulltext"> <xsl:value-of
667 select="$fulltext_a"/> </pz:metadata> </xsl:if> -->
669 <xsl:for-each select="tmarc:d900/tmarc:sb">
670 <pz:metadata type="fulltext">
671 <xsl:value-of select="." />
675 <xsl:for-each select="tmarc:d900/tmarc:se">
676 <pz:metadata type="fulltext">
677 <xsl:value-of select="." />
681 <xsl:for-each select="tmarc:d900/tmarc:sf">
682 <pz:metadata type="fulltext">
683 <xsl:value-of select="." />
687 <xsl:for-each select="tmarc:d900/tmarc:si">
688 <pz:metadata type="fulltext">
689 <xsl:value-of select="." />
693 <xsl:for-each select="tmarc:d900/tmarc:sk">
694 <pz:metadata type="fulltext">
695 <xsl:value-of select="." />
699 <xsl:for-each select="tmarc:d900/tmarc:sq">
700 <pz:metadata type="fulltext">
701 <xsl:value-of select="." />
705 <xsl:for-each select="tmarc:d900/tmarc:ss">
706 <pz:metadata type="fulltext">
707 <xsl:value-of select="." />
711 <xsl:for-each select="tmarc:d900/tmarc:su">
712 <pz:metadata type="fulltext">
713 <xsl:value-of select="." />
717 <xsl:for-each select="tmarc:d900/tmarc:sy">
718 <pz:metadata type="fulltext">
719 <xsl:value-of select="." />
723 <xsl:for-each select="tmarc:d903">
724 <xsl:if test="tmarc:sa">
725 <pz:metadata type="publication-date">
726 <xsl:value-of select="substring(tmarc:sa,1,4)"/>
728 <pz:metadata type="date">
729 <xsl:value-of select="substring(tmarc:sa,1,4)"/>
734 <!-- <xsl:if test="$fulltext_b"> <pz:metadata type="fulltext"> <xsl:value-of
735 select="$fulltext_b"/> </pz:metadata> </xsl:if> -->
737 <pz:metadata type="has-fulltext">
738 <xsl:value-of select="$has_fulltext"/>
741 <xsl:for-each select="tmarc:d907 | tmarc:d901">
742 <pz:metadata type="iii-id">
743 <xsl:value-of select="tmarc:sa" />
747 <xsl:for-each select="tmarc:d926">
748 <pz:metadata type="locallocation" empty="PAZPAR2_NULL_VALUE">
749 <xsl:value-of select="tmarc:sa"/>
751 <pz:metadata type="callnumber" empty="PAZPAR2_NULL_VALUE">
752 <xsl:value-of select="tmarc:sc"/>
754 <pz:metadata type="available" empty="PAZPAR2_NULL_VALUE">
755 <xsl:value-of select="tmarc:se"/>
759 <!-- OhioLINK holdings -->
760 <xsl:for-each select="tmarc:d945">
761 <pz:metadata type="locallocation" empty="PAZPAR2_NULL_VALUE">
762 <xsl:value-of select="tmarc:sa"/>
764 <pz:metadata type="callnumber" empty="PAZPAR2_NULL_VALUE">
765 <xsl:value-of select="tmarc:sb"/>
767 <pz:metadata type="publicnote" empty="PAZPAR2_NULL_VALUE">
768 <xsl:value-of select="tmarc:sc"/>
770 <pz:metadata type="available" empty="PAZPAR2_NULL_VALUE">
772 <xsl:when test="tmarc:ss = 'N'">Available</xsl:when>
774 <xsl:value-of select="tmarc:sd"/>
780 <xsl:for-each select="tmarc:d948">
781 <pz:metadata type="holding">
782 <xsl:for-each select="tmarc:s">
783 <xsl:if test="position() > 1">
784 <xsl:text> </xsl:text>
786 <xsl:value-of select="." />
791 <xsl:for-each select="tmarc:d991">
792 <pz:metadata type="holding">
793 <xsl:for-each select="tmarc:s">
794 <xsl:if test="position() > 1">
795 <xsl:text> </xsl:text>
797 <xsl:value-of select="." />
802 <xsl:for-each select="tmarc:d999">
803 <pz:metadata type="localid">
805 <xsl:when test="tmarc:sa">
806 <xsl:value-of select="tmarc:sa"/>
808 <xsl:when test="tmarc:sc">
809 <xsl:value-of select="tmarc:sc"/>
812 <xsl:value-of select="tmarc:sd"/>
819 <!-- passthrough id data -->
820 <xsl:for-each select="pz:metadata">
821 <xsl:copy-of select="." />
824 <!-- other stylesheets importing this might want to define this -->
825 <xsl:call-template name="record-hook" />
830 <xsl:template match="text()" />