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