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