1 <?xml version="1.0" encoding="UTF-8"?>
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/MARC21/turboxml" >
8 <xsl:output indent="yes" method="xml" version="1.0" encoding="UTF-8"/>
11 Extract metadata from MARC21/USMARC from streamlined marcxml format
12 http://www.loc.gov/marc/bibliographic/ecbdhome.html
14 <xsl:template name="record-hook"/>
17 <xsl:template match="/">
19 <xsl:apply-templates/>
23 <xsl:template match="tmarc:record">
24 <xsl:variable name="title_medium" select="tmarc:d245/tmarc:sh"/>
25 <xsl:variable name="journal_title" select="tmarc:d773/tmarc:st"/>
26 <xsl:variable name="electronic_location_url" select="tmarc:d856/tmarc:su"/>
27 <xsl:variable name="fulltext_a" select="tmarc:d900/tmarc:sa"/>
28 <xsl:variable name="fulltext_b" select="tmarc:d900/tmarc:sb"/>
29 <!-- Does not always hit the right substring. The field is not always fixed-width? -->
30 <xsl:variable name="control_lang" select="substring(tmarc:c008, 36, 3)"/>
31 <xsl:variable name="contains110" select="tmarc:d110"/>
32 <xsl:variable name="hasAuthorFields" select="tmarc:d100 or tmarc:d111"/>
34 <xsl:variable name="medium">
36 <xsl:when test="$title_medium">
37 <xsl:value-of select="translate($title_medium, ' []/', '')" />
39 <xsl:when test="$fulltext_a">
40 <xsl:text>electronic resource</xsl:text>
42 <xsl:when test="$fulltext_b">
43 <xsl:text>electronic resource</xsl:text>
45 <xsl:when test="$journal_title">
46 <xsl:text>article</xsl:text>
49 <xsl:text>book</xsl:text>
55 <xsl:attribute name="mergekey">
56 <xsl:text>title </xsl:text>
57 <xsl:value-of select="tmarc:d245/tmarc:sa" />
58 <xsl:text> author </xsl:text>
59 <xsl:value-of select="tmarc:d100/tmarc:sa" />
60 <xsl:text> medium </xsl:text>
61 <xsl:value-of select="$medium" />
64 <xsl:for-each select="tmarc:c001">
65 <pz:metadata type="id">
66 <xsl:value-of select="."/>
70 <xsl:for-each select="tmarc:d010">
71 <pz:metadata type="lccn">
72 <xsl:value-of select="tmarc:sa"/>
76 <xsl:for-each select="tmarc:d020">
77 <pz:metadata type="isbn">
78 <xsl:value-of select="tmarc:sa"/>
82 <xsl:for-each select="tmarc:d022">
83 <pz:metadata type="issn">
84 <xsl:value-of select="tmarc:sa"/>
88 <xsl:for-each select="tmarc:d027">
89 <pz:metadata type="tech-rep-nr">
90 <xsl:value-of select="tmarc:sa"/>
94 <xsl:for-each select="tmarc:d035">
95 <pz:metadata type="system-control-nr">
96 <xsl:value-of select="tmarc:sa"/>
100 <xsl:for-each select="tmarc:d100">
101 <pz:metadata type="author">
102 <xsl:value-of select="tmarc:sa"/>
104 <pz:metadata type="author-title">
105 <xsl:value-of select="tmarc:sc"/>
107 <pz:metadata type="author-date">
108 <xsl:value-of select="tmarc:sd"/>
112 <xsl:for-each select="tmarc:d110">
113 <pz:metadata type="corporate-name">
114 <xsl:value-of select="tmarc:sa"/>
116 <pz:metadata type="corporate-location">
117 <xsl:value-of select="tmarc:sc"/>
119 <pz:metadata type="corporate-date">
120 <xsl:value-of select="tmarc:sd"/>
124 <xsl:for-each select="tmarc:d111">
125 <pz:metadata type="meeting-name">
126 <xsl:value-of select="tmarc:sa"/>
128 <pz:metadata type="meeting-location">
129 <xsl:value-of select="tmarc:sc"/>
131 <pz:metadata type="meeting-date">
132 <xsl:value-of select="tmarc:sd"/>
136 <xsl:for-each select="tmarc:d260">
137 <pz:metadata type="date">
138 <xsl:value-of select="tmarc:sc"/>
142 <xsl:for-each select="tmarc:d130">
143 <pz:metadata type="title-uniform">
144 <xsl:value-of select="tmarc:sa"/>
146 <pz:metadata type="title-uniform-media">
147 <xsl:value-of select="tmarc:sm"/>
149 <pz:metadata type="title-uniform-parts">
150 <xsl:value-of select="tmarc:sn"/>
152 <pz:metadata type="title-uniform-partname">
153 <xsl:value-of select="tmarc:sp"/>
155 <pz:metadata type="title-uniform-key">
156 <xsl:value-of select="tmarc:sr"/>
160 <xsl:for-each select="tmarc:d245">
161 <pz:metadata type="title">
162 <xsl:value-of select="tmarc:sa"/>
164 <pz:metadata type="title-remainder">
165 <xsl:value-of select="tmarc:sb"/>
167 <pz:metadata type="title-responsibility">
168 <xsl:value-of select="tmarc:sc"/>
170 <pz:metadata type="title-dates">
171 <xsl:value-of select="tmarc:sf"/>
173 <pz:metadata type="title-medium">
174 <xsl:value-of select="tmarc:sh"/>
176 <pz:metadata type="title-number-section">
177 <xsl:value-of select="tmarc:sn"/>
181 <xsl:for-each select="tmarc:d250">
182 <pz:metadata type="edition">
183 <xsl:value-of select="tmarc:sa"/>
187 <xsl:for-each select="tmarc:d260">
188 <pz:metadata type="publication-place">
189 <xsl:value-of select="tmarc:sa"/>
191 <pz:metadata type="publication-name">
192 <xsl:value-of select="tmarc:sb"/>
194 <pz:metadata type="publication-date">
195 <xsl:value-of select="tmarc:sc"/>
199 <xsl:for-each select="tmarc:d300">
200 <pz:metadata type="physical-extent">
201 <xsl:value-of select="tmarc:sa"/>
203 <pz:metadata type="physical-format">
204 <xsl:value-of select="tmarc:sb"/>
206 <pz:metadata type="physical-dimensions">
207 <xsl:value-of select="tmarc:sc"/>
209 <pz:metadata type="physical-accomp">
210 <xsl:value-of select="tmarc:se"/>
212 <pz:metadata type="physical-unittype">
213 <xsl:value-of select="tmarc:sf"/>
215 <pz:metadata type="physical-unitsize">
216 <xsl:value-of select="tmarc:sg"/>
218 <pz:metadata type="physical-specified">
219 <xsl:value-of select="tmarc:s3"/>
223 <xsl:for-each select="tmarc:d440">
224 <pz:metadata type="series-title">
225 <xsl:value-of select="tmarc:sa"/>
229 <xsl:for-each select="tmarc:d500">
230 <pz:metadata type="description">
231 <xsl:value-of select="*/text()"/>
235 <xsl:for-each select="tmarc:d505">
236 <pz:metadata type="description">
237 <xsl:value-of select="*/text()"/>
241 <xsl:for-each select="tmarc:d518">
242 <pz:metadata type="description">
243 <xsl:value-of select="*/text()"/>
247 <xsl:for-each select="tmarc:d520">
248 <pz:metadata type="description">
249 <xsl:value-of select="*/text()"/>
253 <xsl:for-each select="tmarc:d522">
254 <pz:metadata type="description">
255 <xsl:value-of select="*/text()"/>
259 <xsl:for-each select="tmarc:d600" >
260 <pz:metadata type="subject">
261 <xsl:value-of select="tmarc:sa"/>
263 <pz:metadata type="subject-long">
264 <xsl:for-each select="node()/text()">
265 <xsl:if test="position() > 1">
266 <xsl:text>, </xsl:text>
268 <xsl:value-of select="."/>
273 <xsl:for-each select="tmarc:d610" >
274 <pz:metadata type="subject">
275 <xsl:value-of select="tmarc:sa"/>
277 <pz:metadata type="subject-long">
278 <xsl:for-each select="node()/text()">
279 <xsl:if test="position() > 1">
280 <xsl:text>, </xsl:text>
282 <xsl:value-of select="."/>
287 <xsl:for-each select="tmarc:d611" >
288 <pz:metadata type="subject">
289 <xsl:value-of select="tmarc:sa"/>
291 <pz:metadata type="subject-long">
292 <xsl:for-each select="node()/text()">
293 <xsl:if test="position() > 1">
294 <xsl:text>, </xsl:text>
296 <xsl:value-of select="."/>
301 <xsl:for-each select="tmarc:d630" >
302 <pz:metadata type="subject">
303 <xsl:value-of select="tmarc:sa"/>
305 <pz:metadata type="subject-long">
306 <xsl:for-each select="node()/text()">
307 <xsl:if test="position() > 1">
308 <xsl:text>, </xsl:text>
310 <xsl:value-of select="."/>
315 <xsl:for-each select="tmarc:d648" >
316 <pz:metadata type="subject">
317 <xsl:value-of select="tmarc:sa"/>
319 <pz:metadata type="subject-long">
320 <xsl:for-each select="node()/text()">
321 <xsl:if test="position() > 1">
322 <xsl:text>, </xsl:text>
324 <xsl:value-of select="."/>
329 <xsl:for-each select="tmarc:d650" >
330 <pz:metadata type="subject">
331 <xsl:value-of select="tmarc:sa"/>
333 <pz:metadata type="subject-long">
334 <xsl:for-each select="node()/text()">
335 <xsl:if test="position() > 1">
336 <xsl:text>, </xsl:text>
338 <xsl:value-of select="."/>
343 <xsl:for-each select="tmarc:d651" >
344 <pz:metadata type="subject">
345 <xsl:value-of select="tmarc:sa"/>
347 <pz:metadata type="subject-long">
348 <xsl:for-each select="node()/text()">
349 <xsl:if test="position() > 1">
350 <xsl:text>, </xsl:text>
352 <xsl:value-of select="."/>
357 <xsl:for-each select="tmarc:d653" >
358 <pz:metadata type="subject">
359 <xsl:value-of select="tmarc:sa"/>
361 <pz:metadata type="subject-long">
362 <xsl:for-each select="node()/text()">
363 <xsl:if test="position() > 1">
364 <xsl:text>, </xsl:text>
366 <xsl:value-of select="."/>
371 <xsl:for-each select="tmarc:d654" >
372 <pz:metadata type="subject">
373 <xsl:value-of select="tmarc:sa"/>
375 <pz:metadata type="subject-long">
376 <xsl:for-each select="node()/text()">
377 <xsl:if test="position() > 1">
378 <xsl:text>, </xsl:text>
380 <xsl:value-of select="."/>
385 <xsl:for-each select="tmarc:d655" >
386 <pz:metadata type="subject">
387 <xsl:value-of select="tmarc:sa"/>
389 <pz:metadata type="subject-long">
390 <xsl:for-each select="node()/text()">
391 <xsl:if test="position() > 1">
392 <xsl:text>, </xsl:text>
394 <xsl:value-of select="."/>
399 <xsl:for-each select="tmarc:d656" >
400 <pz:metadata type="subject">
401 <xsl:value-of select="tmarc:sa"/>
403 <pz:metadata type="subject-long">
404 <xsl:for-each select="node()/text()">
405 <xsl:if test="position() > 1">
406 <xsl:text>, </xsl:text>
408 <xsl:value-of select="."/>
413 <xsl:for-each select="tmarc:d657" >
414 <pz:metadata type="subject">
415 <xsl:value-of select="tmarc:sa"/>
417 <pz:metadata type="subject-long">
418 <xsl:for-each select="node()/text()">
419 <xsl:if test="position() > 1">
420 <xsl:text>, </xsl:text>
422 <xsl:value-of select="."/>
427 <xsl:for-each select="tmarc:d658" >
428 <pz:metadata type="subject">
429 <xsl:value-of select="tmarc:sa"/>
431 <pz:metadata type="subject-long">
432 <xsl:for-each select="node()/text()">
433 <xsl:if test="position() > 1">
434 <xsl:text>, </xsl:text>
436 <xsl:value-of select="."/>
441 <xsl:for-each select="tmarc:d662" >
442 <pz:metadata type="subject">
443 <xsl:value-of select="tmarc:sa"/>
445 <pz:metadata type="subject-long">
446 <xsl:for-each select="node()/text()">
447 <xsl:if test="position() > 1">
448 <xsl:text>, </xsl:text>
450 <xsl:value-of select="."/>
455 <xsl:for-each select="tmarc:d69X" >
456 <pz:metadata type="subject">
457 <xsl:value-of select="tmarc:sa"/>
459 <pz:metadata type="subject-long">
460 <xsl:for-each select="node()/text()">
461 <xsl:if test="position() > 1">
462 <xsl:text>, </xsl:text>
464 <xsl:value-of select="."/>
470 or tmarc:d651 or tmarc:d653 or tmarc:d654 or tmarc:d655 or tmarc:d656 or tmarc:d657 or tmarc:d658 or tmarc:d662 or tmarc:d69X">
474 <xsl:for-each select="tmarc:d600" >
475 <pz:metadata type="subject">
476 <xsl:value-of select="tmarc:sa"/>
478 <pz:metadata type="subject-long">
479 <xsl:for-each select="tmarc:sa tmarc:sb tmarc:sc tmarc:sd ">
480 <xsl:if test="position() > 1">
481 <xsl:text>, </xsl:text>
483 <xsl:value-of select="."/>
489 <xsl:for-each select="tmarc:d856">
490 <pz:metadata type="electronic-url">
491 <xsl:value-of select="tmarc:su"/>
493 <pz:metadata type="electronic-text">
494 <xsl:if test="tmarc:sy" >
495 <xsl:value-of select="tmarc:sy/text()" />
497 <xsl:if test="tmarc:s3">
498 <xsl:value-of select="tmarc:s3/text()" />
501 <pz:metadata type="electronic-note">
502 <xsl:value-of select="tmarc:sz"/>
504 <pz:metadata type="electronic-format-instruction">
505 <xsl:value-of select="tmarc:si"/>
507 <pz:metadata type="electronic-format-type">
508 <xsl:value-of select="tmarc:sq"/>
512 <xsl:for-each select="tmarc:d773">
513 <pz:metadata type="citation">
514 <xsl:for-each select="*">
515 <xsl:value-of select="normalize-space(.)"/>
516 <xsl:text> </xsl:text>
521 <xsl:for-each select="tmarc:d852">
522 <xsl:if test="tmarc:sy">
523 <pz:metadata type="publicnote">
524 <xsl:value-of select="tmarc:sy"/>
527 <xsl:if test="tmarc:sh">
528 <pz:metadata type="callnumber">
529 <xsl:value-of select="tmarc:sh"/>
534 <pz:metadata type="medium">
535 <xsl:value-of select="$medium"/>
538 <xsl:for-each select="tmarc:d900/tmarc:sa">
539 <pz:metadata type="fulltext">
540 <xsl:value-of select="."/>
544 <!-- <xsl:if test="$fulltext_a">
545 <pz:metadata type="fulltext">
546 <xsl:value-of select="$fulltext_a"/>
551 <xsl:for-each select="tmarc:d900/tmarc:sb">
552 <pz:metadata type="fulltext">
553 <xsl:value-of select="."/>
557 <!-- <xsl:if test="$fulltext_b">
558 <pz:metadata type="fulltext">
559 <xsl:value-of select="$fulltext_b"/>
564 <xsl:for-each select="tmarc:d907">
565 <!-- or tmarc:d901"> -->
566 <pz:metadata type="iii-id">
567 <xsl:value-of select="tmarc:sa"/>
571 <xsl:for-each select="tmarc:d926">
572 <pz:metadata type="holding">
573 <xsl:for-each select="tmarc:s">
574 <xsl:if test="position() > 1">
575 <xsl:text> </xsl:text>
577 <xsl:value-of select="."/>
582 <xsl:for-each select="tmarc:d948">
583 <pz:metadata type="holding">
584 <xsl:for-each select="tmarc:s">
585 <xsl:if test="position() > 1">
586 <xsl:text> </xsl:text>
588 <xsl:value-of select="."/>
593 <xsl:for-each select="tmarc:d991">
594 <pz:metadata type="holding">
595 <xsl:for-each select="tmarc:s">
596 <xsl:if test="position() > 1">
597 <xsl:text> </xsl:text>
599 <xsl:value-of select="."/>
604 <pz:metadata tag="tag100">
605 <xsl:call-template name="shortTitle">
606 <xsl:with-param name="tag" select="100" />
610 <!-- Stuff for FRBR workset key -->
611 <xsl:variable name="title130">
612 <xsl:for-each select="tmarc:d130" >
613 <xsl:value-of select="tmarc:sa" />
614 <xsl:value-of select="tmarc:sm" />
615 <xsl:value-of select="tmarc:sn" />
616 <xsl:value-of select="tmarc:sp" />
617 <xsl:value-of select="tmarc:sr" />
621 <xsl:variable name="title240">
622 <xsl:for-each select="tmarc:d240" >
623 <xsl:value-of select="tmarc:sa" />
624 <xsl:value-of select="tmarc:sm" />
625 <xsl:value-of select="tmarc:sn" />
626 <xsl:value-of select="tmarc:sp" />
627 <xsl:value-of select="tmarc:sr" />
630 <xsl:variable name="title242">
631 <xsl:for-each select="tmarc:d242" >
632 <xsl:value-of select="tmarc:sa" />
633 <xsl:if test="$contains110 and not($hasAuthorFields)">
634 <xsl:value-of select="tmarc:sb" />
635 <xsl:value-of select="tmarc:sf" />
636 <xsl:value-of select="tmarc:sg" />
637 <xsl:value-of select="tmarc:sn" />
638 <xsl:value-of select="tmarc:sp" />
642 <xsl:variable name="title242-full">
643 <xsl:for-each select="tmarc:d242" >
644 <xsl:value-of select="tmarc:sa" />
645 <xsl:value-of select="tmarc:sb" />
646 <xsl:value-of select="tmarc:sf" />
647 <xsl:value-of select="tmarc:sg" />
648 <xsl:value-of select="tmarc:sn" />
649 <xsl:value-of select="tmarc:sp" />
653 <xsl:variable name="title245">
654 <xsl:for-each select="tmarc:d245" >
655 <xsl:value-of select="tmarc:sa" />
656 <xsl:if test="$contains110 and not($hasAuthorFields)">
657 <xsl:value-of select="tmarc:sb" />
658 <xsl:value-of select="tmarc:sf" />
659 <xsl:value-of select="tmarc:sg" />
660 <xsl:value-of select="tmarc:sn" />
661 <xsl:value-of select="tmarc:sp" />
665 <xsl:variable name="title245-full">
666 <xsl:for-each select="tmarc:d245" >
667 <xsl:value-of select="tmarc:sa" />
668 <xsl:value-of select="tmarc:sb" />
669 <xsl:value-of select="tmarc:sf" />
670 <xsl:value-of select="tmarc:sg" />
671 <xsl:value-of select="tmarc:sn" />
672 <xsl:value-of select="tmarc:sp" />
676 <xsl:variable name="title246">
677 <xsl:for-each select="tmarc:d246" >
678 <xsl:value-of select="tmarc:sa" />
679 <xsl:if test="$contains110 and not($hasAuthorFields)">
680 <xsl:value-of select="tmarc:sb" />
681 <xsl:value-of select="tmarc:sf" />
682 <xsl:value-of select="tmarc:sg" />
683 <xsl:value-of select="tmarc:sn" />
684 <xsl:value-of select="tmarc:sp" />
688 <xsl:variable name="title246-full">
689 <xsl:for-each select="tmarc:d246" >
690 <xsl:value-of select="tmarc:sa" />
691 <xsl:value-of select="tmarc:sb" />
692 <xsl:value-of select="tmarc:sf" />
693 <xsl:value-of select="tmarc:sg" />
694 <xsl:value-of select="tmarc:sn" />
695 <xsl:value-of select="tmarc:sp" />
699 <xsl:variable name="title247">
700 <xsl:for-each select="tmarc:d247" >
701 <xsl:value-of select="tmarc:sa" />
702 <xsl:if test="$contains110 and not($hasAuthorFields)">
703 <xsl:value-of select="tmarc:sb" />
704 <xsl:value-of select="tmarc:sf" />
705 <xsl:value-of select="tmarc:sg" />
706 <xsl:value-of select="tmarc:sn" />
707 <xsl:value-of select="tmarc:sp" />
711 <xsl:variable name="title247-full">
712 <xsl:for-each select="tmarc:d247" >
713 <xsl:value-of select="tmarc:sa" />
714 <xsl:value-of select="tmarc:sb" />
715 <xsl:value-of select="tmarc:sf" />
716 <xsl:value-of select="tmarc:sg" />
717 <xsl:value-of select="tmarc:sn" />
718 <xsl:value-of select="tmarc:sp" />
722 <xsl:for-each select="tmarc:c008">
723 <pz:metadata type="meta-marc-cf008">
724 <xsl:value-of select="."/>
728 <pz:metadata type="meta-frbr-short-title">
730 <xsl:when test="$title130!=''">
731 <xsl:value-of select="$title130" />
733 <xsl:when test="$title130='' and $title240!=''">
734 <xsl:value-of select="$title240" />
736 <!-- Missing the prioritization of 246 on non-english records -->
737 <xsl:when test="$title130='' and $title240='' and $title242!=''">
738 <xsl:value-of select="$title242" />
740 <xsl:when test="$title130='' and $title240='' and $title242='' and $title245!=''">
741 <xsl:value-of select="$title245" />
743 <xsl:when test="$title130='' and $title240='' and $title242='' and $title246!=''">
744 <xsl:value-of select="$title246" />
746 <xsl:when test="$title130='' and $title240='' and $title242='' and $title246='' and $title247!=''">
747 <xsl:value-of select="$title247" />
752 <pz:metadata type="meta-frbr-full-title">
754 <xsl:when test="$title130!=''">
755 <xsl:value-of select="$title130" />
757 <xsl:when test="$title130='' and $title240!=''">
758 <xsl:value-of select="$title240" />
760 <!-- Missing the prioritization of 246 on non-english records -->
761 <xsl:when test="$title130='' and $title240='' and $title242!=''">
762 <xsl:value-of select="$title242-full" />
764 <xsl:when test="$title130='' and $title240='' and $title242='' and $title245!=''">
765 <xsl:value-of select="$title245-full" />
767 <xsl:when test="$title130='' and $title240='' and $title242='' and $title246!=''">
768 <xsl:value-of select="$title246-full" />
770 <xsl:when test="$title130='' and $title240='' and $title242='' and $title246='' and $title247!=''">
771 <xsl:value-of select="$title247-full" />
777 <pz:metadata type="meta-frbr-lang">
778 <xsl:value-of select="$control_lang" />
782 <!-- passthrough id data -->
783 <xsl:for-each select="pz:metadata">
784 <xsl:copy-of select="."/>
787 <!-- other stylesheets importing this might want to define this -->
788 <xsl:call-template name="record-hook"/>
793 <xsl:template match="text()"/>
795 <xsl:template name="shortTitle">
796 <xsl:param name="tag" />
797 <xsl:for-each select="tmarc:d">
798 <xsl:value-of select="tmarc:sa" />
799 <xsl:value-of select="tmarc:sm" />
800 <xsl:value-of select="tmarc:sn" />
801 <xsl:value-of select="tmarc:sp" />
802 <xsl:value-of select="tmarc:sr" />
807 <xsl:template name="description">
808 <xsl:param name="element" />
809 <xsl:for-each select="$element">
810 <pz:metadata type="description">
811 <xsl:value-of select="*/text()"/>
814 <xsl:apply-templates/>
818 <xsl:template name="subject">
819 <xsl:param name="element" />
820 <xsl:for-each select="$element" >
821 <pz:metadata type="subject">
822 <xsl:value-of select="tmarc:sa"/>
824 <pz:metadata type="subject-long">
825 <xsl:for-each select="node()/text()">
826 <xsl:if test="position() > 1">
827 <xsl:text>, </xsl:text>
829 <xsl:value-of select="."/>