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:r">
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 <!-- passthrough id data -->
605 <xsl:for-each select="pz:metadata">
606 <xsl:copy-of select="."/>
609 <!-- other stylesheets importing this might want to define this -->
610 <xsl:call-template name="record-hook"/>
615 <xsl:template match="text()"/>
617 <xsl:template name="shortTitle">
618 <xsl:param name="tag" />
619 <xsl:for-each select="tmarc:d">
620 <xsl:value-of select="tmarc:sa" />
621 <xsl:value-of select="tmarc:sm" />
622 <xsl:value-of select="tmarc:sn" />
623 <xsl:value-of select="tmarc:sp" />
624 <xsl:value-of select="tmarc:sr" />
629 <xsl:template name="description">
630 <xsl:param name="element" />
631 <xsl:for-each select="$element">
632 <pz:metadata type="description">
633 <xsl:value-of select="*/text()"/>
636 <xsl:apply-templates/>
640 <xsl:template name="subject">
641 <xsl:param name="element" />
642 <xsl:for-each select="$element" >
643 <pz:metadata type="subject">
644 <xsl:value-of select="tmarc:sa"/>
646 <pz:metadata type="subject-long">
647 <xsl:for-each select="node()/text()">
648 <xsl:if test="position() > 1">
649 <xsl:text>, </xsl:text>
651 <xsl:value-of select="."/>