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