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