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