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:marc="http://www.loc.gov/MARC21/slim">
8 <xsl:output indent="yes" method="xml" version="1.0" encoding="UTF-8"/>
10 <!-- Extract metadata from MARC21/USMARC
11 http://www.loc.gov/marc/bibliographic/ecbdhome.html
13 <xsl:template name="record-hook"/>
15 <xsl:template match="/">
16 <xsl:apply-templates/>
19 <xsl:template match="marc:collection">
21 <xsl:apply-templates/>
25 <xsl:template match="marc:record">
26 <xsl:variable name="title_medium" select="marc:datafield[@tag='245']/marc:subfield[@code='h']"/>
27 <xsl:variable name="journal_title" select="marc:datafield[@tag='773']/marc:subfield[@code='t']"/>
28 <xsl:variable name="electronic_location_url" select="marc:datafield[@tag='856']/marc:subfield[@code='u']"/>
29 <xsl:variable name="fulltext_a" select="marc:datafield[@tag='900']/marc:subfield[@code='a']"/>
30 <xsl:variable name="fulltext_b" select="marc:datafield[@tag='900']/marc:subfield[@code='b']"/>
31 <xsl:variable name="medium">
33 <xsl:when test="$title_medium">
34 <xsl:value-of select="translate($title_medium, ' []/', '')"/>
36 <xsl:when test="$fulltext_a">
37 <xsl:text>electronic resource</xsl:text>
39 <xsl:when test="$fulltext_b">
40 <xsl:text>electronic resource</xsl:text>
42 <xsl:when test="$journal_title">
43 <xsl:text>article</xsl:text>
46 <xsl:text>book</xsl:text>
51 <xsl:variable name="has_fulltext">
53 <xsl:when test="marc:datafield[@tag='856']/marc:subfield[@code='q']">
54 <xsl:text>yes</xsl:text>
56 <xsl:when test="marc:datafield[@tag='856']/marc:subfield[@code='i']='TEXT*'">
57 <xsl:text>yes</xsl:text>
60 <xsl:text>no</xsl:text>
65 <xsl:variable name="oclc_number">
66 <xsl:variable name="c001" select='marc:controlfield[@tag="001"]' />
68 <xsl:when test='contains(marc:controlfield[@tag="001"],"ocn") or
69 contains(marc:controlfield[@tag="001"],"ocm") or
70 contains(marc:controlfield[@tag="001"],"OCoLC")'>
71 <xsl:value-of select="marc:controlfield[@tag='001']"/>
73 <xsl:when test='contains(marc:datafield[@tag="035"]/marc:subfield[@code="a"],"ocn") or
74 contains(marc:datafield[@tag="035"]/marc:subfield[@code="a"],"ocm") or
75 contains(marc:datafield[@tag="035"]/marc:subfield[@code="a"],"OCoLC") '>
76 <xsl:value-of select="marc:datafield[@tag='035']/marc:subfield[@code='a']"/>
81 <xsl:variable name="date_008">
83 <xsl:when test="contains('cestpudikmr', substring(marc:controlfield[@tag='008'], 7, 1))">
84 <xsl:value-of select="substring(marc:controlfield[@tag='008'], 8, 4)" />
89 <xsl:variable name="date_end_008">
91 <xsl:when test="contains('dikmr', substring(marc:controlfield[@tag='008'], 7, 1))">
92 <xsl:value-of select="substring(marc:controlfield[@tag='008'], 12, 4)" />
98 <xsl:for-each select="marc:controlfield[@tag='001']">
99 <pz:metadata type="id">
100 <xsl:value-of select="."/>
104 <pz:metadata type="oclc-number">
105 <xsl:value-of select="$oclc_number" />
108 <xsl:for-each select="marc:datafield[@tag='010']">
109 <pz:metadata type="lccn">
110 <xsl:value-of select="marc:subfield[@code='a']"/>
114 <xsl:for-each select="marc:datafield[@tag='020']">
115 <pz:metadata type="isbn">
116 <xsl:value-of select="marc:subfield[@code='a']"/>
120 <xsl:for-each select="marc:datafield[@tag='022']">
121 <pz:metadata type="issn">
122 <xsl:value-of select="marc:subfield[@code='a']"/>
126 <xsl:for-each select="marc:datafield[@tag='027']">
127 <pz:metadata type="tech-rep-nr">
128 <xsl:value-of select="marc:subfield[@code='a']"/>
132 <xsl:for-each select="marc:datafield[@tag='035']">
133 <pz:metadata type="system-control-nr">
135 <xsl:when test="marc:subfield[@code='a']">
136 <xsl:value-of select="marc:subfield[@code='a']"/>
139 <xsl:value-of select="marc:subfield[@code='b']"/>
145 <xsl:for-each select="marc:datafield[@tag='100']">
146 <pz:metadata type="author">
147 <xsl:value-of select="marc:subfield[@code='a']"/>
149 <pz:metadata type="author-title">
150 <xsl:value-of select="marc:subfield[@code='c']"/>
152 <pz:metadata type="author-date">
153 <xsl:value-of select="marc:subfield[@code='d']"/>
157 <xsl:for-each select="marc:datafield[@tag='110']">
158 <pz:metadata type="corporate-name">
159 <xsl:value-of select="marc:subfield[@code='a']"/>
161 <pz:metadata type="corporate-location">
162 <xsl:value-of select="marc:subfield[@code='c']"/>
164 <pz:metadata type="corporate-date">
165 <xsl:value-of select="marc:subfield[@code='d']"/>
169 <xsl:for-each select="marc:datafield[@tag='111']">
170 <pz:metadata type="meeting-name">
171 <xsl:value-of select="marc:subfield[@code='a']"/>
173 <pz:metadata type="meeting-location">
174 <xsl:value-of select="marc:subfield[@code='c']"/>
176 <pz:metadata type="meeting-date">
177 <xsl:value-of select="marc:subfield[@code='d']"/>
181 <xsl:for-each select="marc:datafield[@tag='130']">
182 <pz:metadata type="title-uniform">
183 <xsl:value-of select="marc:subfield[@code='a']" />
185 <pz:metadata type="title-uniform-media">
186 <xsl:value-of select="marc:subfield[@code='m']" />
188 <pz:metadata type="title-uniform-parts">
189 <xsl:value-of select="marc:subfield[@code='n']" />
191 <pz:metadata type="title-uniform-partname">
192 <xsl:value-of select="marc:subfield[@code='p']" />
194 <pz:metadata type="title-uniform-key">
195 <xsl:value-of select="marc:subfield[@code='r']" />
199 <xsl:for-each select="marc:datafield[@tag='260']">
200 <pz:metadata type="date">
201 <xsl:value-of select="translate(marc:subfield[@code='c'], 'cp[].', '')" />
205 <xsl:if test="$date_008 and not(marc:datafield[@tag='260'])">
206 <pz:metadata type="date">
208 <xsl:when test="$date_end_008">
209 <xsl:value-of select="concat($date_008,'-',$date_end_008)" />
212 <xsl:value-of select="$date_008" />
218 <xsl:for-each select="marc:datafield[@tag='245']">
219 <pz:metadata type="title">
220 <xsl:value-of select="marc:subfield[@code='a']"/>
222 <pz:metadata type="title-remainder">
223 <xsl:value-of select="marc:subfield[@code='b']"/>
225 <pz:metadata type="title-responsibility">
226 <xsl:value-of select="marc:subfield[@code='c']"/>
228 <pz:metadata type="title-dates">
229 <xsl:value-of select="marc:subfield[@code='f']"/>
231 <pz:metadata type="title-medium">
232 <xsl:value-of select="marc:subfield[@code='h']"/>
234 <pz:metadata type="title-number-section">
235 <xsl:value-of select="marc:subfield[@code='n']"/>
237 <pz:metadata type="title-complete">
238 <xsl:value-of select="marc:subfield[@code='a']" />
239 <xsl:if test="marc:subfield[@code='b']" ><xsl:value-of select="concat(' ', marc:subfield[@code='b'])" /></xsl:if>
243 <xsl:for-each select="marc:datafield[@tag='250']">
244 <pz:metadata type="edition">
245 <xsl:value-of select="marc:subfield[@code='a']"/>
249 <xsl:for-each select="marc:datafield[@tag='260']">
250 <pz:metadata type="publication-place">
251 <xsl:value-of select="marc:subfield[@code='a']"/>
253 <pz:metadata type="publication-name">
254 <xsl:value-of select="marc:subfield[@code='b']"/>
256 <pz:metadata type="publication-date">
257 <xsl:value-of select="marc:subfield[@code='c']"/>
261 <xsl:for-each select="marc:datafield[@tag='300']">
262 <pz:metadata type="physical-extent">
263 <xsl:value-of select="marc:subfield[@code='a']"/>
265 <pz:metadata type="physical-format">
266 <xsl:value-of select="marc:subfield[@code='b']"/>
268 <pz:metadata type="physical-dimensions">
269 <xsl:value-of select="marc:subfield[@code='c']"/>
271 <pz:metadata type="physical-accomp">
272 <xsl:value-of select="marc:subfield[@code='e']"/>
274 <pz:metadata type="physical-unittype">
275 <xsl:value-of select="marc:subfield[@code='f']"/>
277 <pz:metadata type="physical-unitsize">
278 <xsl:value-of select="marc:subfield[@code='g']"/>
280 <pz:metadata type="physical-specified">
281 <xsl:value-of select="marc:subfield[@code='3']"/>
285 <xsl:for-each select="marc:datafield[@tag='440']">
286 <pz:metadata type="series-title">
287 <xsl:value-of select="marc:subfield[@code='a']"/>
291 <xsl:for-each select="marc:datafield[@tag = '500' or @tag = '505' or
292 @tag = '518' or @tag = '520' or @tag = '522']">
293 <pz:metadata type="description">
294 <xsl:value-of select="*/text()"/>
299 select="marc:datafield[@tag='600' or @tag='610' or @tag='611' or @tag='630' or @tag='648' or @tag='650' or @tag='651' or @tag='653' or @tag='654' or @tag='655' or @tag='656' or @tag='657' or @tag='658' or @tag='662' or @tag='69X']">
300 <pz:metadata type="subject">
301 <xsl:value-of select="marc:subfield[@code='a']" />
303 <pz:metadata type="subject-long">
304 <xsl:for-each select="node()/text()">
305 <xsl:if test="position() > 1">
306 <xsl:text>, </xsl:text>
308 <xsl:variable name='value'>
309 <xsl:value-of select='normalize-space(.)' />
312 <xsl:when test="substring($value,string-length($value)) = ','">
313 <xsl:value-of select="substring($value,1,string-length($value)-1)" />
316 <xsl:value-of select="$value" />
323 <xsl:for-each select="marc:datafield[@tag='856']">
324 <pz:metadata type="electronic-url">
325 <xsl:value-of select="marc:subfield[@code='u']"/>
327 <pz:metadata type="electronic-text">
328 <xsl:value-of select="marc:subfield[@code='y' or @code='3' or @code='a']"/>
330 <pz:metadata type="electronic-note">
331 <xsl:value-of select="marc:subfield[@code='z']"/>
333 <pz:metadata type="electronic-format-instruction">
334 <xsl:value-of select="marc:subfield[@code='i']"/>
336 <pz:metadata type="electronic-format-type">
337 <xsl:value-of select="marc:subfield[@code='q']"/>
341 <xsl:for-each select="marc:datafield[@tag='773']">
342 <pz:metadata type="citation">
343 <xsl:for-each select="*">
344 <xsl:value-of select="normalize-space(.)"/>
345 <xsl:text> </xsl:text>
348 <xsl:if test="marc:subfield[@code='t']">
349 <pz:metadata type="journal-title">
350 <xsl:value-of select="marc:subfield[@code='t']"/>
353 <xsl:if test="marc:subfield[@code='g']">
354 <pz:metadata type="journal-subpart">
355 <xsl:value-of select="marc:subfield[@code='g']"/>
360 <xsl:for-each select="marc:datafield[@tag='852']">
361 <xsl:if test="marc:subfield[@code='y']">
362 <pz:metadata type="publicnote">
363 <xsl:value-of select="marc:subfield[@code='y']"/>
366 <xsl:if test="marc:subfield[@code='h']">
367 <pz:metadata type="callnumber">
368 <xsl:value-of select="marc:subfield[@code='h']"/>
373 <xsl:for-each select="marc:datafield[@tag='900']/marc:subfield[@code='a']">
374 <pz:metadata type="fulltext">
375 <xsl:value-of select="."/>
379 <pz:metadata type="medium">
380 <xsl:value-of select="$medium"/>
383 <pz:metadata type="has-fulltext">
384 <xsl:value-of select="$has_fulltext"/>
387 <xsl:for-each select="marc:datafield[@tag='900']/marc:subfield[@code='b']">
388 <pz:metadata type="fulltext">
389 <xsl:value-of select="."/>
393 <!-- <xsl:if test="$fulltext_b">
394 <pz:metadata type="fulltext">
395 <xsl:value-of select="$fulltext_b"/>
399 <xsl:for-each select="marc:datafield[@tag='907' or @tag='901']">
400 <pz:metadata type="iii-id">
401 <xsl:value-of select="marc:subfield[@code='a']"/>
405 <xsl:for-each select="marc:datafield[@tag='926']">
406 <pz:metadata type="holding">
407 <xsl:for-each select="marc:subfield">
408 <xsl:if test="position() > 1">
409 <xsl:text> </xsl:text>
411 <xsl:value-of select="."/>
416 <xsl:for-each select="marc:datafield[@tag='948']">
417 <pz:metadata type="holding">
418 <xsl:for-each select="marc:subfield">
419 <xsl:if test="position() > 1">
420 <xsl:text> </xsl:text>
422 <xsl:value-of select="."/>
427 <xsl:for-each select="marc:datafield[@tag='991']">
428 <pz:metadata type="holding">
429 <xsl:for-each select="marc:subfield">
430 <xsl:if test="position() > 1">
431 <xsl:text> </xsl:text>
433 <xsl:value-of select="."/>
438 <xsl:for-each select="marc:datafield[@tag='999']">
439 <pz:metadata type="localid">
441 <xsl:when test="marc:subfield[@code='a']">
442 <xsl:value-of select="marc:subfield[@code='a']"/>
444 <xsl:when test="marc:subfield[@code='c']">
445 <xsl:value-of select="marc:subfield[@code='c']"/>
448 <xsl:value-of select="marc:subfield[@code='d']"/>
454 <!-- passthrough id data -->
455 <xsl:for-each select="pz:metadata">
456 <xsl:copy-of select="."/>
459 <!-- other stylesheets importing this might want to define this -->
460 <xsl:call-template name="record-hook"/>
465 <xsl:template match="text()"/>