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