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 <pz:metadata type="oclc-number">
173 <xsl:value-of select="$oclc_number" />
176 <xsl:for-each select="tmarc:d010">
177 <pz:metadata type="lccn">
178 <xsl:value-of select="tmarc:sa" />
182 <xsl:for-each select="tmarc:d020">
183 <pz:metadata type="isbn">
184 <xsl:value-of select="tmarc:sa" />
188 <xsl:for-each select="tmarc:d022">
189 <pz:metadata type="issn">
190 <xsl:value-of select="tmarc:sa" />
194 <xsl:for-each select="tmarc:d027">
195 <pz:metadata type="tech-rep-nr">
196 <xsl:value-of select="tmarc:sa" />
200 <xsl:for-each select="tmarc:d035">
201 <pz:metadata type="system-control-nr">
203 <xsl:when test="tmarc:sa">
204 <xsl:value-of select="tmarc:sa"/>
207 <xsl:value-of select="tmarc:sb"/>
213 <xsl:for-each select="tmarc:d100">
214 <pz:metadata type="author">
215 <xsl:value-of select="tmarc:sa" />
217 <pz:metadata type="author-title">
218 <xsl:value-of select="tmarc:sc" />
220 <pz:metadata type="author-date">
221 <xsl:value-of select="tmarc:sd" />
225 <xsl:for-each select="tmarc:d110">
226 <pz:metadata type="corporate-name">
227 <xsl:value-of select="tmarc:sa" />
229 <pz:metadata type="corporate-location">
230 <xsl:value-of select="tmarc:sc" />
232 <pz:metadata type="corporate-date">
233 <xsl:value-of select="tmarc:sd" />
237 <xsl:for-each select="tmarc:d111">
238 <pz:metadata type="meeting-name">
239 <xsl:value-of select="tmarc:sa" />
241 <pz:metadata type="meeting-location">
242 <xsl:value-of select="tmarc:sc" />
244 <pz:metadata type="meeting-date">
245 <xsl:value-of select="tmarc:sd" />
249 <xsl:for-each select="tmarc:d260">
250 <pz:metadata type="date">
251 <xsl:value-of select="translate(tmarc:sc, 'cp[].', '')" />
255 <xsl:if test="$date_008 and not(tmarc:d260)">
256 <pz:metadata type="date">
258 <xsl:when test="$date_end_008">
259 <xsl:value-of select="concat($date_008,'-',$date_end_008)" />
262 <xsl:value-of select="$date_008" />
269 <xsl:for-each select="tmarc:d130">
270 <pz:metadata type="title-uniform">
271 <xsl:value-of select="tmarc:sa" />
273 <pz:metadata type="title-uniform-media">
274 <xsl:value-of select="tmarc:sm" />
276 <pz:metadata type="title-uniform-parts">
277 <xsl:value-of select="tmarc:sn" />
279 <pz:metadata type="title-uniform-partname">
280 <xsl:value-of select="tmarc:sp" />
282 <pz:metadata type="title-uniform-key">
283 <xsl:value-of select="tmarc:sr" />
287 <xsl:for-each select="tmarc:d245">
288 <pz:metadata type="title">
289 <xsl:value-of select="tmarc:sa" />
291 <pz:metadata type="title-remainder">
292 <xsl:value-of select="tmarc:sb" />
294 <pz:metadata type="title-responsibility">
295 <xsl:value-of select="tmarc:sc" />
297 <pz:metadata type="title-dates">
298 <xsl:value-of select="tmarc:sf" />
300 <pz:metadata type="title-medium">
301 <xsl:value-of select="tmarc:sh" />
303 <pz:metadata type="title-number-section">
304 <xsl:value-of select="tmarc:sn" />
306 <pz:metadata type="title-complete">
307 <xsl:value-of select="tmarc:sa" />
308 <xsl:if test="tmarc:sb" ><xsl:value-of select="concat(' ', tmarc:sb)" /></xsl:if>
312 <xsl:for-each select="tmarc:d250">
313 <pz:metadata type="edition">
314 <xsl:value-of select="tmarc:sa" />
318 <xsl:for-each select="tmarc:d260">
319 <pz:metadata type="publication-place">
320 <xsl:value-of select="tmarc:sa" />
322 <pz:metadata type="publication-name">
323 <xsl:value-of select="tmarc:sb" />
325 <pz:metadata type="publication-date">
326 <xsl:value-of select="tmarc:sc" />
330 <xsl:for-each select="tmarc:d300">
331 <pz:metadata type="physical-extent">
332 <xsl:value-of select="tmarc:sa" />
334 <pz:metadata type="physical-format">
335 <xsl:value-of select="tmarc:sb" />
337 <pz:metadata type="physical-dimensions">
338 <xsl:value-of select="tmarc:sc" />
340 <pz:metadata type="physical-accomp">
341 <xsl:value-of select="tmarc:se" />
343 <pz:metadata type="physical-unittype">
344 <xsl:value-of select="tmarc:sf" />
346 <pz:metadata type="physical-unitsize">
347 <xsl:value-of select="tmarc:sg" />
349 <pz:metadata type="physical-specified">
350 <xsl:value-of select="tmarc:s3" />
354 <xsl:for-each select="tmarc:d440">
355 <pz:metadata type="series-title">
356 <xsl:value-of select="tmarc:sa" />
360 <xsl:for-each select="tmarc:d500">
361 <pz:metadata type="description">
362 <xsl:for-each select="node()">
363 <xsl:value-of select="text()" />
368 <xsl:for-each select="tmarc:d505">
369 <pz:metadata type="description">
370 <xsl:for-each select="node()">
371 <xsl:value-of select="text()" />
376 <xsl:for-each select="tmarc:d518">
377 <pz:metadata type="description">
378 <xsl:for-each select="node()">
379 <xsl:value-of select="text()" />
384 <xsl:for-each select="tmarc:d520">
385 <pz:metadata type="description">
386 <xsl:for-each select="node()">
387 <xsl:value-of select="text()" />
392 <xsl:for-each select="tmarc:d522">
393 <pz:metadata type="description">
394 <xsl:for-each select="node()">
395 <xsl:value-of select="text()" />
400 <xsl:for-each select="tmarc:d911">
401 <pz:metadata type="description">
402 <xsl:for-each select="node()">
403 <xsl:value-of select="text()" />
408 <xsl:for-each select="tmarc:d600 | tmarc:d610 | tmarc:d611 | tmarc:d630 |
409 tmarc:d648 | tmarc:d650 | tmarc:d651 | tmarc:d653 |
410 tmarc:d654 | tmarc:d655 | tmarc:d656 | tmarc:d657 |
411 tmarc:d658 | tmarc:d662 | tmarc:d69X">
412 <pz:metadata type="subject">
413 <xsl:value-of select="tmarc:sa"/>
415 <pz:metadata type="subject-long">
416 <xsl:for-each select="node()/text()">
417 <xsl:if test="position() > 1">
418 <xsl:text>, </xsl:text>
420 <xsl:variable name='value'>
421 <xsl:value-of select='normalize-space(.)'/>
424 <xsl:when test="substring($value, string-length($value)) = ','">
425 <xsl:value-of select="substring($value, 1, string-length($value)-1)"/>
428 <xsl:value-of select="$value"/>
435 <xsl:for-each select="tmarc:d856">
436 <pz:metadata type="electronic-url">
437 <xsl:value-of select="tmarc:su" />
439 <pz:metadata type="electronic-text">
441 <xsl:when test="tmarc:sy">
442 <xsl:value-of select="tmarc:sy/text()" />
444 <xsl:when test="tmarc:s3">
445 <xsl:value-of select="tmarc:s3/text()" />
447 <xsl:when test="tmarc:sa">
448 <xsl:value-of select="tmarc:sa/text()" />
450 <xsl:otherwise>Get resource</xsl:otherwise>
453 <pz:metadata type="electronic-note">
454 <xsl:value-of select="tmarc:sz" />
456 <pz:metadata type="electronic-format-instruction">
457 <xsl:value-of select="tmarc:si" />
459 <pz:metadata type="electronic-format-type">
460 <xsl:value-of select="tmarc:sq" />
464 <xsl:for-each select="tmarc:d773">
465 <pz:metadata type="citation">
466 <xsl:for-each select="*">
467 <xsl:value-of select="normalize-space(.)" />
468 <xsl:text> </xsl:text>
471 <xsl:if test="tmarc:st">
472 <pz:metadata type="journal-title">
473 <xsl:value-of select="tmarc:st"/>
476 <xsl:if test="tmarc:sg">
477 <xsl:variable name="value">
478 <xsl:for-each select="tmarc:sg">
479 <xsl:value-of select="."/>
482 <pz:metadata type="journal-subpart">
483 <xsl:value-of select="$value"/>
485 <xsl:variable name="l">
486 <xsl:value-of select="translate($value,
487 'ABCDEFGHIJKLMNOPQRSTUVWXYZ.',
488 'abcdefghijklmnopqrstuvwxyz ') "/>
490 <xsl:variable name="volume">
492 <xsl:when test="string-length(substring-after($l,'vol ')) > 0">
493 <xsl:value-of select="substring-before(normalize-space(substring-after($l,'vol ')),' ')"/>
495 <xsl:when test="string-length(substring-after($l,'v ')) > 0">
496 <xsl:value-of select="substring-before(normalize-space(substring-after($l,'v ')),' ')"/>
500 <xsl:variable name="issue">
501 <xsl:value-of select="substring-before(translate(normalize-space(substring-after($l,'issue')), ',', ' '),' ')"/>
503 <xsl:variable name="pages">
505 <xsl:when test="string-length(substring-after($l,' p ')) > 0">
506 <xsl:value-of select="normalize-space(substring-after($l,' p '))"/>
508 <xsl:when test="string-length(substring-after($l,',p')) > 0">
509 <xsl:value-of select="normalize-space(substring-after($l,',p'))"/>
511 <xsl:when test="string-length(substring-after($l,' p')) > 0">
512 <xsl:value-of select="normalize-space(substring-after($l,' p'))"/>
518 <xsl:if test="string-length($volume) > 0">
519 <pz:metadata type="volume-number">
520 <xsl:value-of select="$volume"/>
524 <xsl:if test="string-length($issue) > 0">
525 <pz:metadata type="issue-number">
526 <xsl:value-of select="$issue"/>
530 <xsl:if test="string-length($pages) > 0">
531 <pz:metadata type="pages-number">
532 <xsl:value-of select="$pages"/>
538 <xsl:if test="tmarc:sp">
539 <pz:metadata type="journal-title-abbrev">
540 <xsl:value-of select="tmarc:sp"/>
545 <xsl:for-each select="tmarc:d852">
546 <xsl:if test="tmarc:sy">
547 <pz:metadata type="publicnote">
548 <xsl:value-of select="tmarc:sy" />
551 <xsl:if test="tmarc:sh">
552 <pz:metadata type="callnumber">
553 <xsl:value-of select="tmarc:sh" />
558 <xsl:for-each select="tmarc:d876">
559 <xsl:if test="tmarc:sf">
560 <pz:metadata type="loan-period">
561 <xsl:value-of select="concat(tmarc:s5,':',tmarc:sf)" />
566 <pz:metadata type="medium">
567 <xsl:value-of select="$vmedium" />
568 <xsl:if test="string-length($electronic) and $vmedium != 'electronic'">
569 <xsl:text> (electronic)</xsl:text>
573 <xsl:for-each select="tmarc:d900/tmarc:sa">
574 <pz:metadata type="fulltext">
575 <xsl:value-of select="." />
579 <!-- <xsl:if test="$fulltext_a"> <pz:metadata type="fulltext"> <xsl:value-of
580 select="$fulltext_a"/> </pz:metadata> </xsl:if> -->
582 <xsl:for-each select="tmarc:d900/tmarc:sb">
583 <pz:metadata type="fulltext">
584 <xsl:value-of select="." />
588 <xsl:for-each select="tmarc:d900/tmarc:se">
589 <pz:metadata type="fulltext">
590 <xsl:value-of select="." />
594 <xsl:for-each select="tmarc:d900/tmarc:sf">
595 <pz:metadata type="fulltext">
596 <xsl:value-of select="." />
600 <xsl:for-each select="tmarc:d900/tmarc:si">
601 <pz:metadata type="fulltext">
602 <xsl:value-of select="." />
606 <xsl:for-each select="tmarc:d900/tmarc:sk">
607 <pz:metadata type="fulltext">
608 <xsl:value-of select="." />
612 <xsl:for-each select="tmarc:d900/tmarc:sq">
613 <pz:metadata type="fulltext">
614 <xsl:value-of select="." />
618 <xsl:for-each select="tmarc:d900/tmarc:ss">
619 <pz:metadata type="fulltext">
620 <xsl:value-of select="." />
624 <xsl:for-each select="tmarc:d900/tmarc:su">
625 <pz:metadata type="fulltext">
626 <xsl:value-of select="." />
630 <xsl:for-each select="tmarc:d900/tmarc:sy">
631 <pz:metadata type="fulltext">
632 <xsl:value-of select="." />
637 <!-- <xsl:if test="$fulltext_b"> <pz:metadata type="fulltext"> <xsl:value-of
638 select="$fulltext_b"/> </pz:metadata> </xsl:if> -->
640 <pz:metadata type="has-fulltext">
641 <xsl:value-of select="$has_fulltext"/>
644 <xsl:for-each select="tmarc:d907 | tmarc:d901">
645 <pz:metadata type="iii-id">
646 <xsl:value-of select="tmarc:sa" />
650 <xsl:for-each select="tmarc:d926">
651 <pz:metadata type="locallocation">
652 <xsl:choose><xsl:when test="tmarc:sa">
653 <xsl:value-of select="tmarc:sa"/>
654 </xsl:when><xsl:otherwise>
655 <xsl:text>PAZPAR2_NULL_VALUE</xsl:text>
656 </xsl:otherwise></xsl:choose>
658 <pz:metadata type="callnumber">
659 <xsl:choose><xsl:when test="tmarc:sc">
660 <xsl:value-of select="tmarc:sc"/>
661 </xsl:when><xsl:otherwise>
662 <xsl:text>PAZPAR2_NULL_VALUE</xsl:text>
663 </xsl:otherwise></xsl:choose>
665 <pz:metadata type="available">
666 <xsl:choose><xsl:when test="tmarc:se">
667 <xsl:value-of select="tmarc:se"/>
668 </xsl:when><xsl:otherwise>
669 <xsl:text>PAZPAR2_NULL_VALUE</xsl:text>
670 </xsl:otherwise></xsl:choose>
674 <!-- OhioLINK holdings -->
675 <xsl:for-each select="tmarc:d945">
676 <pz:metadata type="locallocation">
678 <xsl:when test="tmarc:sa">
679 <xsl:value-of select="tmarc:sa"/>
681 <xsl:otherwise>PAZPAR2_NULL_VALUE</xsl:otherwise>
684 <pz:metadata type="callnumber">
686 <xsl:when test="tmarc:sb">
687 <xsl:value-of select="tmarc:sb"/>
689 <xsl:otherwise>PAZPAR2_NULL_VALUE</xsl:otherwise>
692 <pz:metadata type="publicnote">
694 <xsl:when test="tmarc:sc">
695 <xsl:value-of select="tmarc:sc"/>
697 <xsl:otherwise>PAZPAR2_NULL_VALUE</xsl:otherwise>
700 <pz:metadata type="available">
702 <xsl:when test="tmarc:ss = 'N'">Available</xsl:when>
703 <xsl:when test="tmarc:ss != 'N'">
705 <xsl:when test="tmarc:sd">
706 <xsl:value-of select="tmarc:sd"/>
708 <xsl:otherwise>PAZPAR2_NULL_VALUE</xsl:otherwise>
711 <xsl:otherwise>PAZPAR2_NULL_VALUE</xsl:otherwise>
716 <xsl:for-each select="tmarc:d948">
717 <pz:metadata type="holding">
718 <xsl:for-each select="tmarc:s">
719 <xsl:if test="position() > 1">
720 <xsl:text> </xsl:text>
722 <xsl:value-of select="." />
727 <xsl:for-each select="tmarc:d991">
728 <pz:metadata type="holding">
729 <xsl:for-each select="tmarc:s">
730 <xsl:if test="position() > 1">
731 <xsl:text> </xsl:text>
733 <xsl:value-of select="." />
738 <xsl:for-each select="tmarc:d999">
739 <pz:metadata type="localid">
741 <xsl:when test="tmarc:sa">
742 <xsl:value-of select="tmarc:sa"/>
744 <xsl:when test="tmarc:sc">
745 <xsl:value-of select="tmarc:sc"/>
748 <xsl:value-of select="tmarc:sd"/>
755 <!-- passthrough id data -->
756 <xsl:for-each select="pz:metadata">
757 <xsl:copy-of select="." />
760 <!-- other stylesheets importing this might want to define this -->
761 <xsl:call-template name="record-hook" />
766 <xsl:template match="text()" />