Announce new functionality API on Debian
[yaz-moved-to-github.git] / etc / MARC21slim2MODS.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <xsl:stylesheet version="1.0" xmlns:xlink="http://www.w3.org/TR/xlink" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns="http://www.loc.gov/mods/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="marc">
3         <xsl:include href="MARC21slimUtils.xsl"/>
4         <xsl:output method="xml" indent="yes"/>
5         
6         <xsl:template match="/">
7                 <collection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/mods/  http://www.loc.gov/standards/marcxml/schema/mods.xsd">
8                         <xsl:apply-templates/>
9                 </collection>
10         </xsl:template>
11
12         <xsl:template match="marc:record">
13                 <mods>
14                         <xsl:variable name="leader" select="marc:leader"/>
15                         <xsl:variable name="leader6" select="substring($leader,7,1)"/>
16                         <xsl:variable name="leader7" select="substring($leader,8,1)"/>
17                         <xsl:variable name="controlField008" select="marc:controlfield[@tag=008]"/>
18
19                         <xsl:variable name="typeOf008">
20                                 <xsl:choose>
21                                         <xsl:when test="$leader6='a'">
22                                                 <xsl:choose>
23                                                         <xsl:when test="$leader7='a' or $leader7='c' or $leader7='d' or $leader7='m'">BK</xsl:when>
24                                                         <xsl:when test="$leader7='b' or $leader7='i' or $leader7='s'">SE</xsl:when>                             
25                                                 </xsl:choose>
26                                         </xsl:when>
27                                         <xsl:when test="$leader6='t'">BK</xsl:when>
28                                         <xsl:when test="$leader6='p'">MM</xsl:when>
29                                         <xsl:when test="$leader6='m'">CF</xsl:when>     
30                                         <xsl:when test="$leader6='e' or $leader6='f'">MP</xsl:when>     
31                                         <xsl:when test="$leader6='g' or $leader6='k' or $leader6='o' or $leader6='r'">VM</xsl:when>                             
32                                         <xsl:when test="$leader6='c' or $leader6='d' or $leader6='i' or $leader6='j'">MU</xsl:when>                             
33                                 </xsl:choose>
34                         </xsl:variable>
35
36                         <xsl:for-each select="marc:datafield[@tag=245]">
37                                 <titleInfo>
38                                         <xsl:variable name="title">
39                                                 <xsl:call-template name="chopPunctuation">
40                                                         <xsl:with-param name="chopString">
41                                                                 <xsl:call-template name="subfieldSelect">
42                                                                         <xsl:with-param name="codes">abfghk</xsl:with-param>
43                                                                 </xsl:call-template>
44                                                         </xsl:with-param>
45                                                 </xsl:call-template>
46                                         </xsl:variable>
47                                         <xsl:choose>
48                                                 <xsl:when test="@ind2>0">
49                                                         <nonSort>
50                                                                 <xsl:value-of select="substring($title,1,@ind2)"/>
51                                                         </nonSort>
52                                                         <title>
53                                                                 <xsl:value-of select="substring($title,@ind2+1)"/>
54                                                         </title>
55                                                 </xsl:when>
56                                                 <xsl:otherwise>
57                                                         <title>
58                                                                 <xsl:value-of select="$title"/>
59                                                         </title>
60                                                 </xsl:otherwise>
61                                         </xsl:choose>
62                                         <xsl:call-template name="part"/>
63                                 </titleInfo>
64                         </xsl:for-each>
65                         
66                         <xsl:for-each select="marc:datafield[@tag=210]">
67                                 <titleInfo type="abbreviated">
68                                         <title>
69                                                 <xsl:call-template name="subfieldSelect">
70                                                         <xsl:with-param name="codes">ab</xsl:with-param>
71                                                 </xsl:call-template>
72                                         </title>
73                                 </titleInfo>
74                         </xsl:for-each>
75                         
76                         <xsl:for-each select="marc:datafield[@tag=242]">
77                                 <titleInfo type="translated">
78                                         <title>
79                                                 <xsl:call-template name="subfieldSelect">
80                                                         <xsl:with-param name="codes">abh</xsl:with-param>
81                                                 </xsl:call-template>
82                                         </title>
83                                         <xsl:call-template name="part"/>
84                                 </titleInfo>
85                         </xsl:for-each>
86                         
87                         <xsl:for-each select="marc:datafield[@tag=246]">
88                                 <titleInfo type="alternative">
89                                         <xsl:for-each select="marc:subfield[@code='i']">
90                                                 <xsl:attribute name="displayLabel">
91                                                         <xsl:value-of select="text()"/>
92                                                 </xsl:attribute>
93                                         </xsl:for-each>
94                                         <title>
95                                                 <xsl:call-template name="subfieldSelect">
96                                                         <xsl:with-param name="codes">abfh</xsl:with-param>
97                                                 </xsl:call-template>
98                                         </title>
99                                         <xsl:call-template name="part"/>                        
100                                 </titleInfo>
101                         </xsl:for-each>
102
103                         <xsl:for-each select="marc:datafield[@tag=130]|marc:datafield[@tag=240]|marc:datafield[@tag=730][@ind2!=2]">
104                                 <titleInfo type="uniform">
105                                         <title>
106                                                 <xsl:variable name="str">
107                                                         <xsl:for-each select="marc:subfield">
108                                                                 <xsl:if test="(contains('adfhklmor',@code) and (not(../marc:subfield[@code='n' or @code='p']) or (following-sibling::marc:subfield[@code='n' or @code='p'])))">
109                                                                         <xsl:value-of select="text()"/><xsl:text> </xsl:text>
110                                                                 </xsl:if>
111                                                         </xsl:for-each>
112                                                 </xsl:variable>
113                                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
114                                         </title>
115                                         <xsl:call-template name="part"/>                        
116                                 </titleInfo>
117                         </xsl:for-each>
118
119                         <xsl:for-each select="marc:datafield[@tag=740][@ind2!=2]">
120                                 <titleInfo type="alternative">
121                                         <title>
122                                                 <xsl:call-template name="subfieldSelect">
123                                                         <xsl:with-param name="codes">ah</xsl:with-param>
124                                                 </xsl:call-template>
125                                         </title>
126                                         <xsl:call-template name="part"/>                        
127                                 </titleInfo>
128                         </xsl:for-each>
129                         
130                         <xsl:for-each select="marc:datafield[@tag=100]">
131                                 <name type="personal">
132                                         <xsl:call-template name="nameABCDQ"/>
133                                         <xsl:call-template name="affiliation"/>
134                                         <role>creator</role>
135                                         <xsl:call-template name="role"/>
136                                 </name>
137                         </xsl:for-each>
138
139
140                         <xsl:for-each select="marc:datafield[@tag=110]">
141                                 <name type="corporate">
142                                         <xsl:call-template name="nameABCDN"/>
143                                         <role>creator</role>
144                                         <xsl:call-template name="role"/>
145                                 </name>
146                         </xsl:for-each>
147
148                         <xsl:for-each select="marc:datafield[@tag=111]">
149                                 <name type="conference">
150                                         <xsl:call-template name="nameACDEQ"/>
151                                         <role>creator</role>
152                                         <xsl:for-each select="marc:subfield[@code='4']">
153                                                 <role><xsl:value-of select="."/></role>
154                                         </xsl:for-each>
155                                 </name>
156                         </xsl:for-each>
157
158                         <xsl:for-each select="marc:datafield[@tag=700][not(marc:subfield[@code='t'])]">
159                                 <name type="personal">
160                                         <xsl:call-template name="nameABCDQ"/>
161                                         <xsl:call-template name="affiliation"/>
162                                         <xsl:call-template name="role"/>
163                                 </name>
164                         </xsl:for-each>
165
166                         <xsl:for-each select="marc:datafield[@tag=710][not(marc:subfield[@code='t'])]">
167                                 <name type="corporate">
168                                         <xsl:call-template name="nameABCDN"/>
169                                         <xsl:call-template name="role"/>
170                                 </name>
171                         </xsl:for-each>
172
173                         <xsl:for-each select="marc:datafield[@tag=711][not(marc:subfield[@code='t'])]">
174                                 <name type="conference">
175                                         <xsl:call-template name="nameACDEQ"/>
176                                         <xsl:for-each select="marc:subfield[@code='4']">
177                                                 <role><xsl:value-of select="."/></role>
178                                         </xsl:for-each>
179                                 </name>
180                         </xsl:for-each>
181
182                         <xsl:for-each select="marc:datafield[@tag=720][not(marc:subfield[@code='t'])]">
183                                 <name>
184                                         <xsl:if test="@ind1=1">
185                                                 <xsl:attribute name="type">personal</xsl:attribute>
186                                         </xsl:if>
187                                         <namePart>
188                                                 <xsl:value-of select="marc:subfield[@code='a']"/>
189                                         </namePart>
190                                         <xsl:call-template name="role"/>
191                                 </name>
192                         </xsl:for-each>
193
194                         <typeOfResource>                
195                                 <xsl:if test="$leader7='c'">
196                                         <xsl:attribute name="collection">yes</xsl:attribute>
197                                 </xsl:if>
198                                 <xsl:if test="$leader6='d' or $leader6='f' or $leader6='p' or $leader6='t'">
199                                         <xsl:attribute name="manuscript">yes</xsl:attribute>
200                                 </xsl:if>
201
202                                 <xsl:choose>
203                                         <xsl:when test="$leader6='a' or $leader6='t'">text</xsl:when>
204                                         <xsl:when test="$leader6='e' or $leader6='f'">cartographic</xsl:when>
205                                         <xsl:when test="$leader6='c' or $leader6='d'">notated music</xsl:when>
206                                         <xsl:when test="$leader6='i' or $leader6='j'">sound recording</xsl:when>
207                                         <xsl:when test="$leader6='k'">still image</xsl:when>
208                                         <xsl:when test="$leader6='g'">moving image</xsl:when>
209                                         <xsl:when test="$leader6='r'">three dimensional object</xsl:when>
210                                         <xsl:when test="$leader6='m'">software, multimedia</xsl:when>
211                                         <xsl:when test="$leader6='p'">mixed material</xsl:when>
212                                 </xsl:choose>
213                         </typeOfResource>
214
215                                 <xsl:if test="substring($controlField008,26,1)='d'">
216                                         <genre authority="marc">globe</genre>
217                                 </xsl:if>
218                         
219                                 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='r']">
220                                         <genre authority="marc">remote sensing image</genre>
221                                 </xsl:if>
222
223                                 <xsl:if test="$typeOf008='MP'">
224                                         <xsl:variable name="controlField008-25" select="substring($controlField008,26,1)"/>
225                                         <xsl:choose>
226                                                 <xsl:when test="$controlField008-25='a' or $controlField008-25='b' or $controlField008-25='c' or marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='j']">
227                                                         <genre authority="marc">map</genre>
228                                                 </xsl:when>
229                                                 <xsl:when test="$controlField008-25='e' or marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='d']">
230                                                         <genre authority="marc">atlas</genre>
231                                                 </xsl:when>
232                                         </xsl:choose>
233                                 </xsl:if>
234
235                                 <xsl:if test="$typeOf008='SE'">
236                                         <xsl:variable name="controlField008-21" select="substring($controlField008,22,1)"/>
237                                         <xsl:choose>
238                                                 <xsl:when test="$controlField008-21='d'">
239                                                         <genre authority="marc">database</genre>
240                                                 </xsl:when>
241                                                 <xsl:when test="$controlField008-21='l'">       
242                                                         <genre authority="marc">loose-leaf</genre>
243                                                 </xsl:when>
244                                                 <xsl:when test="$controlField008-21='m'">
245                                                         <genre authority="marc">series</genre>
246                                                 </xsl:when>
247                                                 <xsl:when test="$controlField008-21='n'">
248                                                         <genre authority="marc">newspaper</genre>       
249                                                 </xsl:when>
250                                                 <xsl:when test="$controlField008-21='p'">
251                                                         <genre authority="marc">periodical</genre>
252                                                 </xsl:when>
253                                                 <xsl:when test="$controlField008-21='w'">
254                                                         <genre authority="marc">web site</genre>
255                                                 </xsl:when>
256                                         </xsl:choose>
257                                 </xsl:if>
258
259                                 <xsl:if test="$typeOf008='BK' or $typeOf008='SE'">
260                                         <xsl:variable name="controlField008-24" select="substring($controlField008,25,4)"/>
261                                         <xsl:choose>
262                                                 <xsl:when test="contains($controlField008-24,'a')">
263                                                         <genre authority="marc">abstract or summary</genre>
264                                                 </xsl:when>
265                                                 <xsl:when test="contains($controlField008-24,'b')">
266                                                         <genre authority="marc">bibliography</genre>
267                                                 </xsl:when>
268                                                 <xsl:when test="contains($controlField008-24,'c')">
269                                                         <genre authority="marc">catalog</genre>
270                                                 </xsl:when>
271                                                 <xsl:when test="contains($controlField008-24,'d')">
272                                                         <genre authority="marc">dictionary</genre>
273                                                 </xsl:when>
274                                                 <xsl:when test="contains($controlField008-24,'e')">
275                                                         <genre authority="marc">encyclopedia</genre>
276                                                 </xsl:when>
277                                                 <xsl:when test="contains($controlField008-24,'f')">
278                                                         <genre authority="marc">handbook</genre>
279                                                 </xsl:when>
280                                                 <xsl:when test="contains($controlField008-24,'g')">
281                                                         <genre authority="marc">legal article</genre>
282                                                 </xsl:when>
283                                                 <xsl:when test="contains($controlField008-24,'i')">
284                                                         <genre authority="marc">index</genre>
285                                                 </xsl:when>
286                                                 <xsl:when test="contains($controlField008-24,'k')">
287                                                         <genre authority="marc">discography</genre>
288                                                 </xsl:when>
289                                                 <xsl:when test="contains($controlField008-24,'l')">
290                                                         <genre authority="marc">legislation</genre>
291                                                 </xsl:when>
292                                                 <xsl:when test="contains($controlField008-24,'m')">
293                                                         <genre authority="marc">theses</genre>
294                                                 </xsl:when>
295                                                 <xsl:when test="contains($controlField008-24,'n')">
296                                                         <genre authority="marc">survey of literature</genre>
297                                                 </xsl:when>
298                                                 <xsl:when test="contains($controlField008-24,'o')">
299                                                         <genre authority="marc">review</genre>
300                                                 </xsl:when>
301                                                 <xsl:when test="contains($controlField008-24,'p')">
302                                                         <genre authority="marc">programmed text</genre>
303                                                 </xsl:when>                                     
304                                                 <xsl:when test="contains($controlField008-24,'q')">
305                                                         <genre authority="marc">filmography</genre>
306                                                 </xsl:when>
307                                                 <xsl:when test="contains($controlField008-24,'r')">
308                                                         <genre authority="marc">directory</genre>
309                                                 </xsl:when>
310                                                 <xsl:when test="contains($controlField008-24,'s')">
311                                                         <genre authority="marc">statistics</genre>
312                                                 </xsl:when>
313                                                 <xsl:when test="contains($controlField008-24,'t')">
314                                                         <genre authority="marc">technical report</genre>
315                                                 </xsl:when>
316                                                 <xsl:when test="contains($controlField008-24,'v')">
317                                                         <genre authority="marc">legal case and case notes</genre>
318                                                 </xsl:when>
319                                                 <xsl:when test="contains($controlField008-24,'w')">
320                                                         <genre authority="marc">law report or digest</genre>
321                                                 </xsl:when>
322                                                 <xsl:when test="contains($controlField008-24,'z')">
323                                                         <genre authority="marc">treaty</genre>
324                                                 </xsl:when>      
325                                         </xsl:choose>
326                                         <xsl:variable name="controlField008-29" select="substring($controlField008,30,1)"/>
327                                         <xsl:choose>
328                                                 <xsl:when test="$controlField008-29='1'">
329                                                         <genre authority="marc">conference publication</genre>
330                                                 </xsl:when>
331                                         </xsl:choose>
332                                 </xsl:if>
333
334                                 <xsl:if test="$typeOf008='CF'">
335                                         <xsl:variable name="controlField008-26" select="substring($controlField008,27,1)"/>
336                                         <xsl:choose>
337                                                 <xsl:when test="$controlField008-26='a'">
338                                                         <genre authority="marc">numeric data</genre>
339                                                 </xsl:when>
340                                                 <xsl:when test="$controlField008-26='e'">
341                                                         <genre authority="marc">database</genre>
342                                                 </xsl:when>
343                                                 <xsl:when test="$controlField008-26='f'">
344                                                         <genre authority="marc">font</genre>
345                                                 </xsl:when>
346                                                 <xsl:when test="$controlField008-26='g'">
347                                                         <genre authority="marc">game</genre>
348                                                 </xsl:when>
349                                         </xsl:choose>
350                                 </xsl:if>
351
352                                 <xsl:if test="$typeOf008='BK'">
353                                         <xsl:if test="substring($controlField008,25,1)='j'">
354                                                 <genre authority="marc">patent</genre>
355                                         </xsl:if>
356                                         <xsl:if test="substring($controlField008,31,1)='1'">
357                                                 <genre authority="marc">festschrift</genre>
358                                         </xsl:if>
359
360                                         <xsl:variable name="controlField008-34" select="substring($controlField008,35,1)"/>
361                                         <xsl:if test="$controlField008-34='a' or $controlField008-34='b' or $controlField008-34='c' or $controlField008-34='d'">
362                                                 <genre authority="marc">biography</genre>
363                                         </xsl:if>
364
365                                         <xsl:variable name="controlField008-33" select="substring($controlField008,34,1)"/>
366                                         <xsl:choose>
367                                                 <xsl:when test="$controlField008-33='e'">
368                                                         <genre authority="marc">essay</genre>
369                                                 </xsl:when>
370                                                 <xsl:when test="$controlField008-33='d'">
371                                                         <genre authority="marc">drama</genre>
372                                                 </xsl:when>
373                                                 <xsl:when test="$controlField008-33='c'">
374                                                         <genre authority="marc">comic strip</genre>
375                                                 </xsl:when>
376                                                 <xsl:when test="$controlField008-33='l'">
377                                                         <genre authority="marc">fiction</genre>
378                                                 </xsl:when>
379                                                 <xsl:when test="$controlField008-33='h'">
380                                                         <genre authority="marc">humor, satire</genre>
381                                                 </xsl:when>
382                                                 <xsl:when test="$controlField008-33='i'">
383                                                         <genre authority="marc">letter</genre>
384                                                 </xsl:when>
385                                                 <xsl:when test="$controlField008-33='f'">
386                                                         <genre authority="marc">novel</genre>
387                                                 </xsl:when>
388                                                 <xsl:when test="$controlField008-33='j'">
389                                                         <genre authority="marc">short story</genre>
390                                                 </xsl:when>
391                                                 <xsl:when test="$controlField008-33='s'">
392                                                         <genre authority="marc">speech</genre>
393                                                 </xsl:when>
394                                         </xsl:choose>
395                                 </xsl:if>
396
397                                 <xsl:if test="$typeOf008='MU'">
398                                         <xsl:variable name="controlField008-30-31" select="substring($controlField008,31,2)"/>
399                                         <xsl:if test="contains($controlField008-30-31,'b')">
400                                                 <genre authority="marc">biography</genre>
401                                         </xsl:if>
402                                         <xsl:if test="contains($controlField008-30-31,'c')">
403                                                 <genre authority="marc">conference publication</genre>
404                                         </xsl:if>
405                                         <xsl:if test="contains($controlField008-30-31,'d')">
406                                                 <genre authority="marc">drama</genre>
407                                         </xsl:if>
408                                         <xsl:if test="contains($controlField008-30-31,'e')">
409                                                 <genre authority="marc">essay</genre>
410                                         </xsl:if>
411                                         <xsl:if test="contains($controlField008-30-31,'f')">
412                                                 <genre authority="marc">fiction</genre>
413                                         </xsl:if>
414                                         <xsl:if test="contains($controlField008-30-31,'o')">
415                                                 <genre authority="marc">folktale</genre>
416                                         </xsl:if>
417                                         <xsl:if test="contains($controlField008-30-31,'h')">
418                                                 <genre authority="marc">history</genre>
419                                         </xsl:if>
420                                         <xsl:if test="contains($controlField008-30-31,'k')">
421                                                 <genre authority="marc">humor, satire</genre>
422                                         </xsl:if>
423                                         <xsl:if test="contains($controlField008-30-31,'m')">
424                                                 <genre authority="marc">memoir</genre>
425                                         </xsl:if>
426                                         <xsl:if test="contains($controlField008-30-31,'p')">
427                                                 <genre authority="marc">poetry</genre>
428                                         </xsl:if>
429                                         <xsl:if test="contains($controlField008-30-31,'r')">
430                                                 <genre authority="marc">rehersal</genre>
431                                         </xsl:if>
432                                         <xsl:if test="contains($controlField008-30-31,'g')">
433                                                 <genre authority="marc">reporting</genre>
434                                         </xsl:if>
435                                         <xsl:if test="contains($controlField008-30-31,'s')">
436                                                 <genre authority="marc">sound</genre>
437                                         </xsl:if>
438                                         <xsl:if test="contains($controlField008-30-31,'l')">
439                                                 <genre authority="marc">speech</genre>
440                                         </xsl:if>
441                                 </xsl:if>
442
443                                 <xsl:if test="$typeOf008='VM'">
444                                         <xsl:variable name="controlField008-33" select="substring($controlField008,34,1)"/>
445                                         <xsl:choose>
446                                                 <xsl:when test="$controlField008-33='a'">
447                                                         <genre authority="marc">art original</genre>
448                                                 </xsl:when>
449                                                 <xsl:when test="$controlField008-33='b'">
450                                                         <genre authority="marc">kit</genre>
451                                                 </xsl:when>
452                                                 <xsl:when test="$controlField008-33='c'">
453                                                         <genre authority="marc">art reproduction</genre>
454                                                 </xsl:when>
455                                                 <xsl:when test="$controlField008-33='d'">
456                                                         <genre authority="marc">diorama</genre>
457                                                 </xsl:when>
458                                                 <xsl:when test="$controlField008-33='f'">
459                                                         <genre authority="marc">filmstrip</genre>
460                                                 </xsl:when>
461                                                 <xsl:when test="$controlField008-33='g'">
462                                                         <genre authority="marc">legal article</genre>
463                                                 </xsl:when>
464                                                 <xsl:when test="$controlField008-33='i'">
465                                                         <genre authority="marc">picture</genre>
466                                                 </xsl:when>
467                                                 <xsl:when test="$controlField008-33='k'">
468                                                         <genre authority="marc">graphic</genre>
469                                                 </xsl:when>
470                                                 <xsl:when test="$controlField008-33='l'">
471                                                         <genre authority="marc">technical drawing</genre>
472                                                 </xsl:when>
473                                                 <xsl:when test="$controlField008-33='m'">
474                                                         <genre authority="marc">motion picture</genre>
475                                                 </xsl:when>
476                                                 <xsl:when test="$controlField008-33='n'">
477                                                         <genre authority="marc">chart</genre>
478                                                 </xsl:when>
479                                                 <xsl:when test="$controlField008-33='o'">
480                                                         <genre authority="marc">flash card</genre>
481                                                 </xsl:when>
482                                                 <xsl:when test="$controlField008-33='p'">
483                                                         <genre authority="marc">microscope slide</genre>
484                                                 </xsl:when>                                     
485                                                 <xsl:when test="$controlField008-33='q' or marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='q']">
486                                                         <genre authority="marc">model</genre>
487                                                 </xsl:when>
488                                                 <xsl:when test="$controlField008-33='r'">
489                                                         <genre authority="marc">realia</genre>
490                                                 </xsl:when>
491                                                 <xsl:when test="$controlField008-33='s'">
492                                                         <genre authority="marc">slide</genre>
493                                                 </xsl:when>
494                                                 <xsl:when test="$controlField008-33='t'">
495                                                         <genre authority="marc">transparency</genre>
496                                                 </xsl:when>
497                                                 <xsl:when test="$controlField008-33='v'">
498                                                         <genre authority="marc">videorecording</genre>
499                                                 </xsl:when>
500                                                 <xsl:when test="$controlField008-33='w'">
501                                                         <genre authority="marc">toy</genre>
502                                                 </xsl:when> 
503                                         </xsl:choose>
504                                 </xsl:if>
505
506                                 <xsl:for-each select="marc:datafield[@tag=655]">
507                                         <genre authority="marc">
508                                                 <xsl:attribute name="authority">
509                                                         <xsl:value-of select="marc:subfield[@code='2']"/>
510                                                 </xsl:attribute>
511                                                 <xsl:call-template name="subfieldSelect">
512                                                         <xsl:with-param name="codes">abvxyz</xsl:with-param>
513                                                         <xsl:with-param name="delimeter">-</xsl:with-param>
514                                                 </xsl:call-template>
515                                         </genre>
516                                 </xsl:for-each>
517
518                         <publicationInfo>
519                                 <xsl:variable name="MARCpublicationCode" select="normalize-space(substring($controlField008,16,3))"/>
520                                 
521                                 <xsl:if test="translate($MARCpublicationCode,'|','')">
522                                         <placeCode authority="marc">
523                                                 <xsl:value-of select="$MARCpublicationCode"/>
524                                         </placeCode>
525                                 </xsl:if>
526                         
527                                 <xsl:for-each select="marc:datafield[@tag=044]/marc:subfield[@code='c']">
528                                         <placeCode authority="iso3166">
529                                                 <xsl:value-of select="."/>
530                                         </placeCode>
531                                 </xsl:for-each>
532
533                                 <xsl:for-each select="marc:datafield[@tag=260]/marc:subfield[@code='a' or @code='b' or @code='c' or @code='g']">
534                                         <xsl:choose>
535                                                 <xsl:when test="@code='a'">
536                                                         <place>
537                                                                 <xsl:call-template name="chopPunctuation">
538                                                                         <xsl:with-param name="chopString" select="."/>
539                                                                 </xsl:call-template>
540                                                         </place>
541                                                 </xsl:when>
542                                                 <xsl:when test="@code='b'">
543                                                         <publisher>
544                                                                 <xsl:call-template name="chopPunctuation">
545                                                                         <xsl:with-param name="chopString" select="."/>
546                                                                 </xsl:call-template>
547                                                         </publisher>
548                                                 </xsl:when>
549                                                 <xsl:when test="@code='c'">
550                                                         <dateIssued>
551                                                                 <xsl:call-template name="chopPunctuation">
552                                                                         <xsl:with-param name="chopString" select="."/>
553                                                                 </xsl:call-template>
554                                                         </dateIssued>
555                                                 </xsl:when>
556                                                 <xsl:when test="@code='g'">
557                                                         <dateCreated>
558                                                                 <xsl:value-of select="."/>
559                                                         </dateCreated>                  
560                                                 </xsl:when>
561                                         </xsl:choose>
562                                 </xsl:for-each>
563
564                                 <xsl:variable name="dataField260c">
565                                         <xsl:call-template name="chopPunctuation">
566                                                 <xsl:with-param name="chopString" select="marc:datafield[@tag=260]/marc:subfield[@code='c']"/>
567                                         </xsl:call-template>
568                                 </xsl:variable>
569
570                                 <xsl:variable name="controlField008-7-10" select="normalize-space(substring($controlField008, 8, 4))"/>
571                                 <xsl:variable name="controlField008-11-14" select="normalize-space(substring($controlField008, 12, 4))"/>
572                                 <xsl:variable name="controlField008-6" select="normalize-space(substring($controlField008, 7, 1))"/>
573                 
574                                 <xsl:if test="$controlField008-6='e' or $controlField008-6='p' or $controlField008-6='r' or $controlField008-6='t' or $controlField008-6='s'">
575                                         <xsl:if test="$controlField008-7-10 and ($controlField008-7-10 != $dataField260c)">
576                                                 <dateIssued encoding="marc">
577                                                         <xsl:value-of select="$controlField008-7-10"/>
578                                                 </dateIssued>
579                                         </xsl:if>
580                                 </xsl:if>
581                 
582                                 <xsl:if test="$controlField008-6='c' or $controlField008-6='d' or $controlField008-6='i' or $controlField008-6='k' or $controlField008-6='m' or $controlField008-6='q' or $controlField008-6='u'">
583                                         <xsl:if test="$controlField008-7-10">
584                                                 <dateIssued encoding="marc" point="start">
585                                                         <xsl:value-of select="$controlField008-7-10"/>
586                                                 </dateIssued>
587                                         </xsl:if>
588                                 </xsl:if>
589
590                                 <xsl:if test="$controlField008-6='c' or $controlField008-6='d' or $controlField008-6='i' or $controlField008-6='k' or $controlField008-6='m' or $controlField008-6='q' or $controlField008-6='u'">
591                                         <xsl:if test="$controlField008-11-14">
592                                                 <dateIssued encoding="marc" point="end">
593                                                         <xsl:value-of select="$controlField008-11-14"/>
594                                                 </dateIssued>
595                                         </xsl:if>
596                                 </xsl:if>
597
598                                 <xsl:for-each select="marc:datafield[@tag=033][@ind1=0 or @ind1=1]/marc:subfield[@code='a']">
599                                         <dateCaptured encoding="iso8601">
600                                                 <xsl:value-of select="."/>
601                                         </dateCaptured>
602                                 </xsl:for-each>
603
604                                 <xsl:for-each select="marc:datafield[@tag=033][@ind1=2]/marc:subfield[@code='a'][1]">
605                                         <dateCaptured encoding="iso8601" point="start">
606                                                 <xsl:value-of select="."/>
607                                         </dateCaptured>
608                                 </xsl:for-each>
609
610                                 <xsl:for-each select="marc:datafield[@tag=033][@ind1=2]/marc:subfield[@code='a'][2]">
611                                         <dateCaptured encoding="iso8601" point="end">
612                                                 <xsl:value-of select="."/>
613                                         </dateCaptured>
614                                 </xsl:for-each>
615
616                                 <xsl:for-each select="marc:datafield[@tag=250]/marc:subfield[@code='a']">
617                                         <edition>
618                                                 <xsl:value-of select="."/>
619                                         </edition>
620                                 </xsl:for-each>
621
622                                 <xsl:for-each select="marc:leader">
623                                         <issuance>
624                                                 <xsl:choose>
625                                                         <xsl:when test="$leader7='a' or $leader7='c' or $leader7='d' or $leader7='m'">monographic</xsl:when>
626                                                         <xsl:when test="$leader7='b' or $leader7='i' or $leader7='s'">continuing</xsl:when>                                                     
627                                                 </xsl:choose>
628                                         </issuance>
629                                 </xsl:for-each>         
630                                 
631                                 <xsl:for-each select="marc:datafield[@tag=310]|marc:datafield[@tag=321]">
632                                         <frequency>
633                                                 <xsl:call-template name="subfieldSelect">
634                                                         <xsl:with-param name="codes">ab</xsl:with-param>
635                                                 </xsl:call-template>
636                                         </frequency>
637                                 </xsl:for-each>                                                         
638                         </publicationInfo>
639
640
641                         <xsl:for-each select="marc:controlfield[@tag=041]">
642                                 <xsl:for-each select="marc:subfield[@code='a' or @code='d' or @code='e']">
643                                         <language>
644                                                 <xsl:choose>
645                                                         <xsl:when test="../marc:subfield[@code='2']">
646                                                                 <xsl:attribute name="authority">rfc3066</xsl:attribute>
647                                                         </xsl:when>
648                                                         <xsl:otherwise>
649                                                                 <xsl:attribute name="authority">iso639-2b</xsl:attribute>                                               
650                                                         </xsl:otherwise>
651                                                 </xsl:choose>
652                                                 <xsl:value-of select="text()"/>
653                                         </language>
654                                 </xsl:for-each>
655                         </xsl:for-each>                 
656
657                         <xsl:variable name="controlField008-35-37" select="normalize-space(translate(substring($controlField008,36,3),'|#',''))"/>
658                         <xsl:if test="$controlField008-35-37">
659                                 <language authority="iso639-2b">
660                                         <xsl:value-of select="substring($controlField008,36,3)"/>
661                                 </language>
662                         </xsl:if>
663
664                         <xsl:variable name="physicalDescription">
665                                 <xsl:if test="$typeOf008='CF' and marc:controlfield[@tag=007][substring(.,12,1)='a' or substring(.,12,1)='b']">
666                                         <digitalOrigin>reformatted digital</digitalOrigin>
667                                 </xsl:if>
668
669                                 <xsl:variable name="controlField008-23" select="substring($controlField008,24,1)"/>
670                                 <xsl:variable name="controlField008-29" select="substring($controlField008,30,1)"/>
671
672                                 <xsl:variable name="check008-23">
673                                         <xsl:if test="$typeOf008='BK' or $typeOf008='MU' or $typeOf008='SE' or $typeOf008='MM'">
674                                                 <xsl:value-of select="true()"/>
675                                         </xsl:if>
676                                 </xsl:variable>
677
678                                 <xsl:variable name="check008-29">
679                                         <xsl:if test="$typeOf008='MP' or $typeOf008='VM'">
680                                                 <xsl:value-of select="true()"/>
681                                         </xsl:if>
682                                 </xsl:variable>
683
684                                 <xsl:choose>
685                                         <xsl:when test="($check008-23 and $controlField008-23='f') or ($check008-29 and $controlField008-29='f')">
686                                                 <form><controlled>braille</controlled></form>
687                                         </xsl:when>
688                                         <xsl:when test="$leader6 = 'm' or ($check008-23 and $controlField008-23='s') or ($check008-29 and $controlField008-29='s')">
689                                                 <form><controlled>electronic</controlled></form>
690                                         </xsl:when>
691                                         <xsl:when test="($check008-23 and $controlField008-23='b') or ($check008-29 and $controlField008-29='b')">
692                                                 <form><controlled>microfiche</controlled></form>
693                                         </xsl:when>
694                                         <xsl:when test="($check008-23 and $controlField008-23='a') or ($check008-29 and $controlField008-29='a')">
695                                                 <form><controlled>microfilm</controlled></form>
696                                         </xsl:when>
697                                 </xsl:choose>
698
699                                 <xsl:for-each select="marc:datafield[@tag=856]/marc:subfield[@code='q'][string-length(.)>1]">
700                                         <internetMediaType>
701                                                 <xsl:value-of select="."/>
702                                         </internetMediaType>
703                                 </xsl:for-each>
704
705                                 <xsl:for-each select="marc:datafield[@tag=256]/marc:subfield[@code='a']">
706                                         <form>
707                                                 <unControlled>
708                                                         <xsl:value-of select="."/>
709                                                 </unControlled>
710                                         </form>
711                                 </xsl:for-each>
712
713                                 <xsl:for-each select="marc:datafield[@tag=300]">
714                                         <extent>
715                                                 <xsl:call-template name="subfieldSelect">
716                                                         <xsl:with-param name="codes">abce</xsl:with-param>
717                                                 </xsl:call-template>
718                                         </extent>
719                                 </xsl:for-each>
720                         </xsl:variable>
721
722                         <xsl:if test="string-length(normalize-space($physicalDescription))">
723                                 <physicalDescription>
724                                         <xsl:copy-of select="$physicalDescription"/>
725                                 </physicalDescription>
726                         </xsl:if>
727
728                         <xsl:for-each select="marc:datafield[@tag=520]">
729                                 <abstract>
730                                         <xsl:call-template name="uri"/>
731                                         <xsl:call-template name="subfieldSelect">
732                                                 <xsl:with-param name="codes">ab</xsl:with-param>
733                                         </xsl:call-template>
734                                 </abstract>
735                         </xsl:for-each>
736
737                         <xsl:for-each select="marc:datafield[@tag=505]">
738                                 <tableOfContents>
739                                         <xsl:call-template name="uri"/>
740                                         <xsl:call-template name="subfieldSelect">
741                                                 <xsl:with-param name="codes">agrt</xsl:with-param>
742                                         </xsl:call-template>
743                                 </tableOfContents>
744                         </xsl:for-each>
745
746                         <xsl:for-each select="marc:datafield[@tag=521]">
747                                 <targetAudience>
748                                         <xsl:call-template name="subfieldSelect">
749                                                 <xsl:with-param name="codes">ab</xsl:with-param>
750                                         </xsl:call-template>
751                                 </targetAudience>
752                         </xsl:for-each>
753
754                         <xsl:if test="$typeOf008='BK' or $typeOf008='CF' or $typeOf008='MU' or $typeOf008='VM'">
755                                 <xsl:variable name="controlField008-22" select="substring($controlField008,23,1)"/>
756                                 <xsl:choose>
757                                         <xsl:when test="$controlField008-22='d'">
758                                                 <targetAudience>adolescent</targetAudience>
759                                         </xsl:when>
760                                         <xsl:when test="$controlField008-22='e'">
761                                                 <targetAudience>adult</targetAudience>
762                                         </xsl:when>
763                                         <xsl:when test="$controlField008-22='g'">
764                                                 <targetAudience>general</targetAudience>
765                                         </xsl:when>
766                                         <xsl:when test="$controlField008-22='b' or $controlField008-22='c' or $controlField008-22='j'">
767                                                 <targetAudience>juvenile</targetAudience>
768                                         </xsl:when>
769                                         <xsl:when test="$controlField008-22='a'">
770                                                 <targetAudience>preschool</targetAudience>
771                                         </xsl:when>
772                                         <xsl:when test="$controlField008-22='f'">
773                                                 <targetAudience>specialized</targetAudience>
774                                         </xsl:when>
775                                 </xsl:choose>
776                         </xsl:if>
777
778                         <!-- Not in mapping but in conversion -->
779                         <xsl:for-each select="marc:datafield[@tag=245]/marc:subfield[@code='c']">
780                                 <note type="statement of responsibility">
781                                         <xsl:value-of select="."/>
782                                 </note>
783                         </xsl:for-each>
784
785                         <xsl:for-each select="marc:datafield[@tag=500]">
786                                 <note>
787                                         <xsl:value-of select="marc:subfield[@code='a']"/>
788                                         <xsl:call-template name="uri"/>
789                                 </note>
790                         </xsl:for-each>
791
792                         <xsl:for-each select="marc:datafield[@tag=511]">
793                                 <note type="performers">
794                                         <xsl:call-template name="uri"/>
795                                         <xsl:value-of select="marc:subfield[@code='a']"/>
796                                 </note>
797                         </xsl:for-each>
798
799                         <xsl:for-each select="marc:datafield[@tag=518]">
800                                 <note type="venue">
801                                         <xsl:call-template name="uri"/>
802                                         <xsl:value-of select="marc:subfield[@code='a']"/>
803                                 </note>
804                         </xsl:for-each>
805
806                         <xsl:for-each select="marc:datafield[@tag=501 or @tag=502 or @tag=504 or @tag=506 or @tag=507 or @tag=508 or @tag=510 or @tag=513 or @tag=514 or @tag=515 or @tag=516 or @tag=522 or @tag=524 or @tag=525 or @tag=526 or @tag=530 or @tag=533 or @tag=534 or @tag=535 or @tag=536 or @tag=538 or @tag=540 or @tag=541 or @tag=544 or @tag=545 or @tag=546 or @tag=547 or @tag=550 or @tag=552 or @tag=555 or @tag=556 or @tag=561 or @tag=562 or @tag=565 or @tag=567 or @tag=580 or @tag=581 or @tag=583 or @tag=584 or @tag=585 or @tag=586]">
807                                 <note>
808                                         <xsl:call-template name="uri"/>
809                                         <xsl:variable name="str">
810                                                 <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
811                                                         <xsl:value-of select="."/><xsl:text> </xsl:text>
812                                                 </xsl:for-each>
813                                         </xsl:variable>
814                                         <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
815                                 </note>
816                         </xsl:for-each>
817
818                         <xsl:for-each select="marc:datafield[@tag=034][marc:subfield[@code='d' or @code='e' or @code='f' or @code='g']]">
819                                 <cartographics>
820                                         <coordinates>
821                                                 <xsl:call-template name="subfieldSelect">
822                                                         <xsl:with-param name="codes">defg</xsl:with-param>
823                                                 </xsl:call-template>
824                                         </coordinates>
825                                 </cartographics>
826                         </xsl:for-each>
827
828                         <xsl:for-each select="marc:datafield[@tag=255]">
829                                 <cartographics>
830                                         <xsl:for-each select="marc:subfield[@code='c']">
831                                                 <coordinates>
832                                                         <xsl:value-of select="."/>
833                                                 </coordinates>
834                                         </xsl:for-each>
835                                         <xsl:for-each select="marc:subfield[@code='a']">
836                                                 <scale>
837                                                         <xsl:value-of select="."/>
838                                                 </scale>
839                                         </xsl:for-each>
840                                         <xsl:for-each select="marc:subfield[@code='b']">
841                                                 <projection>
842                                                         <xsl:value-of select="."/>
843                                                 </projection>   
844                                         </xsl:for-each>
845                                 </cartographics>
846                         </xsl:for-each>
847
848                         <xsl:apply-templates select="marc:datafield[653 >= @tag and @tag >= 600]"/>
849
850                         <xsl:for-each select="marc:datafield[@tag=752]">
851                                 <subject>
852                                         <hierarchicalGeographic>
853                                                 <xsl:for-each select="marc:subfield[@code='a']">
854                                                         <country>
855                                                                 <xsl:value-of select="."/>
856                                                         </country>
857                                                 </xsl:for-each>         
858                                                 <xsl:for-each select="marc:subfield[@code='b']">
859                                                         <state>
860                                                                 <xsl:value-of select="."/>
861                                                         </state>
862                                                 </xsl:for-each>         
863                                                 <xsl:for-each select="marc:subfield[@code='c']">
864                                                         <county>
865                                                                 <xsl:value-of select="."/>
866                                                         </county>
867                                                 </xsl:for-each>         
868                                                 <xsl:for-each select="marc:subfield[@code='d']">
869                                                         <city>
870                                                                 <xsl:value-of select="."/>
871                                                         </city>
872                                                 </xsl:for-each>         
873                                         </hierarchicalGeographic>
874                                 </subject>
875                         </xsl:for-each>
876
877                         <xsl:for-each select="marc:datafield[@tag=050]">
878                                 <xsl:for-each select="marc:subfield[@code='b']">
879                                         <classification authority="lcc">
880                                                 <xsl:value-of select="preceding-sibling::marc:subfield[@code='a'][1]"/>
881                                                 <xsl:text> </xsl:text>
882                                                 <xsl:value-of select="text()"/>
883                                         </classification>
884                                 </xsl:for-each>
885                                 <xsl:for-each select="marc:subfield[@code='a'][not(following-sibling::marc:subfield[@code='b'])]">
886                                         <classification authority="lcc">
887                                                 <xsl:value-of select="text()"/>
888                                         </classification>
889                                 </xsl:for-each>
890                         </xsl:for-each>
891
892                         <xsl:for-each select="marc:datafield[@tag=082]">
893                                 <classification authority="ddc">
894                                         <xsl:if test="marc:subfield[@code='2']">
895                                                 <xsl:attribute name="edition">
896                                                         <xsl:value-of select="marc:subfield[@code='2']"/>
897                                                 </xsl:attribute>
898                                         </xsl:if>
899                                         <xsl:call-template name="subfieldSelect">
900                                                 <xsl:with-param name="codes">ab</xsl:with-param>
901                                         </xsl:call-template>
902                                 </classification>
903                         </xsl:for-each>
904
905                         <xsl:for-each select="marc:datafield[@tag=080]">
906                                 <classification authority="udc">
907                                         <xsl:call-template name="subfieldSelect">
908                                                 <xsl:with-param name="codes">abx</xsl:with-param>
909                                         </xsl:call-template>
910                                 </classification>
911                         </xsl:for-each>
912
913                         <xsl:for-each select="marc:datafield[@tag=060]">
914                                 <classification authority="nlm">
915                                         <xsl:call-template name="subfieldSelect">
916                                                 <xsl:with-param name="codes">ab</xsl:with-param>
917                                         </xsl:call-template>
918                                 </classification>
919                         </xsl:for-each>
920
921                         <xsl:for-each select="marc:datafield[@tag=086][@ind1=0]">
922                                 <classification authority="sudocs">
923                                         <xsl:value-of select="marc:subfield[@code='a']"/>
924                                 </classification>
925                         </xsl:for-each>
926
927                         <xsl:for-each select="marc:datafield[@tag=086][@ind1=1]">
928                                 <classification authority="candoc">
929                                         <xsl:value-of select="marc:subfield[@code='a']"/>
930                                 </classification>
931                         </xsl:for-each>
932
933                         <xsl:for-each select="marc:datafield[@tag=086]">
934                                 <classification>
935                                         <xsl:attribute name="authority">
936                                                 <xsl:value-of select="marc:subfield[@code='2']"/>
937                                         </xsl:attribute>                                                
938                                         <xsl:value-of select="marc:subfield[@code='a']"/>
939                                 </classification>
940                         </xsl:for-each>
941
942                         <xsl:for-each select="marc:datafield[@tag=084]">
943                                 <classification>
944                                         <xsl:attribute name="authority">
945                                                 <xsl:value-of select="marc:subfield[@code='2']"/>
946                                         </xsl:attribute>
947                                         <xsl:call-template name="subfieldSelect">
948                                                 <xsl:with-param name="codes">ab</xsl:with-param>
949                                         </xsl:call-template>
950                                 </classification>
951                         </xsl:for-each>
952
953                         <xsl:for-each select="marc:datafield[@tag=440]">
954                                 <relatedItem type="series">
955                                         <titleInfo>
956                                                 <title>
957                                                         <xsl:call-template name="subfieldSelect">
958                                                                 <xsl:with-param name="codes">av</xsl:with-param>
959                                                         </xsl:call-template>
960                                                         <xsl:call-template name="part"/>
961                                                 </title>
962                                         </titleInfo>
963                                 </relatedItem>  
964                         </xsl:for-each>
965
966                         <xsl:for-each select="marc:datafield[@tag=490][@ind1=0]">
967                                 <relatedItem type="series">
968                                         <titleInfo>
969                                                 <title>
970                                                         <xsl:call-template name="subfieldSelect">
971                                                                 <xsl:with-param name="codes">av</xsl:with-param>
972                                                         </xsl:call-template>
973                                                         <xsl:call-template name="part"/>
974                                                 </title>
975                                         </titleInfo>
976                                 </relatedItem>  
977                         </xsl:for-each>
978
979                         <xsl:for-each select="marc:datafield[@tag=534]">
980                                 <relatedItem type="original">
981                                         <xsl:call-template name="relatedTitle"/>
982                                         <xsl:call-template name="relatedName"/>
983                                         <xsl:call-template name="relatedIdentifierISSN"/>
984                                         <xsl:for-each select="marc:subfield[@code='z']">
985                                                 <identifier type="isbn">
986                                                         <xsl:value-of select="."/>
987                                                 </identifier>
988                                         </xsl:for-each>
989                                         <xsl:call-template name="relatedNote"/>
990                                 </relatedItem>  
991                         </xsl:for-each>
992
993                         <xsl:for-each select="marc:datafield[@tag=700][marc:subfield[@code='t']]">
994                                 <relatedItem>
995                                         <xsl:call-template name="constituentOrRelatedType"/>
996                                         <titleInfo>
997                                                 <title>
998                                                         <xsl:call-template name="specialSubfieldSelect">
999                                                                 <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
1000                                                                 <xsl:with-param name="axis">t</xsl:with-param>
1001                                                                 <xsl:with-param name="afterCodes">g</xsl:with-param>
1002                                                         </xsl:call-template>
1003                                                 </title>
1004                                                 <xsl:call-template name="part"/>
1005                                         </titleInfo>
1006                                         <name type="personal">
1007                                                 <namePart>
1008                                                         <xsl:call-template name="specialSubfieldSelect">
1009                                                                 <xsl:with-param name="anyCodes">abcq</xsl:with-param>
1010                                                                 <xsl:with-param name="axis">t</xsl:with-param>
1011                                                                 <xsl:with-param name="beforeCodes">g</xsl:with-param>
1012                                                         </xsl:call-template>                                                    
1013                                                 </namePart>
1014                                                 <xsl:call-template name="nameDate"/>
1015                                                 <xsl:for-each select="marc:subfield[@code='e']">
1016                                                         <role>
1017                                                                 <xsl:value-of select="."/>
1018                                                         </role>
1019                                                 </xsl:for-each>
1020                                         </name>
1021                                         <xsl:call-template name="relatedForm"/>
1022                                         <xsl:call-template name="relatedIdentifierISSN"/>
1023                                 </relatedItem>
1024                         </xsl:for-each>
1025
1026                         <xsl:for-each select="marc:datafield[@tag=710][marc:subfield[@code='t']]">
1027                                 <relatedItem>
1028                                         <xsl:call-template name="constituentOrRelatedType"/>
1029                                         <titleInfo>
1030                                                 <title>
1031                                                         <xsl:call-template name="specialSubfieldSelect">
1032                                                                 <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
1033                                                                 <xsl:with-param name="axis">t</xsl:with-param>
1034                                                                 <xsl:with-param name="afterCodes">dg</xsl:with-param>
1035                                                         </xsl:call-template>
1036                                                 </title>
1037                                                 <xsl:call-template name="relatedPart"/>
1038                                         </titleInfo>
1039                                         <name type="corporate">
1040                                                 <xsl:for-each select="marc:subfield[@code='a']">
1041                                                         <namePart>
1042                                                                 <xsl:value-of select="."/>
1043                                                         </namePart>
1044                                                 </xsl:for-each>
1045                                                 <xsl:for-each select="marc:subfield[@code='b']">
1046                                                         <namePart>
1047                                                                 <xsl:value-of select="."/>
1048                                                         </namePart>
1049                                                 </xsl:for-each>
1050                                                 <xsl:variable name="tempNamePart">
1051                                                         <xsl:call-template name="specialSubfieldSelect">
1052                                                                 <xsl:with-param name="anyCodes">c</xsl:with-param>
1053                                                                 <xsl:with-param name="axis">t</xsl:with-param>
1054                                                                 <xsl:with-param name="beforeCodes">dgn</xsl:with-param>
1055                                                         </xsl:call-template>                                                    
1056                                                 </xsl:variable>
1057                                                 <xsl:if test="normalize-space($tempNamePart)">
1058                                                         <namePart>
1059                                                                 <xsl:value-of select="$tempNamePart"/>
1060                                                         </namePart>
1061                                                 </xsl:if>
1062                                                 <xsl:for-each select="marc:subfield[@code='e']">
1063                                                         <role>
1064                                                                 <xsl:value-of select="."/>
1065                                                         </role>
1066                                                 </xsl:for-each>
1067                                         </name>
1068                                         <xsl:call-template name="relatedForm"/>
1069                                         <xsl:call-template name="relatedIdentifierISSN"/>
1070                                 </relatedItem>
1071                         </xsl:for-each>
1072
1073                         <xsl:for-each select="marc:datafield[@tag=711][marc:subfield[@code='t']]">
1074                                 <relatedItem>
1075                                         <xsl:call-template name="constituentOrRelatedType"/>
1076                                         <titleInfo>
1077                                                 <title>
1078                                                         <xsl:call-template name="specialSubfieldSelect">
1079                                                                 <xsl:with-param name="anyCodes">tfklsv</xsl:with-param>
1080                                                                 <xsl:with-param name="axis">t</xsl:with-param>
1081                                                                 <xsl:with-param name="afterCodes">g</xsl:with-param>
1082                                                         </xsl:call-template>
1083                                                 </title>
1084                                                 <xsl:call-template name="relatedPart"/>
1085                                         </titleInfo>
1086                                         <name type="conference">
1087                                                 <namePart>
1088                                                         <xsl:call-template name="specialSubfieldSelect">
1089                                                                 <xsl:with-param name="anyCodes">aqdc</xsl:with-param>
1090                                                                 <xsl:with-param name="axis">t</xsl:with-param>
1091                                                                 <xsl:with-param name="beforeCodes">gn</xsl:with-param>
1092                                                         </xsl:call-template>                                                    
1093                                                 </namePart>
1094                                         </name>
1095                                         <xsl:call-template name="relatedForm"/>
1096                                         <xsl:call-template name="relatedIdentifierISSN"/>
1097                                 </relatedItem>
1098                         </xsl:for-each>
1099
1100                         <xsl:for-each select="marc:datafield[@tag=730][@ind2=2]">
1101                                 <relatedItem>
1102                                         <xsl:call-template name="constituentOrRelatedType"/>
1103                                         <titleInfo>
1104                                                 <title>
1105                                                         <xsl:call-template name="subfieldSelect">
1106                                                                 <xsl:with-param name="codes">adfgklmorsv</xsl:with-param>
1107                                                         </xsl:call-template>
1108                                                 </title>
1109                                                 <xsl:call-template name="part"/>
1110                                         </titleInfo>
1111                                         <xsl:call-template name="relatedForm"/>
1112                                         <xsl:call-template name="relatedIdentifierISSN"/>
1113                                 </relatedItem>
1114                         </xsl:for-each>
1115
1116                         <xsl:for-each select="marc:datafield[@tag=740][@ind2=2]">
1117                                 <relatedItem>
1118                                         <xsl:call-template name="constituentOrRelatedType"/>
1119                                         <titleInfo>
1120                                                 <title>                                 
1121                                                         <xsl:value-of select="marc:subfield[@code='a']"/>
1122                                                 </title>
1123                                                 <xsl:call-template name="part"/>
1124                                         </titleInfo>
1125                                         <xsl:call-template name="relatedForm"/>
1126                                 </relatedItem>
1127                         </xsl:for-each>
1128
1129                         <xsl:for-each select="marc:datafield[@tag=760]|marc:datafield[@tag=762]">
1130                                 <relatedItem type="series">
1131                                         <xsl:call-template name="relatedItem76X-78X"/>
1132                                 </relatedItem>  
1133                         </xsl:for-each>
1134
1135                         <xsl:for-each select="marc:datafield[@tag=765]|marc:datafield[@tag=767]|marc:datafield[@tag=775]|marc:datafield[@tag=777]|marc:datafield[@tag=787]">
1136                                 <relatedItem type="related">
1137                                         <xsl:call-template name="relatedItem76X-78X"/>
1138                                 </relatedItem>  
1139                         </xsl:for-each>
1140
1141                         <xsl:for-each select="marc:datafield[@tag=770]|marc:datafield[@tag=774]">
1142                                 <relatedItem type="constituent">
1143                                         <xsl:call-template name="relatedItem76X-78X"/>
1144                                 </relatedItem>  
1145                         </xsl:for-each>
1146
1147                         <xsl:for-each select="marc:datafield[@tag=772]|marc:datafield[@tag=773]">
1148                                 <relatedItem type="host">
1149                                         <xsl:call-template name="relatedItem76X-78X"/>
1150                                 </relatedItem>  
1151                         </xsl:for-each>
1152
1153                         <xsl:for-each select="marc:datafield[@tag=776]">
1154                                 <relatedItem type="reproduction">
1155                                         <xsl:call-template name="relatedItem76X-78X"/>
1156                                 </relatedItem>  
1157                         </xsl:for-each>
1158
1159                         <xsl:for-each select="marc:datafield[@tag=780]">
1160                                 <relatedItem type="preceding">
1161                                         <xsl:call-template name="relatedItem76X-78X"/>
1162                                 </relatedItem>  
1163                         </xsl:for-each>
1164
1165                         <xsl:for-each select="marc:datafield[@tag=785]">
1166                                 <relatedItem type="succeeding">
1167                                         <xsl:call-template name="relatedItem76X-78X"/>
1168                                 </relatedItem>  
1169                         </xsl:for-each>
1170
1171                         <xsl:for-each select="marc:datafield[@tag=786]">
1172                                 <relatedItem type="original">
1173                                         <xsl:call-template name="relatedItem76X-78X"/>
1174                                 </relatedItem>  
1175                         </xsl:for-each>
1176
1177                         <xsl:for-each select="marc:datafield[@tag=800]">
1178                                 <relatedItem type="series">
1179                                         <titleInfo>
1180                                                 <title>
1181                                                         <xsl:call-template name="specialSubfieldSelect">
1182                                                                 <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
1183                                                                 <xsl:with-param name="axis">t</xsl:with-param>
1184                                                                 <xsl:with-param name="afterCodes">g</xsl:with-param>
1185                                                         </xsl:call-template>
1186                                                 </title>
1187                                                 <xsl:call-template name="part"/>
1188                                         </titleInfo>
1189                                         <name type="personal">
1190                                                 <namePart>
1191                                                         <xsl:call-template name="chopPunctuation">
1192                                                                 <xsl:with-param name="chopString">
1193                                                                         <xsl:call-template name="specialSubfieldSelect">
1194                                                                                 <xsl:with-param name="anyCodes">abcq</xsl:with-param>
1195                                                                                 <xsl:with-param name="axis">t</xsl:with-param>
1196                                                                                 <xsl:with-param name="beforeCodes">g</xsl:with-param>
1197                                                                         </xsl:call-template>
1198                                                                 </xsl:with-param>
1199                                                         </xsl:call-template>
1200                                                 </namePart>
1201                                                 <xsl:call-template name="nameDate"/>
1202                                                 <xsl:for-each select="marc:subfield[@code='e']">
1203                                                         <role>
1204                                                                 <xsl:value-of select="."/>
1205                                                         </role>
1206                                                 </xsl:for-each>
1207                                         </name>
1208                                         <xsl:call-template name="relatedForm"/>
1209                                 </relatedItem>
1210                         </xsl:for-each>
1211
1212                         <xsl:for-each select="marc:datafield[@tag=810]">
1213                                 <relatedItem type="series">
1214                                         <titleInfo>
1215                                                 <title>
1216                                                         <xsl:call-template name="specialSubfieldSelect">
1217                                                                 <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
1218                                                                 <xsl:with-param name="axis">t</xsl:with-param>
1219                                                                 <xsl:with-param name="afterCodes">dg</xsl:with-param>
1220                                                         </xsl:call-template>
1221                                                 </title>
1222                                                 <xsl:call-template name="relatedPart"/>
1223                                         </titleInfo>
1224                                         <name type="corporate">
1225                                                 <xsl:for-each select="marc:subfield[@code='a']">
1226                                                         <namePart>
1227                                                                 <xsl:value-of select="."/>
1228                                                         </namePart>
1229                                                 </xsl:for-each>
1230                                                 <xsl:for-each select="marc:subfield[@code='b']">
1231                                                         <namePart>
1232                                                                 <xsl:value-of select="."/>
1233                                                         </namePart>
1234                                                 </xsl:for-each>
1235                                                 <namePart>
1236                                                         <xsl:call-template name="specialSubfieldSelect">
1237                                                                 <xsl:with-param name="anyCodes">c</xsl:with-param>
1238                                                                 <xsl:with-param name="axis">t</xsl:with-param>
1239                                                                 <xsl:with-param name="beforeCodes">dgn</xsl:with-param>
1240                                                         </xsl:call-template>                                                    
1241                                                 </namePart>
1242                                                 <xsl:for-each select="marc:subfield[@code='e']">
1243                                                         <role>
1244                                                                 <xsl:value-of select="."/>
1245                                                         </role>
1246                                                 </xsl:for-each>
1247                                         </name>
1248                                         <xsl:call-template name="relatedForm"/>
1249                                 </relatedItem>  
1250                         </xsl:for-each>
1251
1252                         <xsl:for-each select="marc:datafield[@tag=811]">
1253                                 <relatedItem type="series">
1254                                         <titleInfo>
1255                                                 <title>
1256                                                         <xsl:call-template name="specialSubfieldSelect">
1257                                                                 <xsl:with-param name="anyCodes">tfklsv</xsl:with-param>
1258                                                                 <xsl:with-param name="axis">t</xsl:with-param>
1259                                                                 <xsl:with-param name="afterCodes">g</xsl:with-param>
1260                                                         </xsl:call-template>
1261                                                 </title>
1262                                                 <xsl:call-template name="relatedPart"/>
1263                                         </titleInfo>
1264                                         <name type="conference">
1265                                                 <namePart>
1266                                                         <xsl:call-template name="specialSubfieldSelect">
1267                                                                 <xsl:with-param name="anyCodes">aqdc</xsl:with-param>
1268                                                                 <xsl:with-param name="axis">t</xsl:with-param>
1269                                                                 <xsl:with-param name="beforeCodes">gn</xsl:with-param>
1270                                                         </xsl:call-template>                                                    
1271                                                 </namePart>
1272                                         </name>
1273                                         <xsl:call-template name="relatedForm"/>
1274                                 </relatedItem>  
1275                         </xsl:for-each>
1276
1277                         <xsl:for-each select="marc:datafield[@tag=830]">
1278                                 <relatedItem type="series">
1279                                         <titleInfo>
1280                                                 <title>
1281                                                         <xsl:call-template name="subfieldSelect">
1282                                                                 <xsl:with-param name="codes">adfgklmorsv</xsl:with-param>
1283                                                         </xsl:call-template>
1284                                                 </title>
1285                                                 <xsl:call-template name="part"/>
1286                                         </titleInfo>
1287                                         <xsl:call-template name="relatedForm"/>
1288                                 </relatedItem>  
1289                         </xsl:for-each>
1290
1291                         <xsl:for-each select="marc:datafield[@tag=856][@ind2=2]/marc:subfield[@code='q']">
1292                                 <relatedItem>
1293                                         <internetMediaType>
1294                                                 <xsl:value-of select="."/>
1295                                         </internetMediaType>
1296                                 </relatedItem>  
1297                         </xsl:for-each>
1298
1299                         <xsl:for-each select="marc:datafield[@tag=020]/marc:subfield[@code='a']">
1300                                 <identifier type="isbn">
1301                                         <xsl:value-of select="."/>
1302                                 </identifier>
1303                         </xsl:for-each>
1304
1305                         <xsl:for-each select="marc:datafield[@tag=024][@ind1=0]/marc:subfield[@code='a']">
1306                                 <identifier type="isrc">
1307                                         <xsl:value-of select="."/>
1308                                 </identifier>
1309                         </xsl:for-each>
1310
1311                         <xsl:for-each select="marc:datafield[@tag=024][@ind1=2]/marc:subfield[@code='a']">
1312                                 <identifier type="ismn">
1313                                         <xsl:value-of select="."/>
1314                                 </identifier>
1315                         </xsl:for-each>
1316
1317                         <xsl:for-each select="marc:datafield[@tag=022]/marc:subfield[@code='a']">
1318                                 <identifier type="issn">
1319                                         <xsl:value-of select="."/>
1320                                 </identifier>
1321                         </xsl:for-each>
1322
1323                         <xsl:for-each select="marc:datafield[@tag=010]/marc:subfield[@code='a']">
1324                                 <identifier type="lccn">
1325                                         <xsl:value-of select="normalize-space(text())"/>
1326                                 </identifier>
1327                         </xsl:for-each>
1328
1329                         <xsl:for-each select="marc:datafield[@tag=028]">
1330                                 <identifier>
1331                                         <xsl:attribute name="type">
1332                                                 <xsl:choose>
1333                                                         <xsl:when test="@ind1=0">issue number</xsl:when>
1334                                                         <xsl:when test="@ind1=1">matrix number</xsl:when>
1335                                                         <xsl:when test="@ind1=2">music plate</xsl:when>
1336                                                         <xsl:when test="@ind1=3">music publisher</xsl:when>
1337                                                         <xsl:when test="@ind1=4">videorecording identifier</xsl:when>
1338                                                 </xsl:choose>
1339                                         </xsl:attribute>
1340                                         <xsl:call-template name="subfieldSelect">
1341                                                 <xsl:with-param name="codes">ab</xsl:with-param>
1342                                         </xsl:call-template>
1343                                 </identifier>
1344                         </xsl:for-each>
1345                 
1346                         <xsl:for-each select="marc:datafield[@tag=024][@ind1=4]">
1347                                 <identifier type="sici">
1348                                         <xsl:call-template name="subfieldSelect">
1349                                                 <xsl:with-param name="codes">ab</xsl:with-param>
1350                                         </xsl:call-template>
1351                                 </identifier>
1352                         </xsl:for-each>
1353
1354                         <xsl:for-each select="marc:datafield[@tag=856]/marc:subfield[@code='u']">
1355                                 <identifier>
1356                                         <xsl:attribute name="type">
1357                                                 <xsl:choose>
1358                                                         <xsl:when test="starts-with(.,'urn:doi') or starts-with(.,'doi:')">doi</xsl:when>
1359                                                         <xsl:otherwise>uri</xsl:otherwise>
1360                                                 </xsl:choose>
1361                                         </xsl:attribute>
1362                                         <xsl:value-of select="."/>
1363                                 </identifier>
1364                         </xsl:for-each>
1365
1366                         <xsl:for-each select="marc:datafield[@tag=024][@ind1=1]/marc:subfield[@code='a']">
1367                                 <identifier type="upc">
1368                                         <xsl:value-of select="."/>
1369                                 </identifier>
1370                         </xsl:for-each>
1371
1372                         <xsl:for-each select="marc:datafield[@tag=852]">
1373                                 <location>
1374                                         <xsl:call-template name="subfieldSelect">
1375                                                 <xsl:with-param name="codes">abj</xsl:with-param>
1376                                         </xsl:call-template>
1377                                 </location>
1378                         </xsl:for-each>
1379
1380                         <xsl:for-each select="marc:datafield[@tag=506]">
1381                                 <accessCondition type="restrictionOnAccess">
1382                                         <xsl:call-template name="subfieldSelect">
1383                                                 <xsl:with-param name="codes">abcd35</xsl:with-param>
1384                                         </xsl:call-template>
1385                                 </accessCondition>
1386                         </xsl:for-each>
1387
1388                         <xsl:for-each select="marc:datafield[@tag=540]">
1389                                 <accessCondition type="useAndReproduction">
1390                                         <xsl:call-template name="subfieldSelect">
1391                                                 <xsl:with-param name="codes">abcde35</xsl:with-param>
1392                                         </xsl:call-template>
1393                                 </accessCondition>
1394                         </xsl:for-each>
1395
1396                         <recordInfo>
1397                                 <xsl:for-each select="marc:datafield[@tag=040]">
1398                                         <recordContentSource>
1399                                                 <xsl:value-of select="marc:subfield[@code='a']"/>
1400                                         </recordContentSource>
1401                                 </xsl:for-each>
1402
1403                                 <xsl:for-each select="marc:controlfield[@tag=008]">
1404                                         <recordCreationDate encoding="marc">
1405                                                 <xsl:value-of select="substring(.,1,6)"/>
1406                                         </recordCreationDate>
1407                                 </xsl:for-each>         
1408                         
1409                                 <xsl:for-each select="marc:controlfield[@tag=005]">
1410                                         <recordChangeDate encoding="iso8601">
1411                                                 <xsl:value-of select="."/>
1412                                         </recordChangeDate>
1413                                 </xsl:for-each>
1414
1415                                 <xsl:for-each select="marc:controlfield[@tag=001]">
1416                                         <recordIdentifier>
1417                                                 <xsl:if test="../marc:controlfield[@tag=003]">
1418                                                         <xsl:attribute name="source">
1419                                                                 <xsl:value-of select="../marc:controlfield[@tag=003]"/>
1420                                                         </xsl:attribute>
1421                                                 </xsl:if>
1422                                                 <xsl:value-of select="."/>
1423                                         </recordIdentifier>
1424                                 </xsl:for-each>
1425                         </recordInfo>
1426                 </mods>
1427         </xsl:template>
1428
1429         <xsl:template name="displayForm">
1430                 <xsl:for-each select="marc:subfield[@code='c']">
1431                         <displayForm>
1432                                 <xsl:value-of select="."/>
1433                         </displayForm>
1434                 </xsl:for-each>
1435         </xsl:template>
1436
1437         <xsl:template name="affiliation">
1438                 <xsl:for-each select="marc:subfield[@code='u']">
1439                         <affiliation>
1440                                 <xsl:value-of select="."/>
1441                         </affiliation>
1442                 </xsl:for-each>
1443         </xsl:template>
1444
1445         <xsl:template name="uri">
1446                 <xsl:for-each select="marc:subfield[@code='u']">
1447                         <xsl:attribute name="xlink:href">
1448                                 <xsl:value-of select="."/>
1449                         </xsl:attribute>
1450                 </xsl:for-each>
1451         </xsl:template>
1452
1453         <xsl:template name="role">
1454                 <xsl:choose>
1455                         <xsl:when test="marc:subfield[@code='e']">
1456                                 <role><xsl:value-of select="marc:subfield[@code='e']"/></role>
1457                         </xsl:when>
1458                         <xsl:when test="marc:subfield[@code='4']">
1459                                 <xsl:for-each select="marc:subfield[@code='4']">
1460                                         <role><xsl:value-of select="text()"/></role>
1461                                 </xsl:for-each>
1462                         </xsl:when>
1463                 </xsl:choose>
1464         </xsl:template>
1465
1466         <xsl:template name="part">
1467                 <xsl:variable name="partNumber">
1468                         <xsl:call-template name="specialSubfieldSelect">
1469                                 <xsl:with-param name="axis">n</xsl:with-param>
1470                                 <xsl:with-param name="anyCodes">n</xsl:with-param>
1471                                 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
1472                         </xsl:call-template>
1473                 </xsl:variable>
1474                 <xsl:variable name="partName">
1475                         <xsl:call-template name="specialSubfieldSelect">
1476                                 <xsl:with-param name="axis">p</xsl:with-param>
1477                                 <xsl:with-param name="anyCodes">p</xsl:with-param>
1478                                 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
1479                         </xsl:call-template>
1480                 </xsl:variable>
1481                 <xsl:if test="string-length(normalize-space($partNumber))">
1482                         <partNumber>
1483                                 <xsl:value-of select="$partNumber"/>
1484                         </partNumber>
1485                 </xsl:if>
1486                 <xsl:if test="string-length(normalize-space($partName))">
1487                         <partName>
1488                                 <xsl:value-of select="$partName"/>
1489                         </partName>
1490                 </xsl:if>
1491         </xsl:template>
1492
1493         <xsl:template name="relatedPart">
1494                 <xsl:for-each select="marc:subfield[@code='n'][preceding-sibling::marc:subfield[@code='t']]">
1495                         <partNumber>
1496                                 <xsl:value-of select="."/>
1497                         </partNumber>
1498                 </xsl:for-each>
1499                 <xsl:for-each select="marc:subfield[@code='p']">
1500                         <partName>
1501                                 <xsl:value-of select="."/>
1502                         </partName>
1503                 </xsl:for-each>
1504         </xsl:template>
1505
1506         <xsl:template name="relatedName">
1507                 <xsl:for-each select="marc:subfield[@code='a']">
1508                         <name>
1509                                 <namePart>
1510                                         <xsl:value-of select="."/>
1511                                 </namePart>
1512                         </name>
1513                 </xsl:for-each>
1514         </xsl:template>
1515
1516         <xsl:template name="relatedForm">
1517                 <xsl:for-each select="marc:subfield[@code='h']">
1518                         <physicalDescription>
1519                                 <form>
1520                                         <unControlled>
1521                                                 <xsl:value-of select="."/>
1522                                         </unControlled>
1523                                 </form>
1524                         </physicalDescription>
1525                 </xsl:for-each>
1526         </xsl:template>
1527
1528         <xsl:template name="relatedExtent">
1529                 <xsl:for-each select="marc:subfield[@code='h']">
1530                         <physicalDescription>
1531                                 <extent>
1532                                         <xsl:value-of select="."/>
1533                                 </extent>
1534                         </physicalDescription>
1535                 </xsl:for-each>
1536         </xsl:template>
1537
1538         <xsl:template name="relatedNote">
1539                 <xsl:for-each select="marc:subfield[@code='n']">
1540                         <note>
1541                                 <xsl:value-of select="."/>
1542                         </note>
1543                 </xsl:for-each>
1544         </xsl:template>
1545
1546         <xsl:template name="relatedIdentifierISSN">
1547                 <xsl:for-each select="marc:subfield[@code='x']">
1548                         <identifier type="issn">
1549                                 <xsl:value-of select="."/>
1550                         </identifier>
1551                 </xsl:for-each>
1552         </xsl:template>
1553
1554         <xsl:template name="relatedIdentifierLocal">
1555                 <xsl:for-each select="marc:subfield[@code='w']">
1556                         <identifier type="local">
1557                                 <xsl:value-of select="."/>
1558                         </identifier>
1559                 </xsl:for-each>
1560         </xsl:template>
1561
1562         <xsl:template name="relatedIdentifier">
1563                 <xsl:for-each select="marc:subfield[@code='o']">
1564                         <identifier>
1565                                 <xsl:value-of select="."/>
1566                         </identifier>
1567                 </xsl:for-each>
1568         </xsl:template>
1569
1570         <xsl:template name="relatedItem76X-78X">
1571                 <xsl:call-template name="relatedTitle76X-78X"/>
1572                 <xsl:call-template name="relatedName"/>
1573                 <xsl:call-template name="relatedExtent"/>
1574                 <xsl:call-template name="relatedIdentifier"/>
1575                 <xsl:call-template name="relatedIdentifierISSN"/>
1576                 <xsl:call-template name="relatedIdentifierLocal"/>
1577                 <xsl:call-template name="relatedNote"/>
1578         </xsl:template>
1579
1580         <xsl:template name="subjectGeographicZ">
1581                 <geographic>
1582                         <xsl:value-of select="."/>
1583                 </geographic>                   
1584         </xsl:template>
1585
1586         <xsl:template name="subjectTemporalY">
1587                 <temporal>
1588                         <xsl:value-of select="."/>
1589                 </temporal>                     
1590         </xsl:template>
1591
1592         <xsl:template name="subjectTopic">
1593                 <topic>
1594                         <xsl:call-template name="chopPunctuation">
1595                                 <xsl:with-param name="chopString" select="."/>
1596                         </xsl:call-template>
1597                 </topic>
1598         </xsl:template>
1599
1600         <xsl:template name="nameABCDN">
1601                 <xsl:for-each select="marc:subfield[@code='a']">
1602                         <namePart>
1603                                 <xsl:call-template name="chopPunctuation">
1604                                         <xsl:with-param name="chopString" select="."/>
1605                                 </xsl:call-template>
1606                         </namePart>                                     
1607                 </xsl:for-each>
1608                 <xsl:for-each select="marc:subfield[@code='b']">
1609                         <namePart>
1610                                 <xsl:value-of select="."/>
1611                         </namePart>                                     
1612                 </xsl:for-each>
1613                 <xsl:if test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">
1614                         <namePart>
1615                                 <xsl:call-template name="subfieldSelect">
1616                                         <xsl:with-param name="codes">cdn</xsl:with-param>
1617                                 </xsl:call-template>
1618                         </namePart>
1619                 </xsl:if>
1620         </xsl:template>
1621
1622         <xsl:template name="nameABCDQ">
1623                 <namePart>
1624                         <xsl:call-template name="chopPunctuation">
1625                                 <xsl:with-param name="chopString">
1626                                         <xsl:call-template name="subfieldSelect">
1627                                                 <xsl:with-param name="codes">abcq</xsl:with-param>
1628                                         </xsl:call-template>
1629                                 </xsl:with-param>
1630                         </xsl:call-template>
1631                 </namePart>
1632                 <xsl:call-template name="nameDate"/>
1633         </xsl:template>
1634
1635         <xsl:template name="nameACDEQ">
1636                 <namePart>
1637                         <xsl:call-template name="subfieldSelect">
1638                                 <xsl:with-param name="codes">acdeq</xsl:with-param>
1639                         </xsl:call-template>
1640                 </namePart>
1641         </xsl:template>
1642
1643         <xsl:template name="constituentOrRelatedType">
1644                 <xsl:attribute name="type">
1645                         <xsl:choose>
1646                                 <xsl:when test="@ind2=2">constituent</xsl:when>
1647                                 <xsl:otherwise>related</xsl:otherwise>
1648                         </xsl:choose>
1649                 </xsl:attribute>
1650         </xsl:template>
1651
1652         <xsl:template name="relatedTitle">
1653                 <xsl:for-each select="marc:subfield[@code='t']">
1654                         <titleInfo>
1655                                 <title>
1656                                         <xsl:value-of select="."/>
1657                                 </title>
1658                         </titleInfo>
1659                 </xsl:for-each>
1660         </xsl:template>
1661
1662         <xsl:template name="relatedTitle76X-78X">
1663                 <titleInfo>
1664                         <xsl:for-each select="marc:subfield[@code='t']">
1665                                 <title>
1666                                         <xsl:value-of select="."/>
1667                                 </title>
1668                         </xsl:for-each>
1669                         <xsl:for-each select="marc:subfield[@code='g']">
1670                                 <partNumber>
1671                                         <xsl:value-of select="."/>
1672                                 </partNumber>
1673                         </xsl:for-each>
1674                 </titleInfo>
1675         </xsl:template>
1676
1677         <xsl:template name="nameDate">
1678                 <xsl:for-each select="marc:subfield[@code='d']">
1679                         <namePart type="date">
1680                                 <xsl:call-template name="chopPunctuation">
1681                                         <xsl:with-param name="chopString" select="."/>
1682                                 </xsl:call-template>
1683                         </namePart>
1684                 </xsl:for-each>
1685         </xsl:template>
1686
1687         <xsl:template name="subjectAuthority">
1688                 <xsl:attribute name="authority">
1689                         <xsl:choose>
1690                         <xsl:when test="@ind2=0">lcsh</xsl:when>
1691                         <xsl:when test="@ind2=1">lcshac</xsl:when>
1692                         <xsl:when test="@ind2=2">mesh</xsl:when>
1693                         <xsl:when test="@ind2=3">csh</xsl:when>
1694                         <xsl:when test="@ind2=5">nal</xsl:when>
1695                         <xsl:when test="@ind2=6">rvm</xsl:when>
1696                         <xsl:when test="@ind2=7"><xsl:value-of select="marc:subfield[@code='2']"/></xsl:when>
1697                         </xsl:choose>
1698                 </xsl:attribute>
1699         </xsl:template>
1700
1701         <xsl:template name="subjectAnyOrder">
1702                 <xsl:for-each select="marc:subfield[@code='v' or @code='x' or @code='y' or @code='z']">
1703                         <xsl:choose>
1704                                 <xsl:when test="@code='v'">
1705                                         <xsl:call-template name="subjectTopic"/>
1706                                 </xsl:when>
1707                                 <xsl:when test="@code='x'">
1708                                         <xsl:call-template name="subjectTopic"/>
1709                                 </xsl:when>
1710                                 <xsl:when test="@code='y'">
1711                                         <xsl:call-template name="subjectTemporalY"/>
1712                                 </xsl:when>
1713                                 <xsl:when test="@code='z'">
1714                                         <xsl:call-template name="subjectGeographicZ"/>
1715                                 </xsl:when>
1716                         </xsl:choose>
1717                 </xsl:for-each>
1718         </xsl:template>
1719
1720 <!--    <xsl:template name="subfieldSelect">
1721                 <xsl:param name="codes"/>
1722                 <xsl:param name="delimeter"><xsl:text> </xsl:text></xsl:param>
1723                 <xsl:variable name="str">
1724                         <xsl:for-each select="marc:subfield">
1725                                 <xsl:if test="contains($codes, @code)">
1726                                         <xsl:value-of select="text()"/><xsl:value-of select="$delimeter"/>
1727                                 </xsl:if>
1728                         </xsl:for-each>
1729                 </xsl:variable>
1730                 <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
1731         </xsl:template>
1732 -->
1733
1734         <xsl:template name="specialSubfieldSelect">
1735                 <xsl:param name="anyCodes"/>
1736                 <xsl:param name="axis"/>
1737                 <xsl:param name="beforeCodes"/>
1738                 <xsl:param name="afterCodes"/>
1739                 <xsl:variable name="str">
1740                         <xsl:for-each select="marc:subfield">
1741                                 <xsl:if test="contains($anyCodes, @code) or (contains($beforeCodes,@code) and following-sibling::marc:subfield[@code=$axis]) or (contains($afterCodes,@code) and preceding-sibling::marc:subfield[@code=$axis])">
1742                                         <xsl:value-of select="text()"/><xsl:text> </xsl:text>
1743                                 </xsl:if>
1744                         </xsl:for-each>
1745                 </xsl:variable>
1746                 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
1747         </xsl:template>
1748
1749         <xsl:template match="marc:datafield[@tag=600]">
1750                 <subject>
1751                         <xsl:call-template name="subjectAuthority"/>
1752                         <name type="personal">
1753                                 <namePart>
1754                                         <xsl:call-template name="chopPunctuation">
1755                                                 <xsl:with-param name="chopString">
1756                                                         <xsl:call-template name="subfieldSelect">
1757                                                                 <xsl:with-param name="codes">abcq</xsl:with-param>
1758                                                         </xsl:call-template>
1759                                                 </xsl:with-param>
1760                                         </xsl:call-template>
1761                                 </namePart>
1762                                 <xsl:call-template name="nameDate"/>
1763                                 <xsl:call-template name="affiliation"/>
1764                                 <xsl:call-template name="role"/>
1765                         </name>
1766                         <xsl:call-template name="subjectAnyOrder"/>
1767                 </subject>
1768         </xsl:template>
1769
1770         <xsl:template match="marc:datafield[@tag=610]">
1771                 <subject>
1772                         <xsl:call-template name="subjectAuthority"/>
1773                         <name type="corporate">
1774                                 <xsl:for-each select="marc:subfield[@code='a']">
1775                                         <namePart>
1776                                                 <xsl:value-of select="."/>
1777                                         </namePart>
1778                                 </xsl:for-each>
1779                                 <xsl:for-each select="marc:subfield[@code='b']">
1780                                         <namePart>
1781                                                 <xsl:value-of select="."/>
1782                                         </namePart>
1783                                 </xsl:for-each>
1784                                 <xsl:if test="marc:subfield[@code='c' or @code='d' or @code='n' or @code='p']">
1785                                         <namePart>
1786                                                 <xsl:call-template name="subfieldSelect">
1787                                                         <xsl:with-param name="codes">cdnp</xsl:with-param>
1788                                                 </xsl:call-template>
1789                                         </namePart>
1790                                 </xsl:if>
1791                                 <xsl:call-template name="role"/>
1792                         </name>
1793                         <xsl:call-template name="subjectAnyOrder"/>
1794                 </subject>
1795         </xsl:template>
1796
1797         <xsl:template match="marc:datafield[@tag=611]">
1798                 <subject>
1799                         <xsl:call-template name="subjectAuthority"/>
1800                         <name type="conference">
1801                                 <namePart>
1802                                         <xsl:call-template name="subfieldSelect">
1803                                                 <xsl:with-param name="codes">abcdeqnp</xsl:with-param>
1804                                         </xsl:call-template>
1805                                 </namePart>
1806                                 <xsl:for-each select="marc:subfield[@code='4']">
1807                                         <role>
1808                                                 <xsl:value-of select="."/>
1809                                         </role>
1810                                 </xsl:for-each>
1811                         </name>
1812                         <xsl:call-template name="subjectAnyOrder"/>
1813                 </subject>
1814         </xsl:template>
1815
1816         <xsl:template match="marc:datafield[@tag=630]">
1817                 <subject>
1818                         <xsl:call-template name="subjectAuthority"/>
1819                         <titleInfo>
1820                                 <title>
1821                                         <xsl:call-template name="subfieldSelect">
1822                                                 <xsl:with-param name="codes">adfhklor</xsl:with-param>
1823                                         </xsl:call-template>
1824                                         <xsl:call-template name="part"/>                        
1825                                 </title>
1826                         </titleInfo>
1827                         <xsl:call-template name="subjectAnyOrder"/>
1828                 </subject>
1829         </xsl:template>
1830
1831         <xsl:template match="marc:datafield[@tag=650]">
1832                 <subject>
1833                         <xsl:call-template name="subjectAuthority"/>
1834                         <topic>
1835                                 <xsl:call-template name="chopPunctuation">
1836                                         <xsl:with-param name="chopString">
1837                                                 <xsl:call-template name="subfieldSelect">
1838                                                         <xsl:with-param name="codes">abcd</xsl:with-param>
1839                                                 </xsl:call-template>
1840                                         </xsl:with-param>
1841                                 </xsl:call-template>
1842                         </topic>
1843                         <xsl:call-template name="subjectAnyOrder"/>
1844                 </subject>
1845         </xsl:template>
1846
1847
1848         <xsl:template match="marc:datafield[@tag=651]">
1849                 <subject>
1850                         <xsl:call-template name="subjectAuthority"/>
1851                         <xsl:for-each select="marc:subfield[@code='a']">
1852                                 <geographic>
1853                                         <xsl:value-of select="."/>
1854                                 </geographic>                   
1855                         </xsl:for-each>
1856                         <xsl:call-template name="subjectAnyOrder"/>
1857                 </subject>
1858         </xsl:template>
1859
1860         <xsl:template match="marc:datafield[@tag=653]">
1861                 <subject>
1862                         <xsl:for-each select="marc:subfield[@code='a']">
1863                                 <topic>
1864                                         <xsl:value-of select="."/>
1865                                 </topic>                        
1866                         </xsl:for-each>
1867                 </subject>
1868         </xsl:template>
1869 </xsl:stylesheet><!-- Stylus Studio meta-information - (c)1998-2002 eXcelon Corp.
1870 <metaInformation>
1871 <scenarios ><scenario default="yes" name="modstst2" userelativepaths="yes" externalpreview="no" url="..\..\..\..\..\..\marcxml\modstst2.xml" htmlbaseurl="" outputurl="" processortype="internal" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext=""/><scenario default="no" name="modstest" userelativepaths="yes" externalpreview="no" url="..\..\..\..\..\..\marcxml\modstest.xml" htmlbaseurl="" outputurl="" processortype="internal" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext=""/><scenario default="no" name="Scenario1" userelativepaths="yes" externalpreview="no" url="..\..\..\..\..\..\marcxml\t.xml" htmlbaseurl="" outputurl="" processortype="internal" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext=""/></scenarios><MapperInfo srcSchemaPath="" srcSchemaRoot="" srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>
1872 </metaInformation>
1873 -->