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