Merge branch 'master' of git.evergreen-ils.org:Evergreen into template-toolkit-opac
[working/Evergreen.git] / Open-ILS / xsl / MARC21slim2SRWDC.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <xsl:stylesheet version="1.0" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:srw_dc="info:srw/schema/1/dc-schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://purl.org/dc/elements/1.1/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="marc">
3         <xsl:import href="MARC21slimUtils.xsl"/>
4         <xsl:output method="xml" indent="yes" encoding="UTF-8"/>
5         <!-- modification log 
6         NT 01/04:  added collection level element
7         and removed attributes
8
9         JR 06/04:  Added ISBN identifier
10
11    JR 09/05:  Added additional <subject> subfields and 651 for <coverage>
12    RG 10/07/05: Corrected subject subfields; 10/12/05: added if statement for <language>
13 -->
14         <xsl:template match="/">
15                 <xsl:if test="marc:collection">
16                         <srw_dc:dcCollection xmlns:srw_dc="info:srw/schema/1/dc-schema" xsi:schemaLocation="info:srw/schema/1/dc-schema http://www.loc.gov/z3950/agency/zing/srw/dc-schema.xsd">
17                                 <xsl:for-each select="marc:collection">
18                                         <xsl:for-each select="marc:record">
19                                                 <srw_dc:dc>
20                                                         <xsl:apply-templates select="."/>
21                                                 </srw_dc:dc>
22                                         </xsl:for-each>
23                                 </xsl:for-each>
24                         </srw_dc:dcCollection>
25                 </xsl:if>
26                 <xsl:if test="marc:record">
27                         <srw_dc:dc xmlns:srw_dc="info:srw/schema/1/dc-schema" xsi:schemaLocation="info:srw/schema/1/dc-schema http://www.loc.gov/z3950/agency/zing/srw/dc-schema.xsd">
28                                 <xsl:apply-templates select="marc:record"/>
29                         </srw_dc:dc>
30                 </xsl:if>
31         </xsl:template>
32         <xsl:template match="marc:record">
33                 <xsl:variable name="leader" select="marc:leader"/>
34                 <xsl:variable name="leader6" select="substring($leader,7,1)"/>
35                 <xsl:variable name="leader7" select="substring($leader,8,1)"/>
36                 <xsl:variable name="controlField008" select="marc:controlfield[@tag=008]"/>
37                 <xsl:for-each select="marc:datafield[@tag=245]">
38                         <title>
39                                 <xsl:call-template name="subfieldSelect">
40                                         <xsl:with-param name="codes">abfghk</xsl:with-param>
41                                 </xsl:call-template>
42                         </title>
43                 </xsl:for-each>
44                 <xsl:for-each select="marc:datafield[@tag=100]|marc:datafield[@tag=110]|marc:datafield[@tag=111]|marc:datafield[@tag=700]|marc:datafield[@tag=710]|marc:datafield[@tag=711]|marc:datafield[@tag=720]">
45                         <creator>
46                                 <xsl:value-of select="normalize-space(.)"/>
47                         </creator>
48                 </xsl:for-each>
49                 <type>
50                         <xsl:if test="$leader7='c'">
51                                 <!-- nt fix 1/04 -->
52                                 <!--<xsl:attribute name="collection">yes</xsl:attribute>-->
53                                 <xsl:text>collection</xsl:text>
54                         </xsl:if>
55                         <xsl:if test="$leader6='d' or $leader6='f' or $leader6='p' or $leader6='t'">
56                                 <!-- nt fix 1/04 -->
57                                 <!--<xsl:attribute name="manuscript">yes</xsl:attribute> -->
58                                 <xsl:text>manuscript</xsl:text>
59                         </xsl:if>
60                         <xsl:choose>
61                                 <xsl:when test="$leader6='a' or $leader6='t'">text</xsl:when>
62                                 <xsl:when test="$leader6='e' or $leader6='f'">cartographic</xsl:when>
63                                 <xsl:when test="$leader6='c' or $leader6='d'">notated music</xsl:when>
64                                 <xsl:when test="$leader6='i' or $leader6='j'">sound recording</xsl:when>
65                                 <xsl:when test="$leader6='k'">still image</xsl:when>
66                                 <xsl:when test="$leader6='g'">moving image</xsl:when>
67                                 <xsl:when test="$leader6='r'">three dimensional object</xsl:when>
68                                 <xsl:when test="$leader6='m'">software, multimedia</xsl:when>
69                                 <xsl:when test="$leader6='p'">mixed material</xsl:when>
70                         </xsl:choose>
71                 </type>
72                 <xsl:for-each select="marc:datafield[@tag=655]">
73                         <type>
74                                 <xsl:value-of select="normalize-space(.)"/>
75                         </type>
76                 </xsl:for-each>
77                 <xsl:for-each select="marc:datafield[@tag=260]">
78                         <publisher>
79                                 <xsl:call-template name="subfieldSelect">
80                                         <xsl:with-param name="codes">ab</xsl:with-param>
81                                 </xsl:call-template>
82                         </publisher>
83                 </xsl:for-each>
84                 <xsl:for-each select="marc:datafield[@tag=260]/marc:subfield[@code='c']">
85                         <date>
86                                 <xsl:value-of select="."/>
87                         </date>
88                 </xsl:for-each>
89                 <xsl:if test="substring($controlField008,36,3)">
90                         <language>
91                                 <xsl:value-of select="substring($controlField008,36,3)"/>
92                         </language>
93                 </xsl:if>               
94                 <xsl:for-each select="marc:datafield[@tag=856]/marc:subfield[@code='q']">
95                         <format>
96                                 <xsl:value-of select="."/>
97                         </format>
98                 </xsl:for-each>
99                 <xsl:for-each select="marc:datafield[@tag=520]">
100                         <description>
101                                 <!-- nt fix 01/04 -->
102                                 <xsl:value-of select="normalize-space(marc:subfield[@code='a'])"/>
103                         </description>
104                 </xsl:for-each>
105                 <xsl:for-each select="marc:datafield[@tag=521]">
106                         <description>
107                                 <xsl:value-of select="marc:subfield[@code='a']"/>
108                         </description>
109                 </xsl:for-each>
110                 <xsl:for-each select="marc:datafield[500&lt;@tag][@tag&lt;=599][not(@tag=506 or @tag=530 or @tag=540 or @tag=546)]">
111                         <description>
112                                 <xsl:value-of select="marc:subfield[@code='a']"/>
113                         </description>
114                 </xsl:for-each>
115                 <xsl:for-each select="marc:datafield[@tag=600]">
116                         <subject>
117                                 <xsl:call-template name="subfieldSelect">
118                                         <xsl:with-param name="codes">abcdefghjklmnopqrstu4</xsl:with-param>
119                                 </xsl:call-template>
120                                 <xsl:if test="marc:subfield[@code='v' or @code='x' or @code='y' or @code='z']">
121                                 <xsl:text>--</xsl:text>
122                                 <xsl:call-template name="subfieldSelect">
123                                         <xsl:with-param name="codes">vxyz</xsl:with-param>
124                                         <xsl:with-param name="delimeter">--</xsl:with-param>
125                                 </xsl:call-template>
126                                 </xsl:if>
127                         </subject>
128                 </xsl:for-each>
129                 <xsl:for-each select="marc:datafield[@tag=610]">
130                         <subject>
131                                 <xsl:call-template name="subfieldSelect">
132                                         <xsl:with-param name="codes">abcdefghklmnoprstu4</xsl:with-param>
133                                 </xsl:call-template>
134                                 <xsl:if test="marc:subfield[@code='v' or @code='x' or @code='y' or
135                                         @code='z']">
136                                         <xsl:text>--</xsl:text>
137                                         <xsl:call-template name="subfieldSelect">
138                                                 <xsl:with-param name="codes">vxyz</xsl:with-param>
139                                                 <xsl:with-param name="delimeter">--</xsl:with-param>
140                                         </xsl:call-template>
141                                 </xsl:if>
142                         </subject>
143                 </xsl:for-each>
144                 <xsl:for-each select="marc:datafield[@tag=611]">
145                         <subject>
146                                 <xsl:call-template name="subfieldSelect">
147                                         <xsl:with-param name="codes">acdefghklnpqstu4</xsl:with-param>
148                                 </xsl:call-template>
149                                 <xsl:if test="marc:subfield[@code='v' or @code='x' or @code='y' or
150                                         @code='z']">
151                                         <xsl:text>--</xsl:text>
152                                         <xsl:call-template name="subfieldSelect">
153                                                 <xsl:with-param name="codes">vxyz</xsl:with-param>
154                                                 <xsl:with-param name="delimeter">--</xsl:with-param>
155                                         </xsl:call-template>
156                                 </xsl:if>
157                         </subject>
158                 </xsl:for-each>
159                 <xsl:for-each select="marc:datafield[@tag=630]">
160                         <subject>
161                                 <xsl:call-template name="subfieldSelect">
162                                         <xsl:with-param name="codes">adfghklmnoprst</xsl:with-param>
163                                 </xsl:call-template>
164                                 <xsl:if test="marc:subfield[@code='v' or @code='x' or @code='y' or
165                                         @code='z']">
166                                         <xsl:text>--</xsl:text>
167                                         <xsl:call-template name="subfieldSelect">
168                                                 <xsl:with-param name="codes">vxyz</xsl:with-param>
169                                                 <xsl:with-param name="delimeter">--</xsl:with-param>
170                                         </xsl:call-template>
171                                 </xsl:if>
172                         </subject>
173                 </xsl:for-each>
174                 <xsl:for-each select="marc:datafield[@tag=650]">
175                         <subject>
176                                 <xsl:call-template name="subfieldSelect">
177                                         <xsl:with-param name="codes">ae</xsl:with-param></xsl:call-template>
178                                 <xsl:if test="marc:subfield[@code='v' or @code='x' or @code='y' or
179                                         @code='z']">
180                                         <xsl:text>--</xsl:text>
181                                         <xsl:call-template name="subfieldSelect">
182                                                 <xsl:with-param name="codes">vxyz</xsl:with-param>
183                                                 <xsl:with-param name="delimeter">--</xsl:with-param>
184                                         </xsl:call-template>
185                                 </xsl:if>
186                         </subject>
187                 </xsl:for-each>
188                 <xsl:for-each select="marc:datafield[@tag=653]">
189                         <subject>
190                                 <xsl:call-template name="subfieldSelect">
191                                         <xsl:with-param name="codes">a</xsl:with-param>
192                                 </xsl:call-template>
193                         </subject>
194                 </xsl:for-each>
195                 <xsl:for-each select="marc:datafield[@tag=651]">
196                         <coverage>
197                                 <xsl:call-template name="subfieldSelect">
198                                         <xsl:with-param name="codes">a</xsl:with-param>
199                                 </xsl:call-template>
200                                 <xsl:if test="marc:subfield[@code='v' or @code='x' or @code='y' or
201                                         @code='z']">
202                                         <xsl:text>--</xsl:text>
203                                         <xsl:call-template name="subfieldSelect">
204                                                 <xsl:with-param name="codes">vxyz</xsl:with-param>
205                                                 <xsl:with-param name="delimeter">--</xsl:with-param>
206                                         </xsl:call-template>
207                                 </xsl:if>
208                         </coverage>
209                 </xsl:for-each>
210                 <xsl:for-each select="marc:datafield[@tag=752]">
211                         <coverage>
212                                 <xsl:call-template name="subfieldSelect">
213                                         <xsl:with-param name="codes">abcd</xsl:with-param>
214                                 </xsl:call-template>
215                         </coverage>
216                 </xsl:for-each>
217                 <xsl:for-each select="marc:datafield[@tag=530]">
218                         <!-- nt 01/04 attribute fix -->
219                         <relation>
220                                 <!--<xsl:attribute name="type">original</xsl:attribute>-->
221                                 <xsl:call-template name="subfieldSelect">
222                                         <xsl:with-param name="codes">abcdu</xsl:with-param>
223                                 </xsl:call-template>
224                         </relation>
225                 </xsl:for-each>
226                 <xsl:for-each select="marc:datafield[@tag=760]|marc:datafield[@tag=762]|marc:datafield[@tag=765]|marc:datafield[@tag=767]|marc:datafield[@tag=770]|marc:datafield[@tag=772]|marc:datafield[@tag=773]|marc:datafield[@tag=774]|marc:datafield[@tag=775]|marc:datafield[@tag=776]|marc:datafield[@tag=777]|marc:datafield[@tag=780]|marc:datafield[@tag=785]|marc:datafield[@tag=786]|marc:datafield[@tag=787]">
227                         <relation>
228                                 <xsl:call-template name="subfieldSelect">
229                                         <xsl:with-param name="codes">ot</xsl:with-param>
230                                 </xsl:call-template>
231                         </relation>
232                 </xsl:for-each>
233                 <xsl:for-each select="marc:datafield[@tag=856]">
234                         <identifier>
235                                 <xsl:value-of select="marc:subfield[@code='u']"/>
236                         </identifier>
237                 </xsl:for-each>
238                 <xsl:for-each select="marc:datafield[@tag=020]">
239                         <identifier>
240                                 <xsl:text>URN:ISBN:</xsl:text>
241                                 <xsl:value-of select="marc:subfield[@code='a']"/>
242                         </identifier>
243                 </xsl:for-each>
244                 <xsl:for-each select="marc:datafield[@tag=506]">
245                         <rights>
246                                 <xsl:value-of select="marc:subfield[@code='a']"/>
247                         </rights>
248                 </xsl:for-each>
249                 <xsl:for-each select="marc:datafield[@tag=540]">
250                         <rights>
251                                 <xsl:value-of select="marc:subfield[@code='a']"/>
252                         </rights>
253                 </xsl:for-each>
254         </xsl:template>
255 </xsl:stylesheet>
256 <!-- Stylus Studio meta-information - (c)1998-2003 Copyright Sonic Software Corporation. All rights reserved.
257 <metaInformation>
258 <scenarios/><MapperInfo srcSchemaPath="" srcSchemaRoot="" srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>
259 </metaInformation>
260 -->