Updated source file headers with new year and no CVS Id.
[pazpar2-moved-to-github.git] / etc / marc21.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <xsl:stylesheet
3     version="1.0"
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">
7
8   
9   <xsl:output indent="yes" method="xml" version="1.0" encoding="UTF-8"/>
10
11 <!-- Extract metadata from MARC21/USMARC 
12       http://www.loc.gov/marc/bibliographic/ecbdhome.html
13 -->  
14   <xsl:include href="pz2-ourl-marc21.xsl" />
15   
16   <xsl:template match="/marc:record">
17     <xsl:variable name="title_medium" select="marc:datafield[@tag='245']/marc:subfield[@code='h']"/>
18     <xsl:variable name="journal_title" select="marc:datafield[@tag='773']/marc:subfield[@code='t']"/>
19     <xsl:variable name="electronic_location_url" select="marc:datafield[@tag='856']/marc:subfield[@code='u']"/>
20     <xsl:variable name="fulltext_a" select="marc:datafield[@tag='900']/marc:subfield[@code='a']"/>
21     <xsl:variable name="fulltext_b" select="marc:datafield[@tag='900']/marc:subfield[@code='b']"/>
22     <xsl:variable name="medium">
23       <xsl:choose>
24         <xsl:when test="$title_medium">
25           <xsl:value-of select="substring-after(substring-before($title_medium,']'),'[')"/>
26         </xsl:when>
27         <xsl:when test="$fulltext_a">
28           <xsl:text>electronic resource</xsl:text>
29         </xsl:when>
30         <xsl:when test="$fulltext_b">
31           <xsl:text>electronic resource</xsl:text>
32         </xsl:when>
33         <xsl:when test="$electronic_location_url">
34           <xsl:text>electronic resource</xsl:text>
35         </xsl:when>
36         <xsl:when test="$journal_title">
37           <xsl:text>article</xsl:text>
38         </xsl:when>
39         <xsl:otherwise>
40           <xsl:text>book</xsl:text>
41         </xsl:otherwise>
42       </xsl:choose>
43     </xsl:variable>
44
45     <pz:record>
46       <xsl:attribute name="mergekey">
47         <xsl:text>title </xsl:text>
48         <xsl:value-of select="marc:datafield[@tag='245']/marc:subfield[@code='a']"/>
49         <xsl:text> author </xsl:text>
50         <xsl:value-of select="marc:datafield[@tag='100']/marc:subfield[@code='a']"/>
51         <xsl:text> medium </xsl:text>
52         <xsl:value-of select="$medium"/>
53       </xsl:attribute>
54
55       
56       <xsl:for-each select="marc:controlfield[@tag='001']">
57         <pz:metadata type="id">
58           <xsl:value-of select="."/>
59         </pz:metadata>
60       </xsl:for-each>
61
62       <xsl:for-each select="marc:datafield[@tag='010']">
63         <pz:metadata type="lccn">
64           <xsl:value-of select="marc:subfield[@code='a']"/>
65         </pz:metadata>
66       </xsl:for-each>
67
68       <xsl:for-each select="marc:datafield[@tag='020']">
69         <pz:metadata type="isbn">
70           <xsl:value-of select="marc:subfield[@code='a']"/>
71         </pz:metadata>
72       </xsl:for-each>
73
74       <xsl:for-each select="marc:datafield[@tag='022']">
75         <pz:metadata type="issn">
76           <xsl:value-of select="marc:subfield[@code='a']"/>
77         </pz:metadata>
78       </xsl:for-each>
79
80       <xsl:for-each select="marc:datafield[@tag='027']">
81         <pz:metadata type="tech-rep-nr">
82           <xsl:value-of select="marc:subfield[@code='a']"/>
83         </pz:metadata>
84       </xsl:for-each>
85
86       <xsl:for-each select="marc:datafield[@tag='100']">
87         <pz:metadata type="author">
88           <xsl:value-of select="marc:subfield[@code='a']"/>
89         </pz:metadata>
90         <pz:metadata type="author-title">
91           <xsl:value-of select="marc:subfield[@code='c']"/>
92         </pz:metadata>
93         <pz:metadata type="author-date">
94           <xsl:value-of select="marc:subfield[@code='d']"/>
95         </pz:metadata>
96       </xsl:for-each>
97
98       <xsl:for-each select="marc:datafield[@tag='110']">
99         <pz:metadata type="corporate-name">
100             <xsl:value-of select="marc:subfield[@code='a']"/>
101         </pz:metadata>
102         <pz:metadata type="corporate-location">
103             <xsl:value-of select="marc:subfield[@code='c']"/>
104         </pz:metadata>
105         <pz:metadata type="corporate-date">
106             <xsl:value-of select="marc:subfield[@code='d']"/>
107         </pz:metadata>
108       </xsl:for-each>
109
110       <xsl:for-each select="marc:datafield[@tag='111']">
111         <pz:metadata type="meeting-name">
112             <xsl:value-of select="marc:subfield[@code='a']"/>
113         </pz:metadata>
114         <pz:metadata type="meeting-location">
115             <xsl:value-of select="marc:subfield[@code='c']"/>
116         </pz:metadata>
117         <pz:metadata type="meeting-date">
118             <xsl:value-of select="marc:subfield[@code='d']"/>
119         </pz:metadata>
120       </xsl:for-each>
121
122       <xsl:for-each select="marc:datafield[@tag='260']">
123         <pz:metadata type="date">
124             <xsl:value-of select="marc:subfield[@code='c']"/>
125         </pz:metadata>
126       </xsl:for-each>
127
128       <xsl:for-each select="marc:datafield[@tag='245']">
129         <pz:metadata type="title">
130           <xsl:value-of select="marc:subfield[@code='a']"/>
131         </pz:metadata>
132         <pz:metadata type="title-remainder">
133           <xsl:value-of select="marc:subfield[@code='b']"/>
134         </pz:metadata>
135         <pz:metadata type="title-responsibility">
136           <xsl:value-of select="marc:subfield[@code='c']"/>
137         </pz:metadata>
138         <pz:metadata type="title-dates">
139           <xsl:value-of select="marc:subfield[@code='f']"/>
140         </pz:metadata>
141         <pz:metadata type="title-medium">
142           <xsl:value-of select="marc:subfield[@code='h']"/>
143         </pz:metadata>
144         <pz:metadata type="title-number-section">
145           <xsl:value-of select="marc:subfield[@code='n']"/>
146         </pz:metadata>
147       </xsl:for-each>
148
149       <xsl:for-each select="marc:datafield[@tag='250']">
150         <pz:metadata type="edition">
151             <xsl:value-of select="marc:subfield[@code='a']"/>
152         </pz:metadata>
153       </xsl:for-each>
154
155       <xsl:for-each select="marc:datafield[@tag='260']">
156         <pz:metadata type="publication-place">
157           <xsl:value-of select="marc:subfield[@code='a']"/>
158         </pz:metadata>
159         <pz:metadata type="publication-name">
160           <xsl:value-of select="marc:subfield[@code='b']"/>
161         </pz:metadata>
162         <pz:metadata type="publication-date">
163           <xsl:value-of select="marc:subfield[@code='c']"/>
164         </pz:metadata>
165       </xsl:for-each>
166
167       <xsl:for-each select="marc:datafield[@tag='300']">
168         <pz:metadata type="physical-extent">
169           <xsl:value-of select="marc:subfield[@code='a']"/>
170         </pz:metadata>
171         <pz:metadata type="physical-format">
172           <xsl:value-of select="marc:subfield[@code='b']"/>
173         </pz:metadata>
174         <pz:metadata type="physical-dimensions">
175           <xsl:value-of select="marc:subfield[@code='c']"/>
176         </pz:metadata>
177         <pz:metadata type="physical-accomp">
178           <xsl:value-of select="marc:subfield[@code='e']"/>
179         </pz:metadata>
180         <pz:metadata type="physical-unittype">
181           <xsl:value-of select="marc:subfield[@code='f']"/>
182         </pz:metadata>
183         <pz:metadata type="physical-unitsize">
184           <xsl:value-of select="marc:subfield[@code='g']"/>
185         </pz:metadata>
186         <pz:metadata type="physical-specified">
187           <xsl:value-of select="marc:subfield[@code='3']"/>
188         </pz:metadata>
189       </xsl:for-each>
190
191       <xsl:for-each select="marc:datafield[@tag='440']">
192         <pz:metadata type="series-title">
193           <xsl:value-of select="marc:subfield[@code='a']"/>
194         </pz:metadata>
195       </xsl:for-each>
196
197       <xsl:for-each select="marc:datafield[@tag &gt;= 500 and @tag &lt;= 599]
198                             [@tag != '506' and @tag != '530' and
199                             @tag != '540' and @tag != '546'
200                             and @tag != '522']">
201         <pz:metadata type="description">
202             <xsl:value-of select="*/text()"/>
203         </pz:metadata>
204       </xsl:for-each>
205       
206       <xsl:for-each select="marc:datafield[@tag='650' or @tag='653']">
207         <pz:metadata type="subject">
208           <xsl:value-of select="marc:subfield[@code='a']"/>
209         </pz:metadata>
210         <pz:metadata type="subject-long">
211           <xsl:for-each select="marc:subfield">
212             <xsl:if test="position() > 1">
213               <xsl:text>, </xsl:text>
214             </xsl:if>
215             <xsl:value-of select="."/>
216           </xsl:for-each>
217         </pz:metadata>
218       </xsl:for-each>
219
220       <xsl:for-each select="marc:datafield[@tag='856']">
221         <pz:metadata type="electronic-url">
222           <xsl:value-of select="marc:subfield[@code='u']"/>
223         </pz:metadata>
224         <pz:metadata type="electronic-text">
225           <xsl:value-of select="marc:subfield[@code='y']"/>
226         </pz:metadata>
227         <pz:metadata type="electronic-note">
228           <xsl:value-of select="marc:subfield[@code='z']"/>
229         </pz:metadata>
230       </xsl:for-each>
231
232       <xsl:for-each select="marc:datafield[@tag='773']">
233         <pz:metadata type="citation">
234           <xsl:for-each select="*">
235             <xsl:value-of select="normalize-space(.)"/>
236             <xsl:text> </xsl:text>
237           </xsl:for-each>
238         </pz:metadata>
239       </xsl:for-each>
240
241       <pz:metadata type="medium">
242         <xsl:value-of select="$medium"/>
243       </pz:metadata>
244       
245       <xsl:if test="$fulltext_a">
246         <pz:metadata type="fulltext">
247           <xsl:value-of select="$fulltext_a"/>
248         </pz:metadata>
249       </xsl:if>
250
251       <xsl:if test="$fulltext_b">
252         <pz:metadata type="fulltext">
253           <xsl:value-of select="$fulltext_b"/>
254         </pz:metadata>
255       </xsl:if>
256
257       <xsl:if test="$open_url_resolver">
258         <pz:metadata type="open-url">
259             <xsl:call-template name="insert-md-openurl" />
260         </pz:metadata>
261       </xsl:if>
262
263     </pz:record>
264
265   </xsl:template>
266
267 </xsl:stylesheet>