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