]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/YYYY.data.mods-title-punctuation-change.sql
LP#1744385: Search and Result Display improvements
[working/Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / YYYY.data.mods-title-punctuation-change.sql
1 BEGIN;
2
3 update config.xml_transform set xslt = $XXXX$<?xml version="1.0" encoding="UTF-8"?>
4 <xsl:stylesheet xmlns="http://www.loc.gov/mods/v3" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xlink marc" version="1.0">
5         <xsl:output encoding="UTF-8" indent="yes" method="xml"/>
6 <!--
7 Revision 1.14 - Fixed template isValid and fields 010, 020, 022, 024, 028, and 037 to output additional identifier elements
8   with corresponding @type and @invalid eq 'yes' when subfields z or y (in the case of 022) exist in the MARCXML ::: 2007/01/04 17:35:20 cred
9
10 Revision 1.13 - Changed order of output under cartographics to reflect schema  2006/11/28 tmee
11
12 Revision 1.12 - Updated to reflect MODS 3.2 Mapping  2006/10/11 tmee
13
14 Revision 1.11 - The attribute objectPart moved from <languageTerm> to <language>
15       2006/04/08  jrad
16
17 Revision 1.10 MODS 3.1 revisions to language and classification elements
18                                 (plus ability to find marc:collection embedded in wrapper elements such as SRU zs: wrappers)
19                                 2006/02/06  ggar
20
21 Revision 1.9 subfield $y was added to field 242 2004/09/02 10:57 jrad
22
23 Revision 1.8 Subject chopPunctuation expanded and attribute fixes 2004/08/12 jrad
24
25 Revision 1.7 2004/03/25 08:29 jrad
26
27 Revision 1.6 various validation fixes 2004/02/20 ntra
28
29 Revision 1.5  2003/10/02 16:18:58  ntra
30 MODS2 to MODS3 updates, language unstacking and
31 de-duping, chopPunctuation expanded
32
33 Revision 1.3  2003/04/03 00:07:19  ntra
34 Revision 1.3 Additional Changes not related to MODS Version 2.0 by ntra
35
36 Revision 1.2  2003/03/24 19:37:42  ckeith
37 Added Log Comment
38
39 -->
40         <xsl:template match="/">
41                 <xsl:choose>
42                         <xsl:when test="//marc:collection">
43                                 <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-2.xsd">
44                                         <xsl:for-each select="//marc:collection/marc:record">
45                                                 <mods version="3.2">
46                                                         <xsl:call-template name="marcRecord"/>
47                                                 </mods>
48                                         </xsl:for-each>
49                                 </modsCollection>
50                         </xsl:when>
51                         <xsl:otherwise>
52                                 <mods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.2" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-2.xsd">
53                                         <xsl:for-each select="//marc:record">
54                                                 <xsl:call-template name="marcRecord"/>
55                                         </xsl:for-each>
56                                 </mods>
57                         </xsl:otherwise>
58                 </xsl:choose>
59         </xsl:template>
60         <xsl:template name="marcRecord">
61                 <xsl:variable name="leader" select="marc:leader"/>
62                 <xsl:variable name="leader6" select="substring($leader,7,1)"/>
63                 <xsl:variable name="leader7" select="substring($leader,8,1)"/>
64                 <xsl:variable name="controlField008" select="marc:controlfield[@tag='008']"/>
65                 <xsl:variable name="typeOf008">
66                         <xsl:choose>
67                                 <xsl:when test="$leader6='a'">
68                                         <xsl:choose>
69                                                 <xsl:when test="$leader7='a' or $leader7='c' or $leader7='d' or $leader7='m'">BK</xsl:when>
70                                                 <xsl:when test="$leader7='b' or $leader7='i' or $leader7='s'">SE</xsl:when>
71                                         </xsl:choose>
72                                 </xsl:when>
73                                 <xsl:when test="$leader6='t'">BK</xsl:when>
74                                 <xsl:when test="$leader6='p'">MM</xsl:when>
75                                 <xsl:when test="$leader6='m'">CF</xsl:when>
76                                 <xsl:when test="$leader6='e' or $leader6='f'">MP</xsl:when>
77                                 <xsl:when test="$leader6='g' or $leader6='k' or $leader6='o' or $leader6='r'">VM</xsl:when>
78                                 <xsl:when test="$leader6='c' or $leader6='d' or $leader6='i' or $leader6='j'">MU</xsl:when>
79                         </xsl:choose>
80                 </xsl:variable>
81                 <xsl:for-each select="marc:datafield[@tag='245']">
82                         <titleInfo>
83                                 <xsl:variable name="title">
84                                         <xsl:choose>
85                                                 <xsl:when test="marc:subfield[@code='b']">
86                                                         <xsl:call-template name="specialSubfieldSelect">
87                                                                 <xsl:with-param name="axis">b</xsl:with-param>
88                                                                 <xsl:with-param name="beforeCodes">afgk</xsl:with-param>
89                                                         </xsl:call-template>
90                                                 </xsl:when>
91                                                 <xsl:otherwise>
92                                                         <xsl:call-template name="subfieldSelect">
93                                                                 <xsl:with-param name="codes">abfgk</xsl:with-param>
94                                                         </xsl:call-template>
95                                                 </xsl:otherwise>
96                                         </xsl:choose>
97                                 </xsl:variable>
98                                 <xsl:variable name="titleChop">
99                                         <xsl:call-template name="chopPunctuation">
100                                                 <xsl:with-param name="chopString">
101                                                         <xsl:value-of select="$title"/>
102                                                 </xsl:with-param>
103                                                 <xsl:with-param name="punctuation">
104                                                     <xsl:text>,;/ </xsl:text>
105                                                 </xsl:with-param>
106                                         </xsl:call-template>
107                                 </xsl:variable>
108                                 <xsl:choose>
109                                         <xsl:when test="@ind2>0">
110                                                 <nonSort>
111                                                         <xsl:value-of select="substring($titleChop,1,@ind2)"/>
112                                                 </nonSort>
113                                                 <title>
114                                                         <xsl:value-of select="substring($titleChop,@ind2+1)"/>
115                                                 </title>
116                                         </xsl:when>
117                                         <xsl:otherwise>
118                                                 <title>
119                                                         <xsl:value-of select="$titleChop"/>
120                                                 </title>
121                                         </xsl:otherwise>
122                                 </xsl:choose>
123                                 <xsl:if test="marc:subfield[@code='b']">
124                                         <subTitle>
125                                                 <xsl:call-template name="chopPunctuation">
126                                                         <xsl:with-param name="chopString">
127                                                                 <xsl:call-template name="specialSubfieldSelect">
128                                                                         <xsl:with-param name="axis">b</xsl:with-param>
129                                                                         <xsl:with-param name="anyCodes">b</xsl:with-param>
130                                                                         <xsl:with-param name="afterCodes">afgk</xsl:with-param>
131                                                                 </xsl:call-template>
132                                                         </xsl:with-param>
133                                                 </xsl:call-template>
134                                         </subTitle>
135                                 </xsl:if>
136                                 <xsl:call-template name="part"></xsl:call-template>
137                         </titleInfo>
138                         <!-- A form of title that ignores non-filing characters; useful
139                                  for not converting "L'Oreal" into "L' Oreal" at index time -->
140                         <titleNonfiling>
141                                 <title>
142                                         <xsl:call-template name="chopPunctuation">
143                                                 <xsl:with-param name="chopString">
144                                                         <xsl:call-template name="subfieldSelect">
145                                                                 <xsl:with-param name="codes">abfgk</xsl:with-param>
146                                                         </xsl:call-template>
147                                                 </xsl:with-param>
148                                         </xsl:call-template>
149                                 </title>
150                                 <xsl:call-template name="part"></xsl:call-template>
151                         </titleNonfiling>
152                         <!-- hybrid of titleInfo and titleNonfiling which will give us a preformatted string (for punctuation)
153                                  but also keep the nonSort stuff in a separate field (for sorting) -->
154                         <titleBrowse>
155                                 <xsl:variable name="titleBrowseChop">
156                                         <xsl:call-template name="chopPunctuation">
157                                                 <xsl:with-param name="chopString">
158                                                         <xsl:call-template name="subfieldSelect">
159                                                                 <xsl:with-param name="codes">abfgk</xsl:with-param>
160                                                         </xsl:call-template>
161                                                 </xsl:with-param>
162                                         </xsl:call-template>
163                                 </xsl:variable>
164                                 <xsl:choose>
165                                         <xsl:when test="@ind2>0">
166                                                 <nonSort>
167                                                         <xsl:value-of select="substring($titleBrowseChop,1,@ind2)"/>
168                                                 </nonSort>
169                                                 <title>
170                                                         <xsl:value-of select="substring($titleBrowseChop,@ind2+1)"/>
171                                                 </title>
172                                         </xsl:when>
173                                         <xsl:otherwise>
174                                                 <title>
175                                                         <xsl:value-of select="$titleBrowseChop"/>
176                                                 </title>
177                                         </xsl:otherwise>
178                                 </xsl:choose>
179                                 <xsl:call-template name="part"></xsl:call-template>
180                         </titleBrowse>
181                 </xsl:for-each>
182                 <xsl:for-each select="marc:datafield[@tag='210']">
183                         <titleInfo type="abbreviated">
184                                 <title>
185                                         <xsl:call-template name="chopPunctuation">
186                                                 <xsl:with-param name="chopString">
187                                                         <xsl:call-template name="subfieldSelect">
188                                                                 <xsl:with-param name="codes">a</xsl:with-param>
189                                                         </xsl:call-template>
190                                                 </xsl:with-param>
191                                         </xsl:call-template>
192                                 </title>
193                                 <xsl:call-template name="subtitle"/>
194                         </titleInfo>
195                 </xsl:for-each>
196                 <xsl:for-each select="marc:datafield[@tag='242']">
197                         <xsl:variable name="titleChop">
198                                 <xsl:call-template name="chopPunctuation">
199                                         <xsl:with-param name="chopString">
200                                                 <xsl:call-template name="subfieldSelect">
201                                                         <!-- 1/04 removed $h, b -->
202                                                         <xsl:with-param name="codes">a</xsl:with-param>
203                                                 </xsl:call-template>
204                                         </xsl:with-param>
205                                 </xsl:call-template>
206                         </xsl:variable>
207                         <titleInfo type="translated">
208                                 <!--09/01/04 Added subfield $y-->
209                                 <xsl:for-each select="marc:subfield[@code='y']">
210                                         <xsl:attribute name="lang">
211                                                 <xsl:value-of select="text()"/>
212                                         </xsl:attribute>
213                                 </xsl:for-each>
214                                 <title>
215                                         <xsl:value-of select="$titleChop" />
216                                 </title>
217                                 <!-- 1/04 fix -->
218                                 <xsl:call-template name="subtitle"/>
219                                 <xsl:call-template name="part"/>
220                         </titleInfo>
221                         <titleInfo type="translated-nfi">
222                                 <xsl:for-each select="marc:subfield[@code='y']">
223                                         <xsl:attribute name="lang">
224                                                 <xsl:value-of select="text()"/>
225                                         </xsl:attribute>
226                                 </xsl:for-each>
227                                 <xsl:choose>
228                                         <xsl:when test="@ind2>0">
229                                                 <nonSort>
230                                                         <xsl:value-of select="substring($titleChop,1,@ind2)"/>
231                                                 </nonSort>
232                                                 <title>
233                                                         <xsl:value-of select="substring($titleChop,@ind2+1)"/>
234                                                 </title>
235                                         </xsl:when>
236                                         <xsl:otherwise>
237                                                 <title>
238                                                         <xsl:value-of select="$titleChop" />
239                                                 </title>
240                                         </xsl:otherwise>
241                                 </xsl:choose>
242                                 <xsl:call-template name="subtitle"/>
243                                 <xsl:call-template name="part"/>
244                         </titleInfo>
245                 </xsl:for-each>
246                 <xsl:for-each select="marc:datafield[@tag='246']">
247                         <titleInfo type="alternative">
248                                 <xsl:for-each select="marc:subfield[@code='i']">
249                                         <xsl:attribute name="displayLabel">
250                                                 <xsl:value-of select="text()"/>
251                                         </xsl:attribute>
252                                 </xsl:for-each>
253                                 <title>
254                                         <xsl:call-template name="chopPunctuation">
255                                                 <xsl:with-param name="chopString">
256                                                         <xsl:call-template name="subfieldSelect">
257                                                                 <!-- 1/04 removed $h, $b -->
258                                                                 <xsl:with-param name="codes">af</xsl:with-param>
259                                                         </xsl:call-template>
260                                                 </xsl:with-param>
261                                         </xsl:call-template>
262                                 </title>
263                                 <xsl:call-template name="subtitle"/>
264                                 <xsl:call-template name="part"/>
265                         </titleInfo>
266                 </xsl:for-each>
267                 <xsl:for-each select="marc:datafield[@tag='130']|marc:datafield[@tag='240']|marc:datafield[@tag='730'][@ind2!='2']">
268                         <xsl:variable name="nfi">
269                                 <xsl:choose>
270                                         <xsl:when test="@tag='240'">
271                                                 <xsl:value-of select="@ind2"/>
272                                         </xsl:when>
273                                         <xsl:otherwise>
274                                                 <xsl:value-of select="@ind1"/>
275                                         </xsl:otherwise>
276                                 </xsl:choose>
277                         </xsl:variable>
278                         <xsl:variable name="titleChop">
279                                 <xsl:call-template name="uri" />
280                                 <xsl:variable name="str">
281                                         <xsl:for-each select="marc:subfield">
282                                                 <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'])))">
283                                                         <xsl:value-of select="text()"/>
284                                                         <xsl:text> </xsl:text>
285                                                 </xsl:if>
286                                         </xsl:for-each>
287                                 </xsl:variable>
288                                 <xsl:call-template name="chopPunctuation">
289                                         <xsl:with-param name="chopString">
290                                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
291                                         </xsl:with-param>
292                                 </xsl:call-template>
293                         </xsl:variable>
294                         <titleInfo type="uniform">
295                                 <title>
296                                         <xsl:value-of select="$titleChop"/>
297                                 </title>
298                                 <xsl:call-template name="part"/>
299                         </titleInfo>
300                         <titleInfo type="uniform-nfi">
301                                 <xsl:choose>
302                                         <xsl:when test="$nfi>0">
303                                                 <nonSort>
304                                                         <xsl:value-of select="substring($titleChop,1,$nfi)"/>
305                                                 </nonSort>
306                                                 <title>
307                                                         <xsl:value-of select="substring($titleChop,$nfi+1)"/>
308                                                 </title>
309                                         </xsl:when>
310                                         <xsl:otherwise>
311                                                 <title>
312                                                         <xsl:value-of select="$titleChop"/>
313                                                 </title>
314                                         </xsl:otherwise>
315                                 </xsl:choose>
316                                 <xsl:call-template name="part"/>
317                         </titleInfo>
318                 </xsl:for-each>
319                 <xsl:for-each select="marc:datafield[@tag='740'][@ind2!='2']">
320                         <xsl:variable name="titleChop">
321                                 <xsl:call-template name="chopPunctuation">
322                                         <xsl:with-param name="chopString">
323                                                 <xsl:call-template name="subfieldSelect">
324                                                         <xsl:with-param name="codes">ah</xsl:with-param>
325                                                 </xsl:call-template>
326                                         </xsl:with-param>
327                                 </xsl:call-template>
328                         </xsl:variable>
329                         <titleInfo type="alternative">
330                                 <title>
331                                         <xsl:value-of select="$titleChop" />
332                                 </title>
333                                 <xsl:call-template name="part"/>
334                         </titleInfo>
335                         <titleInfo type="alternative-nfi">
336                                 <xsl:choose>
337                                         <xsl:when test="@ind1>0">
338                                                 <nonSort>
339                                                         <xsl:value-of select="substring($titleChop,1,@ind1)"/>
340                                                 </nonSort>
341                                                 <title>
342                                                         <xsl:value-of select="substring($titleChop,@ind1+1)"/>
343                                                 </title>
344                                         </xsl:when>
345                                         <xsl:otherwise>
346                                                 <title>
347                                                         <xsl:value-of select="$titleChop" />
348                                                 </title>
349                                         </xsl:otherwise>
350                                 </xsl:choose>
351                                 <xsl:call-template name="part"/>
352                         </titleInfo>
353                 </xsl:for-each>
354                 <xsl:for-each select="marc:datafield[@tag='100']">
355                         <name type="personal">
356                                 <xsl:call-template name="uri" />
357                                 <xsl:call-template name="nameABCDQ"/>
358                                 <xsl:call-template name="affiliation"/>
359                                 <role>
360                                         <roleTerm authority="marcrelator" type="text">creator</roleTerm>
361                                 </role>
362                                 <xsl:call-template name="role"/>
363                         </name>
364                 </xsl:for-each>
365                 <xsl:for-each select="marc:datafield[@tag='110']">
366                         <name type="corporate">
367                                 <xsl:call-template name="uri" />
368                                 <xsl:call-template name="nameABCDN"/>
369                                 <role>
370                                         <roleTerm authority="marcrelator" type="text">creator</roleTerm>
371                                 </role>
372                                 <xsl:call-template name="role"/>
373                         </name>
374                 </xsl:for-each>
375                 <xsl:for-each select="marc:datafield[@tag='111']">
376                         <name type="conference">
377                                 <xsl:call-template name="uri" />
378                                 <xsl:call-template name="nameACDEQ"/>
379                                 <role>
380                                         <roleTerm authority="marcrelator" type="text">creator</roleTerm>
381                                 </role>
382                                 <xsl:call-template name="role"/>
383                         </name>
384                 </xsl:for-each>
385                 <xsl:for-each select="marc:datafield[@tag='700'][not(marc:subfield[@code='t'])]">
386                         <name type="personal">
387                                 <xsl:call-template name="uri" />
388                                 <xsl:call-template name="nameABCDQ"/>
389                                 <xsl:call-template name="affiliation"/>
390                                 <xsl:call-template name="role"/>
391                         </name>
392                 </xsl:for-each>
393                 <xsl:for-each select="marc:datafield[@tag='710'][not(marc:subfield[@code='t'])]">
394                         <name type="corporate">
395                                 <xsl:call-template name="uri" />
396                                 <xsl:call-template name="nameABCDN"/>
397                                 <xsl:call-template name="role"/>
398                         </name>
399                 </xsl:for-each>
400                 <xsl:for-each select="marc:datafield[@tag='711'][not(marc:subfield[@code='t'])]">
401                         <name type="conference">
402                                 <xsl:call-template name="uri" />
403                                 <xsl:call-template name="nameACDEQ"/>
404                                 <xsl:call-template name="role"/>
405                         </name>
406                 </xsl:for-each>
407                 <xsl:for-each select="marc:datafield[@tag='720'][not(marc:subfield[@code='t'])]">
408                         <name>
409                                 <xsl:if test="@ind1=1">
410                                         <xsl:attribute name="type">
411                                                 <xsl:text>personal</xsl:text>
412                                         </xsl:attribute>
413                                 </xsl:if>
414                                 <namePart>
415                                         <xsl:value-of select="marc:subfield[@code='a']"/>
416                                 </namePart>
417                                 <xsl:call-template name="role"/>
418                         </name>
419                 </xsl:for-each>
420                 <typeOfResource>
421                         <xsl:if test="$leader7='c'">
422                                 <xsl:attribute name="collection">yes</xsl:attribute>
423                         </xsl:if>
424                         <xsl:if test="$leader6='d' or $leader6='f' or $leader6='p' or $leader6='t'">
425                                 <xsl:attribute name="manuscript">yes</xsl:attribute>
426                         </xsl:if>
427                         <xsl:choose>
428                                 <xsl:when test="$leader6='a' or $leader6='t'">text</xsl:when>
429                                 <xsl:when test="$leader6='e' or $leader6='f'">cartographic</xsl:when>
430                                 <xsl:when test="$leader6='c' or $leader6='d'">notated music</xsl:when>
431                                 <xsl:when test="$leader6='i'">sound recording-nonmusical</xsl:when>
432                                 <xsl:when test="$leader6='j'">sound recording-musical</xsl:when>
433                                 <xsl:when test="$leader6='k'">still image</xsl:when>
434                                 <xsl:when test="$leader6='g'">moving image</xsl:when>
435                                 <xsl:when test="$leader6='r'">three dimensional object</xsl:when>
436                                 <xsl:when test="$leader6='m'">software, multimedia</xsl:when>
437                                 <xsl:when test="$leader6='p'">mixed material</xsl:when>
438                         </xsl:choose>
439                 </typeOfResource>
440                 <xsl:if test="substring($controlField008,26,1)='d'">
441                         <genre authority="marc">globe</genre>
442                 </xsl:if>
443                 <xsl:if test="marc:controlfield[@tag='007'][substring(text(),1,1)='a'][substring(text(),2,1)='r']">
444                         <genre authority="marc">remote sensing image</genre>
445                 </xsl:if>
446                 <xsl:if test="$typeOf008='MP'">
447                         <xsl:variable name="controlField008-25" select="substring($controlField008,26,1)"></xsl:variable>
448                         <xsl:choose>
449                                 <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']">
450                                         <genre authority="marc">map</genre>
451                                 </xsl:when>
452                                 <xsl:when test="$controlField008-25='e' or marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='d']">
453                                         <genre authority="marc">atlas</genre>
454                                 </xsl:when>
455                         </xsl:choose>
456                 </xsl:if>
457                 <xsl:if test="$typeOf008='SE'">
458                         <xsl:variable name="controlField008-21" select="substring($controlField008,22,1)"></xsl:variable>
459                         <xsl:choose>
460                                 <xsl:when test="$controlField008-21='d'">
461                                         <genre authority="marc">database</genre>
462                                 </xsl:when>
463                                 <xsl:when test="$controlField008-21='l'">
464                                         <genre authority="marc">loose-leaf</genre>
465                                 </xsl:when>
466                                 <xsl:when test="$controlField008-21='m'">
467                                         <genre authority="marc">series</genre>
468                                 </xsl:when>
469                                 <xsl:when test="$controlField008-21='n'">
470                                         <genre authority="marc">newspaper</genre>
471                                 </xsl:when>
472                                 <xsl:when test="$controlField008-21='p'">
473                                         <genre authority="marc">periodical</genre>
474                                 </xsl:when>
475                                 <xsl:when test="$controlField008-21='w'">
476                                         <genre authority="marc">web site</genre>
477                                 </xsl:when>
478                         </xsl:choose>
479                 </xsl:if>
480                 <xsl:if test="$typeOf008='BK' or $typeOf008='SE'">
481                         <xsl:variable name="controlField008-24" select="substring($controlField008,25,4)"></xsl:variable>
482                         <xsl:choose>
483                                 <xsl:when test="contains($controlField008-24,'a')">
484                                         <genre authority="marc">abstract or summary</genre>
485                                 </xsl:when>
486                                 <xsl:when test="contains($controlField008-24,'b')">
487                                         <genre authority="marc">bibliography</genre>
488                                 </xsl:when>
489                                 <xsl:when test="contains($controlField008-24,'c')">
490                                         <genre authority="marc">catalog</genre>
491                                 </xsl:when>
492                                 <xsl:when test="contains($controlField008-24,'d')">
493                                         <genre authority="marc">dictionary</genre>
494                                 </xsl:when>
495                                 <xsl:when test="contains($controlField008-24,'e')">
496                                         <genre authority="marc">encyclopedia</genre>
497                                 </xsl:when>
498                                 <xsl:when test="contains($controlField008-24,'f')">
499                                         <genre authority="marc">handbook</genre>
500                                 </xsl:when>
501                                 <xsl:when test="contains($controlField008-24,'g')">
502                                         <genre authority="marc">legal article</genre>
503                                 </xsl:when>
504                                 <xsl:when test="contains($controlField008-24,'i')">
505                                         <genre authority="marc">index</genre>
506                                 </xsl:when>
507                                 <xsl:when test="contains($controlField008-24,'k')">
508                                         <genre authority="marc">discography</genre>
509                                 </xsl:when>
510                                 <xsl:when test="contains($controlField008-24,'l')">
511                                         <genre authority="marc">legislation</genre>
512                                 </xsl:when>
513                                 <xsl:when test="contains($controlField008-24,'m')">
514                                         <genre authority="marc">theses</genre>
515                                 </xsl:when>
516                                 <xsl:when test="contains($controlField008-24,'n')">
517                                         <genre authority="marc">survey of literature</genre>
518                                 </xsl:when>
519                                 <xsl:when test="contains($controlField008-24,'o')">
520                                         <genre authority="marc">review</genre>
521                                 </xsl:when>
522                                 <xsl:when test="contains($controlField008-24,'p')">
523                                         <genre authority="marc">programmed text</genre>
524                                 </xsl:when>
525                                 <xsl:when test="contains($controlField008-24,'q')">
526                                         <genre authority="marc">filmography</genre>
527                                 </xsl:when>
528                                 <xsl:when test="contains($controlField008-24,'r')">
529                                         <genre authority="marc">directory</genre>
530                                 </xsl:when>
531                                 <xsl:when test="contains($controlField008-24,'s')">
532                                         <genre authority="marc">statistics</genre>
533                                 </xsl:when>
534                                 <xsl:when test="contains($controlField008-24,'t')">
535                                         <genre authority="marc">technical report</genre>
536                                 </xsl:when>
537                                 <xsl:when test="contains($controlField008-24,'v')">
538                                         <genre authority="marc">legal case and case notes</genre>
539                                 </xsl:when>
540                                 <xsl:when test="contains($controlField008-24,'w')">
541                                         <genre authority="marc">law report or digest</genre>
542                                 </xsl:when>
543                                 <xsl:when test="contains($controlField008-24,'z')">
544                                         <genre authority="marc">treaty</genre>
545                                 </xsl:when>
546                         </xsl:choose>
547                         <xsl:variable name="controlField008-29" select="substring($controlField008,30,1)"></xsl:variable>
548                         <xsl:choose>
549                                 <xsl:when test="$controlField008-29='1'">
550                                         <genre authority="marc">conference publication</genre>
551                                 </xsl:when>
552                         </xsl:choose>
553                 </xsl:if>
554                 <xsl:if test="$typeOf008='CF'">
555                         <xsl:variable name="controlField008-26" select="substring($controlField008,27,1)"></xsl:variable>
556                         <xsl:choose>
557                                 <xsl:when test="$controlField008-26='a'">
558                                         <genre authority="marc">numeric data</genre>
559                                 </xsl:when>
560                                 <xsl:when test="$controlField008-26='e'">
561                                         <genre authority="marc">database</genre>
562                                 </xsl:when>
563                                 <xsl:when test="$controlField008-26='f'">
564                                         <genre authority="marc">font</genre>
565                                 </xsl:when>
566                                 <xsl:when test="$controlField008-26='g'">
567                                         <genre authority="marc">game</genre>
568                                 </xsl:when>
569                         </xsl:choose>
570                 </xsl:if>
571                 <xsl:if test="$typeOf008='BK'">
572                         <xsl:if test="substring($controlField008,25,1)='j'">
573                                 <genre authority="marc">patent</genre>
574                         </xsl:if>
575                         <xsl:if test="substring($controlField008,31,1)='1'">
576                                 <genre authority="marc">festschrift</genre>
577                         </xsl:if>
578                         <xsl:variable name="controlField008-34" select="substring($controlField008,35,1)"></xsl:variable>
579                         <xsl:if test="$controlField008-34='a' or $controlField008-34='b' or $controlField008-34='c' or $controlField008-34='d'">
580                                 <genre authority="marc">biography</genre>
581                         </xsl:if>
582                         <xsl:variable name="controlField008-33" select="substring($controlField008,34,1)"></xsl:variable>
583                         <xsl:choose>
584                                 <xsl:when test="$controlField008-33='e'">
585                                         <genre authority="marc">essay</genre>
586                                 </xsl:when>
587                                 <xsl:when test="$controlField008-33='d'">
588                                         <genre authority="marc">drama</genre>
589                                 </xsl:when>
590                                 <xsl:when test="$controlField008-33='c'">
591                                         <genre authority="marc">comic strip</genre>
592                                 </xsl:when>
593                                 <xsl:when test="$controlField008-33='l'">
594                                         <genre authority="marc">fiction</genre>
595                                 </xsl:when>
596                                 <xsl:when test="$controlField008-33='h'">
597                                         <genre authority="marc">humor, satire</genre>
598                                 </xsl:when>
599                                 <xsl:when test="$controlField008-33='i'">
600                                         <genre authority="marc">letter</genre>
601                                 </xsl:when>
602                                 <xsl:when test="$controlField008-33='f'">
603                                         <genre authority="marc">novel</genre>
604                                 </xsl:when>
605                                 <xsl:when test="$controlField008-33='j'">
606                                         <genre authority="marc">short story</genre>
607                                 </xsl:when>
608                                 <xsl:when test="$controlField008-33='s'">
609                                         <genre authority="marc">speech</genre>
610                                 </xsl:when>
611                         </xsl:choose>
612                 </xsl:if>
613                 <xsl:if test="$typeOf008='MU'">
614                         <xsl:variable name="controlField008-30-31" select="substring($controlField008,31,2)"></xsl:variable>
615                         <xsl:if test="contains($controlField008-30-31,'b')">
616                                 <genre authority="marc">biography</genre>
617                         </xsl:if>
618                         <xsl:if test="contains($controlField008-30-31,'c')">
619                                 <genre authority="marc">conference publication</genre>
620                         </xsl:if>
621                         <xsl:if test="contains($controlField008-30-31,'d')">
622                                 <genre authority="marc">drama</genre>
623                         </xsl:if>
624                         <xsl:if test="contains($controlField008-30-31,'e')">
625                                 <genre authority="marc">essay</genre>
626                         </xsl:if>
627                         <xsl:if test="contains($controlField008-30-31,'f')">
628                                 <genre authority="marc">fiction</genre>
629                         </xsl:if>
630                         <xsl:if test="contains($controlField008-30-31,'o')">
631                                 <genre authority="marc">folktale</genre>
632                         </xsl:if>
633                         <xsl:if test="contains($controlField008-30-31,'h')">
634                                 <genre authority="marc">history</genre>
635                         </xsl:if>
636                         <xsl:if test="contains($controlField008-30-31,'k')">
637                                 <genre authority="marc">humor, satire</genre>
638                         </xsl:if>
639                         <xsl:if test="contains($controlField008-30-31,'m')">
640                                 <genre authority="marc">memoir</genre>
641                         </xsl:if>
642                         <xsl:if test="contains($controlField008-30-31,'p')">
643                                 <genre authority="marc">poetry</genre>
644                         </xsl:if>
645                         <xsl:if test="contains($controlField008-30-31,'r')">
646                                 <genre authority="marc">rehearsal</genre>
647                         </xsl:if>
648                         <xsl:if test="contains($controlField008-30-31,'g')">
649                                 <genre authority="marc">reporting</genre>
650                         </xsl:if>
651                         <xsl:if test="contains($controlField008-30-31,'s')">
652                                 <genre authority="marc">sound</genre>
653                         </xsl:if>
654                         <xsl:if test="contains($controlField008-30-31,'l')">
655                                 <genre authority="marc">speech</genre>
656                         </xsl:if>
657                 </xsl:if>
658                 <xsl:if test="$typeOf008='VM'">
659                         <xsl:variable name="controlField008-33" select="substring($controlField008,34,1)"></xsl:variable>
660                         <xsl:choose>
661                                 <xsl:when test="$controlField008-33='a'">
662                                         <genre authority="marc">art original</genre>
663                                 </xsl:when>
664                                 <xsl:when test="$controlField008-33='b'">
665                                         <genre authority="marc">kit</genre>
666                                 </xsl:when>
667                                 <xsl:when test="$controlField008-33='c'">
668                                         <genre authority="marc">art reproduction</genre>
669                                 </xsl:when>
670                                 <xsl:when test="$controlField008-33='d'">
671                                         <genre authority="marc">diorama</genre>
672                                 </xsl:when>
673                                 <xsl:when test="$controlField008-33='f'">
674                                         <genre authority="marc">filmstrip</genre>
675                                 </xsl:when>
676                                 <xsl:when test="$controlField008-33='g'">
677                                         <genre authority="marc">legal article</genre>
678                                 </xsl:when>
679                                 <xsl:when test="$controlField008-33='i'">
680                                         <genre authority="marc">picture</genre>
681                                 </xsl:when>
682                                 <xsl:when test="$controlField008-33='k'">
683                                         <genre authority="marc">graphic</genre>
684                                 </xsl:when>
685                                 <xsl:when test="$controlField008-33='l'">
686                                         <genre authority="marc">technical drawing</genre>
687                                 </xsl:when>
688                                 <xsl:when test="$controlField008-33='m'">
689                                         <genre authority="marc">motion picture</genre>
690                                 </xsl:when>
691                                 <xsl:when test="$controlField008-33='n'">
692                                         <genre authority="marc">chart</genre>
693                                 </xsl:when>
694                                 <xsl:when test="$controlField008-33='o'">
695                                         <genre authority="marc">flash card</genre>
696                                 </xsl:when>
697                                 <xsl:when test="$controlField008-33='p'">
698                                         <genre authority="marc">microscope slide</genre>
699                                 </xsl:when>
700                                 <xsl:when test="$controlField008-33='q' or marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='q']">
701                                         <genre authority="marc">model</genre>
702                                 </xsl:when>
703                                 <xsl:when test="$controlField008-33='r'">
704                                         <genre authority="marc">realia</genre>
705                                 </xsl:when>
706                                 <xsl:when test="$controlField008-33='s'">
707                                         <genre authority="marc">slide</genre>
708                                 </xsl:when>
709                                 <xsl:when test="$controlField008-33='t'">
710                                         <genre authority="marc">transparency</genre>
711                                 </xsl:when>
712                                 <xsl:when test="$controlField008-33='v'">
713                                         <genre authority="marc">videorecording</genre>
714                                 </xsl:when>
715                                 <xsl:when test="$controlField008-33='w'">
716                                         <genre authority="marc">toy</genre>
717                                 </xsl:when>
718                         </xsl:choose>
719                 </xsl:if>
720                 <xsl:for-each select="marc:datafield[@tag=655]">
721                         <genre authority="marc">
722                                 <xsl:attribute name="authority">
723                                         <xsl:value-of select="marc:subfield[@code='2']"/>
724                                 </xsl:attribute>
725                                 <xsl:call-template name="subfieldSelect">
726                                         <xsl:with-param name="codes">abvxyz</xsl:with-param>
727                                         <xsl:with-param name="delimeter">-</xsl:with-param>
728                                 </xsl:call-template>
729                         </genre>
730                 </xsl:for-each>
731                 <originInfo>
732                         <xsl:variable name="MARCpublicationCode" select="normalize-space(substring($controlField008,16,3))"></xsl:variable>
733                         <xsl:if test="translate($MARCpublicationCode,'|','')">
734                                 <place>
735                                         <placeTerm>
736                                                 <xsl:attribute name="type">code</xsl:attribute>
737                                                 <xsl:attribute name="authority">marccountry</xsl:attribute>
738                                                 <xsl:value-of select="$MARCpublicationCode"/>
739                                         </placeTerm>
740                                 </place>
741                         </xsl:if>
742                         <xsl:for-each select="marc:datafield[@tag=044]/marc:subfield[@code='c']">
743                                 <place>
744                                         <placeTerm>
745                                                 <xsl:attribute name="type">code</xsl:attribute>
746                                                 <xsl:attribute name="authority">iso3166</xsl:attribute>
747                                                 <xsl:value-of select="."/>
748                                         </placeTerm>
749                                 </place>
750                         </xsl:for-each>
751                         <xsl:for-each select="marc:datafield[@tag=260]/marc:subfield[@code='a']">
752                                 <place>
753                                         <placeTerm>
754                                                 <xsl:attribute name="type">text</xsl:attribute>
755                                                 <xsl:call-template name="chopPunctuationFront">
756                                                         <xsl:with-param name="chopString">
757                                                                 <xsl:call-template name="chopPunctuation">
758                                                                         <xsl:with-param name="chopString" select="."/>
759                                                                 </xsl:call-template>
760                                                         </xsl:with-param>
761                                                 </xsl:call-template>
762                                         </placeTerm>
763                                 </place>
764                         </xsl:for-each>
765                         <xsl:for-each select="marc:datafield[@tag=046]/marc:subfield[@code='m']">
766                                 <dateValid point="start">
767                                         <xsl:value-of select="."/>
768                                 </dateValid>
769                         </xsl:for-each>
770                         <xsl:for-each select="marc:datafield[@tag=046]/marc:subfield[@code='n']">
771                                 <dateValid point="end">
772                                         <xsl:value-of select="."/>
773                                 </dateValid>
774                         </xsl:for-each>
775                         <xsl:for-each select="marc:datafield[@tag=046]/marc:subfield[@code='j']">
776                                 <dateModified>
777                                         <xsl:value-of select="."/>
778                                 </dateModified>
779                         </xsl:for-each>
780                         <xsl:for-each select="marc:datafield[@tag=260]/marc:subfield[@code='b' or @code='c' or @code='g']">
781                                 <xsl:choose>
782                                         <xsl:when test="@code='b'">
783                                                 <publisher>
784                                                         <xsl:call-template name="chopPunctuation">
785                                                                 <xsl:with-param name="chopString" select="."/>
786                                                                 <xsl:with-param name="punctuation">
787                                                                         <xsl:text>:,;/ </xsl:text>
788                                                                 </xsl:with-param>
789                                                         </xsl:call-template>
790                                                 </publisher>
791                                         </xsl:when>
792                                         <xsl:when test="@code='c'">
793                                                 <dateIssued>
794                                                         <xsl:call-template name="chopPunctuation">
795                                                                 <xsl:with-param name="chopString" select="."/>
796                                                         </xsl:call-template>
797                                                 </dateIssued>
798                                         </xsl:when>
799                                         <xsl:when test="@code='g'">
800                                                 <dateCreated>
801                                                         <xsl:value-of select="."/>
802                                                 </dateCreated>
803                                         </xsl:when>
804                                 </xsl:choose>
805                         </xsl:for-each>
806                         <xsl:variable name="dataField260c">
807                                 <xsl:call-template name="chopPunctuation">
808                                         <xsl:with-param name="chopString" select="marc:datafield[@tag=260]/marc:subfield[@code='c']"></xsl:with-param>
809                                 </xsl:call-template>
810                         </xsl:variable>
811                         <xsl:variable name="controlField008-7-10" select="normalize-space(substring($controlField008, 8, 4))"></xsl:variable>
812                         <xsl:variable name="controlField008-11-14" select="normalize-space(substring($controlField008, 12, 4))"></xsl:variable>
813                         <xsl:variable name="controlField008-6" select="normalize-space(substring($controlField008, 7, 1))"></xsl:variable>
814                         <xsl:if test="$controlField008-6='e' or $controlField008-6='p' or $controlField008-6='r' or $controlField008-6='t' or $controlField008-6='s'">
815                                 <xsl:if test="$controlField008-7-10 and ($controlField008-7-10 != $dataField260c)">
816                                         <dateIssued encoding="marc">
817                                                 <xsl:value-of select="$controlField008-7-10"/>
818                                         </dateIssued>
819                                 </xsl:if>
820                         </xsl:if>
821                         <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'">
822                                 <xsl:if test="$controlField008-7-10">
823                                         <dateIssued encoding="marc" point="start">
824                                                 <xsl:value-of select="$controlField008-7-10"/>
825                                         </dateIssued>
826                                 </xsl:if>
827                         </xsl:if>
828                         <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'">
829                                 <xsl:if test="$controlField008-11-14">
830                                         <dateIssued encoding="marc" point="end">
831                                                 <xsl:value-of select="$controlField008-11-14"/>
832                                         </dateIssued>
833                                 </xsl:if>
834                         </xsl:if>
835                         <xsl:if test="$controlField008-6='q'">
836                                 <xsl:if test="$controlField008-7-10">
837                                         <dateIssued encoding="marc" point="start" qualifier="questionable">
838                                                 <xsl:value-of select="$controlField008-7-10"/>
839                                         </dateIssued>
840                                 </xsl:if>
841                         </xsl:if>
842                         <xsl:if test="$controlField008-6='q'">
843                                 <xsl:if test="$controlField008-11-14">
844                                         <dateIssued encoding="marc" point="end" qualifier="questionable">
845                                                 <xsl:value-of select="$controlField008-11-14"/>
846                                         </dateIssued>
847                                 </xsl:if>
848                         </xsl:if>
849                         <xsl:if test="$controlField008-6='t'">
850                                 <xsl:if test="$controlField008-11-14">
851                                         <copyrightDate encoding="marc">
852                                                 <xsl:value-of select="$controlField008-11-14"/>
853                                         </copyrightDate>
854                                 </xsl:if>
855                         </xsl:if>
856                         <xsl:for-each select="marc:datafield[@tag=033][@ind1=0 or @ind1=1]/marc:subfield[@code='a']">
857                                 <dateCaptured encoding="iso8601">
858                                         <xsl:value-of select="."/>
859                                 </dateCaptured>
860                         </xsl:for-each>
861                         <xsl:for-each select="marc:datafield[@tag=033][@ind1=2]/marc:subfield[@code='a'][1]">
862                                 <dateCaptured encoding="iso8601" point="start">
863                                         <xsl:value-of select="."/>
864                                 </dateCaptured>
865                         </xsl:for-each>
866                         <xsl:for-each select="marc:datafield[@tag=033][@ind1=2]/marc:subfield[@code='a'][2]">
867                                 <dateCaptured encoding="iso8601" point="end">
868                                         <xsl:value-of select="."/>
869                                 </dateCaptured>
870                         </xsl:for-each>
871                         <xsl:for-each select="marc:datafield[@tag=250]/marc:subfield[@code='a']">
872                                 <edition>
873                                         <xsl:value-of select="."/>
874                                 </edition>
875                         </xsl:for-each>
876                         <xsl:for-each select="marc:leader">
877                                 <issuance>
878                                         <xsl:choose>
879                                                 <xsl:when test="$leader7='a' or $leader7='c' or $leader7='d' or $leader7='m'">monographic</xsl:when>
880                                                 <xsl:when test="$leader7='b' or $leader7='i' or $leader7='s'">continuing</xsl:when>
881                                         </xsl:choose>
882                                 </issuance>
883                         </xsl:for-each>
884                         <xsl:for-each select="marc:datafield[@tag=310]|marc:datafield[@tag=321]">
885                                 <frequency>
886                                         <xsl:call-template name="subfieldSelect">
887                                                 <xsl:with-param name="codes">ab</xsl:with-param>
888                                         </xsl:call-template>
889                                 </frequency>
890                         </xsl:for-each>
891                 </originInfo>
892                 <xsl:variable name="controlField008-35-37" select="normalize-space(translate(substring($controlField008,36,3),'|#',''))"></xsl:variable>
893                 <xsl:if test="$controlField008-35-37">
894                         <language>
895                                 <languageTerm authority="iso639-2b" type="code">
896                                         <xsl:value-of select="substring($controlField008,36,3)"/>
897                                 </languageTerm>
898                         </language>
899                 </xsl:if>
900                 <xsl:for-each select="marc:datafield[@tag=041]">
901                         <xsl:for-each select="marc:subfield[@code='a' or @code='b' or @code='d' or @code='e' or @code='f' or @code='g' or @code='h']">
902                                 <xsl:variable name="langCodes" select="."/>
903                                 <xsl:choose>
904                                         <xsl:when test="../marc:subfield[@code='2']='rfc3066'">
905                                                 <!-- not stacked but could be repeated -->
906                                                 <xsl:call-template name="rfcLanguages">
907                                                         <xsl:with-param name="nodeNum">
908                                                                 <xsl:value-of select="1"/>
909                                                         </xsl:with-param>
910                                                         <xsl:with-param name="usedLanguages">
911                                                                 <xsl:text></xsl:text>
912                                                         </xsl:with-param>
913                                                         <xsl:with-param name="controlField008-35-37">
914                                                                 <xsl:value-of select="$controlField008-35-37"></xsl:value-of>
915                                                         </xsl:with-param>
916                                                 </xsl:call-template>
917                                         </xsl:when>
918                                         <xsl:otherwise>
919                                                 <!-- iso -->
920                                                 <xsl:variable name="allLanguages">
921                                                         <xsl:copy-of select="$langCodes"></xsl:copy-of>
922                                                 </xsl:variable>
923                                                 <xsl:variable name="currentLanguage">
924                                                         <xsl:value-of select="substring($allLanguages,1,3)"></xsl:value-of>
925                                                 </xsl:variable>
926                                                 <xsl:call-template name="isoLanguage">
927                                                         <xsl:with-param name="currentLanguage">
928                                                                 <xsl:value-of select="substring($allLanguages,1,3)"></xsl:value-of>
929                                                         </xsl:with-param>
930                                                         <xsl:with-param name="remainingLanguages">
931                                                                 <xsl:value-of select="substring($allLanguages,4,string-length($allLanguages)-3)"></xsl:value-of>
932                                                         </xsl:with-param>
933                                                         <xsl:with-param name="usedLanguages">
934                                                                 <xsl:if test="$controlField008-35-37">
935                                                                         <xsl:value-of select="$controlField008-35-37"></xsl:value-of>
936                                                                 </xsl:if>
937                                                         </xsl:with-param>
938                                                 </xsl:call-template>
939                                         </xsl:otherwise>
940                                 </xsl:choose>
941                         </xsl:for-each>
942                 </xsl:for-each>
943                 <xsl:variable name="physicalDescription">
944                         <!--3.2 change tmee 007/11 -->
945                         <xsl:if test="$typeOf008='CF' and marc:controlfield[@tag=007][substring(.,12,1)='a']">
946                                 <digitalOrigin>reformatted digital</digitalOrigin>
947                         </xsl:if>
948                         <xsl:if test="$typeOf008='CF' and marc:controlfield[@tag=007][substring(.,12,1)='b']">
949                                 <digitalOrigin>digitized microfilm</digitalOrigin>
950                         </xsl:if>
951                         <xsl:if test="$typeOf008='CF' and marc:controlfield[@tag=007][substring(.,12,1)='d']">
952                                 <digitalOrigin>digitized other analog</digitalOrigin>
953                         </xsl:if>
954                         <xsl:variable name="controlField008-23" select="substring($controlField008,24,1)"></xsl:variable>
955                         <xsl:variable name="controlField008-29" select="substring($controlField008,30,1)"></xsl:variable>
956                         <xsl:variable name="check008-23">
957                                 <xsl:if test="$typeOf008='BK' or $typeOf008='MU' or $typeOf008='SE' or $typeOf008='MM'">
958                                         <xsl:value-of select="true()"></xsl:value-of>
959                                 </xsl:if>
960                         </xsl:variable>
961                         <xsl:variable name="check008-29">
962                                 <xsl:if test="$typeOf008='MP' or $typeOf008='VM'">
963                                         <xsl:value-of select="true()"></xsl:value-of>
964                                 </xsl:if>
965                         </xsl:variable>
966                         <xsl:choose>
967                                 <xsl:when test="($check008-23 and $controlField008-23='f') or ($check008-29 and $controlField008-29='f')">
968                                         <form authority="marcform">braille</form>
969                                 </xsl:when>
970                                 <xsl:when test="($controlField008-23=' ' and ($leader6='c' or $leader6='d')) or (($typeOf008='BK' or $typeOf008='SE') and ($controlField008-23=' ' or $controlField008='r'))">
971                                         <form authority="marcform">print</form>
972                                 </xsl:when>
973                                 <xsl:when test="$leader6 = 'm' or ($check008-23 and $controlField008-23='s') or ($check008-29 and $controlField008-29='s')">
974                                         <form authority="marcform">electronic</form>
975                                 </xsl:when>
976                                 <xsl:when test="($check008-23 and $controlField008-23='b') or ($check008-29 and $controlField008-29='b')">
977                                         <form authority="marcform">microfiche</form>
978                                 </xsl:when>
979                                 <xsl:when test="($check008-23 and $controlField008-23='a') or ($check008-29 and $controlField008-29='a')">
980                                         <form authority="marcform">microfilm</form>
981                                 </xsl:when>
982                         </xsl:choose>
983                         <!-- 1/04 fix -->
984                         <xsl:if test="marc:datafield[@tag=130]/marc:subfield[@code='h']">
985                                 <form authority="gmd">
986                                         <xsl:call-template name="chopBrackets">
987                                                 <xsl:with-param name="chopString">
988                                                         <xsl:value-of select="marc:datafield[@tag=130]/marc:subfield[@code='h']"></xsl:value-of>
989                                                 </xsl:with-param>
990                                         </xsl:call-template>
991                                 </form>
992                         </xsl:if>
993                         <xsl:if test="marc:datafield[@tag=240]/marc:subfield[@code='h']">
994                                 <form authority="gmd">
995                                         <xsl:call-template name="chopBrackets">
996                                                 <xsl:with-param name="chopString">
997                                                         <xsl:value-of select="marc:datafield[@tag=240]/marc:subfield[@code='h']"></xsl:value-of>
998                                                 </xsl:with-param>
999                                         </xsl:call-template>
1000                                 </form>
1001                         </xsl:if>
1002                         <xsl:if test="marc:datafield[@tag=242]/marc:subfield[@code='h']">
1003                                 <form authority="gmd">
1004                                         <xsl:call-template name="chopBrackets">
1005                                                 <xsl:with-param name="chopString">
1006                                                         <xsl:value-of select="marc:datafield[@tag=242]/marc:subfield[@code='h']"></xsl:value-of>
1007                                                 </xsl:with-param>
1008                                         </xsl:call-template>
1009                                 </form>
1010                         </xsl:if>
1011                         <xsl:if test="marc:datafield[@tag=245]/marc:subfield[@code='h']">
1012                                 <form authority="gmd">
1013                                         <xsl:call-template name="chopBrackets">
1014                                                 <xsl:with-param name="chopString">
1015                                                         <xsl:value-of select="marc:datafield[@tag=245]/marc:subfield[@code='h']"></xsl:value-of>
1016                                                 </xsl:with-param>
1017                                         </xsl:call-template>
1018                                 </form>
1019                         </xsl:if>
1020                         <xsl:if test="marc:datafield[@tag=246]/marc:subfield[@code='h']">
1021                                 <form authority="gmd">
1022                                         <xsl:call-template name="chopBrackets">
1023                                                 <xsl:with-param name="chopString">
1024                                                         <xsl:value-of select="marc:datafield[@tag=246]/marc:subfield[@code='h']"></xsl:value-of>
1025                                                 </xsl:with-param>
1026                                         </xsl:call-template>
1027                                 </form>
1028                         </xsl:if>
1029                         <xsl:if test="marc:datafield[@tag=730]/marc:subfield[@code='h']">
1030                                 <form authority="gmd">
1031                                         <xsl:call-template name="chopBrackets">
1032                                                 <xsl:with-param name="chopString">
1033                                                         <xsl:value-of select="marc:datafield[@tag=730]/marc:subfield[@code='h']"></xsl:value-of>
1034                                                 </xsl:with-param>
1035                                         </xsl:call-template>
1036                                 </form>
1037                         </xsl:if>
1038                         <xsl:for-each select="marc:datafield[@tag=256]/marc:subfield[@code='a']">
1039                                 <form>
1040                                         <xsl:value-of select="."></xsl:value-of>
1041                                 </form>
1042                         </xsl:for-each>
1043                         <xsl:for-each select="marc:controlfield[@tag=007][substring(text(),1,1)='c']">
1044                                 <xsl:choose>
1045                                         <xsl:when test="substring(text(),14,1)='a'">
1046                                                 <reformattingQuality>access</reformattingQuality>
1047                                         </xsl:when>
1048                                         <xsl:when test="substring(text(),14,1)='p'">
1049                                                 <reformattingQuality>preservation</reformattingQuality>
1050                                         </xsl:when>
1051                                         <xsl:when test="substring(text(),14,1)='r'">
1052                                                 <reformattingQuality>replacement</reformattingQuality>
1053                                         </xsl:when>
1054                                 </xsl:choose>
1055                         </xsl:for-each>
1056                         <!--3.2 change tmee 007/01 -->
1057                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='b']">
1058                                 <form authority="smd">chip cartridge</form>
1059                         </xsl:if>
1060                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='c']">
1061                                 <form authority="smd">computer optical disc cartridge</form>
1062                         </xsl:if>
1063                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='j']">
1064                                 <form authority="smd">magnetic disc</form>
1065                         </xsl:if>
1066                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='m']">
1067                                 <form authority="smd">magneto-optical disc</form>
1068                         </xsl:if>
1069                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='o']">
1070                                 <form authority="smd">optical disc</form>
1071                         </xsl:if>
1072                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='r']">
1073                                 <form authority="smd">remote</form>
1074                         </xsl:if>
1075                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='a']">
1076                                 <form authority="smd">tape cartridge</form>
1077                         </xsl:if>
1078                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='f']">
1079                                 <form authority="smd">tape cassette</form>
1080                         </xsl:if>
1081                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='h']">
1082                                 <form authority="smd">tape reel</form>
1083                         </xsl:if>
1084
1085                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='d'][substring(text(),2,1)='a']">
1086                                 <form authority="smd">celestial globe</form>
1087                         </xsl:if>
1088                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='d'][substring(text(),2,1)='e']">
1089                                 <form authority="smd">earth moon globe</form>
1090                         </xsl:if>
1091                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='d'][substring(text(),2,1)='b']">
1092                                 <form authority="smd">planetary or lunar globe</form>
1093                         </xsl:if>
1094                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='d'][substring(text(),2,1)='c']">
1095                                 <form authority="smd">terrestrial globe</form>
1096                         </xsl:if>
1097
1098                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='o'][substring(text(),2,1)='o']">
1099                                 <form authority="smd">kit</form>
1100                         </xsl:if>
1101
1102                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='d']">
1103                                 <form authority="smd">atlas</form>
1104                         </xsl:if>
1105                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='g']">
1106                                 <form authority="smd">diagram</form>
1107                         </xsl:if>
1108                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='j']">
1109                                 <form authority="smd">map</form>
1110                         </xsl:if>
1111                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='q']">
1112                                 <form authority="smd">model</form>
1113                         </xsl:if>
1114                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='k']">
1115                                 <form authority="smd">profile</form>
1116                         </xsl:if>
1117                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='r']">
1118                                 <form authority="smd">remote-sensing image</form>
1119                         </xsl:if>
1120                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='s']">
1121                                 <form authority="smd">section</form>
1122                         </xsl:if>
1123                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='y']">
1124                                 <form authority="smd">view</form>
1125                         </xsl:if>
1126
1127                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='a']">
1128                                 <form authority="smd">aperture card</form>
1129                         </xsl:if>
1130                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='e']">
1131                                 <form authority="smd">microfiche</form>
1132                         </xsl:if>
1133                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='f']">
1134                                 <form authority="smd">microfiche cassette</form>
1135                         </xsl:if>
1136                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='b']">
1137                                 <form authority="smd">microfilm cartridge</form>
1138                         </xsl:if>
1139                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='c']">
1140                                 <form authority="smd">microfilm cassette</form>
1141                         </xsl:if>
1142                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='d']">
1143                                 <form authority="smd">microfilm reel</form>
1144                         </xsl:if>
1145                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='g']">
1146                                 <form authority="smd">microopaque</form>
1147                         </xsl:if>
1148
1149                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='m'][substring(text(),2,1)='c']">
1150                                 <form authority="smd">film cartridge</form>
1151                         </xsl:if>
1152                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='m'][substring(text(),2,1)='f']">
1153                                 <form authority="smd">film cassette</form>
1154                         </xsl:if>
1155                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='m'][substring(text(),2,1)='r']">
1156                                 <form authority="smd">film reel</form>
1157                         </xsl:if>
1158
1159                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='n']">
1160                                 <form authority="smd">chart</form>
1161                         </xsl:if>
1162                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='c']">
1163                                 <form authority="smd">collage</form>
1164                         </xsl:if>
1165                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='d']">
1166                                 <form authority="smd">drawing</form>
1167                         </xsl:if>
1168                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='o']">
1169                                 <form authority="smd">flash card</form>
1170                         </xsl:if>
1171                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='e']">
1172                                 <form authority="smd">painting</form>
1173                         </xsl:if>
1174                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='f']">
1175                                 <form authority="smd">photomechanical print</form>
1176                         </xsl:if>
1177                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='g']">
1178                                 <form authority="smd">photonegative</form>
1179                         </xsl:if>
1180                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='h']">
1181                                 <form authority="smd">photoprint</form>
1182                         </xsl:if>
1183                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='i']">
1184                                 <form authority="smd">picture</form>
1185                         </xsl:if>
1186                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='j']">
1187                                 <form authority="smd">print</form>
1188                         </xsl:if>
1189                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='l']">
1190                                 <form authority="smd">technical drawing</form>
1191                         </xsl:if>
1192
1193                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='q'][substring(text(),2,1)='q']">
1194                                 <form authority="smd">notated music</form>
1195                         </xsl:if>
1196
1197                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='d']">
1198                                 <form authority="smd">filmslip</form>
1199                         </xsl:if>
1200                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='c']">
1201                                 <form authority="smd">filmstrip cartridge</form>
1202                         </xsl:if>
1203                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='o']">
1204                                 <form authority="smd">filmstrip roll</form>
1205                         </xsl:if>
1206                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='f']">
1207                                 <form authority="smd">other filmstrip type</form>
1208                         </xsl:if>
1209                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='s']">
1210                                 <form authority="smd">slide</form>
1211                         </xsl:if>
1212                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='t']">
1213                                 <form authority="smd">transparency</form>
1214                         </xsl:if>
1215                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='r'][substring(text(),2,1)='r']">
1216                                 <form authority="smd">remote-sensing image</form>
1217                         </xsl:if>
1218                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='e']">
1219                                 <form authority="smd">cylinder</form>
1220                         </xsl:if>
1221                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='q']">
1222                                 <form authority="smd">roll</form>
1223                         </xsl:if>
1224                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='g']">
1225                                 <form authority="smd">sound cartridge</form>
1226                         </xsl:if>
1227                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='s']">
1228                                 <form authority="smd">sound cassette</form>
1229                         </xsl:if>
1230                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='d']">
1231                                 <form authority="smd">sound disc</form>
1232                         </xsl:if>
1233                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='t']">
1234                                 <form authority="smd">sound-tape reel</form>
1235                         </xsl:if>
1236                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='i']">
1237                                 <form authority="smd">sound-track film</form>
1238                         </xsl:if>
1239                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='w']">
1240                                 <form authority="smd">wire recording</form>
1241                         </xsl:if>
1242
1243                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='f'][substring(text(),2,1)='c']">
1244                                 <form authority="smd">braille</form>
1245                         </xsl:if>
1246                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='f'][substring(text(),2,1)='b']">
1247                                 <form authority="smd">combination</form>
1248                         </xsl:if>
1249                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='f'][substring(text(),2,1)='a']">
1250                                 <form authority="smd">moon</form>
1251                         </xsl:if>
1252                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='f'][substring(text(),2,1)='d']">
1253                                 <form authority="smd">tactile, with no writing system</form>
1254                         </xsl:if>
1255
1256                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='t'][substring(text(),2,1)='c']">
1257                                 <form authority="smd">braille</form>
1258                         </xsl:if>
1259                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='t'][substring(text(),2,1)='b']">
1260                                 <form authority="smd">large print</form>
1261                         </xsl:if>
1262                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='t'][substring(text(),2,1)='a']">
1263                                 <form authority="smd">regular print</form>
1264                         </xsl:if>
1265                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='t'][substring(text(),2,1)='d']">
1266                                 <form authority="smd">text in looseleaf binder</form>
1267                         </xsl:if>
1268
1269                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='v'][substring(text(),2,1)='c']">
1270                                 <form authority="smd">videocartridge</form>
1271                         </xsl:if>
1272                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='v'][substring(text(),2,1)='f']">
1273                                 <form authority="smd">videocassette</form>
1274                         </xsl:if>
1275                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='v'][substring(text(),2,1)='d']">
1276                                 <form authority="smd">videodisc</form>
1277                         </xsl:if>
1278                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='v'][substring(text(),2,1)='r']">
1279                                 <form authority="smd">videoreel</form>
1280                         </xsl:if>
1281
1282                         <xsl:for-each select="marc:datafield[@tag=856]/marc:subfield[@code='q'][string-length(.)>1]">
1283                                 <internetMediaType>
1284                                         <xsl:value-of select="."></xsl:value-of>
1285                                 </internetMediaType>
1286                         </xsl:for-each>
1287                         <xsl:for-each select="marc:datafield[@tag=300]">
1288                                 <extent>
1289                                         <xsl:call-template name="subfieldSelect">
1290                                                 <xsl:with-param name="codes">abce</xsl:with-param>
1291                                         </xsl:call-template>
1292                                 </extent>
1293                         </xsl:for-each>
1294                 </xsl:variable>
1295                 <xsl:if test="string-length(normalize-space($physicalDescription))">
1296                         <physicalDescription>
1297                                 <xsl:copy-of select="$physicalDescription"></xsl:copy-of>
1298                         </physicalDescription>
1299                 </xsl:if>
1300                 <xsl:for-each select="marc:datafield[@tag=520]">
1301                         <abstract>
1302                                 <xsl:call-template name="uri"></xsl:call-template>
1303                                 <xsl:call-template name="subfieldSelect">
1304                                         <xsl:with-param name="codes">ab</xsl:with-param>
1305                                 </xsl:call-template>
1306                         </abstract>
1307                 </xsl:for-each>
1308                 <xsl:for-each select="marc:datafield[@tag=505]">
1309                         <tableOfContents>
1310                                 <xsl:call-template name="uri"></xsl:call-template>
1311                                 <xsl:call-template name="subfieldSelect">
1312                                         <xsl:with-param name="codes">agrt</xsl:with-param>
1313                                 </xsl:call-template>
1314                         </tableOfContents>
1315                 </xsl:for-each>
1316                 <xsl:for-each select="marc:datafield[@tag=521]">
1317                         <targetAudience>
1318                                 <xsl:call-template name="subfieldSelect">
1319                                         <xsl:with-param name="codes">ab</xsl:with-param>
1320                                 </xsl:call-template>
1321                         </targetAudience>
1322                 </xsl:for-each>
1323                 <xsl:if test="$typeOf008='BK' or $typeOf008='CF' or $typeOf008='MU' or $typeOf008='VM'">
1324                         <xsl:variable name="controlField008-22" select="substring($controlField008,23,1)"></xsl:variable>
1325                         <xsl:choose>
1326                                 <!-- 01/04 fix -->
1327                                 <xsl:when test="$controlField008-22='d'">
1328                                         <targetAudience authority="marctarget">adolescent</targetAudience>
1329                                 </xsl:when>
1330                                 <xsl:when test="$controlField008-22='e'">
1331                                         <targetAudience authority="marctarget">adult</targetAudience>
1332                                 </xsl:when>
1333                                 <xsl:when test="$controlField008-22='g'">
1334                                         <targetAudience authority="marctarget">general</targetAudience>
1335                                 </xsl:when>
1336                                 <xsl:when test="$controlField008-22='b' or $controlField008-22='c' or $controlField008-22='j'">
1337                                         <targetAudience authority="marctarget">juvenile</targetAudience>
1338                                 </xsl:when>
1339                                 <xsl:when test="$controlField008-22='a'">
1340                                         <targetAudience authority="marctarget">preschool</targetAudience>
1341                                 </xsl:when>
1342                                 <xsl:when test="$controlField008-22='f'">
1343                                         <targetAudience authority="marctarget">specialized</targetAudience>
1344                                 </xsl:when>
1345                         </xsl:choose>
1346                 </xsl:if>
1347                 <xsl:for-each select="marc:datafield[@tag=245]/marc:subfield[@code='c']">
1348                         <note type="statement of responsibility">
1349                                 <xsl:value-of select="."></xsl:value-of>
1350                         </note>
1351                 </xsl:for-each>
1352                 <xsl:for-each select="marc:datafield[@tag=500]">
1353                         <note>
1354                                 <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
1355                                 <xsl:call-template name="uri"></xsl:call-template>
1356                         </note>
1357                 </xsl:for-each>
1358
1359                 <!--3.2 change tmee additional note fields-->
1360
1361                 <xsl:for-each select="marc:datafield[@tag=506]">
1362                         <note type="restrictions">
1363                                 <xsl:call-template name="uri"></xsl:call-template>
1364                                 <xsl:variable name="str">
1365                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
1366                                                 <xsl:value-of select="."></xsl:value-of>
1367                                                 <xsl:text> </xsl:text>
1368                                         </xsl:for-each>
1369                                 </xsl:variable>
1370                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
1371                         </note>
1372                 </xsl:for-each>
1373
1374                 <xsl:for-each select="marc:datafield[@tag=510]">
1375                         <note  type="citation/reference">
1376                                 <xsl:call-template name="uri"></xsl:call-template>
1377                                 <xsl:variable name="str">
1378                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
1379                                                 <xsl:value-of select="."></xsl:value-of>
1380                                                 <xsl:text> </xsl:text>
1381                                         </xsl:for-each>
1382                                 </xsl:variable>
1383                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
1384                         </note>
1385                 </xsl:for-each>
1386
1387
1388                 <xsl:for-each select="marc:datafield[@tag=511]">
1389                         <note type="performers">
1390                                 <xsl:call-template name="uri"></xsl:call-template>
1391                                 <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
1392                         </note>
1393                 </xsl:for-each>
1394                 <xsl:for-each select="marc:datafield[@tag=518]">
1395                         <note type="venue">
1396                                 <xsl:call-template name="uri"></xsl:call-template>
1397                                 <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
1398                         </note>
1399                 </xsl:for-each>
1400
1401                 <xsl:for-each select="marc:datafield[@tag=530]">
1402                         <note  type="additional physical form">
1403                                 <xsl:call-template name="uri"></xsl:call-template>
1404                                 <xsl:variable name="str">
1405                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
1406                                                 <xsl:value-of select="."></xsl:value-of>
1407                                                 <xsl:text> </xsl:text>
1408                                         </xsl:for-each>
1409                                 </xsl:variable>
1410                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
1411                         </note>
1412                 </xsl:for-each>
1413
1414                 <xsl:for-each select="marc:datafield[@tag=533]">
1415                         <note  type="reproduction">
1416                                 <xsl:call-template name="uri"></xsl:call-template>
1417                                 <xsl:variable name="str">
1418                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
1419                                                 <xsl:value-of select="."></xsl:value-of>
1420                                                 <xsl:text> </xsl:text>
1421                                         </xsl:for-each>
1422                                 </xsl:variable>
1423                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
1424                         </note>
1425                 </xsl:for-each>
1426
1427                 <xsl:for-each select="marc:datafield[@tag=534]">
1428                         <note  type="original version">
1429                                 <xsl:call-template name="uri"></xsl:call-template>
1430                                 <xsl:variable name="str">
1431                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
1432                                                 <xsl:value-of select="."></xsl:value-of>
1433                                                 <xsl:text> </xsl:text>
1434                                         </xsl:for-each>
1435                                 </xsl:variable>
1436                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
1437                         </note>
1438                 </xsl:for-each>
1439
1440                 <xsl:for-each select="marc:datafield[@tag=538]">
1441                         <note  type="system details">
1442                                 <xsl:call-template name="uri"></xsl:call-template>
1443                                 <xsl:variable name="str">
1444                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
1445                                                 <xsl:value-of select="."></xsl:value-of>
1446                                                 <xsl:text> </xsl:text>
1447                                         </xsl:for-each>
1448                                 </xsl:variable>
1449                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
1450                         </note>
1451                 </xsl:for-each>
1452
1453                 <xsl:for-each select="marc:datafield[@tag=583]">
1454                         <note type="action">
1455                                 <xsl:call-template name="uri"></xsl:call-template>
1456                                 <xsl:variable name="str">
1457                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
1458                                                 <xsl:value-of select="."></xsl:value-of>
1459                                                 <xsl:text> </xsl:text>
1460                                         </xsl:for-each>
1461                                 </xsl:variable>
1462                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
1463                         </note>
1464                 </xsl:for-each>
1465
1466
1467
1468
1469
1470                 <xsl:for-each select="marc:datafield[@tag=501 or @tag=502 or @tag=504 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=535 or @tag=536 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=584 or @tag=585 or @tag=586]">
1471                         <note>
1472                                 <xsl:call-template name="uri"></xsl:call-template>
1473                                 <xsl:variable name="str">
1474                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
1475                                                 <xsl:value-of select="."></xsl:value-of>
1476                                                 <xsl:text> </xsl:text>
1477                                         </xsl:for-each>
1478                                 </xsl:variable>
1479                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
1480                         </note>
1481                 </xsl:for-each>
1482                 <xsl:for-each select="marc:datafield[@tag=034][marc:subfield[@code='d' or @code='e' or @code='f' or @code='g']]">
1483                         <subject>
1484                                 <cartographics>
1485                                         <coordinates>
1486                                                 <xsl:call-template name="subfieldSelect">
1487                                                         <xsl:with-param name="codes">defg</xsl:with-param>
1488                                                 </xsl:call-template>
1489                                         </coordinates>
1490                                 </cartographics>
1491                         </subject>
1492                 </xsl:for-each>
1493                 <xsl:for-each select="marc:datafield[@tag=043]">
1494                         <subject>
1495                                 <xsl:for-each select="marc:subfield[@code='a' or @code='b' or @code='c']">
1496                                         <geographicCode>
1497                                                 <xsl:attribute name="authority">
1498                                                         <xsl:if test="@code='a'">
1499                                                                 <xsl:text>marcgac</xsl:text>
1500                                                         </xsl:if>
1501                                                         <xsl:if test="@code='b'">
1502                                                                 <xsl:value-of select="following-sibling::marc:subfield[@code=2]"></xsl:value-of>
1503                                                         </xsl:if>
1504                                                         <xsl:if test="@code='c'">
1505                                                                 <xsl:text>iso3166</xsl:text>
1506                                                         </xsl:if>
1507                                                 </xsl:attribute>
1508                                                 <xsl:value-of select="self::marc:subfield"></xsl:value-of>
1509                                         </geographicCode>
1510                                 </xsl:for-each>
1511                         </subject>
1512                 </xsl:for-each>
1513                 <!-- tmee 2006/11/27 -->
1514                 <xsl:for-each select="marc:datafield[@tag=255]">
1515                         <subject>
1516                                 <xsl:for-each select="marc:subfield[@code='a' or @code='b' or @code='c']">
1517                                 <cartographics>
1518                                         <xsl:if test="@code='a'">
1519                                                 <scale>
1520                                                         <xsl:value-of select="."></xsl:value-of>
1521                                                 </scale>
1522                                         </xsl:if>
1523                                         <xsl:if test="@code='b'">
1524                                                 <projection>
1525                                                         <xsl:value-of select="."></xsl:value-of>
1526                                                 </projection>
1527                                         </xsl:if>
1528                                         <xsl:if test="@code='c'">
1529                                                 <coordinates>
1530                                                         <xsl:value-of select="."></xsl:value-of>
1531                                                 </coordinates>
1532                                         </xsl:if>
1533                                 </cartographics>
1534                                 </xsl:for-each>
1535                         </subject>
1536                 </xsl:for-each>
1537
1538                 <xsl:apply-templates select="marc:datafield[653 >= @tag and @tag >= 600]"></xsl:apply-templates>
1539                 <xsl:apply-templates select="marc:datafield[@tag=656]"></xsl:apply-templates>
1540                 <xsl:for-each select="marc:datafield[@tag=752]">
1541                         <subject>
1542                                 <hierarchicalGeographic>
1543                                         <xsl:for-each select="marc:subfield[@code='a']">
1544                                                 <country>
1545                                                         <xsl:call-template name="chopPunctuation">
1546                                                                 <xsl:with-param name="chopString" select="."></xsl:with-param>
1547                                                         </xsl:call-template>
1548                                                 </country>
1549                                         </xsl:for-each>
1550                                         <xsl:for-each select="marc:subfield[@code='b']">
1551                                                 <state>
1552                                                         <xsl:call-template name="chopPunctuation">
1553                                                                 <xsl:with-param name="chopString" select="."></xsl:with-param>
1554                                                         </xsl:call-template>
1555                                                 </state>
1556                                         </xsl:for-each>
1557                                         <xsl:for-each select="marc:subfield[@code='c']">
1558                                                 <county>
1559                                                         <xsl:call-template name="chopPunctuation">
1560                                                                 <xsl:with-param name="chopString" select="."></xsl:with-param>
1561                                                         </xsl:call-template>
1562                                                 </county>
1563                                         </xsl:for-each>
1564                                         <xsl:for-each select="marc:subfield[@code='d']">
1565                                                 <city>
1566                                                         <xsl:call-template name="chopPunctuation">
1567                                                                 <xsl:with-param name="chopString" select="."></xsl:with-param>
1568                                                         </xsl:call-template>
1569                                                 </city>
1570                                         </xsl:for-each>
1571                                 </hierarchicalGeographic>
1572                         </subject>
1573                 </xsl:for-each>
1574                 <xsl:for-each select="marc:datafield[@tag=045][marc:subfield[@code='b']]">
1575                         <subject>
1576                                 <xsl:choose>
1577                                         <xsl:when test="@ind1=2">
1578                                                 <temporal encoding="iso8601" point="start">
1579                                                         <xsl:call-template name="chopPunctuation">
1580                                                                 <xsl:with-param name="chopString">
1581                                                                         <xsl:value-of select="marc:subfield[@code='b'][1]"></xsl:value-of>
1582                                                                 </xsl:with-param>
1583                                                         </xsl:call-template>
1584                                                 </temporal>
1585                                                 <temporal encoding="iso8601" point="end">
1586                                                         <xsl:call-template name="chopPunctuation">
1587                                                                 <xsl:with-param name="chopString">
1588                                                                         <xsl:value-of select="marc:subfield[@code='b'][2]"></xsl:value-of>
1589                                                                 </xsl:with-param>
1590                                                         </xsl:call-template>
1591                                                 </temporal>
1592                                         </xsl:when>
1593                                         <xsl:otherwise>
1594                                                 <xsl:for-each select="marc:subfield[@code='b']">
1595                                                         <temporal encoding="iso8601">
1596                                                                 <xsl:call-template name="chopPunctuation">
1597                                                                         <xsl:with-param name="chopString" select="."></xsl:with-param>
1598                                                                 </xsl:call-template>
1599                                                         </temporal>
1600                                                 </xsl:for-each>
1601                                         </xsl:otherwise>
1602                                 </xsl:choose>
1603                         </subject>
1604                 </xsl:for-each>
1605                 <xsl:for-each select="marc:datafield[@tag=050]">
1606                         <xsl:for-each select="marc:subfield[@code='b']">
1607                                 <classification authority="lcc">
1608                                         <xsl:if test="../marc:subfield[@code='3']">
1609                                                 <xsl:attribute name="displayLabel">
1610                                                         <xsl:value-of select="../marc:subfield[@code='3']"></xsl:value-of>
1611                                                 </xsl:attribute>
1612                                         </xsl:if>
1613                                         <xsl:value-of select="preceding-sibling::marc:subfield[@code='a'][1]"></xsl:value-of>
1614                                         <xsl:text> </xsl:text>
1615                                         <xsl:value-of select="text()"></xsl:value-of>
1616                                 </classification>
1617                         </xsl:for-each>
1618                         <xsl:for-each select="marc:subfield[@code='a'][not(following-sibling::marc:subfield[@code='b'])]">
1619                                 <classification authority="lcc">
1620                                         <xsl:if test="../marc:subfield[@code='3']">
1621                                                 <xsl:attribute name="displayLabel">
1622                                                         <xsl:value-of select="../marc:subfield[@code='3']"></xsl:value-of>
1623                                                 </xsl:attribute>
1624                                         </xsl:if>
1625                                         <xsl:value-of select="text()"></xsl:value-of>
1626                                 </classification>
1627                         </xsl:for-each>
1628                 </xsl:for-each>
1629                 <xsl:for-each select="marc:datafield[@tag=082]">
1630                         <classification authority="ddc">
1631                                 <xsl:if test="marc:subfield[@code='2']">
1632                                         <xsl:attribute name="edition">
1633                                                 <xsl:value-of select="marc:subfield[@code='2']"></xsl:value-of>
1634                                         </xsl:attribute>
1635                                 </xsl:if>
1636                                 <xsl:call-template name="subfieldSelect">
1637                                         <xsl:with-param name="codes">ab</xsl:with-param>
1638                                 </xsl:call-template>
1639                         </classification>
1640                 </xsl:for-each>
1641                 <xsl:for-each select="marc:datafield[@tag=080]">
1642                         <classification authority="udc">
1643                                 <xsl:call-template name="subfieldSelect">
1644                                         <xsl:with-param name="codes">abx</xsl:with-param>
1645                                 </xsl:call-template>
1646                         </classification>
1647                 </xsl:for-each>
1648                 <xsl:for-each select="marc:datafield[@tag=060]">
1649                         <classification authority="nlm">
1650                                 <xsl:call-template name="subfieldSelect">
1651                                         <xsl:with-param name="codes">ab</xsl:with-param>
1652                                 </xsl:call-template>
1653                         </classification>
1654                 </xsl:for-each>
1655                 <xsl:for-each select="marc:datafield[@tag=086][@ind1=0]">
1656                         <classification authority="sudocs">
1657                                 <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
1658                         </classification>
1659                 </xsl:for-each>
1660                 <xsl:for-each select="marc:datafield[@tag=086][@ind1=1]">
1661                         <classification authority="candoc">
1662                                 <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
1663                         </classification>
1664                 </xsl:for-each>
1665                 <xsl:for-each select="marc:datafield[@tag=086]">
1666                         <classification>
1667                                 <xsl:attribute name="authority">
1668                                         <xsl:value-of select="marc:subfield[@code='2']"></xsl:value-of>
1669                                 </xsl:attribute>
1670                                 <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
1671                         </classification>
1672                 </xsl:for-each>
1673                 <xsl:for-each select="marc:datafield[@tag=084]">
1674                         <classification>
1675                                 <xsl:attribute name="authority">
1676                                         <xsl:value-of select="marc:subfield[@code='2']"></xsl:value-of>
1677                                 </xsl:attribute>
1678                                 <xsl:call-template name="subfieldSelect">
1679                                         <xsl:with-param name="codes">ab</xsl:with-param>
1680                                 </xsl:call-template>
1681                         </classification>
1682                 </xsl:for-each>
1683                 <xsl:for-each select="marc:datafield[@tag=440]">
1684                         <relatedItem type="series">
1685                                 <xsl:variable name="titleChop">
1686                                         <xsl:call-template name="chopPunctuation">
1687                                                 <xsl:with-param name="chopString">
1688                                                         <xsl:call-template name="subfieldSelect">
1689                                                                 <xsl:with-param name="codes">av</xsl:with-param>
1690                                                         </xsl:call-template>
1691                                                 </xsl:with-param>
1692                                         </xsl:call-template>
1693                                 </xsl:variable>
1694                                 <titleInfo>
1695                                         <title>
1696                                                 <xsl:value-of select="$titleChop" />
1697                                         </title>
1698                                         <xsl:call-template name="part"></xsl:call-template>
1699                                 </titleInfo>
1700                                 <titleInfo type="nfi">
1701                                         <xsl:choose>
1702                                                 <xsl:when test="@ind2>0">
1703                                                         <nonSort>
1704                                                                 <xsl:value-of select="substring($titleChop,1,@ind2)"/>
1705                                                         </nonSort>
1706                                                         <title>
1707                                                                 <xsl:value-of select="substring($titleChop,@ind2+1)"/>
1708                                                         </title>
1709                                                         <xsl:call-template name="part"/>
1710                                                 </xsl:when>
1711                                                 <xsl:otherwise>
1712                                                         <title>
1713                                                                 <xsl:value-of select="$titleChop" />
1714                                                         </title>
1715                                                 </xsl:otherwise>
1716                                         </xsl:choose>
1717                                         <xsl:call-template name="part"></xsl:call-template>
1718                                 </titleInfo>
1719                         </relatedItem>
1720                 </xsl:for-each>
1721                 <xsl:for-each select="marc:datafield[@tag=490][@ind1=0]">
1722                         <relatedItem type="series">
1723                                 <titleInfo>
1724                                         <title>
1725                                                 <xsl:call-template name="chopPunctuation">
1726                                                         <xsl:with-param name="chopString">
1727                                                                 <xsl:call-template name="subfieldSelect">
1728                                                                         <xsl:with-param name="codes">av</xsl:with-param>
1729                                                                 </xsl:call-template>
1730                                                         </xsl:with-param>
1731                                                 </xsl:call-template>
1732                                         </title>
1733                                         <xsl:call-template name="part"></xsl:call-template>
1734                                 </titleInfo>
1735                         </relatedItem>
1736                 </xsl:for-each>
1737                 <xsl:for-each select="marc:datafield[@tag=510]">
1738                         <relatedItem type="isReferencedBy">
1739                                 <note>
1740                                         <xsl:call-template name="subfieldSelect">
1741                                                 <xsl:with-param name="codes">abcx3</xsl:with-param>
1742                                         </xsl:call-template>
1743                                 </note>
1744                         </relatedItem>
1745                 </xsl:for-each>
1746                 <xsl:for-each select="marc:datafield[@tag=534]">
1747                         <relatedItem type="original">
1748                                 <xsl:call-template name="relatedTitle"></xsl:call-template>
1749                                 <xsl:call-template name="relatedName"></xsl:call-template>
1750                                 <xsl:if test="marc:subfield[@code='b' or @code='c']">
1751                                         <originInfo>
1752                                                 <xsl:for-each select="marc:subfield[@code='c']">
1753                                                         <publisher>
1754                                                                 <xsl:value-of select="."></xsl:value-of>
1755                                                         </publisher>
1756                                                 </xsl:for-each>
1757                                                 <xsl:for-each select="marc:subfield[@code='b']">
1758                                                         <edition>
1759                                                                 <xsl:value-of select="."></xsl:value-of>
1760                                                         </edition>
1761                                                 </xsl:for-each>
1762                                         </originInfo>
1763                                 </xsl:if>
1764                                 <xsl:call-template name="relatedIdentifierISSN"></xsl:call-template>
1765                                 <xsl:for-each select="marc:subfield[@code='z']">
1766                                         <identifier type="isbn">
1767                                                 <xsl:value-of select="."></xsl:value-of>
1768                                         </identifier>
1769                                 </xsl:for-each>
1770                                 <xsl:call-template name="relatedNote"></xsl:call-template>
1771                         </relatedItem>
1772                 </xsl:for-each>
1773                 <xsl:for-each select="marc:datafield[@tag=700][marc:subfield[@code='t']]">
1774                         <relatedItem>
1775                                 <xsl:call-template name="constituentOrRelatedType"></xsl:call-template>
1776                                 <titleInfo>
1777                                         <title>
1778                                                 <xsl:call-template name="chopPunctuation">
1779                                                         <xsl:with-param name="chopString">
1780                                                                 <xsl:call-template name="specialSubfieldSelect">
1781                                                                         <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
1782                                                                         <xsl:with-param name="axis">t</xsl:with-param>
1783                                                                         <xsl:with-param name="afterCodes">g</xsl:with-param>
1784                                                                 </xsl:call-template>
1785                                                         </xsl:with-param>
1786                                                 </xsl:call-template>
1787                                         </title>
1788                                         <xsl:call-template name="part"></xsl:call-template>
1789                                 </titleInfo>
1790                                 <name type="personal">
1791                                         <namePart>
1792                                                 <xsl:call-template name="specialSubfieldSelect">
1793                                                         <xsl:with-param name="anyCodes">aq</xsl:with-param>
1794                                                         <xsl:with-param name="axis">t</xsl:with-param>
1795                                                         <xsl:with-param name="beforeCodes">g</xsl:with-param>
1796                                                 </xsl:call-template>
1797                                         </namePart>
1798                                         <xsl:call-template name="termsOfAddress"></xsl:call-template>
1799                                         <xsl:call-template name="nameDate"></xsl:call-template>
1800                                         <xsl:call-template name="role"></xsl:call-template>
1801                                 </name>
1802                                 <xsl:call-template name="relatedForm"></xsl:call-template>
1803                                 <xsl:call-template name="relatedIdentifierISSN"></xsl:call-template>
1804                         </relatedItem>
1805                 </xsl:for-each>
1806                 <xsl:for-each select="marc:datafield[@tag=710][marc:subfield[@code='t']]">
1807                         <relatedItem>
1808                                 <xsl:call-template name="constituentOrRelatedType"></xsl:call-template>
1809                                 <titleInfo>
1810                                         <title>
1811                                                 <xsl:call-template name="chopPunctuation">
1812                                                         <xsl:with-param name="chopString">
1813                                                                 <xsl:call-template name="specialSubfieldSelect">
1814                                                                         <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
1815                                                                         <xsl:with-param name="axis">t</xsl:with-param>
1816                                                                         <xsl:with-param name="afterCodes">dg</xsl:with-param>
1817                                                                 </xsl:call-template>
1818                                                         </xsl:with-param>
1819                                                 </xsl:call-template>
1820                                         </title>
1821                                         <xsl:call-template name="relatedPartNumName"></xsl:call-template>
1822                                 </titleInfo>
1823                                 <name type="corporate">
1824                                         <xsl:for-each select="marc:subfield[@code='a']">
1825                                                 <namePart>
1826                                                         <xsl:value-of select="."></xsl:value-of>
1827                                                 </namePart>
1828                                         </xsl:for-each>
1829                                         <xsl:for-each select="marc:subfield[@code='b']">
1830                                                 <namePart>
1831                                                         <xsl:value-of select="."></xsl:value-of>
1832                                                 </namePart>
1833                                         </xsl:for-each>
1834                                         <xsl:variable name="tempNamePart">
1835                                                 <xsl:call-template name="specialSubfieldSelect">
1836                                                         <xsl:with-param name="anyCodes">c</xsl:with-param>
1837                                                         <xsl:with-param name="axis">t</xsl:with-param>
1838                                                         <xsl:with-param name="beforeCodes">dgn</xsl:with-param>
1839                                                 </xsl:call-template>
1840                                         </xsl:variable>
1841                                         <xsl:if test="normalize-space($tempNamePart)">
1842                                                 <namePart>
1843                                                         <xsl:value-of select="$tempNamePart"></xsl:value-of>
1844                                                 </namePart>
1845                                         </xsl:if>
1846                                         <xsl:call-template name="role"></xsl:call-template>
1847                                 </name>
1848                                 <xsl:call-template name="relatedForm"></xsl:call-template>
1849                                 <xsl:call-template name="relatedIdentifierISSN"></xsl:call-template>
1850                         </relatedItem>
1851                 </xsl:for-each>
1852                 <xsl:for-each select="marc:datafield[@tag=711][marc:subfield[@code='t']]">
1853                         <relatedItem>
1854                                 <xsl:call-template name="constituentOrRelatedType"></xsl:call-template>
1855                                 <titleInfo>
1856                                         <title>
1857                                                 <xsl:call-template name="chopPunctuation">
1858                                                         <xsl:with-param name="chopString">
1859                                                                 <xsl:call-template name="specialSubfieldSelect">
1860                                                                         <xsl:with-param name="anyCodes">tfklsv</xsl:with-param>
1861                                                                         <xsl:with-param name="axis">t</xsl:with-param>
1862                                                                         <xsl:with-param name="afterCodes">g</xsl:with-param>
1863                                                                 </xsl:call-template>
1864                                                         </xsl:with-param>
1865                                                 </xsl:call-template>
1866                                         </title>
1867                                         <xsl:call-template name="relatedPartNumName"></xsl:call-template>
1868                                 </titleInfo>
1869                                 <name type="conference">
1870                                         <namePart>
1871                                                 <xsl:call-template name="specialSubfieldSelect">
1872                                                         <xsl:with-param name="anyCodes">aqdc</xsl:with-param>
1873                                                         <xsl:with-param name="axis">t</xsl:with-param>
1874                                                         <xsl:with-param name="beforeCodes">gn</xsl:with-param>
1875                                                 </xsl:call-template>
1876                                         </namePart>
1877                                 </name>
1878                                 <xsl:call-template name="relatedForm"></xsl:call-template>
1879                                 <xsl:call-template name="relatedIdentifierISSN"></xsl:call-template>
1880                         </relatedItem>
1881                 </xsl:for-each>
1882                 <xsl:for-each select="marc:datafield[@tag=730][@ind2=2]">
1883                         <relatedItem>
1884                                 <xsl:call-template name="constituentOrRelatedType"></xsl:call-template>
1885                                 <titleInfo>
1886                                         <title>
1887                                                 <xsl:call-template name="chopPunctuation">
1888                                                         <xsl:with-param name="chopString">
1889                                                                 <xsl:call-template name="subfieldSelect">
1890                                                                         <xsl:with-param name="codes">adfgklmorsv</xsl:with-param>
1891                                                                 </xsl:call-template>
1892                                                         </xsl:with-param>
1893                                                 </xsl:call-template>
1894                                         </title>
1895                                         <xsl:call-template name="part"></xsl:call-template>
1896                                 </titleInfo>
1897                                 <xsl:call-template name="relatedForm"></xsl:call-template>
1898                                 <xsl:call-template name="relatedIdentifierISSN"></xsl:call-template>
1899                         </relatedItem>
1900                 </xsl:for-each>
1901                 <xsl:for-each select="marc:datafield[@tag=740][@ind2=2]">
1902                         <relatedItem>
1903                                 <xsl:call-template name="constituentOrRelatedType"></xsl:call-template>
1904                                 <xsl:variable name="titleChop">
1905                                         <xsl:call-template name="chopPunctuation">
1906                                                 <xsl:with-param name="chopString">
1907                                                         <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
1908                                                 </xsl:with-param>
1909                                         </xsl:call-template>
1910                                 </xsl:variable>
1911                                 <titleInfo>
1912                                         <title>
1913                                                 <xsl:value-of select="$titleChop" />
1914                                         </title>
1915                                         <xsl:call-template name="part"></xsl:call-template>
1916                                 </titleInfo>
1917                                 <titleInfo type="nfi">
1918                                         <xsl:choose>
1919                                                 <xsl:when test="@ind1>0">
1920                                                         <nonSort>
1921                                                                 <xsl:value-of select="substring($titleChop,1,@ind1)"/>
1922                                                         </nonSort>
1923                                                         <title>
1924                                                                 <xsl:value-of select="substring($titleChop,@ind1+1)"/>
1925                                                         </title>
1926                                                 </xsl:when>
1927                                                 <xsl:otherwise>
1928                                                         <title>
1929                                                                 <xsl:value-of select="$titleChop" />
1930                                                         </title>
1931                                                 </xsl:otherwise>
1932                                         </xsl:choose>
1933                                         <xsl:call-template name="part"></xsl:call-template>
1934                                 </titleInfo>
1935                                 <xsl:call-template name="relatedForm"></xsl:call-template>
1936                         </relatedItem>
1937                 </xsl:for-each>
1938                 <xsl:for-each select="marc:datafield[@tag=760]|marc:datafield[@tag=762]">
1939                         <relatedItem type="series">
1940                                 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
1941                         </relatedItem>
1942                 </xsl:for-each>
1943                 <xsl:for-each select="marc:datafield[@tag=765]|marc:datafield[@tag=767]|marc:datafield[@tag=777]|marc:datafield[@tag=787]">
1944                         <relatedItem>
1945                                 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
1946                         </relatedItem>
1947                 </xsl:for-each>
1948                 <xsl:for-each select="marc:datafield[@tag=775]">
1949                         <relatedItem type="otherVersion">
1950                                 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
1951                         </relatedItem>
1952                 </xsl:for-each>
1953                 <xsl:for-each select="marc:datafield[@tag=770]|marc:datafield[@tag=774]">
1954                         <relatedItem type="constituent">
1955                                 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
1956                         </relatedItem>
1957                 </xsl:for-each>
1958                 <xsl:for-each select="marc:datafield[@tag=772]|marc:datafield[@tag=773]">
1959                         <relatedItem type="host">
1960                                 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
1961                         </relatedItem>
1962                 </xsl:for-each>
1963                 <xsl:for-each select="marc:datafield[@tag=776]">
1964                         <relatedItem type="otherFormat">
1965                                 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
1966                         </relatedItem>
1967                 </xsl:for-each>
1968                 <xsl:for-each select="marc:datafield[@tag=780]">
1969                         <relatedItem type="preceding">
1970                                 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
1971                         </relatedItem>
1972                 </xsl:for-each>
1973                 <xsl:for-each select="marc:datafield[@tag=785]">
1974                         <relatedItem type="succeeding">
1975                                 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
1976                         </relatedItem>
1977                 </xsl:for-each>
1978                 <xsl:for-each select="marc:datafield[@tag=786]">
1979                         <relatedItem type="original">
1980                                 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
1981                         </relatedItem>
1982                 </xsl:for-each>
1983                 <xsl:for-each select="marc:datafield[@tag=800]">
1984                         <relatedItem type="series">
1985                                 <titleInfo>
1986                                         <title>
1987                                                 <xsl:call-template name="chopPunctuation">
1988                                                         <xsl:with-param name="chopString">
1989                                                                 <xsl:call-template name="specialSubfieldSelect">
1990                                                                         <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
1991                                                                         <xsl:with-param name="axis">t</xsl:with-param>
1992                                                                         <xsl:with-param name="afterCodes">g</xsl:with-param>
1993                                                                 </xsl:call-template>
1994                                                         </xsl:with-param>
1995                                                 </xsl:call-template>
1996                                         </title>
1997                                         <xsl:call-template name="part"></xsl:call-template>
1998                                 </titleInfo>
1999                                 <name type="personal">
2000                                         <namePart>
2001                                                 <xsl:call-template name="chopPunctuation">
2002                                                         <xsl:with-param name="chopString">
2003                                                                 <xsl:call-template name="specialSubfieldSelect">
2004                                                                         <xsl:with-param name="anyCodes">aq</xsl:with-param>
2005                                                                         <xsl:with-param name="axis">t</xsl:with-param>
2006                                                                         <xsl:with-param name="beforeCodes">g</xsl:with-param>
2007                                                                 </xsl:call-template>
2008                                                         </xsl:with-param>
2009                                                 </xsl:call-template>
2010                                         </namePart>
2011                                         <xsl:call-template name="termsOfAddress"></xsl:call-template>
2012                                         <xsl:call-template name="nameDate"></xsl:call-template>
2013                                         <xsl:call-template name="role"></xsl:call-template>
2014                                 </name>
2015                                 <xsl:call-template name="relatedForm"></xsl:call-template>
2016                         </relatedItem>
2017                 </xsl:for-each>
2018                 <xsl:for-each select="marc:datafield[@tag=810]">
2019                         <relatedItem type="series">
2020                                 <titleInfo>
2021                                         <title>
2022                                                 <xsl:call-template name="chopPunctuation">
2023                                                         <xsl:with-param name="chopString">
2024                                                                 <xsl:call-template name="specialSubfieldSelect">
2025                                                                         <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
2026                                                                         <xsl:with-param name="axis">t</xsl:with-param>
2027                                                                         <xsl:with-param name="afterCodes">dg</xsl:with-param>
2028                                                                 </xsl:call-template>
2029                                                         </xsl:with-param>
2030                                                 </xsl:call-template>
2031                                         </title>
2032                                         <xsl:call-template name="relatedPartNumName"></xsl:call-template>
2033                                 </titleInfo>
2034                                 <name type="corporate">
2035                                         <xsl:for-each select="marc:subfield[@code='a']">
2036                                                 <namePart>
2037                                                         <xsl:value-of select="."></xsl:value-of>
2038                                                 </namePart>
2039                                         </xsl:for-each>
2040                                         <xsl:for-each select="marc:subfield[@code='b']">
2041                                                 <namePart>
2042                                                         <xsl:value-of select="."></xsl:value-of>
2043                                                 </namePart>
2044                                         </xsl:for-each>
2045                                         <namePart>
2046                                                 <xsl:call-template name="specialSubfieldSelect">
2047                                                         <xsl:with-param name="anyCodes">c</xsl:with-param>
2048                                                         <xsl:with-param name="axis">t</xsl:with-param>
2049                                                         <xsl:with-param name="beforeCodes">dgn</xsl:with-param>
2050                                                 </xsl:call-template>
2051                                         </namePart>
2052                                         <xsl:call-template name="role"></xsl:call-template>
2053                                 </name>
2054                                 <xsl:call-template name="relatedForm"></xsl:call-template>
2055                         </relatedItem>
2056                 </xsl:for-each>
2057                 <xsl:for-each select="marc:datafield[@tag=811]">
2058                         <relatedItem type="series">
2059                                 <titleInfo>
2060                                         <title>
2061                                                 <xsl:call-template name="chopPunctuation">
2062                                                         <xsl:with-param name="chopString">
2063                                                                 <xsl:call-template name="specialSubfieldSelect">
2064                                                                         <xsl:with-param name="anyCodes">tfklsv</xsl:with-param>
2065                                                                         <xsl:with-param name="axis">t</xsl:with-param>
2066                                                                         <xsl:with-param name="afterCodes">g</xsl:with-param>
2067                                                                 </xsl:call-template>
2068                                                         </xsl:with-param>
2069                                                 </xsl:call-template>
2070                                         </title>
2071                                         <xsl:call-template name="relatedPartNumName"/>
2072                                 </titleInfo>
2073                                 <name type="conference">
2074                                         <namePart>
2075                                                 <xsl:call-template name="specialSubfieldSelect">
2076                                                         <xsl:with-param name="anyCodes">aqdc</xsl:with-param>
2077                                                         <xsl:with-param name="axis">t</xsl:with-param>
2078                                                         <xsl:with-param name="beforeCodes">gn</xsl:with-param>
2079                                                 </xsl:call-template>
2080                                         </namePart>
2081                                         <xsl:call-template name="role"/>
2082                                 </name>
2083                                 <xsl:call-template name="relatedForm"/>
2084                         </relatedItem>
2085                 </xsl:for-each>
2086                 <xsl:for-each select="marc:datafield[@tag='830']">
2087                         <relatedItem type="series">
2088                                 <xsl:variable name="titleChop">
2089                                         <xsl:call-template name="chopPunctuation">
2090                                                 <xsl:with-param name="chopString">
2091                                                         <xsl:call-template name="subfieldSelect">
2092                                                                 <xsl:with-param name="codes">adfgklmorsv</xsl:with-param>
2093                                                         </xsl:call-template>
2094                                                 </xsl:with-param>
2095                                         </xsl:call-template>
2096                                 </xsl:variable>
2097                                 <titleInfo>
2098                                         <title>
2099                                                 <xsl:value-of select="$titleChop" />
2100                                         </title>
2101                                         <xsl:call-template name="part"/>
2102                                 </titleInfo>
2103                                 <titleInfo type="nfi">
2104                                         <xsl:choose>
2105                                                 <xsl:when test="@ind2>0">
2106                                                         <nonSort>
2107                                                                 <xsl:value-of select="substring($titleChop,1,@ind2)"/>
2108                                                         </nonSort>
2109                                                         <title>
2110                                                                 <xsl:value-of select="substring($titleChop,@ind2+1)"/>
2111                                                         </title>
2112                                                 </xsl:when>
2113                                                 <xsl:otherwise>
2114                                                         <title>
2115                                                                 <xsl:value-of select="$titleChop" />
2116                                                         </title>
2117                                                 </xsl:otherwise>
2118                                         </xsl:choose>
2119                                         <xsl:call-template name="part"/>
2120                                 </titleInfo>
2121                                 <xsl:call-template name="relatedForm"/>
2122                         </relatedItem>
2123                 </xsl:for-each>
2124                 <xsl:for-each select="marc:datafield[@tag='856'][@ind2='2']/marc:subfield[@code='q']">
2125                         <relatedItem>
2126                                 <internetMediaType>
2127                                         <xsl:value-of select="."/>
2128                                 </internetMediaType>
2129                         </relatedItem>
2130                 </xsl:for-each>
2131                 <xsl:for-each select="marc:datafield[@tag='020']">
2132                         <xsl:call-template name="isInvalid">
2133                                 <xsl:with-param name="type">isbn</xsl:with-param>
2134                         </xsl:call-template>
2135                         <xsl:if test="marc:subfield[@code='a']">
2136                                 <identifier type="isbn">
2137                                         <xsl:value-of select="marc:subfield[@code='a']"/>
2138                                 </identifier>
2139                         </xsl:if>
2140                 </xsl:for-each>
2141                 <xsl:for-each select="marc:datafield[@tag='024'][@ind1='0']">
2142                         <xsl:call-template name="isInvalid">
2143                                 <xsl:with-param name="type">isrc</xsl:with-param>
2144                         </xsl:call-template>
2145                         <xsl:if test="marc:subfield[@code='a']">
2146                                 <identifier type="isrc">
2147                                         <xsl:value-of select="marc:subfield[@code='a']"/>
2148                                 </identifier>
2149                         </xsl:if>
2150                 </xsl:for-each>
2151                 <xsl:for-each select="marc:datafield[@tag='024'][@ind1='2']">
2152                         <xsl:call-template name="isInvalid">
2153                                 <xsl:with-param name="type">ismn</xsl:with-param>
2154                         </xsl:call-template>
2155                         <xsl:if test="marc:subfield[@code='a']">
2156                                 <identifier type="ismn">
2157                                         <xsl:value-of select="marc:subfield[@code='a']"/>
2158                                 </identifier>
2159                         </xsl:if>
2160                 </xsl:for-each>
2161                 <xsl:for-each select="marc:datafield[@tag='024'][@ind1='4']">
2162                         <xsl:call-template name="isInvalid">
2163                                 <xsl:with-param name="type">sici</xsl:with-param>
2164                         </xsl:call-template>
2165                         <identifier type="sici">
2166                                 <xsl:call-template name="subfieldSelect">
2167                                         <xsl:with-param name="codes">ab</xsl:with-param>
2168                                 </xsl:call-template>
2169                         </identifier>
2170                 </xsl:for-each>
2171                 <xsl:for-each select="marc:datafield[@tag='022']">
2172                         <xsl:call-template name="isInvalid">
2173                                 <xsl:with-param name="type">issn</xsl:with-param>
2174                         </xsl:call-template>
2175                         <identifier type="issn">
2176                                 <xsl:value-of select="marc:subfield[@code='a']"/>
2177                         </identifier>
2178                 </xsl:for-each>
2179                 <xsl:for-each select="marc:datafield[@tag='010']">
2180                         <xsl:call-template name="isInvalid">
2181                                 <xsl:with-param name="type">lccn</xsl:with-param>
2182                         </xsl:call-template>
2183                         <identifier type="lccn">
2184                                 <xsl:value-of select="normalize-space(marc:subfield[@code='a'])"/>
2185                         </identifier>
2186                 </xsl:for-each>
2187                 <xsl:for-each select="marc:datafield[@tag='028']">
2188                         <identifier>
2189                                 <xsl:attribute name="type">
2190                                         <xsl:choose>
2191                                                 <xsl:when test="@ind1='0'">issue number</xsl:when>
2192                                                 <xsl:when test="@ind1='1'">matrix number</xsl:when>
2193                                                 <xsl:when test="@ind1='2'">music plate</xsl:when>
2194                                                 <xsl:when test="@ind1='3'">music publisher</xsl:when>
2195                                                 <xsl:when test="@ind1='4'">videorecording identifier</xsl:when>
2196                                         </xsl:choose>
2197                                 </xsl:attribute>
2198                                 <!--<xsl:call-template name="isInvalid"/>--> <!-- no $z in 028 -->
2199                                 <xsl:call-template name="subfieldSelect">
2200                                         <xsl:with-param name="codes">
2201                                                 <xsl:choose>
2202                                                         <xsl:when test="@ind1='0'">ba</xsl:when>
2203                                                         <xsl:otherwise>ab</xsl:otherwise>
2204                                                 </xsl:choose>
2205                                         </xsl:with-param>
2206                                 </xsl:call-template>
2207                         </identifier>
2208                 </xsl:for-each>
2209                 <xsl:for-each select="marc:datafield[@tag='037']">
2210                         <identifier type="stock number">
2211                                 <!--<xsl:call-template name="isInvalid"/>--> <!-- no $z in 037 -->
2212                                 <xsl:call-template name="subfieldSelect">
2213                                         <xsl:with-param name="codes">ab</xsl:with-param>
2214                                 </xsl:call-template>
2215                         </identifier>
2216                 </xsl:for-each>
2217                 <xsl:for-each select="marc:datafield[@tag='856'][marc:subfield[@code='u']]">
2218                         <identifier>
2219                                 <xsl:attribute name="type">
2220                                         <xsl:choose>
2221                                                 <xsl:when test="starts-with(marc:subfield[@code='u'],'urn:doi') or starts-with(marc:subfield[@code='u'],'doi')">doi</xsl:when>
2222                                                 <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>
2223                                                 <xsl:otherwise>uri</xsl:otherwise>
2224                                         </xsl:choose>
2225                                 </xsl:attribute>
2226                                 <xsl:choose>
2227                                         <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') ">
2228                                                 <xsl:value-of select="concat('hdl:',substring-after(marc:subfield[@code='u'],'http://hdl.loc.gov/'))"></xsl:value-of>
2229                                         </xsl:when>
2230                                         <xsl:otherwise>
2231                                                 <xsl:value-of select="marc:subfield[@code='u']"></xsl:value-of>
2232                                         </xsl:otherwise>
2233                                 </xsl:choose>
2234                         </identifier>
2235                         <xsl:if test="starts-with(marc:subfield[@code='u'],'urn:hdl') or starts-with(marc:subfield[@code='u'],'hdl')">
2236                                 <identifier type="hdl">
2237                                         <xsl:if test="marc:subfield[@code='y' or @code='3' or @code='z']">
2238                                                 <xsl:attribute name="displayLabel">
2239                                                         <xsl:call-template name="subfieldSelect">
2240                                                                 <xsl:with-param name="codes">y3z</xsl:with-param>
2241                                                         </xsl:call-template>
2242                                                 </xsl:attribute>
2243                                         </xsl:if>
2244                                         <xsl:value-of select="concat('hdl:',substring-after(marc:subfield[@code='u'],'http://hdl.loc.gov/'))"></xsl:value-of>
2245                                 </identifier>
2246                         </xsl:if>
2247                 </xsl:for-each>
2248                 <xsl:for-each select="marc:datafield[@tag=024][@ind1=1]">
2249                         <identifier type="upc">
2250                                 <xsl:call-template name="isInvalid"/>
2251                                 <xsl:value-of select="marc:subfield[@code='a']"/>
2252                         </identifier>
2253                 </xsl:for-each>
2254                 <!-- 1/04 fix added $y -->
2255                 <xsl:for-each select="marc:datafield[@tag=856][marc:subfield[@code='u']]">
2256                         <location>
2257                                 <url>
2258                                         <xsl:if test="marc:subfield[@code='y' or @code='3']">
2259                                                 <xsl:attribute name="displayLabel">
2260                                                         <xsl:call-template name="subfieldSelect">
2261                                                                 <xsl:with-param name="codes">y3</xsl:with-param>
2262                                                         </xsl:call-template>
2263                                                 </xsl:attribute>
2264                                         </xsl:if>
2265                                         <xsl:if test="marc:subfield[@code='z' ]">
2266                                                 <xsl:attribute name="note">
2267                                                         <xsl:call-template name="subfieldSelect">
2268                                                                 <xsl:with-param name="codes">z</xsl:with-param>
2269                                                         </xsl:call-template>
2270                                                 </xsl:attribute>
2271                                         </xsl:if>
2272                                         <xsl:value-of select="marc:subfield[@code='u']"></xsl:value-of>
2273
2274                                 </url>
2275                         </location>
2276                 </xsl:for-each>
2277
2278                         <!-- 3.2 change tmee 856z  -->
2279
2280
2281                 <xsl:for-each select="marc:datafield[@tag=852]">
2282                         <location>
2283                                 <physicalLocation>
2284                                         <xsl:call-template name="displayLabel"></xsl:call-template>
2285                                         <xsl:call-template name="subfieldSelect">
2286                                                 <xsl:with-param name="codes">abje</xsl:with-param>
2287                                         </xsl:call-template>
2288                                 </physicalLocation>
2289                         </location>
2290                 </xsl:for-each>
2291                 <xsl:for-each select="marc:datafield[@tag=506]">
2292                         <accessCondition type="restrictionOnAccess">
2293                                 <xsl:call-template name="subfieldSelect">
2294                                         <xsl:with-param name="codes">abcd35</xsl:with-param>
2295                                 </xsl:call-template>
2296                         </accessCondition>
2297                 </xsl:for-each>
2298                 <xsl:for-each select="marc:datafield[@tag=540]">
2299                         <accessCondition type="useAndReproduction">
2300                                 <xsl:call-template name="subfieldSelect">
2301                                         <xsl:with-param name="codes">abcde35</xsl:with-param>
2302                                 </xsl:call-template>
2303                         </accessCondition>
2304                 </xsl:for-each>
2305                 <recordInfo>
2306                         <xsl:for-each select="marc:datafield[@tag=040]">
2307                                 <recordContentSource authority="marcorg">
2308                                         <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
2309                                 </recordContentSource>
2310                         </xsl:for-each>
2311                         <xsl:for-each select="marc:controlfield[@tag=008]">
2312                                 <recordCreationDate encoding="marc">
2313                                         <xsl:value-of select="substring(.,1,6)"></xsl:value-of>
2314                                 </recordCreationDate>
2315                         </xsl:for-each>
2316                         <xsl:for-each select="marc:controlfield[@tag=005]">
2317                                 <recordChangeDate encoding="iso8601">
2318                                         <xsl:value-of select="."></xsl:value-of>
2319                                 </recordChangeDate>
2320                         </xsl:for-each>
2321                         <xsl:for-each select="marc:controlfield[@tag=001]">
2322                                 <recordIdentifier>
2323                                         <xsl:if test="../marc:controlfield[@tag=003]">
2324                                                 <xsl:attribute name="source">
2325                                                         <xsl:value-of select="../marc:controlfield[@tag=003]"></xsl:value-of>
2326                                                 </xsl:attribute>
2327                                         </xsl:if>
2328                                         <xsl:value-of select="."></xsl:value-of>
2329                                 </recordIdentifier>
2330                         </xsl:for-each>
2331                         <xsl:for-each select="marc:datafield[@tag=040]/marc:subfield[@code='b']">
2332                                 <languageOfCataloging>
2333                                         <languageTerm authority="iso639-2b" type="code">
2334                                                 <xsl:value-of select="."></xsl:value-of>
2335                                         </languageTerm>
2336                                 </languageOfCataloging>
2337                         </xsl:for-each>
2338                 </recordInfo>
2339         </xsl:template>
2340         <xsl:template name="displayForm">
2341                 <xsl:for-each select="marc:subfield[@code='c']">
2342                         <displayForm>
2343                                 <xsl:value-of select="."></xsl:value-of>
2344                         </displayForm>
2345                 </xsl:for-each>
2346         </xsl:template>
2347         <xsl:template name="affiliation">
2348                 <xsl:for-each select="marc:subfield[@code='u']">
2349                         <affiliation>
2350                                 <xsl:value-of select="."></xsl:value-of>
2351                         </affiliation>
2352                 </xsl:for-each>
2353         </xsl:template>
2354         <xsl:template name="uri">
2355                 <xsl:for-each select="marc:subfield[@code='u']">
2356                         <xsl:attribute name="xlink:href">
2357                                 <xsl:value-of select="."></xsl:value-of>
2358                         </xsl:attribute>
2359                 </xsl:for-each>
2360                 <xsl:for-each select="marc:subfield[@code='0']">
2361                         <xsl:choose>
2362                                 <xsl:when test="contains(text(), ')')">
2363                                         <xsl:attribute name="xlink:href">
2364                                                 <xsl:value-of select="substring-after(text(), ')')"></xsl:value-of>
2365                                         </xsl:attribute>
2366                                 </xsl:when>
2367                                 <xsl:otherwise>
2368                                         <xsl:attribute name="xlink:href">
2369                                                 <xsl:value-of select="."></xsl:value-of>
2370                                         </xsl:attribute>
2371                                 </xsl:otherwise>
2372                         </xsl:choose>
2373                 </xsl:for-each>
2374         </xsl:template>
2375         <xsl:template name="role">
2376                 <xsl:for-each select="marc:subfield[@code='e']">
2377                         <role>
2378                                 <roleTerm type="text">
2379                                         <xsl:value-of select="."></xsl:value-of>
2380                                 </roleTerm>
2381                         </role>
2382                 </xsl:for-each>
2383                 <xsl:for-each select="marc:subfield[@code='4']">
2384                         <role>
2385                                 <roleTerm authority="marcrelator" type="code">
2386                                         <xsl:value-of select="."></xsl:value-of>
2387                                 </roleTerm>
2388                         </role>
2389                 </xsl:for-each>
2390         </xsl:template>
2391         <xsl:template name="part">
2392                 <xsl:variable name="partNumber">
2393                         <xsl:call-template name="specialSubfieldSelect">
2394                                 <xsl:with-param name="axis">n</xsl:with-param>
2395                                 <xsl:with-param name="anyCodes">n</xsl:with-param>
2396                                 <xsl:with-param name="afterCodes">fgkdlmor</xsl:with-param>
2397                         </xsl:call-template>
2398                 </xsl:variable>
2399                 <xsl:variable name="partName">
2400                         <xsl:call-template name="specialSubfieldSelect">
2401                                 <xsl:with-param name="axis">p</xsl:with-param>
2402                                 <xsl:with-param name="anyCodes">p</xsl:with-param>
2403                                 <xsl:with-param name="afterCodes">fgkdlmor</xsl:with-param>
2404                         </xsl:call-template>
2405                 </xsl:variable>
2406                 <xsl:if test="string-length(normalize-space($partNumber))">
2407                         <partNumber>
2408                                 <xsl:call-template name="chopPunctuation">
2409                                         <xsl:with-param name="chopString" select="$partNumber"></xsl:with-param>
2410                                 </xsl:call-template>
2411                         </partNumber>
2412                 </xsl:if>
2413                 <xsl:if test="string-length(normalize-space($partName))">
2414                         <partName>
2415                                 <xsl:call-template name="chopPunctuation">
2416                                         <xsl:with-param name="chopString" select="$partName"></xsl:with-param>
2417                                 </xsl:call-template>
2418                         </partName>
2419                 </xsl:if>
2420         </xsl:template>
2421         <xsl:template name="relatedPart">
2422                 <xsl:if test="@tag=773">
2423                         <xsl:for-each select="marc:subfield[@code='g']">
2424                                 <part>
2425                                         <text>
2426                                                 <xsl:value-of select="."></xsl:value-of>
2427                                         </text>
2428                                 </part>
2429                         </xsl:for-each>
2430                         <xsl:for-each select="marc:subfield[@code='q']">
2431                                 <part>
2432                                         <xsl:call-template name="parsePart"></xsl:call-template>
2433                                 </part>
2434                         </xsl:for-each>
2435                 </xsl:if>
2436         </xsl:template>
2437         <xsl:template name="relatedPartNumName">
2438                 <xsl:variable name="partNumber">
2439                         <xsl:call-template name="specialSubfieldSelect">
2440                                 <xsl:with-param name="axis">g</xsl:with-param>
2441                                 <xsl:with-param name="anyCodes">g</xsl:with-param>
2442                                 <xsl:with-param name="afterCodes">pst</xsl:with-param>
2443                         </xsl:call-template>
2444                 </xsl:variable>
2445                 <xsl:variable name="partName">
2446                         <xsl:call-template name="specialSubfieldSelect">
2447                                 <xsl:with-param name="axis">p</xsl:with-param>
2448                                 <xsl:with-param name="anyCodes">p</xsl:with-param>
2449                                 <xsl:with-param name="afterCodes">fgkdlmor</xsl:with-param>
2450                         </xsl:call-template>
2451                 </xsl:variable>
2452                 <xsl:if test="string-length(normalize-space($partNumber))">
2453                         <partNumber>
2454                                 <xsl:value-of select="$partNumber"></xsl:value-of>
2455                         </partNumber>
2456                 </xsl:if>
2457                 <xsl:if test="string-length(normalize-space($partName))">
2458                         <partName>
2459                                 <xsl:value-of select="$partName"></xsl:value-of>
2460                         </partName>
2461                 </xsl:if>
2462         </xsl:template>
2463         <xsl:template name="relatedName">
2464                 <xsl:for-each select="marc:subfield[@code='a']">
2465                         <name>
2466                                 <namePart>
2467                                         <xsl:value-of select="."></xsl:value-of>
2468                                 </namePart>
2469                         </name>
2470                 </xsl:for-each>
2471         </xsl:template>
2472         <xsl:template name="relatedForm">
2473                 <xsl:for-each select="marc:subfield[@code='h']">
2474                         <physicalDescription>
2475                                 <form>
2476                                         <xsl:value-of select="."></xsl:value-of>
2477                                 </form>
2478                         </physicalDescription>
2479                 </xsl:for-each>
2480         </xsl:template>
2481         <xsl:template name="relatedExtent">
2482                 <xsl:for-each select="marc:subfield[@code='h']">
2483                         <physicalDescription>
2484                                 <extent>
2485                                         <xsl:value-of select="."></xsl:value-of>
2486                                 </extent>
2487                         </physicalDescription>
2488                 </xsl:for-each>
2489         </xsl:template>
2490         <xsl:template name="relatedNote">
2491                 <xsl:for-each select="marc:subfield[@code='n']">
2492                         <note>
2493                                 <xsl:value-of select="."></xsl:value-of>
2494                         </note>
2495                 </xsl:for-each>
2496         </xsl:template>
2497         <xsl:template name="relatedSubject">
2498                 <xsl:for-each select="marc:subfield[@code='j']">
2499                         <subject>
2500                                 <temporal encoding="iso8601">
2501                                         <xsl:call-template name="chopPunctuation">
2502                                                 <xsl:with-param name="chopString" select="."></xsl:with-param>
2503                                         </xsl:call-template>
2504                                 </temporal>
2505                         </subject>
2506                 </xsl:for-each>
2507         </xsl:template>
2508         <xsl:template name="relatedIdentifierISSN">
2509                 <xsl:for-each select="marc:subfield[@code='x']">
2510                         <identifier type="issn">
2511                                 <xsl:value-of select="."></xsl:value-of>
2512                         </identifier>
2513                 </xsl:for-each>
2514         </xsl:template>
2515         <xsl:template name="relatedIdentifierLocal">
2516                 <xsl:for-each select="marc:subfield[@code='w']">
2517                         <identifier type="local">
2518                                 <xsl:value-of select="."></xsl:value-of>
2519                         </identifier>
2520                 </xsl:for-each>
2521         </xsl:template>
2522         <xsl:template name="relatedIdentifier">
2523                 <xsl:for-each select="marc:subfield[@code='o']">
2524                         <identifier>
2525                                 <xsl:value-of select="."></xsl:value-of>
2526                         </identifier>
2527                 </xsl:for-each>
2528         </xsl:template>
2529         <xsl:template name="relatedItem76X-78X">
2530                 <xsl:call-template name="displayLabel"></xsl:call-template>
2531                 <xsl:call-template name="relatedTitle76X-78X"></xsl:call-template>
2532                 <xsl:call-template name="relatedName"></xsl:call-template>
2533                 <xsl:call-template name="relatedOriginInfo"></xsl:call-template>
2534                 <xsl:call-template name="relatedLanguage"></xsl:call-template>
2535                 <xsl:call-template name="relatedExtent"></xsl:call-template>
2536                 <xsl:call-template name="relatedNote"></xsl:call-template>
2537                 <xsl:call-template name="relatedSubject"></xsl:call-template>
2538                 <xsl:call-template name="relatedIdentifier"></xsl:call-template>
2539                 <xsl:call-template name="relatedIdentifierISSN"></xsl:call-template>
2540                 <xsl:call-template name="relatedIdentifierLocal"></xsl:call-template>
2541                 <xsl:call-template name="relatedPart"></xsl:call-template>
2542         </xsl:template>
2543         <xsl:template name="subjectGeographicZ">
2544                 <geographic>
2545                         <xsl:call-template name="chopPunctuation">
2546                                 <xsl:with-param name="chopString" select="."></xsl:with-param>
2547                         </xsl:call-template>
2548                 </geographic>
2549         </xsl:template>
2550         <xsl:template name="subjectTemporalY">
2551                 <temporal>
2552                         <xsl:call-template name="chopPunctuation">
2553                                 <xsl:with-param name="chopString" select="."></xsl:with-param>
2554                         </xsl:call-template>
2555                 </temporal>
2556         </xsl:template>
2557         <xsl:template name="subjectTopic">
2558                 <topic>
2559                         <xsl:call-template name="chopPunctuation">
2560                                 <xsl:with-param name="chopString" select="."></xsl:with-param>
2561                         </xsl:call-template>
2562                 </topic>
2563         </xsl:template>
2564         <!-- 3.2 change tmee 6xx $v genre -->
2565         <xsl:template name="subjectGenre">
2566                 <genre>
2567                         <xsl:call-template name="chopPunctuation">
2568                                 <xsl:with-param name="chopString" select="."></xsl:with-param>
2569                         </xsl:call-template>
2570                 </genre>
2571         </xsl:template>
2572
2573         <xsl:template name="nameABCDN">
2574                 <xsl:for-each select="marc:subfield[@code='a']">
2575                         <namePart>
2576                                 <xsl:call-template name="chopPunctuation">
2577                                         <xsl:with-param name="chopString" select="."></xsl:with-param>
2578                                 </xsl:call-template>
2579                         </namePart>
2580                 </xsl:for-each>
2581                 <xsl:for-each select="marc:subfield[@code='b']">
2582                         <namePart>
2583                                 <xsl:value-of select="."></xsl:value-of>
2584                         </namePart>
2585                 </xsl:for-each>
2586                 <xsl:if test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">
2587                         <namePart>
2588                                 <xsl:call-template name="subfieldSelect">
2589                                         <xsl:with-param name="codes">cdn</xsl:with-param>
2590                                 </xsl:call-template>
2591                         </namePart>
2592                 </xsl:if>
2593         </xsl:template>
2594         <xsl:template name="nameABCDQ">
2595                 <namePart>
2596                         <xsl:call-template name="chopPunctuation">
2597                                 <xsl:with-param name="chopString">
2598                                         <xsl:call-template name="subfieldSelect">
2599                                                 <xsl:with-param name="codes">aq</xsl:with-param>
2600                                         </xsl:call-template>
2601                                 </xsl:with-param>
2602                                 <xsl:with-param name="punctuation">
2603                                         <xsl:text>:,;/ </xsl:text>
2604                                 </xsl:with-param>
2605                         </xsl:call-template>
2606                 </namePart>
2607                 <xsl:call-template name="termsOfAddress"></xsl:call-template>
2608                 <xsl:call-template name="nameDate"></xsl:call-template>
2609         </xsl:template>
2610         <xsl:template name="nameACDEQ">
2611                 <namePart>
2612                         <xsl:call-template name="subfieldSelect">
2613                                 <xsl:with-param name="codes">acdeq</xsl:with-param>
2614                         </xsl:call-template>
2615                 </namePart>
2616         </xsl:template>
2617         <xsl:template name="constituentOrRelatedType">
2618                 <xsl:if test="@ind2=2">
2619                         <xsl:attribute name="type">constituent</xsl:attribute>
2620                 </xsl:if>
2621         </xsl:template>
2622         <xsl:template name="relatedTitle">
2623                 <xsl:for-each select="marc:subfield[@code='t']">
2624                         <titleInfo>
2625                                 <title>
2626                                         <xsl:call-template name="chopPunctuation">
2627                                                 <xsl:with-param name="chopString">
2628                                                         <xsl:value-of select="."></xsl:value-of>
2629                                                 </xsl:with-param>
2630                                         </xsl:call-template>
2631                                 </title>
2632                         </titleInfo>
2633                 </xsl:for-each>
2634         </xsl:template>
2635         <xsl:template name="relatedTitle76X-78X">
2636                 <xsl:for-each select="marc:subfield[@code='t']">
2637                         <titleInfo>
2638                                 <title>
2639                                         <xsl:call-template name="chopPunctuation">
2640                                                 <xsl:with-param name="chopString">
2641                                                         <xsl:value-of select="."></xsl:value-of>
2642                                                 </xsl:with-param>
2643                                         </xsl:call-template>
2644                                 </title>
2645                                 <xsl:if test="marc:datafield[@tag!=773]and marc:subfield[@code='g']">
2646                                         <xsl:call-template name="relatedPartNumName"></xsl:call-template>
2647                                 </xsl:if>
2648                         </titleInfo>
2649                 </xsl:for-each>
2650                 <xsl:for-each select="marc:subfield[@code='p']">
2651                         <titleInfo type="abbreviated">
2652                                 <title>
2653                                         <xsl:call-template name="chopPunctuation">
2654                                                 <xsl:with-param name="chopString">
2655                                                         <xsl:value-of select="."></xsl:value-of>
2656                                                 </xsl:with-param>
2657                                         </xsl:call-template>
2658                                 </title>
2659                                 <xsl:if test="marc:datafield[@tag!=773]and marc:subfield[@code='g']">
2660                                         <xsl:call-template name="relatedPartNumName"></xsl:call-template>
2661                                 </xsl:if>
2662                         </titleInfo>
2663                 </xsl:for-each>
2664                 <xsl:for-each select="marc:subfield[@code='s']">
2665                         <titleInfo type="uniform">
2666                                 <title>
2667                                         <xsl:call-template name="chopPunctuation">
2668                                                 <xsl:with-param name="chopString">
2669                                                         <xsl:value-of select="."></xsl:value-of>
2670                                                 </xsl:with-param>
2671                                         </xsl:call-template>
2672                                 </title>
2673                                 <xsl:if test="marc:datafield[@tag!=773]and marc:subfield[@code='g']">
2674                                         <xsl:call-template name="relatedPartNumName"></xsl:call-template>
2675                                 </xsl:if>
2676                         </titleInfo>
2677                 </xsl:for-each>
2678         </xsl:template>
2679         <xsl:template name="relatedOriginInfo">
2680                 <xsl:if test="marc:subfield[@code='b' or @code='d'] or marc:subfield[@code='f']">
2681                         <originInfo>
2682                                 <xsl:if test="@tag=775">
2683                                         <xsl:for-each select="marc:subfield[@code='f']">
2684                                                 <place>
2685                                                         <placeTerm>
2686                                                                 <xsl:attribute name="type">code</xsl:attribute>
2687                                                                 <xsl:attribute name="authority">marcgac</xsl:attribute>
2688                                                                 <xsl:value-of select="."></xsl:value-of>
2689                                                         </placeTerm>
2690                                                 </place>
2691                                         </xsl:for-each>
2692                                 </xsl:if>
2693                                 <xsl:for-each select="marc:subfield[@code='d']">
2694                                         <publisher>
2695                                                 <xsl:value-of select="."></xsl:value-of>
2696                                         </publisher>
2697                                 </xsl:for-each>
2698                                 <xsl:for-each select="marc:subfield[@code='b']">
2699                                         <edition>
2700                                                 <xsl:value-of select="."></xsl:value-of>
2701                                         </edition>
2702                                 </xsl:for-each>
2703                         </originInfo>
2704                 </xsl:if>
2705         </xsl:template>
2706         <xsl:template name="relatedLanguage">
2707                 <xsl:for-each select="marc:subfield[@code='e']">
2708                         <xsl:call-template name="getLanguage">
2709                                 <xsl:with-param name="langString">
2710                                         <xsl:value-of select="."></xsl:value-of>
2711                                 </xsl:with-param>
2712                         </xsl:call-template>
2713                 </xsl:for-each>
2714         </xsl:template>
2715         <xsl:template name="nameDate">
2716                 <xsl:for-each select="marc:subfield[@code='d']">
2717                         <namePart type="date">
2718                                 <xsl:call-template name="chopPunctuation">
2719                                         <xsl:with-param name="chopString" select="."></xsl:with-param>
2720                                 </xsl:call-template>
2721                         </namePart>
2722                 </xsl:for-each>
2723         </xsl:template>
2724         <xsl:template name="subjectAuthority">
2725                 <xsl:if test="@ind2!=4">
2726                         <xsl:if test="@ind2!=' '">
2727                                 <xsl:if test="@ind2!=8">
2728                                         <xsl:if test="@ind2!=9">
2729                                                 <xsl:attribute name="authority">
2730                                                         <xsl:choose>
2731                                                                 <xsl:when test="@ind2=0">lcsh</xsl:when>
2732                                                                 <xsl:when test="@ind2=1">lcshac</xsl:when>
2733                                                                 <xsl:when test="@ind2=2">mesh</xsl:when>
2734                                                                 <!-- 1/04 fix -->
2735                                                                 <xsl:when test="@ind2=3">nal</xsl:when>
2736                                                                 <xsl:when test="@ind2=5">csh</xsl:when>
2737                                                                 <xsl:when test="@ind2=6">rvm</xsl:when>
2738                                                                 <xsl:when test="@ind2=7">
2739                                                                         <xsl:value-of select="marc:subfield[@code='2']"></xsl:value-of>
2740                                                                 </xsl:when>
2741                                                         </xsl:choose>
2742                                                 </xsl:attribute>
2743                                         </xsl:if>
2744                                 </xsl:if>
2745                         </xsl:if>
2746                 </xsl:if>
2747         </xsl:template>
2748         <xsl:template name="subjectAnyOrder">
2749                 <xsl:for-each select="marc:subfield[@code='v' or @code='x' or @code='y' or @code='z']">
2750                         <xsl:choose>
2751                                 <xsl:when test="@code='v'">
2752                                         <xsl:call-template name="subjectGenre"></xsl:call-template>
2753                                 </xsl:when>
2754                                 <xsl:when test="@code='x'">
2755                                         <xsl:call-template name="subjectTopic"></xsl:call-template>
2756                                 </xsl:when>
2757                                 <xsl:when test="@code='y'">
2758                                         <xsl:call-template name="subjectTemporalY"></xsl:call-template>
2759                                 </xsl:when>
2760                                 <xsl:when test="@code='z'">
2761                                         <xsl:call-template name="subjectGeographicZ"></xsl:call-template>
2762                                 </xsl:when>
2763                         </xsl:choose>
2764                 </xsl:for-each>
2765         </xsl:template>
2766         <xsl:template name="specialSubfieldSelect">
2767                 <xsl:param name="anyCodes"></xsl:param>
2768                 <xsl:param name="axis"></xsl:param>
2769                 <xsl:param name="beforeCodes"></xsl:param>
2770                 <xsl:param name="afterCodes"></xsl:param>
2771                 <xsl:variable name="str">
2772                         <xsl:for-each select="marc:subfield">
2773                                 <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])">
2774                                         <xsl:value-of select="text()"></xsl:value-of>
2775                                         <xsl:text> </xsl:text>
2776                                 </xsl:if>
2777                         </xsl:for-each>
2778                 </xsl:variable>
2779                 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
2780         </xsl:template>
2781
2782         <!-- 3.2 change tmee 6xx $v genre -->
2783         <xsl:template match="marc:datafield[@tag=600]">
2784                 <subject>
2785                         <xsl:call-template name="subjectAuthority"></xsl:call-template>
2786                         <name type="personal">
2787                                 <xsl:call-template name="uri" />
2788                                 <namePart>
2789                                         <xsl:call-template name="chopPunctuation">
2790                                                 <xsl:with-param name="chopString">
2791                                                         <xsl:call-template name="subfieldSelect">
2792                                                                 <xsl:with-param name="codes">aq</xsl:with-param>
2793                                                         </xsl:call-template>
2794                                                 </xsl:with-param>
2795                                         </xsl:call-template>
2796                                 </namePart>
2797                                 <xsl:call-template name="termsOfAddress"></xsl:call-template>
2798                                 <xsl:call-template name="nameDate"></xsl:call-template>
2799                                 <xsl:call-template name="affiliation"></xsl:call-template>
2800                                 <xsl:call-template name="role"></xsl:call-template>
2801                         </name>
2802                         <xsl:call-template name="subjectAnyOrder"></xsl:call-template>
2803                 </subject>
2804         </xsl:template>
2805         <xsl:template match="marc:datafield[@tag=610]">
2806                 <subject>
2807                         <xsl:call-template name="subjectAuthority"></xsl:call-template>
2808                         <name type="corporate">
2809                                 <xsl:call-template name="uri" />
2810                                 <xsl:for-each select="marc:subfield[@code='a']">
2811                                         <namePart>
2812                                                 <xsl:value-of select="."></xsl:value-of>
2813                                         </namePart>
2814                                 </xsl:for-each>
2815                                 <xsl:for-each select="marc:subfield[@code='b']">
2816                                         <namePart>
2817                                                 <xsl:value-of select="."></xsl:value-of>
2818                                         </namePart>
2819                                 </xsl:for-each>
2820                                 <xsl:if test="marc:subfield[@code='c' or @code='d' or @code='n' or @code='p']">
2821                                         <namePart>
2822                                                 <xsl:call-template name="subfieldSelect">
2823                                                         <xsl:with-param name="codes">cdnp</xsl:with-param>
2824                                                 </xsl:call-template>
2825                                         </namePart>
2826                                 </xsl:if>
2827                                 <xsl:call-template name="role"></xsl:call-template>
2828                         </name>
2829                         <xsl:call-template name="subjectAnyOrder"></xsl:call-template>
2830                 </subject>
2831         </xsl:template>
2832         <xsl:template match="marc:datafield[@tag=611]">
2833                 <subject>
2834                         <xsl:call-template name="subjectAuthority"></xsl:call-template>
2835                         <name type="conference">
2836                                 <xsl:call-template name="uri" />
2837                                 <namePart>
2838                                         <xsl:call-template name="subfieldSelect">
2839                                                 <xsl:with-param name="codes">abcdeqnp</xsl:with-param>
2840                                         </xsl:call-template>
2841                                 </namePart>
2842                                 <xsl:for-each select="marc:subfield[@code='4']">
2843                                         <role>
2844                                                 <roleTerm authority="marcrelator" type="code">
2845                                                         <xsl:value-of select="."></xsl:value-of>
2846                                                 </roleTerm>
2847                                         </role>
2848                                 </xsl:for-each>
2849                         </name>
2850                         <xsl:call-template name="subjectAnyOrder"></xsl:call-template>
2851                 </subject>
2852         </xsl:template>
2853         <xsl:template match="marc:datafield[@tag=630]">
2854                 <subject>
2855                         <xsl:call-template name="subjectAuthority"></xsl:call-template>
2856                         <xsl:variable name="titleChop">
2857                                 <xsl:call-template name="chopPunctuation">
2858                                         <xsl:with-param name="chopString">
2859                                                 <xsl:call-template name="subfieldSelect">
2860                                                         <xsl:with-param name="codes">adfhklor</xsl:with-param>
2861                                                 </xsl:call-template>
2862                                         </xsl:with-param>
2863                                 </xsl:call-template>
2864                         </xsl:variable>
2865                         <titleInfo>
2866                                 <title>
2867                                         <xsl:value-of select="$titleChop" />
2868                                 </title>
2869                                 <xsl:call-template name="part"></xsl:call-template>
2870                         </titleInfo>
2871                         <titleInfo type="nfi">
2872                                 <xsl:choose>
2873                                         <xsl:when test="@ind1>0">
2874                                                 <nonSort>
2875                                                         <xsl:value-of select="substring($titleChop,1,@ind1)"/>
2876                                                 </nonSort>
2877                                                 <title>
2878                                                         <xsl:value-of select="substring($titleChop,@ind1+1)"/>
2879                                                 </title>
2880                                                 <xsl:call-template name="part"/>
2881                                         </xsl:when>
2882                                         <xsl:otherwise>
2883                                                 <title>
2884                                                         <xsl:value-of select="$titleChop" />
2885                                                 </title>
2886                                         </xsl:otherwise>
2887                                 </xsl:choose>
2888                                 <xsl:call-template name="part"></xsl:call-template>
2889                         </titleInfo>
2890                         <xsl:call-template name="subjectAnyOrder"></xsl:call-template>
2891                 </subject>
2892         </xsl:template>
2893         <xsl:template match="marc:datafield[@tag=650]">
2894                 <subject>
2895                         <xsl:call-template name="subjectAuthority"></xsl:call-template>
2896                         <topic>
2897                                 <xsl:call-template name="uri" />
2898                                 <xsl:call-template name="chopPunctuation">
2899                                         <xsl:with-param name="chopString">
2900                                                 <xsl:call-template name="subfieldSelect">
2901                                                         <xsl:with-param name="codes">abcd</xsl:with-param>
2902                                                 </xsl:call-template>
2903                                         </xsl:with-param>
2904                                 </xsl:call-template>
2905                         </topic>
2906                         <xsl:call-template name="subjectAnyOrder"></xsl:call-template>
2907                 </subject>
2908         </xsl:template>
2909         <xsl:template match="marc:datafield[@tag=651]">
2910                 <subject>
2911                         <xsl:call-template name="subjectAuthority"></xsl:call-template>
2912                         <xsl:for-each select="marc:subfield[@code='a']">
2913                                 <geographic>
2914                                         <xsl:call-template name="uri" />
2915                                         <xsl:call-template name="chopPunctuation">
2916                                                 <xsl:with-param name="chopString" select="."></xsl:with-param>
2917                                         </xsl:call-template>
2918                                 </geographic>
2919                         </xsl:for-each>
2920                         <xsl:call-template name="subjectAnyOrder"></xsl:call-template>
2921                 </subject>
2922         </xsl:template>
2923         <xsl:template match="marc:datafield[@tag=653]">
2924                 <subject>
2925                         <xsl:for-each select="marc:subfield[@code='a']">
2926                                 <topic>
2927                                         <xsl:call-template name="uri" />
2928                                         <xsl:value-of select="."></xsl:value-of>
2929                                 </topic>
2930                         </xsl:for-each>
2931                 </subject>
2932         </xsl:template>
2933         <xsl:template match="marc:datafield[@tag=656]">
2934                 <subject>
2935                         <xsl:if test="marc:subfield[@code=2]">
2936                                 <xsl:attribute name="authority">
2937                                         <xsl:value-of select="marc:subfield[@code=2]"></xsl:value-of>
2938                                 </xsl:attribute>
2939                         </xsl:if>
2940                         <occupation>
2941                                 <xsl:call-template name="uri" />
2942                                 <xsl:call-template name="chopPunctuation">
2943                                         <xsl:with-param name="chopString">
2944                                                 <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
2945                                         </xsl:with-param>
2946                                 </xsl:call-template>
2947                         </occupation>
2948                 </subject>
2949         </xsl:template>
2950         <xsl:template name="termsOfAddress">
2951                 <xsl:if test="marc:subfield[@code='b' or @code='c']">
2952                         <namePart type="termsOfAddress">
2953                                 <xsl:call-template name="chopPunctuation">
2954                                         <xsl:with-param name="chopString">
2955                                                 <xsl:call-template name="subfieldSelect">
2956                                                         <xsl:with-param name="codes">bc</xsl:with-param>
2957                                                 </xsl:call-template>
2958                                         </xsl:with-param>
2959                                 </xsl:call-template>
2960                         </namePart>
2961                 </xsl:if>
2962         </xsl:template>
2963         <xsl:template name="displayLabel">
2964                 <xsl:if test="marc:subfield[@code='i']">
2965                         <xsl:attribute name="displayLabel">
2966                                 <xsl:value-of select="marc:subfield[@code='i']"></xsl:value-of>
2967                         </xsl:attribute>
2968                 </xsl:if>
2969                 <xsl:if test="marc:subfield[@code='3']">
2970                         <xsl:attribute name="displayLabel">
2971                                 <xsl:value-of select="marc:subfield[@code='3']"></xsl:value-of>
2972                         </xsl:attribute>
2973                 </xsl:if>
2974         </xsl:template>
2975         <xsl:template name="isInvalid">
2976                 <xsl:param name="type"/>
2977                 <xsl:if test="marc:subfield[@code='z'] or marc:subfield[@code='y']">
2978                         <identifier>
2979                                 <xsl:attribute name="type">
2980                                         <xsl:value-of select="$type"/>
2981                                 </xsl:attribute>
2982                                 <xsl:attribute name="invalid">
2983                                         <xsl:text>yes</xsl:text>
2984                                 </xsl:attribute>
2985                                 <xsl:if test="marc:subfield[@code='z']">
2986                                         <xsl:value-of select="marc:subfield[@code='z']"/>
2987                                 </xsl:if>
2988                                 <xsl:if test="marc:subfield[@code='y']">
2989                                         <xsl:value-of select="marc:subfield[@code='y']"/>
2990                                 </xsl:if>
2991                         </identifier>
2992                 </xsl:if>
2993         </xsl:template>
2994         <xsl:template name="subtitle">
2995                 <xsl:if test="marc:subfield[@code='b']">
2996                         <subTitle>
2997                                 <xsl:call-template name="chopPunctuation">
2998                                         <xsl:with-param name="chopString">
2999                                                 <xsl:value-of select="marc:subfield[@code='b']"/>
3000                                                 <!--<xsl:call-template name="subfieldSelect">
3001                                                         <xsl:with-param name="codes">b</xsl:with-param>
3002                                                 </xsl:call-template>-->
3003                                         </xsl:with-param>
3004                                 </xsl:call-template>
3005                         </subTitle>
3006                 </xsl:if>
3007         </xsl:template>
3008         <xsl:template name="script">
3009                 <xsl:param name="scriptCode"></xsl:param>
3010                 <xsl:attribute name="script">
3011                         <xsl:choose>
3012                                 <xsl:when test="$scriptCode='(3'">Arabic</xsl:when>
3013                                 <xsl:when test="$scriptCode='(B'">Latin</xsl:when>
3014                                 <xsl:when test="$scriptCode='$1'">Chinese, Japanese, Korean</xsl:when>
3015                                 <xsl:when test="$scriptCode='(N'">Cyrillic</xsl:when>
3016                                 <xsl:when test="$scriptCode='(2'">Hebrew</xsl:when>
3017                                 <xsl:when test="$scriptCode='(S'">Greek</xsl:when>
3018                         </xsl:choose>
3019                 </xsl:attribute>
3020         </xsl:template>
3021         <xsl:template name="parsePart">
3022                 <!-- assumes 773$q= 1:2:3<4
3023                      with up to 3 levels and one optional start page
3024                 -->
3025                 <xsl:variable name="level1">
3026                         <xsl:choose>
3027                                 <xsl:when test="contains(text(),':')">
3028                                         <!-- 1:2 -->
3029                                         <xsl:value-of select="substring-before(text(),':')"></xsl:value-of>
3030                                 </xsl:when>
3031                                 <xsl:when test="not(contains(text(),':'))">
3032                                         <!-- 1 or 1<3 -->
3033                                         <xsl:if test="contains(text(),'&lt;')">
3034                                                 <!-- 1<3 -->
3035                                                 <xsl:value-of select="substring-before(text(),'&lt;')"></xsl:value-of>
3036                                         </xsl:if>
3037                                         <xsl:if test="not(contains(text(),'&lt;'))">
3038                                                 <!-- 1 -->
3039                                                 <xsl:value-of select="text()"></xsl:value-of>
3040                                         </xsl:if>
3041                                 </xsl:when>
3042                         </xsl:choose>
3043                 </xsl:variable>
3044                 <xsl:variable name="sici2">
3045                         <xsl:choose>
3046                                 <xsl:when test="starts-with(substring-after(text(),$level1),':')">
3047                                         <xsl:value-of select="substring(substring-after(text(),$level1),2)"></xsl:value-of>
3048                                 </xsl:when>
3049                                 <xsl:otherwise>
3050                                         <xsl:value-of select="substring-after(text(),$level1)"></xsl:value-of>
3051                                 </xsl:otherwise>
3052                         </xsl:choose>
3053                 </xsl:variable>
3054                 <xsl:variable name="level2">
3055                         <xsl:choose>
3056                                 <xsl:when test="contains($sici2,':')">
3057                                         <!--  2:3<4  -->
3058                                         <xsl:value-of select="substring-before($sici2,':')"></xsl:value-of>
3059                                 </xsl:when>
3060                                 <xsl:when test="contains($sici2,'&lt;')">
3061                                         <!-- 1: 2<4 -->
3062                                         <xsl:value-of select="substring-before($sici2,'&lt;')"></xsl:value-of>
3063                                 </xsl:when>
3064                                 <xsl:otherwise>
3065                                         <xsl:value-of select="$sici2"></xsl:value-of>
3066                                         <!-- 1:2 -->
3067                                 </xsl:otherwise>
3068                         </xsl:choose>
3069                 </xsl:variable>
3070                 <xsl:variable name="sici3">
3071                         <xsl:choose>
3072                                 <xsl:when test="starts-with(substring-after($sici2,$level2),':')">
3073                                         <xsl:value-of select="substring(substring-after($sici2,$level2),2)"></xsl:value-of>
3074                                 </xsl:when>
3075                                 <xsl:otherwise>
3076                                         <xsl:value-of select="substring-after($sici2,$level2)"></xsl:value-of>
3077                                 </xsl:otherwise>
3078                         </xsl:choose>
3079                 </xsl:variable>
3080                 <xsl:variable name="level3">
3081                         <xsl:choose>
3082                                 <xsl:when test="contains($sici3,'&lt;')">
3083                                         <!-- 2<4 -->
3084                                         <xsl:value-of select="substring-before($sici3,'&lt;')"></xsl:value-of>
3085                                 </xsl:when>
3086                                 <xsl:otherwise>
3087                                         <xsl:value-of select="$sici3"></xsl:value-of>
3088                                         <!-- 3 -->
3089                                 </xsl:otherwise>
3090                         </xsl:choose>
3091                 </xsl:variable>
3092                 <xsl:variable name="page">
3093                         <xsl:if test="contains(text(),'&lt;')">
3094                                 <xsl:value-of select="substring-after(text(),'&lt;')"></xsl:value-of>
3095                         </xsl:if>
3096                 </xsl:variable>
3097                 <xsl:if test="$level1">
3098                         <detail level="1">
3099                                 <number>
3100                                         <xsl:value-of select="$level1"></xsl:value-of>
3101                                 </number>
3102                         </detail>
3103                 </xsl:if>
3104                 <xsl:if test="$level2">
3105                         <detail level="2">
3106                                 <number>
3107                                         <xsl:value-of select="$level2"></xsl:value-of>
3108                                 </number>
3109                         </detail>
3110                 </xsl:if>
3111                 <xsl:if test="$level3">
3112                         <detail level="3">
3113                                 <number>
3114                                         <xsl:value-of select="$level3"></xsl:value-of>
3115                                 </number>
3116                         </detail>
3117                 </xsl:if>
3118                 <xsl:if test="$page">
3119                         <extent unit="page">
3120                                 <start>
3121                                         <xsl:value-of select="$page"></xsl:value-of>
3122                                 </start>
3123                         </extent>
3124                 </xsl:if>
3125         </xsl:template>
3126         <xsl:template name="getLanguage">
3127                 <xsl:param name="langString"></xsl:param>
3128                 <xsl:param name="controlField008-35-37"></xsl:param>
3129                 <xsl:variable name="length" select="string-length($langString)"></xsl:variable>
3130                 <xsl:choose>
3131                         <xsl:when test="$length=0"></xsl:when>
3132                         <xsl:when test="$controlField008-35-37=substring($langString,1,3)">
3133                                 <xsl:call-template name="getLanguage">
3134                                         <xsl:with-param name="langString" select="substring($langString,4,$length)"></xsl:with-param>
3135                                         <xsl:with-param name="controlField008-35-37" select="$controlField008-35-37"></xsl:with-param>
3136                                 </xsl:call-template>
3137                         </xsl:when>
3138                         <xsl:otherwise>
3139                                 <language>
3140                                         <languageTerm authority="iso639-2b" type="code">
3141                                                 <xsl:value-of select="substring($langString,1,3)"></xsl:value-of>
3142                                         </languageTerm>
3143                                 </language>
3144                                 <xsl:call-template name="getLanguage">
3145                                         <xsl:with-param name="langString" select="substring($langString,4,$length)"></xsl:with-param>
3146                                         <xsl:with-param name="controlField008-35-37" select="$controlField008-35-37"></xsl:with-param>
3147                                 </xsl:call-template>
3148                         </xsl:otherwise>
3149                 </xsl:choose>
3150         </xsl:template>
3151         <xsl:template name="isoLanguage">
3152                 <xsl:param name="currentLanguage"></xsl:param>
3153                 <xsl:param name="usedLanguages"></xsl:param>
3154                 <xsl:param name="remainingLanguages"></xsl:param>
3155                 <xsl:choose>
3156                         <xsl:when test="string-length($currentLanguage)=0"></xsl:when>
3157                         <xsl:when test="not(contains($usedLanguages, $currentLanguage))">
3158                                 <language>
3159                                         <xsl:if test="@code!='a'">
3160                                                 <xsl:attribute name="objectPart">
3161                                                         <xsl:choose>
3162                                                                 <xsl:when test="@code='b'">summary or subtitle</xsl:when>
3163                                                                 <xsl:when test="@code='d'">sung or spoken text</xsl:when>
3164                                                                 <xsl:when test="@code='e'">libretto</xsl:when>
3165                                                                 <xsl:when test="@code='f'">table of contents</xsl:when>
3166                                                                 <xsl:when test="@code='g'">accompanying material</xsl:when>
3167                                                                 <xsl:when test="@code='h'">translation</xsl:when>
3168                                                         </xsl:choose>
3169                                                 </xsl:attribute>
3170                                         </xsl:if>
3171                                         <languageTerm authority="iso639-2b" type="code">
3172                                                 <xsl:value-of select="$currentLanguage"></xsl:value-of>
3173                                         </languageTerm>
3174                                 </language>
3175                                 <xsl:call-template name="isoLanguage">
3176                                         <xsl:with-param name="currentLanguage">
3177                                                 <xsl:value-of select="substring($remainingLanguages,1,3)"></xsl:value-of>
3178                                         </xsl:with-param>
3179                                         <xsl:with-param name="usedLanguages">
3180                                                 <xsl:value-of select="concat($usedLanguages,$currentLanguage)"></xsl:value-of>
3181                                         </xsl:with-param>
3182                                         <xsl:with-param name="remainingLanguages">
3183                                                 <xsl:value-of select="substring($remainingLanguages,4,string-length($remainingLanguages))"></xsl:value-of>
3184                                         </xsl:with-param>
3185                                 </xsl:call-template>
3186                         </xsl:when>
3187                         <xsl:otherwise>
3188                                 <xsl:call-template name="isoLanguage">
3189                                         <xsl:with-param name="currentLanguage">
3190                                                 <xsl:value-of select="substring($remainingLanguages,1,3)"></xsl:value-of>
3191                                         </xsl:with-param>
3192                                         <xsl:with-param name="usedLanguages">
3193                                                 <xsl:value-of select="concat($usedLanguages,$currentLanguage)"></xsl:value-of>
3194                                         </xsl:with-param>
3195                                         <xsl:with-param name="remainingLanguages">
3196                                                 <xsl:value-of select="substring($remainingLanguages,4,string-length($remainingLanguages))"></xsl:value-of>
3197                                         </xsl:with-param>
3198                                 </xsl:call-template>
3199                         </xsl:otherwise>
3200                 </xsl:choose>
3201         </xsl:template>
3202         <xsl:template name="chopBrackets">
3203                 <xsl:param name="chopString"></xsl:param>
3204                 <xsl:variable name="string">
3205                         <xsl:call-template name="chopPunctuation">
3206                                 <xsl:with-param name="chopString" select="$chopString"></xsl:with-param>
3207                         </xsl:call-template>
3208                 </xsl:variable>
3209                 <xsl:if test="substring($string, 1,1)='['">
3210                         <xsl:value-of select="substring($string,2, string-length($string)-2)"></xsl:value-of>
3211                 </xsl:if>
3212                 <xsl:if test="substring($string, 1,1)!='['">
3213                         <xsl:value-of select="$string"></xsl:value-of>
3214                 </xsl:if>
3215         </xsl:template>
3216         <xsl:template name="rfcLanguages">
3217                 <xsl:param name="nodeNum"></xsl:param>
3218                 <xsl:param name="usedLanguages"></xsl:param>
3219                 <xsl:param name="controlField008-35-37"></xsl:param>
3220                 <xsl:variable name="currentLanguage" select="."></xsl:variable>
3221                 <xsl:choose>
3222                         <xsl:when test="not($currentLanguage)"></xsl:when>
3223                         <xsl:when test="$currentLanguage!=$controlField008-35-37 and $currentLanguage!='rfc3066'">
3224                                 <xsl:if test="not(contains($usedLanguages,$currentLanguage))">
3225                                         <language>
3226                                                 <xsl:if test="@code!='a'">
3227                                                         <xsl:attribute name="objectPart">
3228                                                                 <xsl:choose>
3229                                                                         <xsl:when test="@code='b'">summary or subtitle</xsl:when>
3230                                                                         <xsl:when test="@code='d'">sung or spoken text</xsl:when>
3231                                                                         <xsl:when test="@code='e'">libretto</xsl:when>
3232                                                                         <xsl:when test="@code='f'">table of contents</xsl:when>
3233                                                                         <xsl:when test="@code='g'">accompanying material</xsl:when>
3234                                                                         <xsl:when test="@code='h'">translation</xsl:when>
3235                                                                 </xsl:choose>
3236                                                         </xsl:attribute>
3237                                                 </xsl:if>
3238                                                 <languageTerm authority="rfc3066" type="code">
3239                                                         <xsl:value-of select="$currentLanguage"/>
3240                                                 </languageTerm>
3241                                         </language>
3242                                 </xsl:if>
3243                         </xsl:when>
3244                         <xsl:otherwise>
3245                         </xsl:otherwise>
3246                 </xsl:choose>
3247         </xsl:template>
3248         <xsl:template name="datafield">
3249                 <xsl:param name="tag"/>
3250                 <xsl:param name="ind1"><xsl:text> </xsl:text></xsl:param>
3251                 <xsl:param name="ind2"><xsl:text> </xsl:text></xsl:param>
3252                 <xsl:param name="subfields"/>
3253                 <xsl:element name="marc:datafield">
3254                         <xsl:attribute name="tag">
3255                                 <xsl:value-of select="$tag"/>
3256                         </xsl:attribute>
3257                         <xsl:attribute name="ind1">
3258                                 <xsl:value-of select="$ind1"/>
3259                         </xsl:attribute>
3260                         <xsl:attribute name="ind2">
3261                                 <xsl:value-of select="$ind2"/>
3262                         </xsl:attribute>
3263                         <xsl:copy-of select="$subfields"/>
3264                 </xsl:element>
3265         </xsl:template>
3266
3267         <xsl:template name="subfieldSelect">
3268                 <xsl:param name="codes"/>
3269                 <xsl:param name="delimeter"><xsl:text> </xsl:text></xsl:param>
3270                 <xsl:variable name="str">
3271                         <xsl:for-each select="marc:subfield">
3272                                 <xsl:if test="contains($codes, @code)">
3273                                         <xsl:value-of select="text()"/><xsl:value-of select="$delimeter"/>
3274                                 </xsl:if>
3275                         </xsl:for-each>
3276                 </xsl:variable>
3277                 <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
3278         </xsl:template>
3279
3280         <xsl:template name="buildSpaces">
3281                 <xsl:param name="spaces"/>
3282                 <xsl:param name="char"><xsl:text> </xsl:text></xsl:param>
3283                 <xsl:if test="$spaces>0">
3284                         <xsl:value-of select="$char"/>
3285                         <xsl:call-template name="buildSpaces">
3286                                 <xsl:with-param name="spaces" select="$spaces - 1"/>
3287                                 <xsl:with-param name="char" select="$char"/>
3288                         </xsl:call-template>
3289                 </xsl:if>
3290         </xsl:template>
3291
3292         <xsl:template name="chopPunctuation">
3293                 <xsl:param name="chopString"/>
3294                 <xsl:param name="punctuation"><xsl:text>.:,;/ </xsl:text></xsl:param>
3295                 <xsl:variable name="length" select="string-length($chopString)"/>
3296                 <xsl:choose>
3297                         <xsl:when test="$length=0"/>
3298                         <xsl:when test="contains($punctuation, substring($chopString,$length,1))">
3299                                 <xsl:call-template name="chopPunctuation">
3300                                         <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
3301                                         <xsl:with-param name="punctuation" select="$punctuation"/>
3302                                 </xsl:call-template>
3303                         </xsl:when>
3304                         <xsl:when test="not($chopString)"/>
3305                         <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>
3306                 </xsl:choose>
3307         </xsl:template>
3308
3309         <xsl:template name="chopPunctuationFront">
3310                 <xsl:param name="chopString"/>
3311                 <xsl:variable name="length" select="string-length($chopString)"/>
3312                 <xsl:choose>
3313                         <xsl:when test="$length=0"/>
3314                         <xsl:when test="contains('.:,;/[ ', substring($chopString,1,1))">
3315                                 <xsl:call-template name="chopPunctuationFront">
3316                                         <xsl:with-param name="chopString" select="substring($chopString,2,$length - 1)"/>
3317                                 </xsl:call-template>
3318                         </xsl:when>
3319                         <xsl:when test="not($chopString)"/>
3320                         <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>
3321                 </xsl:choose>
3322         </xsl:template>
3323 </xsl:stylesheet>$XXXX$ where name = $$mods32$$;
3324
3325 update config.xml_transform set xslt = $XXXX$<xsl:stylesheet xmlns="http://www.loc.gov/mods/v3" xmlns:marc="http://www.loc.gov/MARC21/slim"
3326         xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3327         exclude-result-prefixes="xlink marc" version="1.0">
3328         <xsl:output encoding="UTF-8" indent="yes" method="xml"/>
3329
3330         <xsl:variable name="ascii">
3331                 <xsl:text> !"#$%&amp;'()*+,-./0123456789:;&lt;=&gt;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~</xsl:text>
3332         </xsl:variable>
3333
3334         <xsl:variable name="latin1">
3335                 <xsl:text> ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ</xsl:text>
3336         </xsl:variable>
3337         <!-- Characters that usually don't need to be escaped -->
3338         <xsl:variable name="safe">
3339                 <xsl:text>!'()*-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~</xsl:text>
3340         </xsl:variable>
3341
3342         <xsl:variable name="hex">0123456789ABCDEF</xsl:variable>
3343
3344     <!-- Evergreen specific: revert Revision 1.23, so we can have those authority xlink attributes back. -->
3345
3346         <!--MARC21slim2MODS3-3.xsl
3347 Revision 1.27 - Mapped 648 to <subject> 2009/03/13 tmee
3348 Revision 1.26 - Added subfield $s mapping for 130/240/730  2008/10/16 tmee
3349 Revision 1.25 - Mapped 040e to <descriptiveStandard> and Leader/18 to <descriptive standard>aacr2  2008/09/18 tmee
3350 Revision 1.24 - Mapped 852 subfields $h, $i, $j, $k, $l, $m, $t to <shelfLocation> and 852 subfield $u to <physicalLocation> with @xlink 2008/09/17 tmee
3351 Revision 1.23 - Commented out xlink/uri for subfield 0 for 130/240/730, 100/700, 110/710, 111/711 as these are currently unactionable  2008/09/17  tmee
3352 Revision 1.22 - Mapped 022 subfield $l to type "issn-l" subfield $m to output identifier element with corresponding @type and @invalid eq 'yes'2008/09/17  tmee
3353 Revision 1.21 - Mapped 856 ind2=1 or ind2=2 to <relatedItem><location><url>  2008/07/03  tmee
3354 Revision 1.20 - Added genre w/@auth="contents of 2" and type= "musical composition"  2008/07/01  tmee
3355 Revision 1.19 - Added genre offprint for 008/24+ BK code 2  2008/07/01  tmee
3356 Revision 1.18 - Added xlink/uri for subfield 0 for 130/240/730, 100/700, 110/710, 111/711  2008/06/26  tmee
3357 Revision 1.17 - Added mapping of 662 2008/05/14 tmee
3358 Revision 1.16 - Changed @authority from "marc" to "marcgt" for 007 and 008 codes mapped to a term in <genre> 2007/07/10  tmee
3359 Revision 1.15 - For field 630, moved call to part template outside title element  2007/07/10  tmee
3360 Revision 1.14 - Fixed template isValid and fields 010, 020, 022, 024, 028, and 037 to output additional identifier elements with corresponding @type and @invalid eq 'yes' when subfields z or y (in the case of 022) exist in the MARCXML ::: 2007/01/04 17:35:20 cred
3361 Revision 1.13 - Changed order of output under cartographics to reflect schema  2006/11/28  tmee
3362 Revision 1.12 - Updated to reflect MODS 3.2 Mapping  2006/10/11  tmee
3363 Revision 1.11 - The attribute objectPart moved from <languageTerm> to <language>  2006/04/08  jrad
3364 Revision 1.10 - MODS 3.1 revisions to language and classification elements  (plus ability to find marc:collection embedded in wrapper elements such as SRU zs: wrappers)  2006/02/06  ggar
3365 Revision 1.9 - Subfield $y was added to field 242 2004/09/02 10:57 jrad
3366 Revision 1.8 - Subject chopPunctuation expanded and attribute fixes 2004/08/12 jrad
3367 Revision 1.7 - 2004/03/25 08:29 jrad
3368 Revision 1.6 - Various validation fixes 2004/02/20 ntra
3369 Revision 1.5 - MODS2 to MODS3 updates, language unstacking and de-duping, chopPunctuation expanded  2003/10/02 16:18:58  ntra
3370 Revision 1.3 - Additional Changes not related to MODS Version 2.0 by ntra
3371 Revision 1.2 - Added Log Comment  2003/03/24 19:37:42  ckeith
3372 -->
3373         <xsl:template match="/">
3374                 <xsl:choose>
3375                         <xsl:when test="//marc:collection">
3376                                 <modsCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3377                                         xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-2.xsd">
3378                                         <xsl:for-each select="//marc:collection/marc:record">
3379                                                 <mods version="3.3">
3380                                                         <xsl:call-template name="marcRecord"/>
3381                                                 </mods>
3382                                         </xsl:for-each>
3383                                 </modsCollection>
3384                         </xsl:when>
3385                         <xsl:otherwise>
3386                                 <mods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.3"
3387                                         xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-2.xsd">
3388                                         <xsl:for-each select="//marc:record">
3389                                                 <xsl:call-template name="marcRecord"/>
3390                                         </xsl:for-each>
3391                                 </mods>
3392                         </xsl:otherwise>
3393                 </xsl:choose>
3394         </xsl:template>
3395         <xsl:template name="marcRecord">
3396                 <xsl:variable name="leader" select="marc:leader"/>
3397                 <xsl:variable name="leader6" select="substring($leader,7,1)"/>
3398                 <xsl:variable name="leader7" select="substring($leader,8,1)"/>
3399                 <xsl:variable name="controlField008" select="marc:controlfield[@tag='008']"/>
3400                 <xsl:variable name="typeOf008">
3401                         <xsl:choose>
3402                                 <xsl:when test="$leader6='a'">
3403                                         <xsl:choose>
3404                                                 <xsl:when
3405                                                         test="$leader7='a' or $leader7='c' or $leader7='d' or $leader7='m'">BK</xsl:when>
3406                                                 <xsl:when test="$leader7='b' or $leader7='i' or $leader7='s'">SE</xsl:when>
3407                                         </xsl:choose>
3408                                 </xsl:when>
3409                                 <xsl:when test="$leader6='t'">BK</xsl:when>
3410                                 <xsl:when test="$leader6='p'">MM</xsl:when>
3411                                 <xsl:when test="$leader6='m'">CF</xsl:when>
3412                                 <xsl:when test="$leader6='e' or $leader6='f'">MP</xsl:when>
3413                                 <xsl:when test="$leader6='g' or $leader6='k' or $leader6='o' or $leader6='r'">VM</xsl:when>
3414                                 <xsl:when test="$leader6='c' or $leader6='d' or $leader6='i' or $leader6='j'"
3415                                 >MU</xsl:when>
3416                         </xsl:choose>
3417                 </xsl:variable>
3418                 <xsl:for-each select="marc:datafield[@tag='245']">
3419                         <titleInfo>
3420                                 <xsl:variable name="title">
3421                                         <xsl:choose>
3422                                                 <xsl:when test="marc:subfield[@code='b']">
3423                                                         <xsl:call-template name="specialSubfieldSelect">
3424                                                                 <xsl:with-param name="axis">b</xsl:with-param>
3425                                                                 <xsl:with-param name="beforeCodes">afgk</xsl:with-param>
3426                                                         </xsl:call-template>
3427                                                 </xsl:when>
3428                                                 <xsl:otherwise>
3429                                                         <xsl:call-template name="subfieldSelect">
3430                                                                 <xsl:with-param name="codes">abfgk</xsl:with-param>
3431                                                         </xsl:call-template>
3432                                                 </xsl:otherwise>
3433                                         </xsl:choose>
3434                                 </xsl:variable>
3435                                 <xsl:variable name="titleChop">
3436                                         <xsl:call-template name="chopPunctuation">
3437                                                 <xsl:with-param name="chopString">
3438                                                         <xsl:value-of select="$title"/>
3439                                                 </xsl:with-param>
3440                                                 <xsl:with-param name="punctuation">
3441                                                     <xsl:text>,;/ </xsl:text>
3442                                                 </xsl:with-param>
3443                                         </xsl:call-template>
3444                                 </xsl:variable>
3445                                 <xsl:choose>
3446                                         <xsl:when test="@ind2&gt;0">
3447                                                 <nonSort>
3448                                                         <xsl:value-of select="substring($titleChop,1,@ind2)"/>
3449                                                 </nonSort>
3450                                                 <title>
3451                                                         <xsl:value-of select="substring($titleChop,@ind2+1)"/>
3452                                                 </title>
3453                                         </xsl:when>
3454                                         <xsl:otherwise>
3455                                                 <title>
3456                                                         <xsl:value-of select="$titleChop"/>
3457                                                 </title>
3458                                         </xsl:otherwise>
3459                                 </xsl:choose>
3460                                 <xsl:if test="marc:subfield[@code='b']">
3461                                         <subTitle>
3462                                                 <xsl:call-template name="chopPunctuation">
3463                                                         <xsl:with-param name="chopString">
3464                                                                 <xsl:call-template name="specialSubfieldSelect">
3465                                                                         <xsl:with-param name="axis">b</xsl:with-param>
3466                                                                         <xsl:with-param name="anyCodes">b</xsl:with-param>
3467                                                                         <xsl:with-param name="afterCodes">afgk</xsl:with-param>
3468                                                                 </xsl:call-template>
3469                                                         </xsl:with-param>
3470                                                 </xsl:call-template>
3471                                         </subTitle>
3472                                 </xsl:if>
3473                                 <xsl:call-template name="part"/>
3474                         </titleInfo>
3475                 </xsl:for-each>
3476                 <xsl:for-each select="marc:datafield[@tag='210']">
3477                         <titleInfo type="abbreviated">
3478                                 <title>
3479                                         <xsl:call-template name="chopPunctuation">
3480                                                 <xsl:with-param name="chopString">
3481                                                         <xsl:call-template name="subfieldSelect">
3482                                                                 <xsl:with-param name="codes">a</xsl:with-param>
3483                                                         </xsl:call-template>
3484                                                 </xsl:with-param>
3485                                         </xsl:call-template>
3486                                 </title>
3487                                 <xsl:call-template name="subtitle"/>
3488                         </titleInfo>
3489                 </xsl:for-each>
3490                 <xsl:for-each select="marc:datafield[@tag='242']">
3491                         <titleInfo type="translated">
3492                                 <!--09/01/04 Added subfield $y-->
3493                                 <xsl:for-each select="marc:subfield[@code='y']">
3494                                         <xsl:attribute name="lang">
3495                                                 <xsl:value-of select="text()"/>
3496                                         </xsl:attribute>
3497                                 </xsl:for-each>
3498                                 <xsl:for-each select="marc:subfield[@code='i']">
3499                                         <xsl:attribute name="displayLabel">
3500                                                 <xsl:value-of select="text()"/>
3501                                         </xsl:attribute>
3502                                 </xsl:for-each>
3503                                 <title>
3504                                         <xsl:call-template name="chopPunctuation">
3505                                                 <xsl:with-param name="chopString">
3506                                                         <xsl:call-template name="subfieldSelect">
3507                                                                 <!-- 1/04 removed $h, b -->
3508                                                                 <xsl:with-param name="codes">a</xsl:with-param>
3509                                                         </xsl:call-template>
3510                                                 </xsl:with-param>
3511                                         </xsl:call-template>
3512                                 </title>
3513                                 <!-- 1/04 fix -->
3514                                 <xsl:call-template name="subtitle"/>
3515                                 <xsl:call-template name="part"/>
3516                         </titleInfo>
3517                 </xsl:for-each>
3518                 <xsl:for-each select="marc:datafield[@tag='246']">
3519                         <titleInfo type="alternative">
3520                                 <xsl:for-each select="marc:subfield[@code='i']">
3521                                         <xsl:attribute name="displayLabel">
3522                                                 <xsl:value-of select="text()"/>
3523                                         </xsl:attribute>
3524                                 </xsl:for-each>
3525                                 <title>
3526                                         <xsl:call-template name="chopPunctuation">
3527                                                 <xsl:with-param name="chopString">
3528                                                         <xsl:call-template name="subfieldSelect">
3529                                                                 <!-- 1/04 removed $h, $b -->
3530                                                                 <xsl:with-param name="codes">af</xsl:with-param>
3531                                                         </xsl:call-template>
3532                                                 </xsl:with-param>
3533                                         </xsl:call-template>
3534                                 </title>
3535                                 <xsl:call-template name="subtitle"/>
3536                                 <xsl:call-template name="part"/>
3537                         </titleInfo>
3538                 </xsl:for-each>
3539                 <xsl:for-each
3540                         select="marc:datafield[@tag='130']|marc:datafield[@tag='240']|marc:datafield[@tag='730'][@ind2!='2']">
3541                         <titleInfo type="uniform">
3542                                 <title>
3543                                                 <xsl:call-template name="uri"/>
3544
3545                                         <xsl:variable name="str">
3546                                                 <xsl:for-each select="marc:subfield">
3547                                                         <xsl:if
3548                                                                 test="(contains('adfklmors',@code) and (not(../marc:subfield[@code='n' or @code='p']) or (following-sibling::marc:subfield[@code='n' or @code='p'])))">
3549                                                                 <xsl:value-of select="text()"/>
3550                                                                 <xsl:text> </xsl:text>
3551                                                         </xsl:if>
3552                                                 </xsl:for-each>
3553                                         </xsl:variable>
3554                                         <xsl:call-template name="chopPunctuation">
3555                                                 <xsl:with-param name="chopString">
3556                                                         <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
3557                                                 </xsl:with-param>
3558                                         </xsl:call-template>
3559                                 </title>
3560                                 <xsl:call-template name="part"/>
3561                         </titleInfo>
3562                 </xsl:for-each>
3563                 <xsl:for-each select="marc:datafield[@tag='740'][@ind2!='2']">
3564                         <titleInfo type="alternative">
3565                                 <title>
3566                                         <xsl:call-template name="chopPunctuation">
3567                                                 <xsl:with-param name="chopString">
3568                                                         <xsl:call-template name="subfieldSelect">
3569                                                                 <xsl:with-param name="codes">ah</xsl:with-param>
3570                                                         </xsl:call-template>
3571                                                 </xsl:with-param>
3572                                         </xsl:call-template>
3573                                 </title>
3574                                 <xsl:call-template name="part"/>
3575                         </titleInfo>
3576                 </xsl:for-each>
3577                 <xsl:for-each select="marc:datafield[@tag='100']">
3578                         <name type="personal">
3579
3580                                 <xsl:call-template name="uri"/>
3581
3582                                 <xsl:call-template name="nameABCDQ"/>
3583                                 <xsl:call-template name="affiliation"/>
3584                                 <role>
3585                                         <roleTerm authority="marcrelator" type="text">creator</roleTerm>
3586                                 </role>
3587                                 <xsl:call-template name="role"/>
3588                         </name>
3589                 </xsl:for-each>
3590                 <xsl:for-each select="marc:datafield[@tag='110']">
3591                         <name type="corporate">
3592
3593                                         <xsl:call-template name="uri"/>
3594
3595                                 <xsl:call-template name="nameABCDN"/>
3596                                 <role>
3597                                         <roleTerm authority="marcrelator" type="text">creator</roleTerm>
3598                                 </role>
3599                                 <xsl:call-template name="role"/>
3600                         </name>
3601                 </xsl:for-each>
3602                 <xsl:for-each select="marc:datafield[@tag='111']">
3603                         <name type="conference">
3604
3605                                         <xsl:call-template name="uri"/>
3606
3607                                 <xsl:call-template name="nameACDEQ"/>
3608                                 <role>
3609                                         <roleTerm authority="marcrelator" type="text">creator</roleTerm>
3610                                 </role>
3611                                 <xsl:call-template name="role"/>
3612                         </name>
3613                 </xsl:for-each>
3614                 <xsl:for-each select="marc:datafield[@tag='700'][not(marc:subfield[@code='t'])]">
3615                         <name type="personal">
3616
3617                                         <xsl:call-template name="uri"/>
3618
3619                                 <xsl:call-template name="nameABCDQ"/>
3620                                 <xsl:call-template name="affiliation"/>
3621                                 <xsl:call-template name="role"/>
3622                         </name>
3623                 </xsl:for-each>
3624                 <xsl:for-each select="marc:datafield[@tag='710'][not(marc:subfield[@code='t'])]">
3625                         <name type="corporate">
3626
3627                                         <xsl:call-template name="uri"/>
3628
3629                                 <xsl:call-template name="nameABCDN"/>
3630                                 <xsl:call-template name="role"/>
3631                         </name>
3632                 </xsl:for-each>
3633                 <xsl:for-each select="marc:datafield[@tag='711'][not(marc:subfield[@code='t'])]">
3634                         <name type="conference">
3635
3636                                         <xsl:call-template name="uri"/>
3637
3638                                 <xsl:call-template name="nameACDEQ"/>
3639                                 <xsl:call-template name="role"/>
3640                         </name>
3641                 </xsl:for-each>
3642                 <xsl:for-each select="marc:datafield[@tag='720'][not(marc:subfield[@code='t'])]">
3643                         <name>
3644                                 <xsl:if test="@ind1=1">
3645                                         <xsl:attribute name="type">
3646                                                 <xsl:text>personal</xsl:text>
3647                                         </xsl:attribute>
3648                                 </xsl:if>
3649                                 <namePart>
3650                                         <xsl:value-of select="marc:subfield[@code='a']"/>
3651                                 </namePart>
3652                                 <xsl:call-template name="role"/>
3653                         </name>
3654                 </xsl:for-each>
3655                 <typeOfResource>
3656                         <xsl:if test="$leader7='c'">
3657                                 <xsl:attribute name="collection">yes</xsl:attribute>
3658                         </xsl:if>
3659                         <xsl:if test="$leader6='d' or $leader6='f' or $leader6='p' or $leader6='t'">
3660                                 <xsl:attribute name="manuscript">yes</xsl:attribute>
3661                         </xsl:if>
3662                         <xsl:choose>
3663                                 <xsl:when test="$leader6='a' or $leader6='t'">text</xsl:when>
3664                                 <xsl:when test="$leader6='e' or $leader6='f'">cartographic</xsl:when>
3665                                 <xsl:when test="$leader6='c' or $leader6='d'">notated music</xsl:when>
3666                                 <xsl:when test="$leader6='i'">sound recording-nonmusical</xsl:when>
3667                                 <xsl:when test="$leader6='j'">sound recording-musical</xsl:when>
3668                                 <xsl:when test="$leader6='k'">still image</xsl:when>
3669                                 <xsl:when test="$leader6='g'">moving image</xsl:when>
3670                                 <xsl:when test="$leader6='r'">three dimensional object</xsl:when>
3671                                 <xsl:when test="$leader6='m'">software, multimedia</xsl:when>
3672                                 <xsl:when test="$leader6='p'">mixed material</xsl:when>
3673                         </xsl:choose>
3674                 </typeOfResource>
3675                 <xsl:if test="substring($controlField008,26,1)='d'">
3676                         <genre authority="marcgt">globe</genre>
3677                 </xsl:if>
3678                 <xsl:if
3679                         test="marc:controlfield[@tag='007'][substring(text(),1,1)='a'][substring(text(),2,1)='r']">
3680                         <genre authority="marcgt">remote-sensing image</genre>
3681                 </xsl:if>
3682                 <xsl:if test="$typeOf008='MP'">
3683                         <xsl:variable name="controlField008-25" select="substring($controlField008,26,1)"/>
3684                         <xsl:choose>
3685                                 <xsl:when
3686                                         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']">
3687                                         <genre authority="marcgt">map</genre>
3688                                 </xsl:when>
3689                                 <xsl:when
3690                                         test="$controlField008-25='e' or marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='d']">
3691                                         <genre authority="marcgt">atlas</genre>
3692                                 </xsl:when>
3693                         </xsl:choose>
3694                 </xsl:if>
3695                 <xsl:if test="$typeOf008='SE'">
3696                         <xsl:variable name="controlField008-21" select="substring($controlField008,22,1)"/>
3697                         <xsl:choose>
3698                                 <xsl:when test="$controlField008-21='d'">
3699                                         <genre authority="marcgt">database</genre>
3700                                 </xsl:when>
3701                                 <xsl:when test="$controlField008-21='l'">
3702                                         <genre authority="marcgt">loose-leaf</genre>
3703                                 </xsl:when>
3704                                 <xsl:when test="$controlField008-21='m'">
3705                                         <genre authority="marcgt">series</genre>
3706                                 </xsl:when>
3707                                 <xsl:when test="$controlField008-21='n'">
3708                                         <genre authority="marcgt">newspaper</genre>
3709                                 </xsl:when>
3710                                 <xsl:when test="$controlField008-21='p'">
3711                                         <genre authority="marcgt">periodical</genre>
3712                                 </xsl:when>
3713                                 <xsl:when test="$controlField008-21='w'">
3714                                         <genre authority="marcgt">web site</genre>
3715                                 </xsl:when>
3716                         </xsl:choose>
3717                 </xsl:if>
3718                 <xsl:if test="$typeOf008='BK' or $typeOf008='SE'">
3719                         <xsl:variable name="controlField008-24" select="substring($controlField008,25,4)"/>
3720                         <xsl:choose>
3721                                 <xsl:when test="contains($controlField008-24,'a')">
3722                                         <genre authority="marcgt">abstract or summary</genre>
3723                                 </xsl:when>
3724                                 <xsl:when test="contains($controlField008-24,'b')">
3725                                         <genre authority="marcgt">bibliography</genre>
3726                                 </xsl:when>
3727                                 <xsl:when test="contains($controlField008-24,'c')">
3728                                         <genre authority="marcgt">catalog</genre>
3729                                 </xsl:when>
3730                                 <xsl:when test="contains($controlField008-24,'d')">
3731                                         <genre authority="marcgt">dictionary</genre>
3732                                 </xsl:when>
3733                                 <xsl:when test="contains($controlField008-24,'e')">
3734                                         <genre authority="marcgt">encyclopedia</genre>
3735                                 </xsl:when>
3736                                 <xsl:when test="contains($controlField008-24,'f')">
3737                                         <genre authority="marcgt">handbook</genre>
3738                                 </xsl:when>
3739                                 <xsl:when test="contains($controlField008-24,'g')">
3740                                         <genre authority="marcgt">legal article</genre>
3741                                 </xsl:when>
3742                                 <xsl:when test="contains($controlField008-24,'i')">
3743                                         <genre authority="marcgt">index</genre>
3744                                 </xsl:when>
3745                                 <xsl:when test="contains($controlField008-24,'k')">
3746                                         <genre authority="marcgt">discography</genre>
3747                                 </xsl:when>
3748                                 <xsl:when test="contains($controlField008-24,'l')">
3749                                         <genre authority="marcgt">legislation</genre>
3750                                 </xsl:when>
3751                                 <xsl:when test="contains($controlField008-24,'m')">
3752                                         <genre authority="marcgt">theses</genre>
3753                                 </xsl:when>
3754                                 <xsl:when test="contains($controlField008-24,'n')">
3755                                         <genre authority="marcgt">survey of literature</genre>
3756                                 </xsl:when>
3757                                 <xsl:when test="contains($controlField008-24,'o')">
3758                                         <genre authority="marcgt">review</genre>
3759                                 </xsl:when>
3760                                 <xsl:when test="contains($controlField008-24,'p')">
3761                                         <genre authority="marcgt">programmed text</genre>
3762                                 </xsl:when>
3763                                 <xsl:when test="contains($controlField008-24,'q')">
3764                                         <genre authority="marcgt">filmography</genre>
3765                                 </xsl:when>
3766                                 <xsl:when test="contains($controlField008-24,'r')">
3767                                         <genre authority="marcgt">directory</genre>
3768                                 </xsl:when>
3769                                 <xsl:when test="contains($controlField008-24,'s')">
3770                                         <genre authority="marcgt">statistics</genre>
3771                                 </xsl:when>
3772                                 <xsl:when test="contains($controlField008-24,'t')">
3773                                         <genre authority="marcgt">technical report</genre>
3774                                 </xsl:when>
3775                                 <xsl:when test="contains($controlField008-24,'v')">
3776                                         <genre authority="marcgt">legal case and case notes</genre>
3777                                 </xsl:when>
3778                                 <xsl:when test="contains($controlField008-24,'w')">
3779                                         <genre authority="marcgt">law report or digest</genre>
3780                                 </xsl:when>
3781                                 <xsl:when test="contains($controlField008-24,'z')">
3782                                         <genre authority="marcgt">treaty</genre>
3783                                 </xsl:when>
3784                         </xsl:choose>
3785                         <xsl:variable name="controlField008-29" select="substring($controlField008,30,1)"/>
3786                         <xsl:choose>
3787                                 <xsl:when test="$controlField008-29='1'">
3788                                         <genre authority="marcgt">conference publication</genre>
3789                                 </xsl:when>
3790                         </xsl:choose>
3791                 </xsl:if>
3792                 <xsl:if test="$typeOf008='CF'">
3793                         <xsl:variable name="controlField008-26" select="substring($controlField008,27,1)"/>
3794                         <xsl:choose>
3795                                 <xsl:when test="$controlField008-26='a'">
3796                                         <genre authority="marcgt">numeric data</genre>
3797                                 </xsl:when>
3798                                 <xsl:when test="$controlField008-26='e'">
3799                                         <genre authority="marcgt">database</genre>
3800                                 </xsl:when>
3801                                 <xsl:when test="$controlField008-26='f'">
3802                                         <genre authority="marcgt">font</genre>
3803                                 </xsl:when>
3804                                 <xsl:when test="$controlField008-26='g'">
3805                                         <genre authority="marcgt">game</genre>
3806                                 </xsl:when>
3807                         </xsl:choose>
3808                 </xsl:if>
3809                 <xsl:if test="$typeOf008='BK'">
3810                         <xsl:if test="substring($controlField008,25,1)='j'">
3811                                 <genre authority="marcgt">patent</genre>
3812                         </xsl:if>
3813                         <xsl:if test="substring($controlField008,25,1)='2'">
3814                                 <genre authority="marcgt">offprint</genre>
3815                         </xsl:if>
3816                         <xsl:if test="substring($controlField008,31,1)='1'">
3817                                 <genre authority="marcgt">festschrift</genre>
3818                         </xsl:if>
3819                         <xsl:variable name="controlField008-34" select="substring($controlField008,35,1)"/>
3820                         <xsl:if
3821                                 test="$controlField008-34='a' or $controlField008-34='b' or $controlField008-34='c' or $controlField008-34='d'">
3822                                 <genre authority="marcgt">biography</genre>
3823                         </xsl:if>
3824                         <xsl:variable name="controlField008-33" select="substring($controlField008,34,1)"/>
3825                         <xsl:choose>
3826                                 <xsl:when test="$controlField008-33='e'">
3827                                         <genre authority="marcgt">essay</genre>
3828                                 </xsl:when>
3829                                 <xsl:when test="$controlField008-33='d'">
3830                                         <genre authority="marcgt">drama</genre>
3831                                 </xsl:when>
3832                                 <xsl:when test="$controlField008-33='c'">
3833                                         <genre authority="marcgt">comic strip</genre>
3834                                 </xsl:when>
3835                                 <xsl:when test="$controlField008-33='l'">
3836                                         <genre authority="marcgt">fiction</genre>
3837                                 </xsl:when>
3838                                 <xsl:when test="$controlField008-33='h'">
3839                                         <genre authority="marcgt">humor, satire</genre>
3840                                 </xsl:when>
3841                                 <xsl:when test="$controlField008-33='i'">
3842                                         <genre authority="marcgt">letter</genre>
3843                                 </xsl:when>
3844                                 <xsl:when test="$controlField008-33='f'">
3845                                         <genre authority="marcgt">novel</genre>
3846                                 </xsl:when>
3847                                 <xsl:when test="$controlField008-33='j'">
3848                                         <genre authority="marcgt">short story</genre>
3849                                 </xsl:when>
3850                                 <xsl:when test="$controlField008-33='s'">
3851                                         <genre authority="marcgt">speech</genre>
3852                                 </xsl:when>
3853                         </xsl:choose>
3854                 </xsl:if>
3855                 <xsl:if test="$typeOf008='MU'">
3856                         <xsl:variable name="controlField008-30-31" select="substring($controlField008,31,2)"/>
3857                         <xsl:if test="contains($controlField008-30-31,'b')">
3858                                 <genre authority="marcgt">biography</genre>
3859                         </xsl:if>
3860                         <xsl:if test="contains($controlField008-30-31,'c')">
3861                                 <genre authority="marcgt">conference publication</genre>
3862                         </xsl:if>
3863                         <xsl:if test="contains($controlField008-30-31,'d')">
3864                                 <genre authority="marcgt">drama</genre>
3865                         </xsl:if>
3866                         <xsl:if test="contains($controlField008-30-31,'e')">
3867                                 <genre authority="marcgt">essay</genre>
3868                         </xsl:if>
3869                         <xsl:if test="contains($controlField008-30-31,'f')">
3870                                 <genre authority="marcgt">fiction</genre>
3871                         </xsl:if>
3872                         <xsl:if test="contains($controlField008-30-31,'o')">
3873                                 <genre authority="marcgt">folktale</genre>
3874                         </xsl:if>
3875                         <xsl:if test="contains($controlField008-30-31,'h')">
3876                                 <genre authority="marcgt">history</genre>
3877                         </xsl:if>
3878                         <xsl:if test="contains($controlField008-30-31,'k')">
3879                                 <genre authority="marcgt">humor, satire</genre>
3880                         </xsl:if>
3881                         <xsl:if test="contains($controlField008-30-31,'m')">
3882                                 <genre authority="marcgt">memoir</genre>
3883                         </xsl:if>
3884                         <xsl:if test="contains($controlField008-30-31,'p')">
3885                                 <genre authority="marcgt">poetry</genre>
3886                         </xsl:if>
3887                         <xsl:if test="contains($controlField008-30-31,'r')">
3888                                 <genre authority="marcgt">rehearsal</genre>
3889                         </xsl:if>
3890                         <xsl:if test="contains($controlField008-30-31,'g')">
3891                                 <genre authority="marcgt">reporting</genre>
3892                         </xsl:if>
3893                         <xsl:if test="contains($controlField008-30-31,'s')">
3894                                 <genre authority="marcgt">sound</genre>
3895                         </xsl:if>
3896                         <xsl:if test="contains($controlField008-30-31,'l')">
3897                                 <genre authority="marcgt">speech</genre>
3898                         </xsl:if>
3899                 </xsl:if>
3900                 <xsl:if test="$typeOf008='VM'">
3901                         <xsl:variable name="controlField008-33" select="substring($controlField008,34,1)"/>
3902                         <xsl:choose>
3903                                 <xsl:when test="$controlField008-33='a'">
3904                                         <genre authority="marcgt">art original</genre>
3905                                 </xsl:when>
3906                                 <xsl:when test="$controlField008-33='b'">
3907                                         <genre authority="marcgt">kit</genre>
3908                                 </xsl:when>
3909                                 <xsl:when test="$controlField008-33='c'">
3910                                         <genre authority="marcgt">art reproduction</genre>
3911                                 </xsl:when>
3912                                 <xsl:when test="$controlField008-33='d'">
3913                                         <genre authority="marcgt">diorama</genre>
3914                                 </xsl:when>
3915                                 <xsl:when test="$controlField008-33='f'">
3916                                         <genre authority="marcgt">filmstrip</genre>
3917                                 </xsl:when>
3918                                 <xsl:when test="$controlField008-33='g'">
3919                                         <genre authority="marcgt">legal article</genre>
3920                                 </xsl:when>
3921                                 <xsl:when test="$controlField008-33='i'">
3922                                         <genre authority="marcgt">picture</genre>
3923                                 </xsl:when>
3924                                 <xsl:when test="$controlField008-33='k'">
3925                                         <genre authority="marcgt">graphic</genre>
3926                                 </xsl:when>
3927                                 <xsl:when test="$controlField008-33='l'">
3928                                         <genre authority="marcgt">technical drawing</genre>
3929                                 </xsl:when>
3930                                 <xsl:when test="$controlField008-33='m'">
3931                                         <genre authority="marcgt">motion picture</genre>
3932                                 </xsl:when>
3933                                 <xsl:when test="$controlField008-33='n'">
3934                                         <genre authority="marcgt">chart</genre>
3935                                 </xsl:when>
3936                                 <xsl:when test="$controlField008-33='o'">
3937                                         <genre authority="marcgt">flash card</genre>
3938                                 </xsl:when>
3939                                 <xsl:when test="$controlField008-33='p'">
3940                                         <genre authority="marcgt">microscope slide</genre>
3941                                 </xsl:when>
3942                                 <xsl:when
3943                                         test="$controlField008-33='q' or marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='q']">
3944                                         <genre authority="marcgt">model</genre>
3945                                 </xsl:when>
3946                                 <xsl:when test="$controlField008-33='r'">
3947                                         <genre authority="marcgt">realia</genre>
3948                                 </xsl:when>
3949                                 <xsl:when test="$controlField008-33='s'">
3950                                         <genre authority="marcgt">slide</genre>
3951                                 </xsl:when>
3952                                 <xsl:when test="$controlField008-33='t'">
3953                                         <genre authority="marcgt">transparency</genre>
3954                                 </xsl:when>
3955                                 <xsl:when test="$controlField008-33='v'">
3956                                         <genre authority="marcgt">videorecording</genre>
3957                                 </xsl:when>
3958                                 <xsl:when test="$controlField008-33='w'">
3959                                         <genre authority="marcgt">toy</genre>
3960                                 </xsl:when>
3961                         </xsl:choose>
3962                 </xsl:if>
3963
3964                 <!-- 1.20 047 genre tmee-->
3965
3966                 <xsl:for-each select="marc:datafield[@tag=047]">
3967                         <genre authority="marcgt">
3968                                 <xsl:attribute name="authority">
3969                                         <xsl:value-of select="marc:subfield[@code='2']"/>
3970                                 </xsl:attribute>
3971                                 <xsl:call-template name="subfieldSelect">
3972                                         <xsl:with-param name="codes">abcdef</xsl:with-param>
3973                                         <xsl:with-param name="delimeter">-</xsl:with-param>
3974                                 </xsl:call-template>
3975                         </genre>
3976                 </xsl:for-each>
3977                 <xsl:for-each select="marc:datafield[@tag=655]">
3978                         <genre authority="marcgt">
3979                                 <xsl:attribute name="authority">
3980                                         <xsl:value-of select="marc:subfield[@code='2']"/>
3981                                 </xsl:attribute>
3982                                 <xsl:call-template name="subfieldSelect">
3983                                         <xsl:with-param name="codes">abvxyz</xsl:with-param>
3984                                         <xsl:with-param name="delimeter">-</xsl:with-param>
3985                                 </xsl:call-template>
3986                         </genre>
3987                 </xsl:for-each>
3988                 <originInfo>
3989                         <xsl:variable name="MARCpublicationCode"
3990                                 select="normalize-space(substring($controlField008,16,3))"/>
3991                         <xsl:if test="translate($MARCpublicationCode,'|','')">
3992                                 <place>
3993                                         <placeTerm>
3994                                                 <xsl:attribute name="type">code</xsl:attribute>
3995                                                 <xsl:attribute name="authority">marccountry</xsl:attribute>
3996                                                 <xsl:value-of select="$MARCpublicationCode"/>
3997                                         </placeTerm>
3998                                 </place>
3999                         </xsl:if>
4000                         <xsl:for-each select="marc:datafield[@tag=044]/marc:subfield[@code='c']">
4001                                 <place>
4002                                         <placeTerm>
4003                                                 <xsl:attribute name="type">code</xsl:attribute>
4004                                                 <xsl:attribute name="authority">iso3166</xsl:attribute>
4005                                                 <xsl:value-of select="."/>
4006                                         </placeTerm>
4007                                 </place>
4008                         </xsl:for-each>
4009                         <xsl:for-each select="marc:datafield[@tag=260]/marc:subfield[@code='a']">
4010                                 <place>
4011                                         <placeTerm>
4012                                                 <xsl:attribute name="type">text</xsl:attribute>
4013                                                 <xsl:call-template name="chopPunctuationFront">
4014                                                         <xsl:with-param name="chopString">
4015                                                                 <xsl:call-template name="chopPunctuation">
4016                                                                         <xsl:with-param name="chopString" select="."/>
4017                                                                 </xsl:call-template>
4018                                                         </xsl:with-param>
4019                                                 </xsl:call-template>
4020                                         </placeTerm>
4021                                 </place>
4022                         </xsl:for-each>
4023                         <xsl:for-each select="marc:datafield[@tag=046]/marc:subfield[@code='m']">
4024                                 <dateValid point="start">
4025                                         <xsl:value-of select="."/>
4026                                 </dateValid>
4027                         </xsl:for-each>
4028                         <xsl:for-each select="marc:datafield[@tag=046]/marc:subfield[@code='n']">
4029                                 <dateValid point="end">
4030                                         <xsl:value-of select="."/>
4031                                 </dateValid>
4032                         </xsl:for-each>
4033                         <xsl:for-each select="marc:datafield[@tag=046]/marc:subfield[@code='j']">
4034                                 <dateModified>
4035                                         <xsl:value-of select="."/>
4036                                 </dateModified>
4037                         </xsl:for-each>
4038                         <xsl:for-each
4039                                 select="marc:datafield[@tag=260]/marc:subfield[@code='b' or @code='c' or @code='g']">
4040                                 <xsl:choose>
4041                                         <xsl:when test="@code='b'">
4042                                                 <publisher>
4043                                                         <xsl:call-template name="chopPunctuation">
4044                                                                 <xsl:with-param name="chopString" select="."/>
4045                                                                 <xsl:with-param name="punctuation">
4046                                                                         <xsl:text>:,;/ </xsl:text>
4047                                                                 </xsl:with-param>
4048                                                         </xsl:call-template>
4049                                                 </publisher>
4050                                         </xsl:when>
4051                                         <xsl:when test="@code='c'">
4052                                                 <dateIssued>
4053                                                         <xsl:call-template name="chopPunctuation">
4054                                                                 <xsl:with-param name="chopString" select="."/>
4055                                                         </xsl:call-template>
4056                                                 </dateIssued>
4057                                         </xsl:when>
4058                                         <xsl:when test="@code='g'">
4059                                                 <dateCreated>
4060                                                         <xsl:value-of select="."/>
4061                                                 </dateCreated>
4062                                         </xsl:when>
4063                                 </xsl:choose>
4064                         </xsl:for-each>
4065                         <xsl:variable name="dataField260c">
4066                                 <xsl:call-template name="chopPunctuation">
4067                                         <xsl:with-param name="chopString"
4068                                                 select="marc:datafield[@tag=260]/marc:subfield[@code='c']"/>
4069                                 </xsl:call-template>
4070                         </xsl:variable>
4071                         <xsl:variable name="controlField008-7-10"
4072                                 select="normalize-space(substring($controlField008, 8, 4))"/>
4073                         <xsl:variable name="controlField008-11-14"
4074                                 select="normalize-space(substring($controlField008, 12, 4))"/>
4075                         <xsl:variable name="controlField008-6"
4076                                 select="normalize-space(substring($controlField008, 7, 1))"/>
4077                         <xsl:if
4078                                 test="$controlField008-6='e' or $controlField008-6='p' or $controlField008-6='r' or $controlField008-6='t' or $controlField008-6='s'">
4079                                 <xsl:if test="$controlField008-7-10 and ($controlField008-7-10 != $dataField260c)">
4080                                         <dateIssued encoding="marc">
4081                                                 <xsl:value-of select="$controlField008-7-10"/>
4082                                         </dateIssued>
4083                                 </xsl:if>
4084                         </xsl:if>
4085                         <xsl:if
4086                                 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'">
4087                                 <xsl:if test="$controlField008-7-10">
4088                                         <dateIssued encoding="marc" point="start">
4089                                                 <xsl:value-of select="$controlField008-7-10"/>
4090                                         </dateIssued>
4091                                 </xsl:if>
4092                         </xsl:if>
4093                         <xsl:if
4094                                 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'">
4095                                 <xsl:if test="$controlField008-11-14">
4096                                         <dateIssued encoding="marc" point="end">
4097                                                 <xsl:value-of select="$controlField008-11-14"/>
4098                                         </dateIssued>
4099                                 </xsl:if>
4100                         </xsl:if>
4101                         <xsl:if test="$controlField008-6='q'">
4102                                 <xsl:if test="$controlField008-7-10">
4103                                         <dateIssued encoding="marc" point="start" qualifier="questionable">
4104                                                 <xsl:value-of select="$controlField008-7-10"/>
4105                                         </dateIssued>
4106                                 </xsl:if>
4107                         </xsl:if>
4108                         <xsl:if test="$controlField008-6='q'">
4109                                 <xsl:if test="$controlField008-11-14">
4110                                         <dateIssued encoding="marc" point="end" qualifier="questionable">
4111                                                 <xsl:value-of select="$controlField008-11-14"/>
4112                                         </dateIssued>
4113                                 </xsl:if>
4114                         </xsl:if>
4115                         <xsl:if test="$controlField008-6='t'">
4116                                 <xsl:if test="$controlField008-11-14">
4117                                         <copyrightDate encoding="marc">
4118                                                 <xsl:value-of select="$controlField008-11-14"/>
4119                                         </copyrightDate>
4120                                 </xsl:if>
4121                         </xsl:if>
4122                         <xsl:for-each
4123                                 select="marc:datafield[@tag=033][@ind1=0 or @ind1=1]/marc:subfield[@code='a']">
4124                                 <dateCaptured encoding="iso8601">
4125                                         <xsl:value-of select="."/>
4126                                 </dateCaptured>
4127                         </xsl:for-each>
4128                         <xsl:for-each select="marc:datafield[@tag=033][@ind1=2]/marc:subfield[@code='a'][1]">
4129                                 <dateCaptured encoding="iso8601" point="start">
4130                                         <xsl:value-of select="."/>
4131                                 </dateCaptured>
4132                         </xsl:for-each>
4133                         <xsl:for-each select="marc:datafield[@tag=033][@ind1=2]/marc:subfield[@code='a'][2]">
4134                                 <dateCaptured encoding="iso8601" point="end">
4135                                         <xsl:value-of select="."/>
4136                                 </dateCaptured>
4137                         </xsl:for-each>
4138                         <xsl:for-each select="marc:datafield[@tag=250]/marc:subfield[@code='a']">
4139                                 <edition>
4140                                         <xsl:value-of select="."/>
4141                                 </edition>
4142                         </xsl:for-each>
4143                         <xsl:for-each select="marc:leader">
4144                                 <issuance>
4145                                         <xsl:choose>
4146                                                 <xsl:when
4147                                                         test="$leader7='a' or $leader7='c' or $leader7='d' or $leader7='m'"
4148                                                         >monographic</xsl:when>
4149                                                 <xsl:when test="$leader7='b' or $leader7='i' or $leader7='s'"
4150                                                 >continuing</xsl:when>
4151                                         </xsl:choose>
4152                                 </issuance>
4153                         </xsl:for-each>
4154                         <xsl:for-each select="marc:datafield[@tag=310]|marc:datafield[@tag=321]">
4155                                 <frequency>
4156                                         <xsl:call-template name="subfieldSelect">
4157                                                 <xsl:with-param name="codes">ab</xsl:with-param>
4158                                         </xsl:call-template>
4159                                 </frequency>
4160                         </xsl:for-each>
4161                 </originInfo>
4162                 <xsl:variable name="controlField008-35-37"
4163                         select="normalize-space(translate(substring($controlField008,36,3),'|#',''))"/>
4164                 <xsl:if test="$controlField008-35-37">
4165                         <language>
4166                                 <languageTerm authority="iso639-2b" type="code">
4167                                         <xsl:value-of select="substring($controlField008,36,3)"/>
4168                                 </languageTerm>
4169                         </language>
4170                 </xsl:if>
4171                 <xsl:for-each select="marc:datafield[@tag=041]">
4172                         <xsl:for-each
4173                                 select="marc:subfield[@code='a' or @code='b' or @code='d' or @code='e' or @code='f' or @code='g' or @code='h']">
4174                                 <xsl:variable name="langCodes" select="."/>
4175                                 <xsl:choose>
4176                                         <xsl:when test="../marc:subfield[@code='2']='rfc3066'">
4177                                                 <!-- not stacked but could be repeated -->
4178                                                 <xsl:call-template name="rfcLanguages">
4179                                                         <xsl:with-param name="nodeNum">
4180                                                                 <xsl:value-of select="1"/>
4181                                                         </xsl:with-param>
4182                                                         <xsl:with-param name="usedLanguages">
4183                                                                 <xsl:text/>
4184                                                         </xsl:with-param>
4185                                                         <xsl:with-param name="controlField008-35-37">
4186                                                                 <xsl:value-of select="$controlField008-35-37"/>
4187                                                         </xsl:with-param>
4188                                                 </xsl:call-template>
4189                                         </xsl:when>
4190                                         <xsl:otherwise>
4191                                                 <!-- iso -->
4192                                                 <xsl:variable name="allLanguages">
4193                                                         <xsl:copy-of select="$langCodes"/>
4194                                                 </xsl:variable>
4195                                                 <xsl:variable name="currentLanguage">
4196                                                         <xsl:value-of select="substring($allLanguages,1,3)"/>
4197                                                 </xsl:variable>
4198                                                 <xsl:call-template name="isoLanguage">
4199                                                         <xsl:with-param name="currentLanguage">
4200                                                                 <xsl:value-of select="substring($allLanguages,1,3)"/>
4201                                                         </xsl:with-param>
4202                                                         <xsl:with-param name="remainingLanguages">
4203                                                                 <xsl:value-of
4204                                                                         select="substring($allLanguages,4,string-length($allLanguages)-3)"
4205                                                                 />
4206                                                         </xsl:with-param>
4207                                                         <xsl:with-param name="usedLanguages">
4208                                                                 <xsl:if test="$controlField008-35-37">
4209                                                                         <xsl:value-of select="$controlField008-35-37"/>
4210                                                                 </xsl:if>
4211                                                         </xsl:with-param>
4212                                                 </xsl:call-template>
4213                                         </xsl:otherwise>
4214                                 </xsl:choose>
4215                         </xsl:for-each>
4216                 </xsl:for-each>
4217                 <xsl:variable name="physicalDescription">
4218                         <!--3.2 change tmee 007/11 -->
4219                         <xsl:if test="$typeOf008='CF' and marc:controlfield[@tag=007][substring(.,12,1)='a']">
4220                                 <digitalOrigin>reformatted digital</digitalOrigin>
4221                         </xsl:if>
4222                         <xsl:if test="$typeOf008='CF' and marc:controlfield[@tag=007][substring(.,12,1)='b']">
4223                                 <digitalOrigin>digitized microfilm</digitalOrigin>
4224                         </xsl:if>
4225                         <xsl:if test="$typeOf008='CF' and marc:controlfield[@tag=007][substring(.,12,1)='d']">
4226                                 <digitalOrigin>digitized other analog</digitalOrigin>
4227                         </xsl:if>
4228                         <xsl:variable name="controlField008-23" select="substring($controlField008,24,1)"/>
4229                         <xsl:variable name="controlField008-29" select="substring($controlField008,30,1)"/>
4230                         <xsl:variable name="check008-23">
4231                                 <xsl:if
4232                                         test="$typeOf008='BK' or $typeOf008='MU' or $typeOf008='SE' or $typeOf008='MM'">
4233                                         <xsl:value-of select="true()"/>
4234                                 </xsl:if>
4235                         </xsl:variable>
4236                         <xsl:variable name="check008-29">
4237                                 <xsl:if test="$typeOf008='MP' or $typeOf008='VM'">
4238                                         <xsl:value-of select="true()"/>
4239                                 </xsl:if>
4240                         </xsl:variable>
4241                         <xsl:choose>
4242                                 <xsl:when
4243                                         test="($check008-23 and $controlField008-23='f') or ($check008-29 and $controlField008-29='f')">
4244                                         <form authority="marcform">braille</form>
4245                                 </xsl:when>
4246                                 <xsl:when
4247                                         test="($controlField008-23=' ' and ($leader6='c' or $leader6='d')) or (($typeOf008='BK' or $typeOf008='SE') and ($controlField008-23=' ' or $controlField008='r'))">
4248                                         <form authority="marcform">print</form>
4249                                 </xsl:when>
4250                                 <xsl:when
4251                                         test="$leader6 = 'm' or ($check008-23 and $controlField008-23='s') or ($check008-29 and $controlField008-29='s')">
4252                                         <form authority="marcform">electronic</form>
4253                                 </xsl:when>
4254                                 <xsl:when
4255                                         test="($check008-23 and $controlField008-23='b') or ($check008-29 and $controlField008-29='b')">
4256                                         <form authority="marcform">microfiche</form>
4257                                 </xsl:when>
4258                                 <xsl:when
4259                                         test="($check008-23 and $controlField008-23='a') or ($check008-29 and $controlField008-29='a')">
4260                                         <form authority="marcform">microfilm</form>
4261                                 </xsl:when>
4262                         </xsl:choose>
4263                         <!-- 1/04 fix -->
4264                         <xsl:if test="marc:datafield[@tag=130]/marc:subfield[@code='h']">
4265                                 <form authority="gmd">
4266                                         <xsl:call-template name="chopBrackets">
4267                                                 <xsl:with-param name="chopString">
4268                                                         <xsl:value-of select="marc:datafield[@tag=130]/marc:subfield[@code='h']"
4269                                                         />
4270                                                 </xsl:with-param>
4271                                         </xsl:call-template>
4272                                 </form>
4273                         </xsl:if>
4274                         <xsl:if test="marc:datafield[@tag=240]/marc:subfield[@code='h']">
4275                                 <form authority="gmd">
4276                                         <xsl:call-template name="chopBrackets">
4277                                                 <xsl:with-param name="chopString">
4278                                                         <xsl:value-of select="marc:datafield[@tag=240]/marc:subfield[@code='h']"
4279                                                         />
4280                                                 </xsl:with-param>
4281                                         </xsl:call-template>
4282                                 </form>
4283                         </xsl:if>
4284                         <xsl:if test="marc:datafield[@tag=242]/marc:subfield[@code='h']">
4285                                 <form authority="gmd">
4286                                         <xsl:call-template name="chopBrackets">
4287                                                 <xsl:with-param name="chopString">
4288                                                         <xsl:value-of select="marc:datafield[@tag=242]/marc:subfield[@code='h']"
4289                                                         />
4290                                                 </xsl:with-param>
4291                                         </xsl:call-template>
4292                                 </form>
4293                         </xsl:if>
4294                         <xsl:if test="marc:datafield[@tag=245]/marc:subfield[@code='h']">
4295                                 <form authority="gmd">
4296                                         <xsl:call-template name="chopBrackets">
4297                                                 <xsl:with-param name="chopString">
4298                                                         <xsl:value-of select="marc:datafield[@tag=245]/marc:subfield[@code='h']"
4299                                                         />
4300                                                 </xsl:with-param>
4301                                         </xsl:call-template>
4302                                 </form>
4303                         </xsl:if>
4304                         <xsl:if test="marc:datafield[@tag=246]/marc:subfield[@code='h']">
4305                                 <form authority="gmd">
4306                                         <xsl:call-template name="chopBrackets">
4307                                                 <xsl:with-param name="chopString">
4308                                                         <xsl:value-of select="marc:datafield[@tag=246]/marc:subfield[@code='h']"
4309                                                         />
4310                                                 </xsl:with-param>
4311                                         </xsl:call-template>
4312                                 </form>
4313                         </xsl:if>
4314                         <xsl:if test="marc:datafield[@tag=730]/marc:subfield[@code='h']">
4315                                 <form authority="gmd">
4316                                         <xsl:call-template name="chopBrackets">
4317                                                 <xsl:with-param name="chopString">
4318                                                         <xsl:value-of select="marc:datafield[@tag=730]/marc:subfield[@code='h']"
4319                                                         />
4320                                                 </xsl:with-param>
4321                                         </xsl:call-template>
4322                                 </form>
4323                         </xsl:if>
4324                         <xsl:for-each select="marc:datafield[@tag=256]/marc:subfield[@code='a']">
4325                                 <form>
4326                                         <xsl:value-of select="."/>
4327                                 </form>
4328                         </xsl:for-each>
4329                         <xsl:for-each select="marc:controlfield[@tag=007][substring(text(),1,1)='c']">
4330                                 <xsl:choose>
4331                                         <xsl:when test="substring(text(),14,1)='a'">
4332                                                 <reformattingQuality>access</reformattingQuality>
4333                                         </xsl:when>
4334                                         <xsl:when test="substring(text(),14,1)='p'">
4335                                                 <reformattingQuality>preservation</reformattingQuality>
4336                                         </xsl:when>
4337                                         <xsl:when test="substring(text(),14,1)='r'">
4338                                                 <reformattingQuality>replacement</reformattingQuality>
4339                                         </xsl:when>
4340                                 </xsl:choose>
4341                         </xsl:for-each>
4342                         <!--3.2 change tmee 007/01 -->
4343                         <xsl:if
4344                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='b']">
4345                                 <form authority="smd">chip cartridge</form>
4346                         </xsl:if>
4347                         <xsl:if
4348                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='c']">
4349                                 <form authority="smd">computer optical disc cartridge</form>
4350                         </xsl:if>
4351                         <xsl:if
4352                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='j']">
4353                                 <form authority="smd">magnetic disc</form>
4354                         </xsl:if>
4355                         <xsl:if
4356                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='m']">
4357                                 <form authority="smd">magneto-optical disc</form>
4358                         </xsl:if>
4359                         <xsl:if
4360                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='o']">
4361                                 <form authority="smd">optical disc</form>
4362                         </xsl:if>
4363                         <xsl:if
4364                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='r']">
4365                                 <form authority="smd">remote</form>
4366                         </xsl:if>
4367                         <xsl:if
4368                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='a']">
4369                                 <form authority="smd">tape cartridge</form>
4370                         </xsl:if>
4371                         <xsl:if
4372                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='f']">
4373                                 <form authority="smd">tape cassette</form>
4374                         </xsl:if>
4375                         <xsl:if
4376                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='h']">
4377                                 <form authority="smd">tape reel</form>
4378                         </xsl:if>
4379
4380                         <xsl:if
4381                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='d'][substring(text(),2,1)='a']">
4382                                 <form authority="smd">celestial globe</form>
4383                         </xsl:if>
4384                         <xsl:if
4385                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='d'][substring(text(),2,1)='e']">
4386                                 <form authority="smd">earth moon globe</form>
4387                         </xsl:if>
4388                         <xsl:if
4389                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='d'][substring(text(),2,1)='b']">
4390                                 <form authority="smd">planetary or lunar globe</form>
4391                         </xsl:if>
4392                         <xsl:if
4393                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='d'][substring(text(),2,1)='c']">
4394                                 <form authority="smd">terrestrial globe</form>
4395                         </xsl:if>
4396
4397                         <xsl:if
4398                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='o'][substring(text(),2,1)='o']">
4399                                 <form authority="smd">kit</form>
4400                         </xsl:if>
4401
4402                         <xsl:if
4403                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='d']">
4404                                 <form authority="smd">atlas</form>
4405                         </xsl:if>
4406                         <xsl:if
4407                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='g']">
4408                                 <form authority="smd">diagram</form>
4409                         </xsl:if>
4410                         <xsl:if
4411                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='j']">
4412                                 <form authority="smd">map</form>
4413                         </xsl:if>
4414                         <xsl:if
4415                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='q']">
4416                                 <form authority="smd">model</form>
4417                         </xsl:if>
4418                         <xsl:if
4419                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='k']">
4420                                 <form authority="smd">profile</form>
4421                         </xsl:if>
4422                         <xsl:if
4423                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='r']">
4424                                 <form authority="smd">remote-sensing image</form>
4425                         </xsl:if>
4426                         <xsl:if
4427                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='s']">
4428                                 <form authority="smd">section</form>
4429                         </xsl:if>
4430                         <xsl:if
4431                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='y']">
4432                                 <form authority="smd">view</form>
4433                         </xsl:if>
4434
4435                         <xsl:if
4436                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='a']">
4437                                 <form authority="smd">aperture card</form>
4438                         </xsl:if>
4439                         <xsl:if
4440                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='e']">
4441                                 <form authority="smd">microfiche</form>
4442                         </xsl:if>
4443                         <xsl:if
4444                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='f']">
4445                                 <form authority="smd">microfiche cassette</form>
4446                         </xsl:if>
4447                         <xsl:if
4448                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='b']">
4449                                 <form authority="smd">microfilm cartridge</form>
4450                         </xsl:if>
4451                         <xsl:if
4452                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='c']">
4453                                 <form authority="smd">microfilm cassette</form>
4454                         </xsl:if>
4455                         <xsl:if
4456                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='d']">
4457                                 <form authority="smd">microfilm reel</form>
4458                         </xsl:if>
4459                         <xsl:if
4460                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='g']">
4461                                 <form authority="smd">microopaque</form>
4462                         </xsl:if>
4463
4464                         <xsl:if
4465                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='m'][substring(text(),2,1)='c']">
4466                                 <form authority="smd">film cartridge</form>
4467                         </xsl:if>
4468                         <xsl:if
4469                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='m'][substring(text(),2,1)='f']">
4470                                 <form authority="smd">film cassette</form>
4471                         </xsl:if>
4472                         <xsl:if
4473                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='m'][substring(text(),2,1)='r']">
4474                                 <form authority="smd">film reel</form>
4475                         </xsl:if>
4476
4477                         <xsl:if
4478                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='n']">
4479                                 <form authority="smd">chart</form>
4480                         </xsl:if>
4481                         <xsl:if
4482                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='c']">
4483                                 <form authority="smd">collage</form>
4484                         </xsl:if>
4485                         <xsl:if
4486                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='d']">
4487                                 <form authority="smd">drawing</form>
4488                         </xsl:if>
4489                         <xsl:if
4490                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='o']">
4491                                 <form authority="smd">flash card</form>
4492                         </xsl:if>
4493                         <xsl:if
4494                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='e']">
4495                                 <form authority="smd">painting</form>
4496                         </xsl:if>
4497                         <xsl:if
4498                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='f']">
4499                                 <form authority="smd">photomechanical print</form>
4500                         </xsl:if>
4501                         <xsl:if
4502                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='g']">
4503                                 <form authority="smd">photonegative</form>
4504                         </xsl:if>
4505                         <xsl:if
4506                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='h']">
4507                                 <form authority="smd">photoprint</form>
4508                         </xsl:if>
4509                         <xsl:if
4510                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='i']">
4511                                 <form authority="smd">picture</form>
4512                         </xsl:if>
4513                         <xsl:if
4514                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='j']">
4515                                 <form authority="smd">print</form>
4516                         </xsl:if>
4517                         <xsl:if
4518                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='l']">
4519                                 <form authority="smd">technical drawing</form>
4520                         </xsl:if>
4521
4522                         <xsl:if
4523                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='q'][substring(text(),2,1)='q']">
4524                                 <form authority="smd">notated music</form>
4525                         </xsl:if>
4526
4527                         <xsl:if
4528                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='d']">
4529                                 <form authority="smd">filmslip</form>
4530                         </xsl:if>
4531                         <xsl:if
4532                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='c']">
4533                                 <form authority="smd">filmstrip cartridge</form>
4534                         </xsl:if>
4535                         <xsl:if
4536                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='o']">
4537                                 <form authority="smd">filmstrip roll</form>
4538                         </xsl:if>
4539                         <xsl:if
4540                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='f']">
4541                                 <form authority="smd">other filmstrip type</form>
4542                         </xsl:if>
4543                         <xsl:if
4544                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='s']">
4545                                 <form authority="smd">slide</form>
4546                         </xsl:if>
4547                         <xsl:if
4548                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='t']">
4549                                 <form authority="smd">transparency</form>
4550                         </xsl:if>
4551                         <xsl:if
4552                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='r'][substring(text(),2,1)='r']">
4553                                 <form authority="smd">remote-sensing image</form>
4554                         </xsl:if>
4555                         <xsl:if
4556                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='e']">
4557                                 <form authority="smd">cylinder</form>
4558                         </xsl:if>
4559                         <xsl:if
4560                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='q']">
4561                                 <form authority="smd">roll</form>
4562                         </xsl:if>
4563                         <xsl:if
4564                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='g']">
4565                                 <form authority="smd">sound cartridge</form>
4566                         </xsl:if>
4567                         <xsl:if
4568                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='s']">
4569                                 <form authority="smd">sound cassette</form>
4570                         </xsl:if>
4571                         <xsl:if
4572                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='d']">
4573                                 <form authority="smd">sound disc</form>
4574                         </xsl:if>
4575                         <xsl:if
4576                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='t']">
4577                                 <form authority="smd">sound-tape reel</form>
4578                         </xsl:if>
4579                         <xsl:if
4580                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='i']">
4581                                 <form authority="smd">sound-track film</form>
4582                         </xsl:if>
4583                         <xsl:if
4584                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='w']">
4585                                 <form authority="smd">wire recording</form>
4586                         </xsl:if>
4587
4588                         <xsl:if
4589                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='f'][substring(text(),2,1)='c']">
4590                                 <form authority="smd">braille</form>
4591                         </xsl:if>
4592                         <xsl:if
4593                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='f'][substring(text(),2,1)='b']">
4594                                 <form authority="smd">combination</form>
4595                         </xsl:if>
4596                         <xsl:if
4597                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='f'][substring(text(),2,1)='a']">
4598                                 <form authority="smd">moon</form>
4599                         </xsl:if>
4600                         <xsl:if
4601                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='f'][substring(text(),2,1)='d']">
4602                                 <form authority="smd">tactile, with no writing system</form>
4603                         </xsl:if>
4604
4605                         <xsl:if
4606                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='t'][substring(text(),2,1)='c']">
4607                                 <form authority="smd">braille</form>
4608                         </xsl:if>
4609                         <xsl:if
4610                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='t'][substring(text(),2,1)='b']">
4611                                 <form authority="smd">large print</form>
4612                         </xsl:if>
4613                         <xsl:if
4614                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='t'][substring(text(),2,1)='a']">
4615                                 <form authority="smd">regular print</form>
4616                         </xsl:if>
4617                         <xsl:if
4618                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='t'][substring(text(),2,1)='d']">
4619                                 <form authority="smd">text in looseleaf binder</form>
4620                         </xsl:if>
4621
4622                         <xsl:if
4623                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='v'][substring(text(),2,1)='c']">
4624                                 <form authority="smd">videocartridge</form>
4625                         </xsl:if>
4626                         <xsl:if
4627                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='v'][substring(text(),2,1)='f']">
4628                                 <form authority="smd">videocassette</form>
4629                         </xsl:if>
4630                         <xsl:if
4631                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='v'][substring(text(),2,1)='d']">
4632                                 <form authority="smd">videodisc</form>
4633                         </xsl:if>
4634                         <xsl:if
4635                                 test="marc:controlfield[@tag=007][substring(text(),1,1)='v'][substring(text(),2,1)='r']">
4636                                 <form authority="smd">videoreel</form>
4637                         </xsl:if>
4638
4639                         <xsl:for-each
4640                                 select="marc:datafield[@tag=856]/marc:subfield[@code='q'][string-length(.)&gt;1]">
4641                                 <internetMediaType>
4642                                         <xsl:value-of select="."/>
4643                                 </internetMediaType>
4644                         </xsl:for-each>
4645                         <xsl:for-each select="marc:datafield[@tag=300]">
4646                                 <extent>
4647                                         <xsl:call-template name="subfieldSelect">
4648                                                 <xsl:with-param name="codes">abce</xsl:with-param>
4649                                         </xsl:call-template>
4650                                 </extent>
4651                         </xsl:for-each>
4652                 </xsl:variable>
4653                 <xsl:if test="string-length(normalize-space($physicalDescription))">
4654                         <physicalDescription>
4655                                 <xsl:copy-of select="$physicalDescription"/>
4656                         </physicalDescription>
4657                 </xsl:if>
4658                 <xsl:for-each select="marc:datafield[@tag=520]">
4659                         <abstract>
4660                                 <xsl:call-template name="uri"/>
4661                                 <xsl:call-template name="subfieldSelect">
4662                                         <xsl:with-param name="codes">ab</xsl:with-param>
4663                                 </xsl:call-template>
4664                         </abstract>
4665                 </xsl:for-each>
4666                 <xsl:for-each select="marc:datafield[@tag=505]">
4667                         <tableOfContents>
4668                                 <xsl:call-template name="uri"/>
4669                                 <xsl:call-template name="subfieldSelect">
4670                                         <xsl:with-param name="codes">agrt</xsl:with-param>
4671                                 </xsl:call-template>
4672                         </tableOfContents>
4673                 </xsl:for-each>
4674                 <xsl:for-each select="marc:datafield[@tag=521]">
4675                         <targetAudience>
4676                                 <xsl:call-template name="subfieldSelect">
4677                                         <xsl:with-param name="codes">ab</xsl:with-param>
4678                                 </xsl:call-template>
4679                         </targetAudience>
4680                 </xsl:for-each>
4681                 <xsl:if test="$typeOf008='BK' or $typeOf008='CF' or $typeOf008='MU' or $typeOf008='VM'">
4682                         <xsl:variable name="controlField008-22" select="substring($controlField008,23,1)"/>
4683                         <xsl:choose>
4684                                 <!-- 01/04 fix -->
4685                                 <xsl:when test="$controlField008-22='d'">
4686                                         <targetAudience authority="marctarget">adolescent</targetAudience>
4687                                 </xsl:when>
4688                                 <xsl:when test="$controlField008-22='e'">
4689                                         <targetAudience authority="marctarget">adult</targetAudience>
4690                                 </xsl:when>
4691                                 <xsl:when test="$controlField008-22='g'">
4692                                         <targetAudience authority="marctarget">general</targetAudience>
4693                                 </xsl:when>
4694                                 <xsl:when
4695                                         test="$controlField008-22='b' or $controlField008-22='c' or $controlField008-22='j'">
4696                                         <targetAudience authority="marctarget">juvenile</targetAudience>
4697                                 </xsl:when>
4698                                 <xsl:when test="$controlField008-22='a'">
4699                                         <targetAudience authority="marctarget">preschool</targetAudience>
4700                                 </xsl:when>
4701                                 <xsl:when test="$controlField008-22='f'">
4702                                         <targetAudience authority="marctarget">specialized</targetAudience>
4703                                 </xsl:when>
4704                         </xsl:choose>
4705                 </xsl:if>
4706                 <xsl:for-each select="marc:datafield[@tag=245]/marc:subfield[@code='c']">
4707                         <note type="statement of responsibility">
4708                                 <xsl:value-of select="."/>
4709                         </note>
4710                 </xsl:for-each>
4711                 <xsl:for-each select="marc:datafield[@tag=500]">
4712                         <note>
4713                                 <xsl:value-of select="marc:subfield[@code='a']"/>
4714                                 <xsl:call-template name="uri"/>
4715                         </note>
4716                 </xsl:for-each>
4717
4718                 <!--3.2 change tmee additional note fields-->
4719
4720                 <xsl:for-each select="marc:datafield[@tag=506]">
4721                         <note type="restrictions">
4722                                 <xsl:call-template name="uri"/>
4723                                 <xsl:variable name="str">
4724                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
4725                                                 <xsl:value-of select="."/>
4726                                                 <xsl:text> </xsl:text>
4727                                         </xsl:for-each>
4728                                 </xsl:variable>
4729                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
4730                         </note>
4731                 </xsl:for-each>
4732
4733                 <xsl:for-each select="marc:datafield[@tag=510]">
4734                         <note type="citation/reference">
4735                                 <xsl:call-template name="uri"/>
4736                                 <xsl:variable name="str">
4737                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
4738                                                 <xsl:value-of select="."/>
4739                                                 <xsl:text> </xsl:text>
4740                                         </xsl:for-each>
4741                                 </xsl:variable>
4742                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
4743                         </note>
4744                 </xsl:for-each>
4745
4746
4747                 <xsl:for-each select="marc:datafield[@tag=511]">
4748                         <note type="performers">
4749                                 <xsl:call-template name="uri"/>
4750                                 <xsl:value-of select="marc:subfield[@code='a']"/>
4751                         </note>
4752                 </xsl:for-each>
4753                 <xsl:for-each select="marc:datafield[@tag=518]">
4754                         <note type="venue">
4755                                 <xsl:call-template name="uri"/>
4756                                 <xsl:value-of select="marc:subfield[@code='a']"/>
4757                         </note>
4758                 </xsl:for-each>
4759
4760                 <xsl:for-each select="marc:datafield[@tag=530]">
4761                         <note type="additional physical form">
4762                                 <xsl:call-template name="uri"/>
4763                                 <xsl:variable name="str">
4764                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
4765                                                 <xsl:value-of select="."/>
4766                                                 <xsl:text> </xsl:text>
4767                                         </xsl:for-each>
4768                                 </xsl:variable>
4769                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
4770                         </note>
4771                 </xsl:for-each>
4772
4773                 <xsl:for-each select="marc:datafield[@tag=533]">
4774                         <note type="reproduction">
4775                                 <xsl:call-template name="uri"/>
4776                                 <xsl:variable name="str">
4777                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
4778                                                 <xsl:value-of select="."/>
4779                                                 <xsl:text> </xsl:text>
4780                                         </xsl:for-each>
4781                                 </xsl:variable>
4782                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
4783                         </note>
4784                 </xsl:for-each>
4785
4786                 <xsl:for-each select="marc:datafield[@tag=534]">
4787                         <note type="original version">
4788                                 <xsl:call-template name="uri"/>
4789                                 <xsl:variable name="str">
4790                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
4791                                                 <xsl:value-of select="."/>
4792                                                 <xsl:text> </xsl:text>
4793                                         </xsl:for-each>
4794                                 </xsl:variable>
4795                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
4796                         </note>
4797                 </xsl:for-each>
4798
4799                 <xsl:for-each select="marc:datafield[@tag=538]">
4800                         <note type="system details">
4801                                 <xsl:call-template name="uri"/>
4802                                 <xsl:variable name="str">
4803                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
4804                                                 <xsl:value-of select="."/>
4805                                                 <xsl:text> </xsl:text>
4806                                         </xsl:for-each>
4807                                 </xsl:variable>
4808                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
4809                         </note>
4810                 </xsl:for-each>
4811
4812                 <xsl:for-each select="marc:datafield[@tag=583]">
4813                         <note type="action">
4814                                 <xsl:call-template name="uri"/>
4815                                 <xsl:variable name="str">
4816                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
4817                                                 <xsl:value-of select="."/>
4818                                                 <xsl:text> </xsl:text>
4819                                         </xsl:for-each>
4820                                 </xsl:variable>
4821                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
4822                         </note>
4823                 </xsl:for-each>
4824
4825                 <xsl:for-each
4826                         select="marc:datafield[@tag=501 or @tag=502 or @tag=504 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=535 or @tag=536 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=584 or @tag=585 or @tag=586]">+
4827                         <note>
4828                                 <xsl:call-template name="uri"/>
4829                                 <xsl:variable name="str">
4830                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
4831                                                 <xsl:value-of select="."/>
4832                                                 <xsl:text> </xsl:text>
4833                                         </xsl:for-each>
4834                                 </xsl:variable>
4835                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
4836                         </note>
4837                 </xsl:for-each>
4838                 <xsl:for-each
4839                         select="marc:datafield[@tag=034][marc:subfield[@code='d' or @code='e' or @code='f' or @code='g']]">
4840                         <subject>
4841                                 <cartographics>
4842                                         <coordinates>
4843                                                 <xsl:call-template name="subfieldSelect">
4844                                                         <xsl:with-param name="codes">defg</xsl:with-param>
4845                                                 </xsl:call-template>
4846                                         </coordinates>
4847                                 </cartographics>
4848                         </subject>
4849                 </xsl:for-each>
4850                 <xsl:for-each select="marc:datafield[@tag=043]">
4851                         <subject>
4852                                 <xsl:for-each select="marc:subfield[@code='a' or @code='b' or @code='c']">
4853                                         <geographicCode>
4854                                                 <xsl:attribute name="authority">
4855                                                         <xsl:if test="@code='a'">
4856                                                                 <xsl:text>marcgac</xsl:text>
4857                                                         </xsl:if>
4858                                                         <xsl:if test="@code='b'">
4859                                                                 <xsl:value-of select="following-sibling::marc:subfield[@code=2]"/>
4860                                                         </xsl:if>
4861                                                         <xsl:if test="@code='c'">
4862                                                                 <xsl:text>iso3166</xsl:text>
4863                                                         </xsl:if>
4864                                                 </xsl:attribute>
4865                                                 <xsl:value-of select="self::marc:subfield"/>
4866                                         </geographicCode>
4867                                 </xsl:for-each>
4868                         </subject>
4869                 </xsl:for-each>
4870                 <!-- tmee 2006/11/27 -->
4871                 <xsl:for-each select="marc:datafield[@tag=255]">
4872                         <subject>
4873                                 <xsl:for-each select="marc:subfield[@code='a' or @code='b' or @code='c']">
4874                                         <cartographics>
4875                                                 <xsl:if test="@code='a'">
4876                                                         <scale>
4877                                                                 <xsl:value-of select="."/>
4878                                                         </scale>
4879                                                 </xsl:if>
4880                                                 <xsl:if test="@code='b'">
4881                                                         <projection>
4882                                                                 <xsl:value-of select="."/>
4883                                                         </projection>
4884                                                 </xsl:if>
4885                                                 <xsl:if test="@code='c'">
4886                                                         <coordinates>
4887                                                                 <xsl:value-of select="."/>
4888                                                         </coordinates>
4889                                                 </xsl:if>
4890                                         </cartographics>
4891                                 </xsl:for-each>
4892                         </subject>
4893                 </xsl:for-each>
4894
4895                 <xsl:apply-templates select="marc:datafield[653 &gt;= @tag and @tag &gt;= 600]"/>
4896                 <xsl:apply-templates select="marc:datafield[@tag=656]"/>
4897                 <xsl:for-each select="marc:datafield[@tag=752 or @tag=662]">
4898                         <subject>
4899                                 <hierarchicalGeographic>
4900                                         <xsl:for-each select="marc:subfield[@code='a']">
4901                                                 <country>
4902                                                         <xsl:call-template name="chopPunctuation">
4903                                                                 <xsl:with-param name="chopString" select="."/>
4904                                                         </xsl:call-template>
4905                                                 </country>
4906                                         </xsl:for-each>
4907                                         <xsl:for-each select="marc:subfield[@code='b']">
4908                                                 <state>
4909                                                         <xsl:call-template name="chopPunctuation">
4910                                                                 <xsl:with-param name="chopString" select="."/>
4911                                                         </xsl:call-template>
4912                                                 </state>
4913                                         </xsl:for-each>
4914                                         <xsl:for-each select="marc:subfield[@code='c']">
4915                                                 <county>
4916                                                         <xsl:call-template name="chopPunctuation">
4917                                                                 <xsl:with-param name="chopString" select="."/>
4918                                                         </xsl:call-template>
4919                                                 </county>
4920                                         </xsl:for-each>
4921                                         <xsl:for-each select="marc:subfield[@code='d']">
4922                                                 <city>
4923                                                         <xsl:call-template name="chopPunctuation">
4924                                                                 <xsl:with-param name="chopString" select="."/>
4925                                                         </xsl:call-template>
4926                                                 </city>
4927                                         </xsl:for-each>
4928                                         <xsl:for-each select="marc:subfield[@code='e']">
4929                                                 <citySection>
4930                                                         <xsl:call-template name="chopPunctuation">
4931                                                                 <xsl:with-param name="chopString" select="."/>
4932                                                         </xsl:call-template>
4933                                                 </citySection>
4934                                         </xsl:for-each>
4935                                         <xsl:for-each select="marc:subfield[@code='g']">
4936                                                 <region>
4937                                                         <xsl:call-template name="chopPunctuation">
4938                                                                 <xsl:with-param name="chopString" select="."/>
4939                                                         </xsl:call-template>
4940                                                 </region>
4941                                         </xsl:for-each>
4942                                         <xsl:for-each select="marc:subfield[@code='h']">
4943                                                 <extraterrestrialArea>
4944                                                         <xsl:call-template name="chopPunctuation">
4945                                                                 <xsl:with-param name="chopString" select="."/>
4946                                                         </xsl:call-template>
4947                                                 </extraterrestrialArea>
4948                                         </xsl:for-each>
4949                                 </hierarchicalGeographic>
4950                         </subject>
4951                 </xsl:for-each>
4952                 <xsl:for-each select="marc:datafield[@tag=045][marc:subfield[@code='b']]">
4953                         <subject>
4954                                 <xsl:choose>
4955                                         <xsl:when test="@ind1=2">
4956                                                 <temporal encoding="iso8601" point="start">
4957                                                         <xsl:call-template name="chopPunctuation">
4958                                                                 <xsl:with-param name="chopString">
4959                                                                         <xsl:value-of select="marc:subfield[@code='b'][1]"/>
4960                                                                 </xsl:with-param>
4961                                                         </xsl:call-template>
4962                                                 </temporal>
4963                                                 <temporal encoding="iso8601" point="end">
4964                                                         <xsl:call-template name="chopPunctuation">
4965                                                                 <xsl:with-param name="chopString">
4966                                                                         <xsl:value-of select="marc:subfield[@code='b'][2]"/>
4967                                                                 </xsl:with-param>
4968                                                         </xsl:call-template>
4969                                                 </temporal>
4970                                         </xsl:when>
4971                                         <xsl:otherwise>
4972                                                 <xsl:for-each select="marc:subfield[@code='b']">
4973                                                         <temporal encoding="iso8601">
4974                                                                 <xsl:call-template name="chopPunctuation">
4975                                                                         <xsl:with-param name="chopString" select="."/>
4976                                                                 </xsl:call-template>
4977                                                         </temporal>
4978                                                 </xsl:for-each>
4979                                         </xsl:otherwise>
4980                                 </xsl:choose>
4981                         </subject>
4982                 </xsl:for-each>
4983                 <xsl:for-each select="marc:datafield[@tag=050]">
4984                         <xsl:for-each select="marc:subfield[@code='b']">
4985                                 <classification authority="lcc">
4986                                         <xsl:if test="../marc:subfield[@code='3']">
4987                                                 <xsl:attribute name="displayLabel">
4988                                                         <xsl:value-of select="../marc:subfield[@code='3']"/>
4989                                                 </xsl:attribute>
4990                                         </xsl:if>
4991                                         <xsl:value-of select="preceding-sibling::marc:subfield[@code='a'][1]"/>
4992                                         <xsl:text> </xsl:text>
4993                                         <xsl:value-of select="text()"/>
4994                                 </classification>
4995                         </xsl:for-each>
4996                         <xsl:for-each
4997                                 select="marc:subfield[@code='a'][not(following-sibling::marc:subfield[@code='b'])]">
4998                                 <classification authority="lcc">
4999                                         <xsl:if test="../marc:subfield[@code='3']">
5000                                                 <xsl:attribute name="displayLabel">
5001                                                         <xsl:value-of select="../marc:subfield[@code='3']"/>
5002                                                 </xsl:attribute>
5003                                         </xsl:if>
5004                                         <xsl:value-of select="text()"/>
5005                                 </classification>
5006                         </xsl:for-each>
5007                 </xsl:for-each>
5008                 <xsl:for-each select="marc:datafield[@tag=082]">
5009                         <classification authority="ddc">
5010                                 <xsl:if test="marc:subfield[@code='2']">
5011                                         <xsl:attribute name="edition">
5012                                                 <xsl:value-of select="marc:subfield[@code='2']"/>
5013                                         </xsl:attribute>
5014                                 </xsl:if>
5015                                 <xsl:call-template name="subfieldSelect">
5016                                         <xsl:with-param name="codes">ab</xsl:with-param>
5017                                 </xsl:call-template>
5018                         </classification>
5019                 </xsl:for-each>
5020                 <xsl:for-each select="marc:datafield[@tag=080]">
5021                         <classification authority="udc">
5022                                 <xsl:call-template name="subfieldSelect">
5023                                         <xsl:with-param name="codes">abx</xsl:with-param>
5024                                 </xsl:call-template>
5025                         </classification>
5026                 </xsl:for-each>
5027                 <xsl:for-each select="marc:datafield[@tag=060]">
5028                         <classification authority="nlm">
5029                                 <xsl:call-template name="subfieldSelect">
5030                                         <xsl:with-param name="codes">ab</xsl:with-param>
5031                                 </xsl:call-template>
5032                         </classification>
5033                 </xsl:for-each>
5034                 <xsl:for-each select="marc:datafield[@tag=086][@ind1=0]">
5035                         <classification authority="sudocs">
5036                                 <xsl:value-of select="marc:subfield[@code='a']"/>
5037                         </classification>
5038                 </xsl:for-each>
5039                 <xsl:for-each select="marc:datafield[@tag=086][@ind1=1]">
5040                         <classification authority="candoc">
5041                                 <xsl:value-of select="marc:subfield[@code='a']"/>
5042                         </classification>
5043                 </xsl:for-each>
5044                 <xsl:for-each select="marc:datafield[@tag=086]">
5045                         <classification>
5046                                 <xsl:attribute name="authority">
5047                                         <xsl:value-of select="marc:subfield[@code='2']"/>
5048                                 </xsl:attribute>
5049                                 <xsl:value-of select="marc:subfield[@code='a']"/>
5050                         </classification>
5051                 </xsl:for-each>
5052                 <xsl:for-each select="marc:datafield[@tag=084]">
5053                         <classification>
5054                                 <xsl:attribute name="authority">
5055                                         <xsl:value-of select="marc:subfield[@code='2']"/>
5056                                 </xsl:attribute>
5057                                 <xsl:call-template name="subfieldSelect">
5058                                         <xsl:with-param name="codes">ab</xsl:with-param>
5059                                 </xsl:call-template>
5060                         </classification>
5061                 </xsl:for-each>
5062                 <xsl:for-each select="marc:datafield[@tag=440]">
5063                         <relatedItem type="series">
5064                                 <titleInfo>
5065                                         <title>
5066                                                 <xsl:call-template name="chopPunctuation">
5067                                                         <xsl:with-param name="chopString">
5068                                                                 <xsl:call-template name="subfieldSelect">
5069                                                                         <xsl:with-param name="codes">av</xsl:with-param>
5070                                                                 </xsl:call-template>
5071                                                         </xsl:with-param>
5072                                                 </xsl:call-template>
5073                                         </title>
5074                                         <xsl:call-template name="part"/>
5075                                 </titleInfo>
5076                         </relatedItem>
5077                 </xsl:for-each>
5078                 <xsl:for-each select="marc:datafield[@tag=490][@ind1=0]">
5079                         <relatedItem type="series">
5080                                 <titleInfo>
5081                                         <title>
5082                                                 <xsl:call-template name="chopPunctuation">
5083                                                         <xsl:with-param name="chopString">
5084                                                                 <xsl:call-template name="subfieldSelect">
5085                                                                         <xsl:with-param name="codes">av</xsl:with-param>
5086                                                                 </xsl:call-template>
5087                                                         </xsl:with-param>
5088                                                 </xsl:call-template>
5089                                         </title>
5090                                         <xsl:call-template name="part"/>
5091                                 </titleInfo>
5092                         </relatedItem>
5093                 </xsl:for-each>
5094                 <xsl:for-each select="marc:datafield[@tag=510]">
5095                         <relatedItem type="isReferencedBy">
5096                                 <note>
5097                                         <xsl:call-template name="subfieldSelect">
5098                                                 <xsl:with-param name="codes">abcx3</xsl:with-param>
5099                                         </xsl:call-template>
5100                                 </note>
5101                         </relatedItem>
5102                 </xsl:for-each>
5103                 <xsl:for-each select="marc:datafield[@tag=534]">
5104                         <relatedItem type="original">
5105                                 <xsl:call-template name="relatedTitle"/>
5106                                 <xsl:call-template name="relatedName"/>
5107                                 <xsl:if test="marc:subfield[@code='b' or @code='c']">
5108                                         <originInfo>
5109                                                 <xsl:for-each select="marc:subfield[@code='c']">
5110                                                         <publisher>
5111                                                                 <xsl:value-of select="."/>
5112                                                         </publisher>
5113                                                 </xsl:for-each>
5114                                                 <xsl:for-each select="marc:subfield[@code='b']">
5115                                                         <edition>
5116                                                                 <xsl:value-of select="."/>
5117                                                         </edition>
5118                                                 </xsl:for-each>
5119                                         </originInfo>
5120                                 </xsl:if>
5121                                 <xsl:call-template name="relatedIdentifierISSN"/>
5122                                 <xsl:for-each select="marc:subfield[@code='z']">
5123                                         <identifier type="isbn">
5124                                                 <xsl:value-of select="."/>
5125                                         </identifier>
5126                                 </xsl:for-each>
5127                                 <xsl:call-template name="relatedNote"/>
5128                         </relatedItem>
5129                 </xsl:for-each>
5130                 <xsl:for-each select="marc:datafield[@tag=700][marc:subfield[@code='t']]">
5131                         <relatedItem>
5132                                 <xsl:call-template name="constituentOrRelatedType"/>
5133                                 <titleInfo>
5134                                         <title>
5135                                                 <xsl:call-template name="chopPunctuation">
5136                                                         <xsl:with-param name="chopString">
5137                                                                 <xsl:call-template name="specialSubfieldSelect">
5138                                                                         <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
5139                                                                         <xsl:with-param name="axis">t</xsl:with-param>
5140                                                                         <xsl:with-param name="afterCodes">g</xsl:with-param>
5141                                                                 </xsl:call-template>
5142                                                         </xsl:with-param>
5143                                                 </xsl:call-template>
5144                                         </title>
5145                                         <xsl:call-template name="part"/>
5146                                 </titleInfo>
5147                                 <name type="personal">
5148                                         <namePart>
5149                                                 <xsl:call-template name="specialSubfieldSelect">
5150                                                         <xsl:with-param name="anyCodes">aq</xsl:with-param>
5151                                                         <xsl:with-param name="axis">t</xsl:with-param>
5152                                                         <xsl:with-param name="beforeCodes">g</xsl:with-param>
5153                                                 </xsl:call-template>
5154                                         </namePart>
5155                                         <xsl:call-template name="termsOfAddress"/>
5156                                         <xsl:call-template name="nameDate"/>
5157                                         <xsl:call-template name="role"/>
5158                                 </name>
5159                                 <xsl:call-template name="relatedForm"/>
5160                                 <xsl:call-template name="relatedIdentifierISSN"/>
5161                         </relatedItem>
5162                 </xsl:for-each>
5163                 <xsl:for-each select="marc:datafield[@tag=710][marc:subfield[@code='t']]">
5164                         <relatedItem>
5165                                 <xsl:call-template name="constituentOrRelatedType"/>
5166                                 <titleInfo>
5167                                         <title>
5168                                                 <xsl:call-template name="chopPunctuation">
5169                                                         <xsl:with-param name="chopString">
5170                                                                 <xsl:call-template name="specialSubfieldSelect">
5171                                                                         <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
5172                                                                         <xsl:with-param name="axis">t</xsl:with-param>
5173                                                                         <xsl:with-param name="afterCodes">dg</xsl:with-param>
5174                                                                 </xsl:call-template>
5175                                                         </xsl:with-param>
5176                                                 </xsl:call-template>
5177                                         </title>
5178                                         <xsl:call-template name="relatedPartNumName"/>
5179                                 </titleInfo>
5180                                 <name type="corporate">
5181                                         <xsl:for-each select="marc:subfield[@code='a']">
5182                                                 <namePart>
5183                                                         <xsl:value-of select="."/>
5184                                                 </namePart>
5185                                         </xsl:for-each>
5186                                         <xsl:for-each select="marc:subfield[@code='b']">
5187                                                 <namePart>
5188                                                         <xsl:value-of select="."/>
5189                                                 </namePart>
5190                                         </xsl:for-each>
5191                                         <xsl:variable name="tempNamePart">
5192                                                 <xsl:call-template name="specialSubfieldSelect">
5193                                                         <xsl:with-param name="anyCodes">c</xsl:with-param>
5194                                                         <xsl:with-param name="axis">t</xsl:with-param>
5195                                                         <xsl:with-param name="beforeCodes">dgn</xsl:with-param>
5196                                                 </xsl:call-template>
5197                                         </xsl:variable>
5198                                         <xsl:if test="normalize-space($tempNamePart)">
5199                                                 <namePart>
5200                                                         <xsl:value-of select="$tempNamePart"/>
5201                                                 </namePart>
5202                                         </xsl:if>
5203                                         <xsl:call-template name="role"/>
5204                                 </name>
5205                                 <xsl:call-template name="relatedForm"/>
5206                                 <xsl:call-template name="relatedIdentifierISSN"/>
5207                         </relatedItem>
5208                 </xsl:for-each>
5209                 <xsl:for-each select="marc:datafield[@tag=711][marc:subfield[@code='t']]">
5210                         <relatedItem>
5211                                 <xsl:call-template name="constituentOrRelatedType"/>
5212                                 <titleInfo>
5213                                         <title>
5214                                                 <xsl:call-template name="chopPunctuation">
5215                                                         <xsl:with-param name="chopString">
5216                                                                 <xsl:call-template name="specialSubfieldSelect">
5217                                                                         <xsl:with-param name="anyCodes">tfklsv</xsl:with-param>
5218                                                                         <xsl:with-param name="axis">t</xsl:with-param>
5219                                                                         <xsl:with-param name="afterCodes">g</xsl:with-param>
5220                                                                 </xsl:call-template>
5221                                                         </xsl:with-param>
5222                                                 </xsl:call-template>
5223                                         </title>
5224                                         <xsl:call-template name="relatedPartNumName"/>
5225                                 </titleInfo>
5226                                 <name type="conference">
5227                                         <namePart>
5228                                                 <xsl:call-template name="specialSubfieldSelect">
5229                                                         <xsl:with-param name="anyCodes">aqdc</xsl:with-param>
5230                                                         <xsl:with-param name="axis">t</xsl:with-param>
5231                                                         <xsl:with-param name="beforeCodes">gn</xsl:with-param>
5232                                                 </xsl:call-template>
5233                                         </namePart>
5234                                 </name>
5235                                 <xsl:call-template name="relatedForm"/>
5236                                 <xsl:call-template name="relatedIdentifierISSN"/>
5237                         </relatedItem>
5238                 </xsl:for-each>
5239                 <xsl:for-each select="marc:datafield[@tag=730][@ind2=2]">
5240                         <relatedItem>
5241                                 <xsl:call-template name="constituentOrRelatedType"/>
5242                                 <titleInfo>
5243                                         <title>
5244                                                 <xsl:call-template name="chopPunctuation">
5245                                                         <xsl:with-param name="chopString">
5246                                                                 <xsl:call-template name="subfieldSelect">
5247                                                                         <xsl:with-param name="codes">adfgklmorsv</xsl:with-param>
5248                                                                 </xsl:call-template>
5249                                                         </xsl:with-param>
5250                                                 </xsl:call-template>
5251                                         </title>
5252                                         <xsl:call-template name="part"/>
5253                                 </titleInfo>
5254                                 <xsl:call-template name="relatedForm"/>
5255                                 <xsl:call-template name="relatedIdentifierISSN"/>
5256                         </relatedItem>
5257                 </xsl:for-each>
5258                 <xsl:for-each select="marc:datafield[@tag=740][@ind2=2]">
5259                         <relatedItem>
5260                                 <xsl:call-template name="constituentOrRelatedType"/>
5261                                 <titleInfo>
5262                                         <title>
5263                                                 <xsl:call-template name="chopPunctuation">
5264                                                         <xsl:with-param name="chopString">
5265                                                                 <xsl:value-of select="marc:subfield[@code='a']"/>
5266                                                         </xsl:with-param>
5267                                                 </xsl:call-template>
5268                                         </title>
5269                                         <xsl:call-template name="part"/>
5270                                 </titleInfo>
5271                                 <xsl:call-template name="relatedForm"/>
5272                         </relatedItem>
5273                 </xsl:for-each>
5274                 <xsl:for-each select="marc:datafield[@tag=760]|marc:datafield[@tag=762]">
5275                         <relatedItem type="series">
5276                                 <xsl:call-template name="relatedItem76X-78X"/>
5277                         </relatedItem>
5278                 </xsl:for-each>
5279                 <xsl:for-each
5280                         select="marc:datafield[@tag=765]|marc:datafield[@tag=767]|marc:datafield[@tag=777]|marc:datafield[@tag=787]">
5281                         <relatedItem>
5282                                 <xsl:call-template name="relatedItem76X-78X"/>
5283                         </relatedItem>
5284                 </xsl:for-each>
5285                 <xsl:for-each select="marc:datafield[@tag=775]">
5286                         <relatedItem type="otherVersion">
5287                                 <xsl:call-template name="relatedItem76X-78X"/>
5288                         </relatedItem>
5289                 </xsl:for-each>
5290                 <xsl:for-each select="marc:datafield[@tag=770]|marc:datafield[@tag=774]">
5291                         <relatedItem type="constituent">
5292                                 <xsl:call-template name="relatedItem76X-78X"/>
5293                         </relatedItem>
5294                 </xsl:for-each>
5295                 <xsl:for-each select="marc:datafield[@tag=772]|marc:datafield[@tag=773]">
5296                         <relatedItem type="host">
5297                                 <xsl:call-template name="relatedItem76X-78X"/>
5298                         </relatedItem>
5299                 </xsl:for-each>
5300                 <xsl:for-each select="marc:datafield[@tag=776]">
5301                         <relatedItem type="otherFormat">
5302                                 <xsl:call-template name="relatedItem76X-78X"/>
5303                         </relatedItem>
5304                 </xsl:for-each>
5305                 <xsl:for-each select="marc:datafield[@tag=780]">
5306                         <relatedItem type="preceding">
5307                                 <xsl:call-template name="relatedItem76X-78X"/>
5308                         </relatedItem>
5309                 </xsl:for-each>
5310                 <xsl:for-each select="marc:datafield[@tag=785]">
5311                         <relatedItem type="succeeding">
5312                                 <xsl:call-template name="relatedItem76X-78X"/>
5313                         </relatedItem>
5314                 </xsl:for-each>
5315                 <xsl:for-each select="marc:datafield[@tag=786]">
5316                         <relatedItem type="original">
5317                                 <xsl:call-template name="relatedItem76X-78X"/>
5318                         </relatedItem>
5319                 </xsl:for-each>
5320                 <xsl:for-each select="marc:datafield[@tag=800]">
5321                         <relatedItem type="series">
5322                                 <titleInfo>
5323                                         <title>
5324                                                 <xsl:call-template name="chopPunctuation">
5325                                                         <xsl:with-param name="chopString">
5326                                                                 <xsl:call-template name="specialSubfieldSelect">
5327                                                                         <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
5328                                                                         <xsl:with-param name="axis">t</xsl:with-param>
5329                                                                         <xsl:with-param name="afterCodes">g</xsl:with-param>
5330                                                                 </xsl:call-template>
5331                                                         </xsl:with-param>
5332                                                 </xsl:call-template>
5333                                         </title>
5334                                         <xsl:call-template name="part"/>
5335                                 </titleInfo>
5336                                 <name type="personal">
5337                                         <namePart>
5338                                                 <xsl:call-template name="chopPunctuation">
5339                                                         <xsl:with-param name="chopString">
5340                                                                 <xsl:call-template name="specialSubfieldSelect">
5341                                                                         <xsl:with-param name="anyCodes">aq</xsl:with-param>
5342                                                                         <xsl:with-param name="axis">t</xsl:with-param>
5343                                                                         <xsl:with-param name="beforeCodes">g</xsl:with-param>
5344                                                                 </xsl:call-template>
5345                                                         </xsl:with-param>
5346                                                 </xsl:call-template>
5347                                         </namePart>
5348                                         <xsl:call-template name="termsOfAddress"/>
5349                                         <xsl:call-template name="nameDate"/>
5350                                         <xsl:call-template name="role"/>
5351                                 </name>
5352                                 <xsl:call-template name="relatedForm"/>
5353                         </relatedItem>
5354                 </xsl:for-each>
5355                 <xsl:for-each select="marc:datafield[@tag=810]">
5356                         <relatedItem type="series">
5357                                 <titleInfo>
5358                                         <title>
5359                                                 <xsl:call-template name="chopPunctuation">
5360                                                         <xsl:with-param name="chopString">
5361                                                                 <xsl:call-template name="specialSubfieldSelect">
5362                                                                         <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
5363                                                                         <xsl:with-param name="axis">t</xsl:with-param>
5364                                                                         <xsl:with-param name="afterCodes">dg</xsl:with-param>
5365                                                                 </xsl:call-template>
5366                                                         </xsl:with-param>
5367                                                 </xsl:call-template>
5368                                         </title>
5369                                         <xsl:call-template name="relatedPartNumName"/>
5370                                 </titleInfo>
5371                                 <name type="corporate">
5372                                         <xsl:for-each select="marc:subfield[@code='a']">
5373                                                 <namePart>
5374                                                         <xsl:value-of select="."/>
5375                                                 </namePart>
5376                                         </xsl:for-each>
5377                                         <xsl:for-each select="marc:subfield[@code='b']">
5378                                                 <namePart>
5379                                                         <xsl:value-of select="."/>
5380                                                 </namePart>
5381                                         </xsl:for-each>
5382                                         <namePart>
5383                                                 <xsl:call-template name="specialSubfieldSelect">
5384                                                         <xsl:with-param name="anyCodes">c</xsl:with-param>
5385                                                         <xsl:with-param name="axis">t</xsl:with-param>
5386                                                         <xsl:with-param name="beforeCodes">dgn</xsl:with-param>
5387                                                 </xsl:call-template>
5388                                         </namePart>
5389                                         <xsl:call-template name="role"/>
5390                                 </name>
5391                                 <xsl:call-template name="relatedForm"/>
5392                         </relatedItem>
5393                 </xsl:for-each>
5394                 <xsl:for-each select="marc:datafield[@tag=811]">
5395                         <relatedItem type="series">
5396                                 <titleInfo>
5397                                         <title>
5398                                                 <xsl:call-template name="chopPunctuation">
5399                                                         <xsl:with-param name="chopString">
5400                                                                 <xsl:call-template name="specialSubfieldSelect">
5401                                                                         <xsl:with-param name="anyCodes">tfklsv</xsl:with-param>
5402                                                                         <xsl:with-param name="axis">t</xsl:with-param>
5403                                                                         <xsl:with-param name="afterCodes">g</xsl:with-param>
5404                                                                 </xsl:call-template>
5405                                                         </xsl:with-param>
5406                                                 </xsl:call-template>
5407                                         </title>
5408                                         <xsl:call-template name="relatedPartNumName"/>
5409                                 </titleInfo>
5410                                 <name type="conference">
5411                                         <namePart>
5412                                                 <xsl:call-template name="specialSubfieldSelect">
5413                                                         <xsl:with-param name="anyCodes">aqdc</xsl:with-param>
5414                                                         <xsl:with-param name="axis">t</xsl:with-param>
5415                                                         <xsl:with-param name="beforeCodes">gn</xsl:with-param>
5416                                                 </xsl:call-template>
5417                                         </namePart>
5418                                         <xsl:call-template name="role"/>
5419                                 </name>
5420                                 <xsl:call-template name="relatedForm"/>
5421                         </relatedItem>
5422                 </xsl:for-each>
5423                 <xsl:for-each select="marc:datafield[@tag='830']">
5424                         <relatedItem type="series">
5425                                 <titleInfo>
5426                                         <title>
5427                                                 <xsl:call-template name="chopPunctuation">
5428                                                         <xsl:with-param name="chopString">
5429                                                                 <xsl:call-template name="subfieldSelect">
5430                                                                         <xsl:with-param name="codes">adfgklmorsv</xsl:with-param>
5431                                                                 </xsl:call-template>
5432                                                         </xsl:with-param>
5433                                                 </xsl:call-template>
5434                                         </title>
5435                                         <xsl:call-template name="part"/>
5436                                 </titleInfo>
5437                                 <xsl:call-template name="relatedForm"/>
5438                         </relatedItem>
5439                 </xsl:for-each>
5440                 <xsl:for-each select="marc:datafield[@tag='856'][@ind2='2']/marc:subfield[@code='q']">
5441                         <relatedItem>
5442                                 <internetMediaType>
5443                                         <xsl:value-of select="."/>
5444                                 </internetMediaType>
5445                         </relatedItem>
5446                 </xsl:for-each>
5447                 <xsl:for-each select="marc:datafield[@tag='020']">
5448                         <xsl:call-template name="isInvalid">
5449                                 <xsl:with-param name="type">isbn</xsl:with-param>
5450                         </xsl:call-template>
5451                         <xsl:if test="marc:subfield[@code='a']">
5452                                 <identifier type="isbn">
5453                                         <xsl:value-of select="marc:subfield[@code='a']"/>
5454                                 </identifier>
5455                         </xsl:if>
5456                 </xsl:for-each>
5457                 <xsl:for-each select="marc:datafield[@tag='024'][@ind1='0']">
5458                         <xsl:call-template name="isInvalid">
5459                                 <xsl:with-param name="type">isrc</xsl:with-param>
5460                         </xsl:call-template>
5461                         <xsl:if test="marc:subfield[@code='a']">
5462                                 <identifier type="isrc">
5463                                         <xsl:value-of select="marc:subfield[@code='a']"/>
5464                                 </identifier>
5465                         </xsl:if>
5466                 </xsl:for-each>
5467                 <xsl:for-each select="marc:datafield[@tag='024'][@ind1='2']">
5468                         <xsl:call-template name="isInvalid">
5469                                 <xsl:with-param name="type">ismn</xsl:with-param>
5470                         </xsl:call-template>
5471                         <xsl:if test="marc:subfield[@code='a']">
5472                                 <identifier type="ismn">
5473                                         <xsl:value-of select="marc:subfield[@code='a']"/>
5474                                 </identifier>
5475                         </xsl:if>
5476                 </xsl:for-each>
5477                 <xsl:for-each select="marc:datafield[@tag='024'][@ind1='4']">
5478                         <xsl:call-template name="isInvalid">
5479                                 <xsl:with-param name="type">sici</xsl:with-param>
5480                         </xsl:call-template>
5481                         <identifier type="sici">
5482                                 <xsl:call-template name="subfieldSelect">
5483                                         <xsl:with-param name="codes">ab</xsl:with-param>
5484                                 </xsl:call-template>
5485                         </identifier>
5486                 </xsl:for-each>
5487                 <xsl:for-each select="marc:datafield[@tag='022']">
5488                         <xsl:if test="marc:subfield[@code='a']">
5489                                 <xsl:call-template name="isInvalid">
5490                                         <xsl:with-param name="type">issn</xsl:with-param>
5491                                 </xsl:call-template>
5492                                 <identifier type="issn">
5493                                         <xsl:value-of select="marc:subfield[@code='a']"/>
5494                                 </identifier>
5495                         </xsl:if>
5496                         <xsl:if test="marc:subfield[@code='l']">
5497                                 <xsl:call-template name="isInvalid">
5498                                         <xsl:with-param name="type">issn-l</xsl:with-param>
5499                                 </xsl:call-template>
5500                                 <identifier type="issn-l">
5501                                         <xsl:value-of select="marc:subfield[@code='l']"/>
5502                                 </identifier>
5503                         </xsl:if>
5504                 </xsl:for-each>
5505
5506
5507
5508                 <xsl:for-each select="marc:datafield[@tag='010']">
5509                         <xsl:call-template name="isInvalid">
5510                                 <xsl:with-param name="type">lccn</xsl:with-param>
5511                         </xsl:call-template>
5512                         <identifier type="lccn">
5513                                 <xsl:value-of select="normalize-space(marc:subfield[@code='a'])"/>
5514                         </identifier>
5515                 </xsl:for-each>
5516                 <xsl:for-each select="marc:datafield[@tag='028']">
5517                         <identifier>
5518                                 <xsl:attribute name="type">
5519                                         <xsl:choose>
5520                                                 <xsl:when test="@ind1='0'">issue number</xsl:when>
5521                                                 <xsl:when test="@ind1='1'">matrix number</xsl:when>
5522                                                 <xsl:when test="@ind1='2'">music plate</xsl:when>
5523                                                 <xsl:when test="@ind1='3'">music publisher</xsl:when>
5524                                                 <xsl:when test="@ind1='4'">videorecording identifier</xsl:when>
5525                                         </xsl:choose>
5526                                 </xsl:attribute>
5527                                 <!--<xsl:call-template name="isInvalid"/>-->
5528                                 <!-- no $z in 028 -->
5529                                 <xsl:call-template name="subfieldSelect">
5530                                         <xsl:with-param name="codes">
5531                                                 <xsl:choose>
5532                                                         <xsl:when test="@ind1='0'">ba</xsl:when>
5533                                                         <xsl:otherwise>ab</xsl:otherwise>
5534                                                 </xsl:choose>
5535                                         </xsl:with-param>
5536                                 </xsl:call-template>
5537                         </identifier>
5538                 </xsl:for-each>
5539                 <xsl:for-each select="marc:datafield[@tag='037']">
5540                         <identifier type="stock number">
5541                                 <!--<xsl:call-template name="isInvalid"/>-->
5542                                 <!-- no $z in 037 -->
5543                                 <xsl:call-template name="subfieldSelect">
5544                                         <xsl:with-param name="codes">ab</xsl:with-param>
5545                                 </xsl:call-template>
5546                         </identifier>
5547                 </xsl:for-each>
5548                 <xsl:for-each select="marc:datafield[@tag='856'][marc:subfield[@code='u']]">
5549                         <identifier>
5550                                 <xsl:attribute name="type">
5551                                         <xsl:choose>
5552                                                 <xsl:when
5553                                                         test="starts-with(marc:subfield[@code='u'],'urn:doi') or starts-with(marc:subfield[@code='u'],'doi')"
5554                                                         >doi</xsl:when>
5555                                                 <xsl:when
5556                                                         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')"
5557                                                         >hdl</xsl:when>
5558                                                 <xsl:otherwise>uri</xsl:otherwise>
5559                                         </xsl:choose>
5560                                 </xsl:attribute>
5561                                 <xsl:choose>
5562                                         <xsl:when
5563                                                 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') ">
5564                                                 <xsl:value-of
5565                                                         select="concat('hdl:',substring-after(marc:subfield[@code='u'],'http://hdl.loc.gov/'))"
5566                                                 />
5567                                         </xsl:when>
5568                                         <xsl:otherwise>
5569                                                 <xsl:value-of select="marc:subfield[@code='u']"/>
5570                                         </xsl:otherwise>
5571                                 </xsl:choose>
5572                         </identifier>
5573                         <xsl:if
5574                                 test="starts-with(marc:subfield[@code='u'],'urn:hdl') or starts-with(marc:subfield[@code='u'],'hdl')">
5575                                 <identifier type="hdl">
5576                                         <xsl:if test="marc:subfield[@code='y' or @code='3' or @code='z']">
5577                                                 <xsl:attribute name="displayLabel">
5578                                                         <xsl:call-template name="subfieldSelect">
5579                                                                 <xsl:with-param name="codes">y3z</xsl:with-param>
5580                                                         </xsl:call-template>
5581                                                 </xsl:attribute>
5582                                         </xsl:if>
5583                                         <xsl:value-of
5584                                                 select="concat('hdl:',substring-after(marc:subfield[@code='u'],'http://hdl.loc.gov/'))"
5585                                         />
5586                                 </identifier>
5587                         </xsl:if>
5588                 </xsl:for-each>
5589                 <xsl:for-each select="marc:datafield[@tag=024][@ind1=1]">
5590                         <identifier type="upc">
5591                                 <xsl:call-template name="isInvalid"/>
5592                                 <xsl:value-of select="marc:subfield[@code='a']"/>
5593                         </identifier>
5594                 </xsl:for-each>
5595
5596                 <!-- 1/04 fix added $y -->
5597
5598                 <!-- 1.21  tmee-->
5599                 <xsl:for-each select="marc:datafield[@tag=856][@ind2=1][marc:subfield[@code='u']]">
5600                         <relatedItem type="otherVersion">
5601                                 <location>
5602                                         <url>
5603                                                 <xsl:if test="marc:subfield[@code='y' or @code='3']">
5604                                                         <xsl:attribute name="displayLabel">
5605                                                                 <xsl:call-template name="subfieldSelect">
5606                                                                         <xsl:with-param name="codes">y3</xsl:with-param>
5607                                                                 </xsl:call-template>
5608                                                         </xsl:attribute>
5609                                                 </xsl:if>
5610                                                 <xsl:if test="marc:subfield[@code='z' ]">
5611                                                         <xsl:attribute name="note">
5612                                                                 <xsl:call-template name="subfieldSelect">
5613                                                                         <xsl:with-param name="codes">z</xsl:with-param>
5614                                                                 </xsl:call-template>
5615                                                         </xsl:attribute>
5616                                                 </xsl:if>
5617                                                 <xsl:value-of select="marc:subfield[@code='u']"/>
5618                                         </url>
5619                                 </location>
5620                         </relatedItem>
5621                 </xsl:for-each>
5622                 <xsl:for-each select="marc:datafield[@tag=856][@ind2=2][marc:subfield[@code='u']]">
5623                         <relatedItem>
5624                                 <location>
5625                                         <url>
5626                                                 <xsl:if test="marc:subfield[@code='y' or @code='3']">
5627                                                         <xsl:attribute name="displayLabel">
5628                                                                 <xsl:call-template name="subfieldSelect">
5629                                                                         <xsl:with-param name="codes">y3</xsl:with-param>
5630                                                                 </xsl:call-template>
5631                                                         </xsl:attribute>
5632                                                 </xsl:if>
5633                                                 <xsl:if test="marc:subfield[@code='z' ]">
5634                                                         <xsl:attribute name="note">
5635                                                                 <xsl:call-template name="subfieldSelect">
5636                                                                         <xsl:with-param name="codes">z</xsl:with-param>
5637                                                                 </xsl:call-template>
5638                                                         </xsl:attribute>
5639                                                 </xsl:if>
5640                                                 <xsl:value-of select="marc:subfield[@code='u']"/>
5641                                         </url>
5642                                 </location>
5643                         </relatedItem>
5644                 </xsl:for-each>
5645
5646                 <!-- 3.2 change tmee 856z  -->
5647
5648                 <!-- 1.24  tmee  -->
5649                 <xsl:for-each select="marc:datafield[@tag=852]">
5650                         <location>
5651                                 <xsl:if test="marc:subfield[@code='a' or @code='b' or @code='e']">
5652                                         <physicalLocation>
5653                                                 <xsl:call-template name="subfieldSelect">
5654                                                         <xsl:with-param name="codes">abe</xsl:with-param>
5655                                                 </xsl:call-template>
5656                                         </physicalLocation>
5657                                 </xsl:if>
5658
5659                                 <xsl:if test="marc:subfield[@code='u']">
5660                                         <physicalLocation>
5661                                                 <xsl:call-template name="uri"/>
5662                                                 <xsl:call-template name="subfieldSelect">
5663                                                         <xsl:with-param name="codes">u</xsl:with-param>
5664                                                 </xsl:call-template>
5665                                         </physicalLocation>
5666                                 </xsl:if>
5667
5668                                 <xsl:if
5669                                         test="marc:subfield[@code='h' or @code='i' or @code='j' or @code='k' or @code='l' or @code='m' or @code='t']">
5670                                         <shelfLocation>
5671                                                 <xsl:call-template name="subfieldSelect">
5672                                                         <xsl:with-param name="codes">hijklmt</xsl:with-param>
5673                                                 </xsl:call-template>
5674                                         </shelfLocation>
5675                                 </xsl:if>
5676                         </location>
5677                 </xsl:for-each>
5678
5679                 <xsl:for-each select="marc:datafield[@tag=506]">
5680                         <accessCondition type="restrictionOnAccess">
5681                                 <xsl:call-template name="subfieldSelect">
5682                                         <xsl:with-param name="codes">abcd35</xsl:with-param>
5683                                 </xsl:call-template>
5684                         </accessCondition>
5685                 </xsl:for-each>
5686                 <xsl:for-each select="marc:datafield[@tag=540]">
5687                         <accessCondition type="useAndReproduction">
5688                                 <xsl:call-template name="subfieldSelect">
5689                                         <xsl:with-param name="codes">abcde35</xsl:with-param>
5690                                 </xsl:call-template>
5691                         </accessCondition>
5692                 </xsl:for-each>
5693
5694                 <recordInfo>
5695                         <!-- 1.25  tmee-->
5696
5697
5698                         <xsl:for-each select="marc:leader[substring($leader,19,1)='a']">
5699                                 <descriptionStandard>aacr2</descriptionStandard>
5700                         </xsl:for-each>
5701
5702                         <xsl:for-each select="marc:datafield[@tag=040]">
5703                                 <xsl:if test="marc:subfield[@code='e']">
5704                                         <descriptionStandard>
5705                                                 <xsl:value-of select="marc:subfield[@code='e']"/>
5706                                         </descriptionStandard>
5707                                 </xsl:if>
5708                                 <recordContentSource authority="marcorg">
5709                                         <xsl:value-of select="marc:subfield[@code='a']"/>
5710                                 </recordContentSource>
5711                         </xsl:for-each>
5712                         <xsl:for-each select="marc:controlfield[@tag=008]">
5713                                 <recordCreationDate encoding="marc">
5714                                         <xsl:value-of select="substring(.,1,6)"/>
5715                                 </recordCreationDate>
5716                         </xsl:for-each>
5717
5718                         <xsl:for-each select="marc:controlfield[@tag=005]">
5719                                 <recordChangeDate encoding="iso8601">
5720                                         <xsl:value-of select="."/>
5721                                 </recordChangeDate>
5722                         </xsl:for-each>
5723                         <xsl:for-each select="marc:controlfield[@tag=001]">
5724                                 <recordIdentifier>
5725                                         <xsl:if test="../marc:controlfield[@tag=003]">
5726                                                 <xsl:attribute name="source">
5727                                                         <xsl:value-of select="../marc:controlfield[@tag=003]"/>
5728                                                 </xsl:attribute>
5729                                         </xsl:if>
5730                                         <xsl:value-of select="."/>
5731                                 </recordIdentifier>
5732                         </xsl:for-each>
5733                         <xsl:for-each select="marc:datafield[@tag=040]/marc:subfield[@code='b']">
5734                                 <languageOfCataloging>
5735                                         <languageTerm authority="iso639-2b" type="code">
5736                                                 <xsl:value-of select="."/>
5737                                         </languageTerm>
5738                                 </languageOfCataloging>
5739                         </xsl:for-each>
5740                 </recordInfo>
5741         </xsl:template>
5742         <xsl:template name="displayForm">
5743                 <xsl:for-each select="marc:subfield[@code='c']">
5744                         <displayForm>
5745                                 <xsl:value-of select="."/>
5746                         </displayForm>
5747                 </xsl:for-each>
5748         </xsl:template>
5749         <xsl:template name="affiliation">
5750                 <xsl:for-each select="marc:subfield[@code='u']">
5751                         <affiliation>
5752                                 <xsl:value-of select="."/>
5753                         </affiliation>
5754                 </xsl:for-each>
5755         </xsl:template>
5756         <xsl:template name="uri">
5757                 <xsl:for-each select="marc:subfield[@code='u']">
5758                         <xsl:attribute name="xlink:href">
5759                                 <xsl:value-of select="."/>
5760                         </xsl:attribute>
5761                 </xsl:for-each>
5762                 <xsl:for-each select="marc:subfield[@code='0']">
5763                         <xsl:choose>
5764                                 <xsl:when test="contains(text(), ')')">
5765                                         <xsl:attribute name="xlink:href">
5766                                                 <xsl:value-of select="substring-after(text(), ')')"></xsl:value-of>
5767                                         </xsl:attribute>
5768                                 </xsl:when>
5769                                 <xsl:otherwise>
5770                                         <xsl:attribute name="xlink:href">
5771                                                 <xsl:value-of select="."></xsl:value-of>
5772                                         </xsl:attribute>
5773                                 </xsl:otherwise>
5774                         </xsl:choose>
5775                 </xsl:for-each>
5776         </xsl:template>
5777         <xsl:template name="role">
5778                 <xsl:for-each select="marc:subfield[@code='e']">
5779                         <role>
5780                                 <roleTerm type="text">
5781                                         <xsl:value-of select="."/>
5782                                 </roleTerm>
5783                         </role>
5784                 </xsl:for-each>
5785                 <xsl:for-each select="marc:subfield[@code='4']">
5786                         <role>
5787                                 <roleTerm authority="marcrelator" type="code">
5788                                         <xsl:value-of select="."/>
5789                                 </roleTerm>
5790                         </role>
5791                 </xsl:for-each>
5792         </xsl:template>
5793         <xsl:template name="part">
5794                 <xsl:variable name="partNumber">
5795                         <xsl:call-template name="specialSubfieldSelect">
5796                                 <xsl:with-param name="axis">n</xsl:with-param>
5797                                 <xsl:with-param name="anyCodes">n</xsl:with-param>
5798                                 <xsl:with-param name="afterCodes">fgkdlmor</xsl:with-param>
5799                         </xsl:call-template>
5800                 </xsl:variable>
5801                 <xsl:variable name="partName">
5802                         <xsl:call-template name="specialSubfieldSelect">
5803                                 <xsl:with-param name="axis">p</xsl:with-param>
5804                                 <xsl:with-param name="anyCodes">p</xsl:with-param>
5805                                 <xsl:with-param name="afterCodes">fgkdlmor</xsl:with-param>
5806                         </xsl:call-template>
5807                 </xsl:variable>
5808                 <xsl:if test="string-length(normalize-space($partNumber))">
5809                         <partNumber>
5810                                 <xsl:call-template name="chopPunctuation">
5811                                         <xsl:with-param name="chopString" select="$partNumber"/>
5812                                 </xsl:call-template>
5813                         </partNumber>
5814                 </xsl:if>
5815                 <xsl:if test="string-length(normalize-space($partName))">
5816                         <partName>
5817                                 <xsl:call-template name="chopPunctuation">
5818                                         <xsl:with-param name="chopString" select="$partName"/>
5819                                 </xsl:call-template>
5820                         </partName>
5821                 </xsl:if>
5822         </xsl:template>
5823         <xsl:template name="relatedPart">
5824                 <xsl:if test="@tag=773">
5825                         <xsl:for-each select="marc:subfield[@code='g']">
5826                                 <part>
5827                                         <text>
5828                                                 <xsl:value-of select="."/>
5829                                         </text>
5830                                 </part>
5831                         </xsl:for-each>
5832                         <xsl:for-each select="marc:subfield[@code='q']">
5833                                 <part>
5834                                         <xsl:call-template name="parsePart"/>
5835                                 </part>
5836                         </xsl:for-each>
5837                 </xsl:if>
5838         </xsl:template>
5839         <xsl:template name="relatedPartNumName">
5840                 <xsl:variable name="partNumber">
5841                         <xsl:call-template name="specialSubfieldSelect">
5842                                 <xsl:with-param name="axis">g</xsl:with-param>
5843                                 <xsl:with-param name="anyCodes">g</xsl:with-param>
5844                                 <xsl:with-param name="afterCodes">pst</xsl:with-param>
5845                         </xsl:call-template>
5846                 </xsl:variable>
5847                 <xsl:variable name="partName">
5848                         <xsl:call-template name="specialSubfieldSelect">
5849                                 <xsl:with-param name="axis">p</xsl:with-param>
5850                                 <xsl:with-param name="anyCodes">p</xsl:with-param>
5851                                 <xsl:with-param name="afterCodes">fgkdlmor</xsl:with-param>
5852                         </xsl:call-template>
5853                 </xsl:variable>
5854                 <xsl:if test="string-length(normalize-space($partNumber))">
5855                         <partNumber>
5856                                 <xsl:value-of select="$partNumber"/>
5857                         </partNumber>
5858                 </xsl:if>
5859                 <xsl:if test="string-length(normalize-space($partName))">
5860                         <partName>
5861                                 <xsl:value-of select="$partName"/>
5862                         </partName>
5863                 </xsl:if>
5864         </xsl:template>
5865         <xsl:template name="relatedName">
5866                 <xsl:for-each select="marc:subfield[@code='a']">
5867                         <name>
5868                                 <namePart>
5869                                         <xsl:value-of select="."/>
5870                                 </namePart>
5871                         </name>
5872                 </xsl:for-each>
5873         </xsl:template>
5874         <xsl:template name="relatedForm">
5875                 <xsl:for-each select="marc:subfield[@code='h']">
5876                         <physicalDescription>
5877                                 <form>
5878                                         <xsl:value-of select="."/>
5879                                 </form>
5880                         </physicalDescription>
5881                 </xsl:for-each>
5882         </xsl:template>
5883         <xsl:template name="relatedExtent">
5884                 <xsl:for-each select="marc:subfield[@code='h']">
5885                         <physicalDescription>
5886                                 <extent>
5887                                         <xsl:value-of select="."/>
5888                                 </extent>
5889                         </physicalDescription>
5890                 </xsl:for-each>
5891         </xsl:template>
5892         <xsl:template name="relatedNote">
5893                 <xsl:for-each select="marc:subfield[@code='n']">
5894                         <note>
5895                                 <xsl:value-of select="."/>
5896                         </note>
5897                 </xsl:for-each>
5898         </xsl:template>
5899         <xsl:template name="relatedSubject">
5900                 <xsl:for-each select="marc:subfield[@code='j']">
5901                         <subject>
5902                                 <temporal encoding="iso8601">
5903                                         <xsl:call-template name="chopPunctuation">
5904                                                 <xsl:with-param name="chopString" select="."/>
5905                                         </xsl:call-template>
5906                                 </temporal>
5907                         </subject>
5908                 </xsl:for-each>
5909         </xsl:template>
5910         <xsl:template name="relatedIdentifierISSN">
5911                 <xsl:for-each select="marc:subfield[@code='x']">
5912                         <identifier type="issn">
5913                                 <xsl:value-of select="."/>
5914                         </identifier>
5915                 </xsl:for-each>
5916         </xsl:template>
5917         <xsl:template name="relatedIdentifierLocal">
5918                 <xsl:for-each select="marc:subfield[@code='w']">
5919                         <identifier type="local">
5920                                 <xsl:value-of select="."/>
5921                         </identifier>
5922                 </xsl:for-each>
5923         </xsl:template>
5924         <xsl:template name="relatedIdentifier">
5925                 <xsl:for-each select="marc:subfield[@code='o']">
5926                         <identifier>
5927                                 <xsl:value-of select="."/>
5928                         </identifier>
5929                 </xsl:for-each>
5930         </xsl:template>
5931         <xsl:template name="relatedItem76X-78X">
5932                 <xsl:call-template name="displayLabel"/>
5933                 <xsl:call-template name="relatedTitle76X-78X"/>
5934                 <xsl:call-template name="relatedName"/>
5935                 <xsl:call-template name="relatedOriginInfo"/>
5936                 <xsl:call-template name="relatedLanguage"/>
5937                 <xsl:call-template name="relatedExtent"/>
5938                 <xsl:call-template name="relatedNote"/>
5939                 <xsl:call-template name="relatedSubject"/>
5940                 <xsl:call-template name="relatedIdentifier"/>
5941                 <xsl:call-template name="relatedIdentifierISSN"/>
5942                 <xsl:call-template name="relatedIdentifierLocal"/>
5943                 <xsl:call-template name="relatedPart"/>
5944         </xsl:template>
5945         <xsl:template name="subjectGeographicZ">
5946                 <geographic>
5947                         <xsl:call-template name="chopPunctuation">
5948                                 <xsl:with-param name="chopString" select="."/>
5949                         </xsl:call-template>
5950                 </geographic>
5951         </xsl:template>
5952         <xsl:template name="subjectTemporalY">
5953                 <temporal>
5954                         <xsl:call-template name="chopPunctuation">
5955                                 <xsl:with-param name="chopString" select="."/>
5956                         </xsl:call-template>
5957                 </temporal>
5958         </xsl:template>
5959         <xsl:template name="subjectTopic">
5960                 <topic>
5961                         <xsl:call-template name="chopPunctuation">
5962                                 <xsl:with-param name="chopString" select="."/>
5963                         </xsl:call-template>
5964                 </topic>
5965         </xsl:template>
5966         <!-- 3.2 change tmee 6xx $v genre -->
5967         <xsl:template name="subjectGenre">
5968                 <genre>
5969                         <xsl:call-template name="chopPunctuation">
5970                                 <xsl:with-param name="chopString" select="."/>
5971                         </xsl:call-template>
5972                 </genre>
5973         </xsl:template>
5974
5975         <xsl:template name="nameABCDN">
5976                 <xsl:for-each select="marc:subfield[@code='a']">
5977                         <namePart>
5978                                 <xsl:call-template name="chopPunctuation">
5979                                         <xsl:with-param name="chopString" select="."/>
5980                                 </xsl:call-template>
5981                         </namePart>
5982                 </xsl:for-each>
5983                 <xsl:for-each select="marc:subfield[@code='b']">
5984                         <namePart>
5985                                 <xsl:value-of select="."/>
5986                         </namePart>
5987                 </xsl:for-each>
5988                 <xsl:if
5989                         test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">
5990                         <namePart>
5991                                 <xsl:call-template name="subfieldSelect">
5992                                         <xsl:with-param name="codes">cdn</xsl:with-param>
5993                                 </xsl:call-template>
5994                         </namePart>
5995                 </xsl:if>
5996         </xsl:template>
5997         <xsl:template name="nameABCDQ">
5998                 <namePart>
5999                         <xsl:call-template name="chopPunctuation">
6000                                 <xsl:with-param name="chopString">
6001                                         <xsl:call-template name="subfieldSelect">
6002                                                 <xsl:with-param name="codes">aq</xsl:with-param>
6003                                         </xsl:call-template>
6004                                 </xsl:with-param>
6005                                 <xsl:with-param name="punctuation">
6006                                         <xsl:text>:,;/ </xsl:text>
6007                                 </xsl:with-param>
6008                         </xsl:call-template>
6009                 </namePart>
6010                 <xsl:call-template name="termsOfAddress"/>
6011                 <xsl:call-template name="nameDate"/>
6012         </xsl:template>
6013         <xsl:template name="nameACDEQ">
6014                 <namePart>
6015                         <xsl:call-template name="subfieldSelect">
6016                                 <xsl:with-param name="codes">acdeq</xsl:with-param>
6017                         </xsl:call-template>
6018                 </namePart>
6019         </xsl:template>
6020         <xsl:template name="constituentOrRelatedType">
6021                 <xsl:if test="@ind2=2">
6022                         <xsl:attribute name="type">constituent</xsl:attribute>
6023                 </xsl:if>
6024         </xsl:template>
6025         <xsl:template name="relatedTitle">
6026                 <xsl:for-each select="marc:subfield[@code='t']">
6027                         <titleInfo>
6028                                 <title>
6029                                         <xsl:call-template name="chopPunctuation">
6030                                                 <xsl:with-param name="chopString">
6031                                                         <xsl:value-of select="."/>
6032                                                 </xsl:with-param>
6033                                         </xsl:call-template>
6034                                 </title>
6035                         </titleInfo>
6036                 </xsl:for-each>
6037         </xsl:template>
6038         <xsl:template name="relatedTitle76X-78X">
6039                 <xsl:for-each select="marc:subfield[@code='t']">
6040                         <titleInfo>
6041                                 <title>
6042                                         <xsl:call-template name="chopPunctuation">
6043                                                 <xsl:with-param name="chopString">
6044                                                         <xsl:value-of select="."/>
6045                                                 </xsl:with-param>
6046                                         </xsl:call-template>
6047                                 </title>
6048                                 <xsl:if test="marc:datafield[@tag!=773]and marc:subfield[@code='g']">
6049                                         <xsl:call-template name="relatedPartNumName"/>
6050                                 </xsl:if>
6051                         </titleInfo>
6052                 </xsl:for-each>
6053                 <xsl:for-each select="marc:subfield[@code='p']">
6054                         <titleInfo type="abbreviated">
6055                                 <title>
6056                                         <xsl:call-template name="chopPunctuation">
6057                                                 <xsl:with-param name="chopString">
6058                                                         <xsl:value-of select="."/>
6059                                                 </xsl:with-param>
6060                                         </xsl:call-template>
6061                                 </title>
6062                                 <xsl:if test="marc:datafield[@tag!=773]and marc:subfield[@code='g']">
6063                                         <xsl:call-template name="relatedPartNumName"/>
6064                                 </xsl:if>
6065                         </titleInfo>
6066                 </xsl:for-each>
6067                 <xsl:for-each select="marc:subfield[@code='s']">
6068                         <titleInfo type="uniform">
6069                                 <title>
6070                                         <xsl:call-template name="chopPunctuation">
6071                                                 <xsl:with-param name="chopString">
6072                                                         <xsl:value-of select="."/>
6073                                                 </xsl:with-param>
6074                                         </xsl:call-template>
6075                                 </title>
6076                                 <xsl:if test="marc:datafield[@tag!=773]and marc:subfield[@code='g']">
6077                                         <xsl:call-template name="relatedPartNumName"/>
6078                                 </xsl:if>
6079                         </titleInfo>
6080                 </xsl:for-each>
6081         </xsl:template>
6082         <xsl:template name="relatedOriginInfo">
6083                 <xsl:if test="marc:subfield[@code='b' or @code='d'] or marc:subfield[@code='f']">
6084                         <originInfo>
6085                                 <xsl:if test="@tag=775">
6086                                         <xsl:for-each select="marc:subfield[@code='f']">
6087                                                 <place>
6088                                                         <placeTerm>
6089                                                                 <xsl:attribute name="type">code</xsl:attribute>
6090                                                                 <xsl:attribute name="authority">marcgac</xsl:attribute>
6091                                                                 <xsl:value-of select="."/>
6092                                                         </placeTerm>
6093                                                 </place>
6094                                         </xsl:for-each>
6095                                 </xsl:if>
6096                                 <xsl:for-each select="marc:subfield[@code='d']">
6097                                         <publisher>
6098                                                 <xsl:value-of select="."/>
6099                                         </publisher>
6100                                 </xsl:for-each>
6101                                 <xsl:for-each select="marc:subfield[@code='b']">
6102                                         <edition>
6103                                                 <xsl:value-of select="."/>
6104                                         </edition>
6105                                 </xsl:for-each>
6106                         </originInfo>
6107                 </xsl:if>
6108         </xsl:template>
6109         <xsl:template name="relatedLanguage">
6110                 <xsl:for-each select="marc:subfield[@code='e']">
6111                         <xsl:call-template name="getLanguage">
6112                                 <xsl:with-param name="langString">
6113                                         <xsl:value-of select="."/>
6114                                 </xsl:with-param>
6115                         </xsl:call-template>
6116                 </xsl:for-each>
6117         </xsl:template>
6118         <xsl:template name="nameDate">
6119                 <xsl:for-each select="marc:subfield[@code='d']">
6120                         <namePart type="date">
6121                                 <xsl:call-template name="chopPunctuation">
6122                                         <xsl:with-param name="chopString" select="."/>
6123                                 </xsl:call-template>
6124                         </namePart>
6125                 </xsl:for-each>
6126         </xsl:template>
6127         <xsl:template name="subjectAuthority">
6128                 <xsl:if test="@ind2!=4">
6129                         <xsl:if test="@ind2!=' '">
6130                                 <xsl:if test="@ind2!=8">
6131                                         <xsl:if test="@ind2!=9">
6132                                                 <xsl:attribute name="authority">
6133                                                         <xsl:choose>
6134                                                                 <xsl:when test="@ind2=0">lcsh</xsl:when>
6135                                                                 <xsl:when test="@ind2=1">lcshac</xsl:when>
6136                                                                 <xsl:when test="@ind2=2">mesh</xsl:when>
6137                                                                 <!-- 1/04 fix -->
6138                                                                 <xsl:when test="@ind2=3">nal</xsl:when>
6139                                                                 <xsl:when test="@ind2=5">csh</xsl:when>
6140                                                                 <xsl:when test="@ind2=6">rvm</xsl:when>
6141                                                                 <xsl:when test="@ind2=7">
6142                                                                         <xsl:value-of select="marc:subfield[@code='2']"/>
6143                                                                 </xsl:when>
6144                                                         </xsl:choose>
6145                                                 </xsl:attribute>
6146                                         </xsl:if>
6147                                 </xsl:if>
6148                         </xsl:if>
6149                 </xsl:if>
6150         </xsl:template>
6151         <xsl:template name="subjectAnyOrder">
6152                 <xsl:for-each select="marc:subfield[@code='v' or @code='x' or @code='y' or @code='z']">
6153                         <xsl:choose>
6154                                 <xsl:when test="@code='v'">
6155                                         <xsl:call-template name="subjectGenre"/>
6156                                 </xsl:when>
6157                                 <xsl:when test="@code='x'">
6158                                         <xsl:call-template name="subjectTopic"/>
6159                                 </xsl:when>
6160                                 <xsl:when test="@code='y'">
6161                                         <xsl:call-template name="subjectTemporalY"/>
6162                                 </xsl:when>
6163                                 <xsl:when test="@code='z'">
6164                                         <xsl:call-template name="subjectGeographicZ"/>
6165                                 </xsl:when>
6166                         </xsl:choose>
6167                 </xsl:for-each>
6168         </xsl:template>
6169         <xsl:template name="specialSubfieldSelect">
6170                 <xsl:param name="anyCodes"/>
6171                 <xsl:param name="axis"/>
6172                 <xsl:param name="beforeCodes"/>
6173                 <xsl:param name="afterCodes"/>
6174                 <xsl:variable name="str">
6175                         <xsl:for-each select="marc:subfield">
6176                                 <xsl:if
6177                                         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])">
6178                                         <xsl:value-of select="text()"/>
6179                                         <xsl:text> </xsl:text>
6180                                 </xsl:if>
6181                         </xsl:for-each>
6182                 </xsl:variable>
6183                 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
6184         </xsl:template>
6185
6186         <!-- 3.2 change tmee 6xx $v genre -->
6187         <xsl:template match="marc:datafield[@tag=600]">
6188                 <subject>
6189                         <xsl:call-template name="subjectAuthority"/>
6190                         <name type="personal">
6191                                 <xsl:call-template name="termsOfAddress"/>
6192                                 <namePart>
6193                                         <xsl:call-template name="chopPunctuation">
6194                                                 <xsl:with-param name="chopString">
6195                                                         <xsl:call-template name="subfieldSelect">
6196                                                                 <xsl:with-param name="codes">aq</xsl:with-param>
6197                                                         </xsl:call-template>
6198                                                 </xsl:with-param>
6199                                         </xsl:call-template>
6200                                 </namePart>
6201                                 <xsl:call-template name="nameDate"/>
6202                                 <xsl:call-template name="affiliation"/>
6203                                 <xsl:call-template name="role"/>
6204                         </name>
6205                         <xsl:call-template name="subjectAnyOrder"/>
6206                 </subject>
6207         </xsl:template>
6208         <xsl:template match="marc:datafield[@tag=610]">
6209                 <subject>
6210                         <xsl:call-template name="subjectAuthority"/>
6211                         <name type="corporate">
6212                                 <xsl:for-each select="marc:subfield[@code='a']">
6213                                         <namePart>
6214                                                 <xsl:value-of select="."/>
6215                                         </namePart>
6216                                 </xsl:for-each>
6217                                 <xsl:for-each select="marc:subfield[@code='b']">
6218                                         <namePart>
6219                                                 <xsl:value-of select="."/>
6220                                         </namePart>
6221                                 </xsl:for-each>
6222                                 <xsl:if test="marc:subfield[@code='c' or @code='d' or @code='n' or @code='p']">
6223                                         <namePart>
6224                                                 <xsl:call-template name="subfieldSelect">
6225                                                         <xsl:with-param name="codes">cdnp</xsl:with-param>
6226                                                 </xsl:call-template>
6227                                         </namePart>
6228                                 </xsl:if>
6229                                 <xsl:call-template name="role"/>
6230                         </name>
6231                         <xsl:call-template name="subjectAnyOrder"/>
6232                 </subject>
6233         </xsl:template>
6234         <xsl:template match="marc:datafield[@tag=611]">
6235                 <subject>
6236                         <xsl:call-template name="subjectAuthority"/>
6237                         <name type="conference">
6238                                 <namePart>
6239                                         <xsl:call-template name="subfieldSelect">
6240                                                 <xsl:with-param name="codes">abcdeqnp</xsl:with-param>
6241                                         </xsl:call-template>
6242                                 </namePart>
6243                                 <xsl:for-each select="marc:subfield[@code='4']">
6244                                         <role>
6245                                                 <roleTerm authority="marcrelator" type="code">
6246                                                         <xsl:value-of select="."/>
6247                                                 </roleTerm>
6248                                         </role>
6249                                 </xsl:for-each>
6250                         </name>
6251                         <xsl:call-template name="subjectAnyOrder"/>
6252                 </subject>
6253         </xsl:template>
6254         <xsl:template match="marc:datafield[@tag=630]">
6255                 <subject>
6256                         <xsl:call-template name="subjectAuthority"/>
6257                         <titleInfo>
6258                                 <title>
6259                                         <xsl:call-template name="chopPunctuation">
6260                                                 <xsl:with-param name="chopString">
6261                                                         <xsl:call-template name="subfieldSelect">
6262                                                                 <xsl:with-param name="codes">adfhklor</xsl:with-param>
6263                                                         </xsl:call-template>
6264                                                 </xsl:with-param>
6265                                         </xsl:call-template>
6266                                 </title>
6267                                 <xsl:call-template name="part"/>
6268                         </titleInfo>
6269                         <xsl:call-template name="subjectAnyOrder"/>
6270                 </subject>
6271         </xsl:template>
6272         <!-- 1.27 648 tmee-->
6273         <xsl:template match="marc:datafield[@tag=648]">
6274                 <subject>
6275                         <xsl:if test="marc:subfield[@code=2]">
6276                                 <xsl:attribute name="authority">
6277                                         <xsl:value-of select="marc:subfield[@code=2]"/>
6278                                 </xsl:attribute>
6279                         </xsl:if>
6280                         <xsl:call-template name="uri"/>
6281
6282                         <xsl:call-template name="subjectAuthority"/>
6283                         <temporal>
6284                                 <xsl:call-template name="chopPunctuation">
6285                                         <xsl:with-param name="chopString">
6286                                                 <xsl:call-template name="subfieldSelect">
6287                                                         <xsl:with-param name="codes">abcd</xsl:with-param>
6288                                                 </xsl:call-template>
6289                                         </xsl:with-param>
6290                                 </xsl:call-template>
6291                         </temporal>
6292                         <xsl:call-template name="subjectAnyOrder"/>
6293
6294                 </subject>
6295         </xsl:template>
6296         <xsl:template match="marc:datafield[@tag=650]">
6297                 <subject>
6298                         <xsl:call-template name="subjectAuthority"/>
6299                         <topic>
6300                                 <xsl:call-template name="chopPunctuation">
6301                                         <xsl:with-param name="chopString">
6302                                                 <xsl:call-template name="subfieldSelect">
6303                                                         <xsl:with-param name="codes">abcd</xsl:with-param>
6304                                                 </xsl:call-template>
6305                                         </xsl:with-param>
6306                                 </xsl:call-template>
6307                         </topic>
6308                         <xsl:call-template name="subjectAnyOrder"/>
6309                 </subject>
6310         </xsl:template>
6311         <xsl:template match="marc:datafield[@tag=651]">
6312                 <subject>
6313                         <xsl:call-template name="subjectAuthority"/>
6314                         <xsl:for-each select="marc:subfield[@code='a']">
6315                                 <geographic>
6316                                         <xsl:call-template name="chopPunctuation">
6317                                                 <xsl:with-param name="chopString" select="."/>
6318                                         </xsl:call-template>
6319                                 </geographic>
6320                         </xsl:for-each>
6321                         <xsl:call-template name="subjectAnyOrder"/>
6322                 </subject>
6323         </xsl:template>
6324         <xsl:template match="marc:datafield[@tag=653]">
6325                 <subject>
6326                         <xsl:for-each select="marc:subfield[@code='a']">
6327                                 <topic>
6328                                         <xsl:value-of select="."/>
6329                                 </topic>
6330                         </xsl:for-each>
6331                 </subject>
6332         </xsl:template>
6333         <xsl:template match="marc:datafield[@tag=656]">
6334                 <subject>
6335                         <xsl:if test="marc:subfield[@code=2]">
6336                                 <xsl:attribute name="authority">
6337                                         <xsl:value-of select="marc:subfield[@code=2]"/>
6338                                 </xsl:attribute>
6339                         </xsl:if>
6340                         <occupation>
6341                                 <xsl:call-template name="chopPunctuation">
6342                                         <xsl:with-param name="chopString">
6343                                                 <xsl:value-of select="marc:subfield[@code='a']"/>
6344                                         </xsl:with-param>
6345                                 </xsl:call-template>
6346                         </occupation>
6347                 </subject>
6348         </xsl:template>
6349         <xsl:template name="termsOfAddress">
6350                 <xsl:if test="marc:subfield[@code='b' or @code='c']">
6351                         <namePart type="termsOfAddress">
6352                                 <xsl:call-template name="chopPunctuation">
6353                                         <xsl:with-param name="chopString">
6354                                                 <xsl:call-template name="subfieldSelect">
6355                                                         <xsl:with-param name="codes">bc</xsl:with-param>
6356                                                 </xsl:call-template>
6357                                         </xsl:with-param>
6358                                 </xsl:call-template>
6359                         </namePart>
6360                 </xsl:if>
6361         </xsl:template>
6362         <xsl:template name="displayLabel">
6363                 <xsl:if test="marc:subfield[@code='i']">
6364                         <xsl:attribute name="displayLabel">
6365                                 <xsl:value-of select="marc:subfield[@code='i']"/>
6366                         </xsl:attribute>
6367                 </xsl:if>
6368                 <xsl:if test="marc:subfield[@code='3']">
6369                         <xsl:attribute name="displayLabel">
6370                                 <xsl:value-of select="marc:subfield[@code='3']"/>
6371                         </xsl:attribute>
6372                 </xsl:if>
6373         </xsl:template>
6374         <xsl:template name="isInvalid">
6375                 <xsl:param name="type"/>
6376                 <xsl:if
6377                         test="marc:subfield[@code='z'] or marc:subfield[@code='y']  or marc:subfield[@code='m']">
6378                         <identifier>
6379                                 <xsl:attribute name="type">
6380                                         <xsl:value-of select="$type"/>
6381                                 </xsl:attribute>
6382                                 <xsl:attribute name="invalid">
6383                                         <xsl:text>yes</xsl:text>
6384                                 </xsl:attribute>
6385                                 <xsl:if test="marc:subfield[@code='z']">
6386                                         <xsl:value-of select="marc:subfield[@code='z']"/>
6387                                 </xsl:if>
6388                                 <xsl:if test="marc:subfield[@code='y']">
6389                                         <xsl:value-of select="marc:subfield[@code='y']"/>
6390                                 </xsl:if>
6391                                 <xsl:if test="marc:subfield[@code='m']">
6392                                         <xsl:value-of select="marc:subfield[@code='m']"/>
6393                                 </xsl:if>
6394                         </identifier>
6395                 </xsl:if>
6396         </xsl:template>
6397         <xsl:template name="subtitle">
6398                 <xsl:if test="marc:subfield[@code='b']">
6399                         <subTitle>
6400                                 <xsl:call-template name="chopPunctuation">
6401                                         <xsl:with-param name="chopString">
6402                                                 <xsl:value-of select="marc:subfield[@code='b']"/>
6403                                                 <!--<xsl:call-template name="subfieldSelect">
6404                                                         <xsl:with-param name="codes">b</xsl:with-param>
6405                                                 </xsl:call-template>-->
6406                                         </xsl:with-param>
6407                                 </xsl:call-template>
6408                         </subTitle>
6409                 </xsl:if>
6410         </xsl:template>
6411         <xsl:template name="script">
6412                 <xsl:param name="scriptCode"/>
6413                 <xsl:attribute name="script">
6414                         <xsl:choose>
6415                                 <xsl:when test="$scriptCode='(3'">Arabic</xsl:when>
6416                                 <xsl:when test="$scriptCode='(B'">Latin</xsl:when>
6417                                 <xsl:when test="$scriptCode='$1'">Chinese, Japanese, Korean</xsl:when>
6418                                 <xsl:when test="$scriptCode='(N'">Cyrillic</xsl:when>
6419                                 <xsl:when test="$scriptCode='(2'">Hebrew</xsl:when>
6420                                 <xsl:when test="$scriptCode='(S'">Greek</xsl:when>
6421                         </xsl:choose>
6422                 </xsl:attribute>
6423         </xsl:template>
6424         <xsl:template name="parsePart">
6425                 <!-- assumes 773$q= 1:2:3<4
6426                      with up to 3 levels and one optional start page
6427                 -->
6428                 <xsl:variable name="level1">
6429                         <xsl:choose>
6430                                 <xsl:when test="contains(text(),':')">
6431                                         <!-- 1:2 -->
6432                                         <xsl:value-of select="substring-before(text(),':')"/>
6433                                 </xsl:when>
6434                                 <xsl:when test="not(contains(text(),':'))">
6435                                         <!-- 1 or 1<3 -->
6436                                         <xsl:if test="contains(text(),'&lt;')">
6437                                                 <!-- 1<3 -->
6438                                                 <xsl:value-of select="substring-before(text(),'&lt;')"/>
6439                                         </xsl:if>
6440                                         <xsl:if test="not(contains(text(),'&lt;'))">
6441                                                 <!-- 1 -->
6442                                                 <xsl:value-of select="text()"/>
6443                                         </xsl:if>
6444                                 </xsl:when>
6445                         </xsl:choose>
6446                 </xsl:variable>
6447                 <xsl:variable name="sici2">
6448                         <xsl:choose>
6449                                 <xsl:when test="starts-with(substring-after(text(),$level1),':')">
6450                                         <xsl:value-of select="substring(substring-after(text(),$level1),2)"/>
6451                                 </xsl:when>
6452                                 <xsl:otherwise>
6453                                         <xsl:value-of select="substring-after(text(),$level1)"/>
6454                                 </xsl:otherwise>
6455                         </xsl:choose>
6456                 </xsl:variable>
6457                 <xsl:variable name="level2">
6458                         <xsl:choose>
6459                                 <xsl:when test="contains($sici2,':')">
6460                                         <!--  2:3<4  -->
6461                                         <xsl:value-of select="substring-before($sici2,':')"/>
6462                                 </xsl:when>
6463                                 <xsl:when test="contains($sici2,'&lt;')">
6464                                         <!-- 1: 2<4 -->
6465                                         <xsl:value-of select="substring-before($sici2,'&lt;')"/>
6466                                 </xsl:when>
6467                                 <xsl:otherwise>
6468                                         <xsl:value-of select="$sici2"/>
6469                                         <!-- 1:2 -->
6470                                 </xsl:otherwise>
6471                         </xsl:choose>
6472                 </xsl:variable>
6473                 <xsl:variable name="sici3">
6474                         <xsl:choose>
6475                                 <xsl:when test="starts-with(substring-after($sici2,$level2),':')">
6476                                         <xsl:value-of select="substring(substring-after($sici2,$level2),2)"/>
6477                                 </xsl:when>
6478                                 <xsl:otherwise>
6479                                         <xsl:value-of select="substring-after($sici2,$level2)"/>
6480                                 </xsl:otherwise>
6481                         </xsl:choose>
6482                 </xsl:variable>
6483                 <xsl:variable name="level3">
6484                         <xsl:choose>
6485                                 <xsl:when test="contains($sici3,'&lt;')">
6486                                         <!-- 2<4 -->
6487                                         <xsl:value-of select="substring-before($sici3,'&lt;')"/>
6488                                 </xsl:when>
6489                                 <xsl:otherwise>
6490                                         <xsl:value-of select="$sici3"/>
6491                                         <!-- 3 -->
6492                                 </xsl:otherwise>
6493                         </xsl:choose>
6494                 </xsl:variable>
6495                 <xsl:variable name="page">
6496                         <xsl:if test="contains(text(),'&lt;')">
6497                                 <xsl:value-of select="substring-after(text(),'&lt;')"/>
6498                         </xsl:if>
6499                 </xsl:variable>
6500                 <xsl:if test="$level1">
6501                         <detail level="1">
6502                                 <number>
6503                                         <xsl:value-of select="$level1"/>
6504                                 </number>
6505                         </detail>
6506                 </xsl:if>
6507                 <xsl:if test="$level2">
6508                         <detail level="2">
6509                                 <number>
6510                                         <xsl:value-of select="$level2"/>
6511                                 </number>
6512                         </detail>
6513                 </xsl:if>
6514                 <xsl:if test="$level3">
6515                         <detail level="3">
6516                                 <number>
6517                                         <xsl:value-of select="$level3"/>
6518                                 </number>
6519                         </detail>
6520                 </xsl:if>
6521                 <xsl:if test="$page">
6522                         <extent unit="page">
6523                                 <start>
6524                                         <xsl:value-of select="$page"/>
6525                                 </start>
6526                         </extent>
6527                 </xsl:if>
6528         </xsl:template>
6529         <xsl:template name="getLanguage">
6530                 <xsl:param name="langString"/>
6531                 <xsl:param name="controlField008-35-37"/>
6532                 <xsl:variable name="length" select="string-length($langString)"/>
6533                 <xsl:choose>
6534                         <xsl:when test="$length=0"/>
6535                         <xsl:when test="$controlField008-35-37=substring($langString,1,3)">
6536                                 <xsl:call-template name="getLanguage">
6537                                         <xsl:with-param name="langString" select="substring($langString,4,$length)"/>
6538                                         <xsl:with-param name="controlField008-35-37" select="$controlField008-35-37"/>
6539                                 </xsl:call-template>
6540                         </xsl:when>
6541                         <xsl:otherwise>
6542                                 <language>
6543                                         <languageTerm authority="iso639-2b" type="code">
6544                                                 <xsl:value-of select="substring($langString,1,3)"/>
6545                                         </languageTerm>
6546                                 </language>
6547                                 <xsl:call-template name="getLanguage">
6548                                         <xsl:with-param name="langString" select="substring($langString,4,$length)"/>
6549                                         <xsl:with-param name="controlField008-35-37" select="$controlField008-35-37"/>
6550                                 </xsl:call-template>
6551                         </xsl:otherwise>
6552                 </xsl:choose>
6553         </xsl:template>
6554         <xsl:template name="isoLanguage">
6555                 <xsl:param name="currentLanguage"/>
6556                 <xsl:param name="usedLanguages"/>
6557                 <xsl:param name="remainingLanguages"/>
6558                 <xsl:choose>
6559                         <xsl:when test="string-length($currentLanguage)=0"/>
6560                         <xsl:when test="not(contains($usedLanguages, $currentLanguage))">
6561                                 <language>
6562                                         <xsl:if test="@code!='a'">
6563                                                 <xsl:attribute name="objectPart">
6564                                                         <xsl:choose>
6565                                                                 <xsl:when test="@code='b'">summary or subtitle</xsl:when>
6566                                                                 <xsl:when test="@code='d'">sung or spoken text</xsl:when>
6567                                                                 <xsl:when test="@code='e'">libretto</xsl:when>
6568                                                                 <xsl:when test="@code='f'">table of contents</xsl:when>
6569                                                                 <xsl:when test="@code='g'">accompanying material</xsl:when>
6570                                                                 <xsl:when test="@code='h'">translation</xsl:when>
6571                                                         </xsl:choose>
6572                                                 </xsl:attribute>
6573                                         </xsl:if>
6574                                         <languageTerm authority="iso639-2b" type="code">
6575                                                 <xsl:value-of select="$currentLanguage"/>
6576                                         </languageTerm>
6577                                 </language>
6578                                 <xsl:call-template name="isoLanguage">
6579                                         <xsl:with-param name="currentLanguage">
6580                                                 <xsl:value-of select="substring($remainingLanguages,1,3)"/>
6581                                         </xsl:with-param>
6582                                         <xsl:with-param name="usedLanguages">
6583                                                 <xsl:value-of select="concat($usedLanguages,$currentLanguage)"/>
6584                                         </xsl:with-param>
6585                                         <xsl:with-param name="remainingLanguages">
6586                                                 <xsl:value-of
6587                                                         select="substring($remainingLanguages,4,string-length($remainingLanguages))"
6588                                                 />
6589                                         </xsl:with-param>
6590                                 </xsl:call-template>
6591                         </xsl:when>
6592                         <xsl:otherwise>
6593                                 <xsl:call-template name="isoLanguage">
6594                                         <xsl:with-param name="currentLanguage">
6595                                                 <xsl:value-of select="substring($remainingLanguages,1,3)"/>
6596                                         </xsl:with-param>
6597                                         <xsl:with-param name="usedLanguages">
6598                                                 <xsl:value-of select="concat($usedLanguages,$currentLanguage)"/>
6599                                         </xsl:with-param>
6600                                         <xsl:with-param name="remainingLanguages">
6601                                                 <xsl:value-of
6602                                                         select="substring($remainingLanguages,4,string-length($remainingLanguages))"
6603                                                 />
6604                                         </xsl:with-param>
6605                                 </xsl:call-template>
6606                         </xsl:otherwise>
6607                 </xsl:choose>
6608         </xsl:template>
6609         <xsl:template name="chopBrackets">
6610                 <xsl:param name="chopString"/>
6611                 <xsl:variable name="string">
6612                         <xsl:call-template name="chopPunctuation">
6613                                 <xsl:with-param name="chopString" select="$chopString"/>
6614                         </xsl:call-template>
6615                 </xsl:variable>
6616                 <xsl:if test="substring($string, 1,1)='['">
6617                         <xsl:value-of select="substring($string,2, string-length($string)-2)"/>
6618                 </xsl:if>
6619                 <xsl:if test="substring($string, 1,1)!='['">
6620                         <xsl:value-of select="$string"/>
6621                 </xsl:if>
6622         </xsl:template>
6623         <xsl:template name="rfcLanguages">
6624                 <xsl:param name="nodeNum"/>
6625                 <xsl:param name="usedLanguages"/>
6626                 <xsl:param name="controlField008-35-37"/>
6627                 <xsl:variable name="currentLanguage" select="."/>
6628                 <xsl:choose>
6629                         <xsl:when test="not($currentLanguage)"/>
6630                         <xsl:when
6631                                 test="$currentLanguage!=$controlField008-35-37 and $currentLanguage!='rfc3066'">
6632                                 <xsl:if test="not(contains($usedLanguages,$currentLanguage))">
6633                                         <language>
6634                                                 <xsl:if test="@code!='a'">
6635                                                         <xsl:attribute name="objectPart">
6636                                                                 <xsl:choose>
6637                                                                         <xsl:when test="@code='b'">summary or subtitle</xsl:when>
6638                                                                         <xsl:when test="@code='d'">sung or spoken text</xsl:when>
6639                                                                         <xsl:when test="@code='e'">libretto</xsl:when>
6640                                                                         <xsl:when test="@code='f'">table of contents</xsl:when>
6641                                                                         <xsl:when test="@code='g'">accompanying material</xsl:when>
6642                                                                         <xsl:when test="@code='h'">translation</xsl:when>
6643                                                                 </xsl:choose>
6644                                                         </xsl:attribute>
6645                                                 </xsl:if>
6646                                                 <languageTerm authority="rfc3066" type="code">
6647                                                         <xsl:value-of select="$currentLanguage"/>
6648                                                 </languageTerm>
6649                                         </language>
6650                                 </xsl:if>
6651                         </xsl:when>
6652                         <xsl:otherwise> </xsl:otherwise>
6653                 </xsl:choose>
6654         </xsl:template>
6655
6656     <xsl:template name="datafield">
6657                 <xsl:param name="tag"/>
6658                 <xsl:param name="ind1">
6659                         <xsl:text> </xsl:text>
6660                 </xsl:param>
6661                 <xsl:param name="ind2">
6662                         <xsl:text> </xsl:text>
6663                 </xsl:param>
6664                 <xsl:param name="subfields"/>
6665                 <xsl:element name="marc:datafield">
6666                         <xsl:attribute name="tag">
6667                                 <xsl:value-of select="$tag"/>
6668                         </xsl:attribute>
6669                         <xsl:attribute name="ind1">
6670                                 <xsl:value-of select="$ind1"/>
6671                         </xsl:attribute>
6672                         <xsl:attribute name="ind2">
6673                                 <xsl:value-of select="$ind2"/>
6674                         </xsl:attribute>
6675                         <xsl:copy-of select="$subfields"/>
6676                 </xsl:element>
6677         </xsl:template>
6678
6679         <xsl:template name="subfieldSelect">
6680                 <xsl:param name="codes">abcdefghijklmnopqrstuvwxyz</xsl:param>
6681                 <xsl:param name="delimeter">
6682                         <xsl:text> </xsl:text>
6683                 </xsl:param>
6684                 <xsl:variable name="str">
6685                         <xsl:for-each select="marc:subfield">
6686                                 <xsl:if test="contains($codes, @code)">
6687                                         <xsl:value-of select="text()"/>
6688                                         <xsl:value-of select="$delimeter"/>
6689                                 </xsl:if>
6690                         </xsl:for-each>
6691                 </xsl:variable>
6692                 <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
6693         </xsl:template>
6694
6695         <xsl:template name="buildSpaces">
6696                 <xsl:param name="spaces"/>
6697                 <xsl:param name="char">
6698                         <xsl:text> </xsl:text>
6699                 </xsl:param>
6700                 <xsl:if test="$spaces>0">
6701                         <xsl:value-of select="$char"/>
6702                         <xsl:call-template name="buildSpaces">
6703                                 <xsl:with-param name="spaces" select="$spaces - 1"/>
6704                                 <xsl:with-param name="char" select="$char"/>
6705                         </xsl:call-template>
6706                 </xsl:if>
6707         </xsl:template>
6708
6709         <xsl:template name="chopPunctuation">
6710                 <xsl:param name="chopString"/>
6711                 <xsl:param name="punctuation">
6712                         <xsl:text>.:,;/ </xsl:text>
6713                 </xsl:param>
6714                 <xsl:variable name="length" select="string-length($chopString)"/>
6715                 <xsl:choose>
6716                         <xsl:when test="$length=0"/>
6717                         <xsl:when test="contains($punctuation, substring($chopString,$length,1))">
6718                                 <xsl:call-template name="chopPunctuation">
6719                                         <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
6720                                         <xsl:with-param name="punctuation" select="$punctuation"/>
6721                                 </xsl:call-template>
6722                         </xsl:when>
6723                         <xsl:when test="not($chopString)"/>
6724                         <xsl:otherwise>
6725                                 <xsl:value-of select="$chopString"/>
6726                         </xsl:otherwise>
6727                 </xsl:choose>
6728         </xsl:template>
6729
6730         <xsl:template name="chopPunctuationFront">
6731                 <xsl:param name="chopString"/>
6732                 <xsl:variable name="length" select="string-length($chopString)"/>
6733                 <xsl:choose>
6734                         <xsl:when test="$length=0"/>
6735                         <xsl:when test="contains('.:,;/[ ', substring($chopString,1,1))">
6736                                 <xsl:call-template name="chopPunctuationFront">
6737                                         <xsl:with-param name="chopString" select="substring($chopString,2,$length - 1)"
6738                                         />
6739                                 </xsl:call-template>
6740                         </xsl:when>
6741                         <xsl:when test="not($chopString)"/>
6742                         <xsl:otherwise>
6743                                 <xsl:value-of select="$chopString"/>
6744                         </xsl:otherwise>
6745                 </xsl:choose>
6746         </xsl:template>
6747
6748         <xsl:template name="chopPunctuationBack">
6749                 <xsl:param name="chopString"/>
6750                 <xsl:param name="punctuation">
6751                         <xsl:text>.:,;/] </xsl:text>
6752                 </xsl:param>
6753                 <xsl:variable name="length" select="string-length($chopString)"/>
6754                 <xsl:choose>
6755                         <xsl:when test="$length=0"/>
6756                         <xsl:when test="contains($punctuation, substring($chopString,$length,1))">
6757                                 <xsl:call-template name="chopPunctuation">
6758                                         <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
6759                                         <xsl:with-param name="punctuation" select="$punctuation"/>
6760                                 </xsl:call-template>
6761                         </xsl:when>
6762                         <xsl:when test="not($chopString)"/>
6763                         <xsl:otherwise>
6764                                 <xsl:value-of select="$chopString"/>
6765                         </xsl:otherwise>
6766                 </xsl:choose>
6767         </xsl:template>
6768
6769         <!-- nate added 12/14/2007 for lccn.loc.gov: url encode ampersand, etc. -->
6770         <xsl:template name="url-encode">
6771
6772                 <xsl:param name="str"/>
6773
6774                 <xsl:if test="$str">
6775                         <xsl:variable name="first-char" select="substring($str,1,1)"/>
6776                         <xsl:choose>
6777                                 <xsl:when test="contains($safe,$first-char)">
6778                                         <xsl:value-of select="$first-char"/>
6779                                 </xsl:when>
6780                                 <xsl:otherwise>
6781                                         <xsl:variable name="codepoint">
6782                                                 <xsl:choose>
6783                                                         <xsl:when test="contains($ascii,$first-char)">
6784                                                                 <xsl:value-of
6785                                                                         select="string-length(substring-before($ascii,$first-char)) + 32"
6786                                                                 />
6787                                                         </xsl:when>
6788                                                         <xsl:when test="contains($latin1,$first-char)">
6789                                                                 <xsl:value-of
6790                                                                         select="string-length(substring-before($latin1,$first-char)) + 160"/>
6791                                                                 <!-- was 160 -->
6792                                                         </xsl:when>
6793                                                         <xsl:otherwise>
6794                                                                 <xsl:message terminate="no">Warning: string contains a character
6795                                                                         that is out of range! Substituting "?".</xsl:message>
6796                                                                 <xsl:text>63</xsl:text>
6797                                                         </xsl:otherwise>
6798                                                 </xsl:choose>
6799                                         </xsl:variable>
6800                                         <xsl:variable name="hex-digit1"
6801                                                 select="substring($hex,floor($codepoint div 16) + 1,1)"/>
6802                                         <xsl:variable name="hex-digit2" select="substring($hex,$codepoint mod 16 + 1,1)"/>
6803                                         <!-- <xsl:value-of select="concat('%',$hex-digit2)"/> -->
6804                                         <xsl:value-of select="concat('%',$hex-digit1,$hex-digit2)"/>
6805                                 </xsl:otherwise>
6806                         </xsl:choose>
6807                         <xsl:if test="string-length($str) &gt; 1">
6808                                 <xsl:call-template name="url-encode">
6809                                         <xsl:with-param name="str" select="substring($str,2)"/>
6810                                 </xsl:call-template>
6811                         </xsl:if>
6812                 </xsl:if>
6813         </xsl:template>
6814 </xsl:stylesheet>$XXXX$ where name = $$mods33$$;
6815
6816 COMMIT;
6817