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