Updated source file headers with new year and no CVS Id.
[pazpar2-moved-to-github.git] / test / 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     <xsl:param name="test"/>
9   
10   <xsl:output indent="yes" method="xml" version="1.0" encoding="UTF-8"/>
11
12 <!-- Extract metadata from MARC21/USMARC 
13       http://www.loc.gov/marc/bibliographic/ecbdhome.html
14 -->  
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       <pz:metadata type="test_usersetting_2">
56         Shit: 
57         <xsl:value-of select="$test"/>
58       </pz:metadata>
59
60       <xsl:for-each select="marc:controlfield[@tag='001']">
61         <pz:metadata type="id">
62           <xsl:value-of select="."/>
63         </pz:metadata>
64       </xsl:for-each>
65
66       <xsl:for-each select="marc:datafield[@tag='010']">
67         <pz:metadata type="lccn">
68           <xsl:value-of select="marc:subfield[@code='a']"/>
69         </pz:metadata>
70       </xsl:for-each>
71
72       <xsl:for-each select="marc:datafield[@tag='020']">
73         <pz:metadata type="isbn">
74           <xsl:value-of select="marc:subfield[@code='a']"/>
75         </pz:metadata>
76       </xsl:for-each>
77
78       <xsl:for-each select="marc:datafield[@tag='022']">
79         <pz:metadata type="issn">
80           <xsl:value-of select="marc:subfield[@code='a']"/>
81         </pz:metadata>
82       </xsl:for-each>
83
84       <xsl:for-each select="marc:datafield[@tag='027']">
85         <pz:metadata type="tech-rep-nr">
86           <xsl:value-of select="marc:subfield[@code='a']"/>
87         </pz:metadata>
88       </xsl:for-each>
89
90       <xsl:for-each select="marc:datafield[@tag='100']">
91         <pz:metadata type="author">
92           <xsl:value-of select="marc:subfield[@code='a']"/>
93         </pz:metadata>
94         <pz:metadata type="author-title">
95           <xsl:value-of select="marc:subfield[@code='c']"/>
96         </pz:metadata>
97         <pz:metadata type="author-date">
98           <xsl:value-of select="marc:subfield[@code='d']"/>
99         </pz:metadata>
100       </xsl:for-each>
101
102       <xsl:for-each select="marc:datafield[@tag='110']">
103         <pz:metadata type="corporate-name">
104             <xsl:value-of select="marc:subfield[@code='a']"/>
105         </pz:metadata>
106         <pz:metadata type="corporate-location">
107             <xsl:value-of select="marc:subfield[@code='c']"/>
108         </pz:metadata>
109         <pz:metadata type="corporate-date">
110             <xsl:value-of select="marc:subfield[@code='d']"/>
111         </pz:metadata>
112       </xsl:for-each>
113
114       <xsl:for-each select="marc:datafield[@tag='111']">
115         <pz:metadata type="meeting-name">
116             <xsl:value-of select="marc:subfield[@code='a']"/>
117         </pz:metadata>
118         <pz:metadata type="meeting-location">
119             <xsl:value-of select="marc:subfield[@code='c']"/>
120         </pz:metadata>
121         <pz:metadata type="meeting-date">
122             <xsl:value-of select="marc:subfield[@code='d']"/>
123         </pz:metadata>
124       </xsl:for-each>
125
126       <xsl:for-each select="marc:datafield[@tag='260']">
127         <pz:metadata type="date">
128             <xsl:value-of select="marc:subfield[@code='c']"/>
129         </pz:metadata>
130       </xsl:for-each>
131
132       <xsl:for-each select="marc:datafield[@tag='245']">
133         <pz:metadata type="title">
134           <xsl:value-of select="marc:subfield[@code='a']"/>
135         </pz:metadata>
136         <pz:metadata type="title-remainder">
137           <xsl:value-of select="marc:subfield[@code='b']"/>
138         </pz:metadata>
139         <pz:metadata type="title-responsibility">
140           <xsl:value-of select="marc:subfield[@code='c']"/>
141         </pz:metadata>
142         <pz:metadata type="title-dates">
143           <xsl:value-of select="marc:subfield[@code='f']"/>
144         </pz:metadata>
145         <pz:metadata type="title-medium">
146           <xsl:value-of select="marc:subfield[@code='h']"/>
147         </pz:metadata>
148       </xsl:for-each>
149
150       <xsl:for-each select="marc:datafield[@tag='250']">
151         <pz:metadata type="edition">
152             <xsl:value-of select="marc:subfield[@code='a']"/>
153         </pz:metadata>
154       </xsl:for-each>
155
156       <xsl:for-each select="marc:datafield[@tag='260']">
157         <pz:metadata type="publication-place">
158           <xsl:value-of select="marc:subfield[@code='a']"/>
159         </pz:metadata>
160         <pz:metadata type="publication-name">
161           <xsl:value-of select="marc:subfield[@code='b']"/>
162         </pz:metadata>
163         <pz:metadata type="publication-date">
164           <xsl:value-of select="marc:subfield[@code='c']"/>
165         </pz:metadata>
166       </xsl:for-each>
167
168       <xsl:for-each select="marc:datafield[@tag='300']">
169         <pz:metadata type="physical-extent">
170           <xsl:value-of select="marc:subfield[@code='a']"/>
171         </pz:metadata>
172         <pz:metadata type="physical-format">
173           <xsl:value-of select="marc:subfield[@code='b']"/>
174         </pz:metadata>
175         <pz:metadata type="physical-dimensions">
176           <xsl:value-of select="marc:subfield[@code='c']"/>
177         </pz:metadata>
178         <pz:metadata type="physical-accomp">
179           <xsl:value-of select="marc:subfield[@code='e']"/>
180         </pz:metadata>
181         <pz:metadata type="physical-unittype">
182           <xsl:value-of select="marc:subfield[@code='f']"/>
183         </pz:metadata>
184         <pz:metadata type="physical-unitsize">
185           <xsl:value-of select="marc:subfield[@code='g']"/>
186         </pz:metadata>
187         <pz:metadata type="physical-specified">
188           <xsl:value-of select="marc:subfield[@code='3']"/>
189         </pz:metadata>
190       </xsl:for-each>
191
192       <xsl:for-each select="marc:datafield[@tag='440']">
193         <pz:metadata type="series-title">
194           <xsl:value-of select="marc:subfield[@code='a']"/>
195         </pz:metadata>
196       </xsl:for-each>
197
198       <xsl:for-each select="marc:datafield[@tag &gt;= 500 and @tag &lt;= 599]
199                             [@tag != '506' and @tag != '530' and
200                             @tag != '540' and @tag != '546'
201                             and @tag != '522']">
202         <pz:metadata type="description">
203             <xsl:value-of select="*/text()"/>
204         </pz:metadata>
205       </xsl:for-each>
206       
207       <xsl:for-each select="marc:datafield[@tag='650' or @tag='653']">
208         <pz:metadata type="subject">
209           <xsl:value-of select="marc:subfield[@code='a']"/>
210         </pz:metadata>
211       </xsl:for-each>
212
213       <xsl:for-each select="marc:datafield[@tag='856']">
214         <pz:metadata type="electronic-url">
215           <xsl:value-of select="marc:subfield[@code='u']"/>
216         </pz:metadata>
217         <pz:metadata type="electronic-text">
218           <xsl:value-of select="marc:subfield[@code='y']"/>
219         </pz:metadata>
220         <pz:metadata type="electronic-note">
221           <xsl:value-of select="marc:subfield[@code='z']"/>
222         </pz:metadata>
223       </xsl:for-each>
224
225       <xsl:for-each select="marc:datafield[@tag='773']">
226         <pz:metadata type="citation">
227           <xsl:for-each select="*">
228             <xsl:value-of select="normalize-space(.)"/>
229             <xsl:text> </xsl:text>
230           </xsl:for-each>
231         </pz:metadata>
232       </xsl:for-each>
233
234       <pz:metadata type="medium">
235         <xsl:value-of select="$medium"/>
236       </pz:metadata>
237       
238       <xsl:if test="$fulltext_a">
239         <pz:metadata type="fulltext">
240           <xsl:value-of select="$fulltext_a"/>
241         </pz:metadata>
242       </xsl:if>
243
244       <xsl:if test="$fulltext_b">
245         <pz:metadata type="fulltext">
246           <xsl:value-of select="$fulltext_b"/>
247         </pz:metadata>
248       </xsl:if>
249     </pz:record>
250   </xsl:template>
251
252 </xsl:stylesheet>