1 <?xml version="1.0" encoding="UTF-8"?>
2 <xsl:stylesheet version="1.0"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:pz="http://www.indexdata.com/pazpar2/1.0"
4 xmlns:tmarc="http://www.indexdata.com/turbomarc">
6 <xsl:output indent="yes" method="xml" version="1.0"
9 <!-- Extract metadata from MARC21/USMARC from streamlined marcxml format
10 http://www.loc.gov/marc/bibliographic/ecbdhome.html -->
11 <xsl:template name="record-hook" />
14 <xsl:template match="/">
15 <xsl:apply-templates />
18 <xsl:template match="tmarc:collection">
20 <xsl:apply-templates />
24 <xsl:template match="tmarc:r">
25 <xsl:variable name="title_medium" select="tmarc:d245/tmarc:sh" />
26 <xsl:variable name="journal_title" select="tmarc:d773/tmarc:st" />
27 <xsl:variable name="electronic_location_url" select="tmarc:d856/tmarc:su" />
28 <xsl:variable name="fulltext_a" select="tmarc:d900/tmarc:sa" />
29 <xsl:variable name="fulltext_b" select="tmarc:d900/tmarc:sb" />
30 <!-- Does not always hit the right substring. The field is not always fixed-width? -->
31 <xsl:variable name="control_lang" select="substring(tmarc:c008, 36, 3)" />
32 <xsl:variable name="contains110" select="tmarc:d110" />
33 <xsl:variable name="hasAuthorFields" select="tmarc:d100 or tmarc:d111" />
34 <xsl:variable name="typeofrec" select="substring(tmarc:l, 7, 1)"/>
35 <xsl:variable name="typeofvm" select="substring(tmarc:c008, 34, 1)"/>
36 <xsl:variable name="biblevel" select="substring(tmarc:l, 8, 1)"/>
37 <xsl:variable name="physdes" select="substring(tmarc:c007, 1, 1)"/>
38 <xsl:variable name="form1" select="substring(tmarc:c008, 24, 1)"/>
39 <xsl:variable name="form2" select="substring(tmarc:c008, 30, 1)"/>
40 <xsl:variable name="oclca" select="substring(tmarc:c007, 1, 1)"/>
41 <xsl:variable name="oclcb" select="substring(tmarc:c007, 2, 1)"/>
42 <xsl:variable name="oclcd" select="substring(tmarc:c007, 4, 1)"/>
43 <xsl:variable name="oclce" select="substring(tmarc:c007, 5, 1)"/>
44 <xsl:variable name="typeofserial" select="substring(tmarc:c008, 22, 1)"/>
46 <xsl:variable name="electronic">
48 <xsl:when test="$form1='s' or $form1='q' or $form1='o' or
49 $form2='s' or $form2='q' or $form2='o'">
50 <xsl:text>yes</xsl:text>
56 <xsl:variable name="medium">
58 <xsl:when test="($typeofrec='a' or $typeofrec='t') and $biblevel='m'">book</xsl:when>
59 <xsl:when test="$typeofrec='j' or $typeofrec='i'">
60 <xsl:text>recording</xsl:text>
62 <xsl:when test="$oclcb='d' and $oclcd='f'">-cd</xsl:when>
63 <xsl:when test="$oclcb='s'">-cassette</xsl:when>
64 <xsl:when test="$oclcb='d' and $oclcd='a' or $oclcd='b' or
65 $oclcd='c' or $oclcd='d' or $oclcd='e'">-vinyl</xsl:when>
68 <xsl:when test="$typeofrec='g'">
70 <xsl:when test="$typeofvm='m' or $typeofvm='v'">
71 <xsl:text>video</xsl:text>
73 <xsl:when test="$oclca='v' and $oclcb='d' and $oclce='v'">-dvd</xsl:when>
74 <xsl:when test="$oclca='v' and $oclcb='d' and $oclce='s'">-blu-ray</xsl:when>
75 <xsl:when test="$oclca='v' and $oclcb='f' and $oclce='b'">-vhs</xsl:when>
78 <xsl:otherwise>audio-visual</xsl:otherwise>
81 <xsl:when test="$typeofrec='a' and $biblevel='s'">
83 <xsl:when test="$typeofserial='n'">newspaper</xsl:when>
84 <xsl:otherwise>journal</xsl:otherwise>
87 <xsl:when test="$typeofrec='e' or $typeofrec='f'">map</xsl:when>
88 <xsl:when test="$typeofrec='c' or $typeofrec='d'">music-score</xsl:when>
89 <xsl:when test="$form1='a' or $form1='b' or $form1='c'">microform</xsl:when>
90 <xsl:when test="$typeofrec='t'">thesis</xsl:when>
91 <!-- <xsl:when test="$journal_title">article</xsl:when> -->
92 <xsl:when test="$typeofrec='a' or $typeofrec='i' and
93 ($typeofserial='d' or $typeofserial='w')">web</xsl:when>
94 <xsl:when test="$typeofrec='a' and $biblevel='b'">article</xsl:when>
95 <xsl:when test="$typeofrec='m'">electronic</xsl:when>
96 <xsl:when test="$title_medium">
97 <xsl:value-of select="translate($title_medium, ' []/:', '')" />
100 <xsl:text>other</xsl:text>
107 <xsl:attribute name="mergekey">
108 <xsl:text>title </xsl:text>
109 <xsl:value-of select="tmarc:d245/tmarc:sa" />
110 <xsl:text> author </xsl:text>
111 <xsl:value-of select="tmarc:d100/tmarc:sa" />
112 <xsl:text> medium </xsl:text>
113 <xsl:value-of select="$medium" />
117 <xsl:for-each select="tmarc:c001">
118 <pz:metadata type="id">
119 <xsl:value-of select="." />
123 <xsl:for-each select="tmarc:d010">
124 <pz:metadata type="lccn">
125 <xsl:value-of select="tmarc:sa" />
129 <xsl:for-each select="tmarc:d020">
130 <pz:metadata type="isbn">
131 <xsl:value-of select="tmarc:sa" />
135 <xsl:for-each select="tmarc:d022">
136 <pz:metadata type="issn">
137 <xsl:value-of select="tmarc:sa" />
141 <xsl:for-each select="tmarc:d027">
142 <pz:metadata type="tech-rep-nr">
143 <xsl:value-of select="tmarc:sa" />
147 <xsl:for-each select="tmarc:d035">
148 <pz:metadata type="system-control-nr">
150 <xsl:when test="tmarc:sa">
151 <xsl:value-of select="tmarc:sa"/>
154 <xsl:value-of select="tmarc:sb"/>
160 <xsl:for-each select="tmarc:d100">
161 <pz:metadata type="author">
162 <xsl:value-of select="tmarc:sa" />
164 <pz:metadata type="author-title">
165 <xsl:value-of select="tmarc:sc" />
167 <pz:metadata type="author-date">
168 <xsl:value-of select="tmarc:sd" />
172 <xsl:for-each select="tmarc:d110">
173 <pz:metadata type="corporate-name">
174 <xsl:value-of select="tmarc:sa" />
176 <pz:metadata type="corporate-location">
177 <xsl:value-of select="tmarc:sc" />
179 <pz:metadata type="corporate-date">
180 <xsl:value-of select="tmarc:sd" />
184 <xsl:for-each select="tmarc:d111">
185 <pz:metadata type="meeting-name">
186 <xsl:value-of select="tmarc:sa" />
188 <pz:metadata type="meeting-location">
189 <xsl:value-of select="tmarc:sc" />
191 <pz:metadata type="meeting-date">
192 <xsl:value-of select="tmarc:sd" />
196 <xsl:for-each select="tmarc:d260">
197 <pz:metadata type="date">
198 <xsl:value-of select="translate(tmarc:sc, 'cp[].', '')" />
202 <xsl:for-each select="tmarc:d130">
203 <pz:metadata type="title-uniform">
204 <xsl:value-of select="tmarc:sa" />
206 <pz:metadata type="title-uniform-media">
207 <xsl:value-of select="tmarc:sm" />
209 <pz:metadata type="title-uniform-parts">
210 <xsl:value-of select="tmarc:sn" />
212 <pz:metadata type="title-uniform-partname">
213 <xsl:value-of select="tmarc:sp" />
215 <pz:metadata type="title-uniform-key">
216 <xsl:value-of select="tmarc:sr" />
220 <xsl:for-each select="tmarc:d245">
221 <pz:metadata type="title">
222 <xsl:value-of select="tmarc:sa" />
224 <pz:metadata type="title-remainder">
225 <xsl:value-of select="tmarc:sb" />
227 <pz:metadata type="title-responsibility">
228 <xsl:value-of select="tmarc:sc" />
230 <pz:metadata type="title-dates">
231 <xsl:value-of select="tmarc:sf" />
233 <pz:metadata type="title-medium">
234 <xsl:value-of select="tmarc:sh" />
236 <pz:metadata type="title-number-section">
237 <xsl:value-of select="tmarc:sn" />
239 <pz:metadata type="title-complete">
240 <xsl:value-of select="tmarc:sa" />
241 <xsl:if test="tmarc:sb" ><xsl:value-of select="concat(' ', tmarc:sb)" /></xsl:if>
245 <xsl:for-each select="tmarc:d250">
246 <pz:metadata type="edition">
247 <xsl:value-of select="tmarc:sa" />
251 <xsl:for-each select="tmarc:d260">
252 <pz:metadata type="publication-place">
253 <xsl:value-of select="tmarc:sa" />
255 <pz:metadata type="publication-name">
256 <xsl:value-of select="tmarc:sb" />
258 <pz:metadata type="publication-date">
259 <xsl:value-of select="tmarc:sc" />
263 <xsl:for-each select="tmarc:d300">
264 <pz:metadata type="physical-extent">
265 <xsl:value-of select="tmarc:sa" />
267 <pz:metadata type="physical-format">
268 <xsl:value-of select="tmarc:sb" />
270 <pz:metadata type="physical-dimensions">
271 <xsl:value-of select="tmarc:sc" />
273 <pz:metadata type="physical-accomp">
274 <xsl:value-of select="tmarc:se" />
276 <pz:metadata type="physical-unittype">
277 <xsl:value-of select="tmarc:sf" />
279 <pz:metadata type="physical-unitsize">
280 <xsl:value-of select="tmarc:sg" />
282 <pz:metadata type="physical-specified">
283 <xsl:value-of select="tmarc:s3" />
287 <xsl:for-each select="tmarc:d440">
288 <pz:metadata type="series-title">
289 <xsl:value-of select="tmarc:sa" />
293 <xsl:for-each select="tmarc:d500">
294 <pz:metadata type="description">
295 <xsl:for-each select="node()">
296 <xsl:value-of select="text()" />
301 <xsl:for-each select="tmarc:d505">
302 <pz:metadata type="description">
303 <xsl:for-each select="node()">
304 <xsl:value-of select="text()" />
309 <xsl:for-each select="tmarc:d518">
310 <pz:metadata type="description">
311 <xsl:for-each select="node()">
312 <xsl:value-of select="text()" />
317 <xsl:for-each select="tmarc:d520">
318 <pz:metadata type="description">
319 <xsl:for-each select="node()">
320 <xsl:value-of select="text()" />
325 <xsl:for-each select="tmarc:d522">
326 <pz:metadata type="description">
327 <xsl:for-each select="node()">
328 <xsl:value-of select="text()" />
333 <xsl:for-each select="tmarc:d600">
334 <pz:metadata type="subject">
335 <xsl:value-of select="tmarc:sa" />
337 <pz:metadata type="subject-long">
338 <xsl:for-each select="node()/text()">
339 <xsl:if test="position() > 1">
340 <xsl:text>, </xsl:text>
342 <xsl:value-of select="." />
347 <xsl:for-each select="tmarc:d610">
348 <pz:metadata type="subject">
349 <xsl:value-of select="tmarc:sa" />
351 <pz:metadata type="subject-long">
352 <xsl:for-each select="node()/text()">
353 <xsl:if test="position() > 1">
354 <xsl:text>, </xsl:text>
356 <xsl:value-of select="." />
361 <xsl:for-each select="tmarc:d611">
362 <pz:metadata type="subject">
363 <xsl:value-of select="tmarc:sa" />
365 <pz:metadata type="subject-long">
366 <xsl:for-each select="node()/text()">
367 <xsl:if test="position() > 1">
368 <xsl:text>, </xsl:text>
370 <xsl:value-of select="." />
375 <xsl:for-each select="tmarc:d630">
376 <pz:metadata type="subject">
377 <xsl:value-of select="tmarc:sa" />
379 <pz:metadata type="subject-long">
380 <xsl:for-each select="node()/text()">
381 <xsl:if test="position() > 1">
382 <xsl:text>, </xsl:text>
384 <xsl:value-of select="." />
389 <xsl:for-each select="tmarc:d648">
390 <pz:metadata type="subject">
391 <xsl:value-of select="tmarc:sa" />
393 <pz:metadata type="subject-long">
394 <xsl:for-each select="node()/text()">
395 <xsl:if test="position() > 1">
396 <xsl:text>, </xsl:text>
398 <xsl:value-of select="." />
403 <xsl:for-each select="tmarc:d650">
404 <pz:metadata type="subject">
405 <xsl:value-of select="tmarc:sa" />
407 <pz:metadata type="subject-long">
408 <xsl:for-each select="node()/text()">
409 <xsl:if test="position() > 1">
410 <xsl:text>, </xsl:text>
412 <xsl:value-of select="." />
417 <xsl:for-each select="tmarc:d651">
418 <pz:metadata type="subject">
419 <xsl:value-of select="tmarc:sa" />
421 <pz:metadata type="subject-long">
422 <xsl:for-each select="node()/text()">
423 <xsl:if test="position() > 1">
424 <xsl:text>, </xsl:text>
426 <xsl:value-of select="." />
431 <xsl:for-each select="tmarc:d653">
432 <pz:metadata type="subject">
433 <xsl:value-of select="tmarc:sa" />
435 <pz:metadata type="subject-long">
436 <xsl:for-each select="node()/text()">
437 <xsl:if test="position() > 1">
438 <xsl:text>, </xsl:text>
440 <xsl:value-of select="." />
445 <xsl:for-each select="tmarc:d654">
446 <pz:metadata type="subject">
447 <xsl:value-of select="tmarc:sa" />
449 <pz:metadata type="subject-long">
450 <xsl:for-each select="node()/text()">
451 <xsl:if test="position() > 1">
452 <xsl:text>, </xsl:text>
454 <xsl:value-of select="." />
459 <xsl:for-each select="tmarc:d655">
460 <pz:metadata type="subject">
461 <xsl:value-of select="tmarc:sa" />
463 <pz:metadata type="subject-long">
464 <xsl:for-each select="node()/text()">
465 <xsl:if test="position() > 1">
466 <xsl:text>, </xsl:text>
468 <xsl:value-of select="." />
473 <xsl:for-each select="tmarc:d656">
474 <pz:metadata type="subject">
475 <xsl:value-of select="tmarc:sa" />
477 <pz:metadata type="subject-long">
478 <xsl:for-each select="node()/text()">
479 <xsl:if test="position() > 1">
480 <xsl:text>, </xsl:text>
482 <xsl:value-of select="." />
487 <xsl:for-each select="tmarc:d657">
488 <pz:metadata type="subject">
489 <xsl:value-of select="tmarc:sa" />
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:value-of select="." />
501 <xsl:for-each select="tmarc:d658">
502 <pz:metadata type="subject">
503 <xsl:value-of select="tmarc:sa" />
505 <pz:metadata type="subject-long">
506 <xsl:for-each select="node()/text()">
507 <xsl:if test="position() > 1">
508 <xsl:text>, </xsl:text>
510 <xsl:value-of select="." />
515 <xsl:for-each select="tmarc:d662">
516 <pz:metadata type="subject">
517 <xsl:value-of select="tmarc:sa" />
519 <pz:metadata type="subject-long">
520 <xsl:for-each select="node()/text()">
521 <xsl:if test="position() > 1">
522 <xsl:text>, </xsl:text>
524 <xsl:value-of select="." />
529 <xsl:for-each select="tmarc:d69X">
530 <pz:metadata type="subject">
531 <xsl:value-of select="tmarc:sa" />
533 <pz:metadata type="subject-long">
534 <xsl:for-each select="node()/text()">
535 <xsl:if test="position() > 1">
536 <xsl:text>, </xsl:text>
538 <xsl:value-of select="." />
543 <!-- or tmarc:d651 or tmarc:d653 or tmarc:d654 or tmarc:d655 or tmarc:d656
544 or tmarc:d657 or tmarc:d658 or tmarc:d662 or tmarc:d69X"> -->
546 <!-- <xsl:for-each select="tmarc:d600" > <pz:metadata type="subject">
547 <xsl:value-of select="tmarc:sa"/> </pz:metadata> <pz:metadata type="subject-long">
548 <xsl:for-each select="tmarc:sa tmarc:sb tmarc:sc tmarc:sd "> <xsl:if test="position()
549 > 1"> <xsl:text>, </xsl:text> </xsl:if> <xsl:value-of select="."/> </xsl:for-each>
550 </pz:metadata> </xsl:for-each> -->
552 <xsl:for-each select="tmarc:d856">
553 <pz:metadata type="electronic-url">
554 <xsl:value-of select="tmarc:su" />
556 <pz:metadata type="electronic-text">
557 <xsl:if test="tmarc:sy">
558 <xsl:value-of select="tmarc:sy/text()" />
560 <xsl:if test="tmarc:s3">
561 <xsl:value-of select="tmarc:s3/text()" />
564 <pz:metadata type="electronic-note">
565 <xsl:value-of select="tmarc:sz" />
567 <pz:metadata type="electronic-format-instruction">
568 <xsl:value-of select="tmarc:si" />
570 <pz:metadata type="electronic-format-type">
571 <xsl:value-of select="tmarc:sq" />
575 <xsl:for-each select="tmarc:d773">
576 <pz:metadata type="citation">
577 <xsl:for-each select="*">
578 <xsl:value-of select="normalize-space(.)" />
579 <xsl:text> </xsl:text>
584 <xsl:for-each select="tmarc:d852">
585 <xsl:if test="tmarc:sy">
586 <pz:metadata type="publicnote">
587 <xsl:value-of select="tmarc:sy" />
590 <xsl:if test="tmarc:sh">
591 <pz:metadata type="callnumber">
592 <xsl:value-of select="tmarc:sh" />
597 <pz:metadata type="medium">
598 <xsl:value-of select="$medium" />
599 <xsl:if test="string-length($electronic) and $medium != 'electronic'">
600 <xsl:text> (electronic)</xsl:text>
604 <xsl:for-each select="tmarc:d900/tmarc:sa">
605 <pz:metadata type="fulltext">
606 <xsl:value-of select="." />
610 <!-- <xsl:if test="$fulltext_a"> <pz:metadata type="fulltext"> <xsl:value-of
611 select="$fulltext_a"/> </pz:metadata> </xsl:if> -->
613 <xsl:for-each select="tmarc:d900/tmarc:sb">
614 <pz:metadata type="fulltext">
615 <xsl:value-of select="." />
619 <!-- <xsl:if test="$fulltext_b"> <pz:metadata type="fulltext"> <xsl:value-of
620 select="$fulltext_b"/> </pz:metadata> </xsl:if> -->
622 <xsl:for-each select="tmarc:d907">
623 <!-- or tmarc:d901"> -->
624 <pz:metadata type="iii-id">
625 <xsl:value-of select="tmarc:sa" />
629 <xsl:for-each select="tmarc:d926">
630 <pz:metadata type="locallocation">
631 <xsl:choose><xsl:when test="tmarc:sa">
632 <xsl:value-of select="tmarc:sa"/>
633 </xsl:when><xsl:otherwise>
634 <xsl:text>PAZPAR2_NULL_VALUE</xsl:text>
635 </xsl:otherwise></xsl:choose>
637 <pz:metadata type="callnumber">
638 <xsl:choose><xsl:when test="tmarc:sc">
639 <xsl:value-of select="tmarc:sc"/>
640 </xsl:when><xsl:otherwise>
641 <xsl:text>PAZPAR2_NULL_VALUE</xsl:text>
642 </xsl:otherwise></xsl:choose>
644 <pz:metadata type="available">
645 <xsl:choose><xsl:when test="tmarc:se">
646 <xsl:value-of select="tmarc:se"/>
647 </xsl:when><xsl:otherwise>
648 <xsl:text>PAZPAR2_NULL_VALUE</xsl:text>
649 </xsl:otherwise></xsl:choose>
653 <xsl:for-each select="tmarc:d948">
654 <pz:metadata type="holding">
655 <xsl:for-each select="tmarc:s">
656 <xsl:if test="position() > 1">
657 <xsl:text> </xsl:text>
659 <xsl:value-of select="." />
664 <xsl:for-each select="tmarc:d991">
665 <pz:metadata type="holding">
666 <xsl:for-each select="tmarc:s">
667 <xsl:if test="position() > 1">
668 <xsl:text> </xsl:text>
670 <xsl:value-of select="." />
675 <!-- passthrough id data -->
676 <xsl:for-each select="pz:metadata">
677 <xsl:copy-of select="." />
680 <!-- other stylesheets importing this might want to define this -->
681 <xsl:call-template name="record-hook" />
686 <xsl:template match="text()" />
688 <!-- TODO Does not work anymore -->
689 <xsl:template name="shortTitle">
690 <xsl:param name="tag" />
691 <xsl:for-each select="tmarc:d">
692 <xsl:value-of select="tmarc:sa" />
693 <xsl:value-of select="tmarc:sm" />
694 <xsl:value-of select="tmarc:sn" />
695 <xsl:value-of select="tmarc:sp" />
696 <xsl:value-of select="tmarc:sr" />
700 <!-- No working as expected -->
701 <xsl:template name="description">
702 <xsl:param name="element" />
703 <xsl:for-each select="$element">
704 <pz:metadata type="description">
705 <xsl:for-each select="node()">
706 <xsl:value-of select="text()" />
710 <xsl:apply-templates />
713 <!-- <xsl:for-each select="tmarc:d500"> <pz:metadata type="description">
714 <xsl:for-each select="node()"> <xsl:value-of select="text()"/> </xsl:for-each>
715 </pz:metadata> </xsl:for-each> -->
719 <xsl:template name="subject">
720 <xsl:param name="element" />
721 <xsl:for-each select="$element">
722 <pz:metadata type="subject">
723 <xsl:value-of select="tmarc:sa" />
725 <pz:metadata type="subject-long">
726 <xsl:for-each select="node()/text()">
727 <xsl:if test="position() > 1">
728 <xsl:text>, </xsl:text>
730 <xsl:value-of select="." />