LP#1744385: Stamping upgrade scripts for search and display infrastructure improvements
[working/Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 1102.data.mods-title-punctuation-change.sql
1 BEGIN;
2
3 SELECT evergreen.upgrade_deps_block_check('1102', :eg_version);
4
5 update config.xml_transform set xslt = $XXXX$<?xml version="1.0" encoding="UTF-8"?>
6 <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">
7         <xsl:output encoding="UTF-8" indent="yes" method="xml"/>
8 <!--
9 Revision 1.14 - Fixed template isValid and fields 010, 020, 022, 024, 028, and 037 to output additional identifier elements
10   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
11
12 Revision 1.13 - Changed order of output under cartographics to reflect schema  2006/11/28 tmee
13
14 Revision 1.12 - Updated to reflect MODS 3.2 Mapping  2006/10/11 tmee
15
16 Revision 1.11 - The attribute objectPart moved from <languageTerm> to <language>
17       2006/04/08  jrad
18
19 Revision 1.10 MODS 3.1 revisions to language and classification elements
20                                 (plus ability to find marc:collection embedded in wrapper elements such as SRU zs: wrappers)
21                                 2006/02/06  ggar
22
23 Revision 1.9 subfield $y was added to field 242 2004/09/02 10:57 jrad
24
25 Revision 1.8 Subject chopPunctuation expanded and attribute fixes 2004/08/12 jrad
26
27 Revision 1.7 2004/03/25 08:29 jrad
28
29 Revision 1.6 various validation fixes 2004/02/20 ntra
30
31 Revision 1.5  2003/10/02 16:18:58  ntra
32 MODS2 to MODS3 updates, language unstacking and
33 de-duping, chopPunctuation expanded
34
35 Revision 1.3  2003/04/03 00:07:19  ntra
36 Revision 1.3 Additional Changes not related to MODS Version 2.0 by ntra
37
38 Revision 1.2  2003/03/24 19:37:42  ckeith
39 Added Log Comment
40
41 -->
42         <xsl:template match="/">
43                 <xsl:choose>
44                         <xsl:when test="//marc:collection">
45                                 <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">
46                                         <xsl:for-each select="//marc:collection/marc:record">
47                                                 <mods version="3.2">
48                                                         <xsl:call-template name="marcRecord"/>
49                                                 </mods>
50                                         </xsl:for-each>
51                                 </modsCollection>
52                         </xsl:when>
53                         <xsl:otherwise>
54                                 <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">
55                                         <xsl:for-each select="//marc:record">
56                                                 <xsl:call-template name="marcRecord"/>
57                                         </xsl:for-each>
58                                 </mods>
59                         </xsl:otherwise>
60                 </xsl:choose>
61         </xsl:template>
62         <xsl:template name="marcRecord">
63                 <xsl:variable name="leader" select="marc:leader"/>
64                 <xsl:variable name="leader6" select="substring($leader,7,1)"/>
65                 <xsl:variable name="leader7" select="substring($leader,8,1)"/>
66                 <xsl:variable name="controlField008" select="marc:controlfield[@tag='008']"/>
67                 <xsl:variable name="typeOf008">
68                         <xsl:choose>
69                                 <xsl:when test="$leader6='a'">
70                                         <xsl:choose>
71                                                 <xsl:when test="$leader7='a' or $leader7='c' or $leader7='d' or $leader7='m'">BK</xsl:when>
72                                                 <xsl:when test="$leader7='b' or $leader7='i' or $leader7='s'">SE</xsl:when>
73                                         </xsl:choose>
74                                 </xsl:when>
75                                 <xsl:when test="$leader6='t'">BK</xsl:when>
76                                 <xsl:when test="$leader6='p'">MM</xsl:when>
77                                 <xsl:when test="$leader6='m'">CF</xsl:when>
78                                 <xsl:when test="$leader6='e' or $leader6='f'">MP</xsl:when>
79                                 <xsl:when test="$leader6='g' or $leader6='k' or $leader6='o' or $leader6='r'">VM</xsl:when>
80                                 <xsl:when test="$leader6='c' or $leader6='d' or $leader6='i' or $leader6='j'">MU</xsl:when>
81                         </xsl:choose>
82                 </xsl:variable>
83                 <xsl:for-each select="marc:datafield[@tag='245']">
84                         <titleInfo>
85                                 <xsl:variable name="title">
86                                         <xsl:choose>
87                                                 <xsl:when test="marc:subfield[@code='b']">
88                                                         <xsl:call-template name="specialSubfieldSelect">
89                                                                 <xsl:with-param name="axis">b</xsl:with-param>
90                                                                 <xsl:with-param name="beforeCodes">afgk</xsl:with-param>
91                                                         </xsl:call-template>
92                                                 </xsl:when>
93                                                 <xsl:otherwise>
94                                                         <xsl:call-template name="subfieldSelect">
95                                                                 <xsl:with-param name="codes">abfgk</xsl:with-param>
96                                                         </xsl:call-template>
97                                                 </xsl:otherwise>
98                                         </xsl:choose>
99                                 </xsl:variable>
100                                 <xsl:variable name="titleChop">
101                                         <xsl:call-template name="chopPunctuation">
102                                                 <xsl:with-param name="chopString">
103                                                         <xsl:value-of select="$title"/>
104                                                 </xsl:with-param>
105                                                 <xsl:with-param name="punctuation">
106                                                     <xsl:text>,;/ </xsl:text>
107                                                 </xsl:with-param>
108                                         </xsl:call-template>
109                                 </xsl:variable>
110                                 <xsl:choose>
111                                         <xsl:when test="@ind2>0">
112                                                 <nonSort>
113                                                         <xsl:value-of select="substring($titleChop,1,@ind2)"/>
114                                                 </nonSort>
115                                                 <title>
116                                                         <xsl:value-of select="substring($titleChop,@ind2+1)"/>
117                                                 </title>
118                                         </xsl:when>
119                                         <xsl:otherwise>
120                                                 <title>
121                                                         <xsl:value-of select="$titleChop"/>
122                                                 </title>
123                                         </xsl:otherwise>
124                                 </xsl:choose>
125                                 <xsl:if test="marc:subfield[@code='b']">
126                                         <subTitle>
127                                                 <xsl:call-template name="chopPunctuation">
128                                                         <xsl:with-param name="chopString">
129                                                                 <xsl:call-template name="specialSubfieldSelect">
130                                                                         <xsl:with-param name="axis">b</xsl:with-param>
131                                                                         <xsl:with-param name="anyCodes">b</xsl:with-param>
132                                                                         <xsl:with-param name="afterCodes">afgk</xsl:with-param>
133                                                                 </xsl:call-template>
134                                                         </xsl:with-param>
135                                                 </xsl:call-template>
136                                         </subTitle>
137                                 </xsl:if>
138                                 <xsl:call-template name="part"></xsl:call-template>
139                         </titleInfo>
140                         <!-- A form of title that ignores non-filing characters; useful
141                                  for not converting "L'Oreal" into "L' Oreal" at index time -->
142                         <titleNonfiling>
143                                 <title>
144                                         <xsl:call-template name="chopPunctuation">
145                                                 <xsl:with-param name="chopString">
146                                                         <xsl:call-template name="subfieldSelect">
147                                                                 <xsl:with-param name="codes">abfgk</xsl:with-param>
148                                                         </xsl:call-template>
149                                                 </xsl:with-param>
150                                         </xsl:call-template>
151                                 </title>
152                                 <xsl:call-template name="part"></xsl:call-template>
153                         </titleNonfiling>
154                         <!-- hybrid of titleInfo and titleNonfiling which will give us a preformatted string (for punctuation)
155                                  but also keep the nonSort stuff in a separate field (for sorting) -->
156                         <titleBrowse>
157                                 <xsl:variable name="titleBrowseChop">
158                                         <xsl:call-template name="chopPunctuation">
159                                                 <xsl:with-param name="chopString">
160                                                         <xsl:call-template name="subfieldSelect">
161                                                                 <xsl:with-param name="codes">abfgk</xsl:with-param>
162                                                         </xsl:call-template>
163                                                 </xsl:with-param>
164                                         </xsl:call-template>
165                                 </xsl:variable>
166                                 <xsl:choose>
167                                         <xsl:when test="@ind2>0">
168                                                 <nonSort>
169                                                         <xsl:value-of select="substring($titleBrowseChop,1,@ind2)"/>
170                                                 </nonSort>
171                                                 <title>
172                                                         <xsl:value-of select="substring($titleBrowseChop,@ind2+1)"/>
173                                                 </title>
174                                         </xsl:when>
175                                         <xsl:otherwise>
176                                                 <title>
177                                                         <xsl:value-of select="$titleBrowseChop"/>
178                                                 </title>
179                                         </xsl:otherwise>
180                                 </xsl:choose>
181                                 <xsl:call-template name="part"></xsl:call-template>
182                         </titleBrowse>
183                 </xsl:for-each>
184                 <xsl:for-each select="marc:datafield[@tag='210']">
185                         <titleInfo type="abbreviated">
186                                 <title>
187                                         <xsl:call-template name="chopPunctuation">
188                                                 <xsl:with-param name="chopString">
189                                                         <xsl:call-template name="subfieldSelect">
190                                                                 <xsl:with-param name="codes">a</xsl:with-param>
191                                                         </xsl:call-template>
192                                                 </xsl:with-param>
193                                         </xsl:call-template>
194                                 </title>
195                                 <xsl:call-template name="subtitle"/>
196                         </titleInfo>
197                 </xsl:for-each>
198                 <xsl:for-each select="marc:datafield[@tag='242']">
199                         <xsl:variable name="titleChop">
200                                 <xsl:call-template name="chopPunctuation">
201                                         <xsl:with-param name="chopString">
202                                                 <xsl:call-template name="subfieldSelect">
203                                                         <!-- 1/04 removed $h, b -->
204                                                         <xsl:with-param name="codes">a</xsl:with-param>
205                                                 </xsl:call-template>
206                                         </xsl:with-param>
207                                 </xsl:call-template>
208                         </xsl:variable>
209                         <titleInfo type="translated">
210                                 <!--09/01/04 Added subfield $y-->
211                                 <xsl:for-each select="marc:subfield[@code='y']">
212                                         <xsl:attribute name="lang">
213                                                 <xsl:value-of select="text()"/>
214                                         </xsl:attribute>
215                                 </xsl:for-each>
216                                 <title>
217                                         <xsl:value-of select="$titleChop" />
218                                 </title>
219                                 <!-- 1/04 fix -->
220                                 <xsl:call-template name="subtitle"/>
221                                 <xsl:call-template name="part"/>
222                         </titleInfo>
223                         <titleInfo type="translated-nfi">
224                                 <xsl:for-each select="marc:subfield[@code='y']">
225                                         <xsl:attribute name="lang">
226                                                 <xsl:value-of select="text()"/>
227                                         </xsl:attribute>
228                                 </xsl:for-each>
229                                 <xsl:choose>
230                                         <xsl:when test="@ind2>0">
231                                                 <nonSort>
232                                                         <xsl:value-of select="substring($titleChop,1,@ind2)"/>
233                                                 </nonSort>
234                                                 <title>
235                                                         <xsl:value-of select="substring($titleChop,@ind2+1)"/>
236                                                 </title>
237                                         </xsl:when>
238                                         <xsl:otherwise>
239                                                 <title>
240                                                         <xsl:value-of select="$titleChop" />
241                                                 </title>
242                                         </xsl:otherwise>
243                                 </xsl:choose>
244                                 <xsl:call-template name="subtitle"/>
245                                 <xsl:call-template name="part"/>
246                         </titleInfo>
247                 </xsl:for-each>
248                 <xsl:for-each select="marc:datafield[@tag='246']">
249                         <titleInfo type="alternative">
250                                 <xsl:for-each select="marc:subfield[@code='i']">
251                                         <xsl:attribute name="displayLabel">
252                                                 <xsl:value-of select="text()"/>
253                                         </xsl:attribute>
254                                 </xsl:for-each>
255                                 <title>
256                                         <xsl:call-template name="chopPunctuation">
257                                                 <xsl:with-param name="chopString">
258                                                         <xsl:call-template name="subfieldSelect">
259                                                                 <!-- 1/04 removed $h, $b -->
260                                                                 <xsl:with-param name="codes">af</xsl:with-param>
261                                                         </xsl:call-template>
262                                                 </xsl:with-param>
263                                         </xsl:call-template>
264                                 </title>
265                                 <xsl:call-template name="subtitle"/>
266                                 <xsl:call-template name="part"/>
267                         </titleInfo>
268                 </xsl:for-each>
269                 <xsl:for-each select="marc:datafield[@tag='130']|marc:datafield[@tag='240']|marc:datafield[@tag='730'][@ind2!='2']">
270                         <xsl:variable name="nfi">
271                                 <xsl:choose>
272                                         <xsl:when test="@tag='240'">
273                                                 <xsl:value-of select="@ind2"/>
274                                         </xsl:when>
275                                         <xsl:otherwise>
276                                                 <xsl:value-of select="@ind1"/>
277                                         </xsl:otherwise>
278                                 </xsl:choose>
279                         </xsl:variable>
280                         <xsl:variable name="titleChop">
281                                 <xsl:call-template name="uri" />
282                                 <xsl:variable name="str">
283                                         <xsl:for-each select="marc:subfield">
284                                                 <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'])))">
285                                                         <xsl:value-of select="text()"/>
286                                                         <xsl:text> </xsl:text>
287                                                 </xsl:if>
288                                         </xsl:for-each>
289                                 </xsl:variable>
290                                 <xsl:call-template name="chopPunctuation">
291                                         <xsl:with-param name="chopString">
292                                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
293                                         </xsl:with-param>
294                                 </xsl:call-template>
295                         </xsl:variable>
296                         <titleInfo type="uniform">
297                                 <title>
298                                         <xsl:value-of select="$titleChop"/>
299                                 </title>
300                                 <xsl:call-template name="part"/>
301                         </titleInfo>
302                         <titleInfo type="uniform-nfi">
303                                 <xsl:choose>
304                                         <xsl:when test="$nfi>0">
305                                                 <nonSort>
306                                                         <xsl:value-of select="substring($titleChop,1,$nfi)"/>
307                                                 </nonSort>
308                                                 <title>
309                                                         <xsl:value-of select="substring($titleChop,$nfi+1)"/>
310                                                 </title>
311                                         </xsl:when>
312                                         <xsl:otherwise>
313                                                 <title>
314                                                         <xsl:value-of select="$titleChop"/>
315                                                 </title>
316                                         </xsl:otherwise>
317                                 </xsl:choose>
318                                 <xsl:call-template name="part"/>
319                         </titleInfo>
320                 </xsl:for-each>
321                 <xsl:for-each select="marc:datafield[@tag='740'][@ind2!='2']">
322                         <xsl:variable name="titleChop">
323                                 <xsl:call-template name="chopPunctuation">
324                                         <xsl:with-param name="chopString">
325                                                 <xsl:call-template name="subfieldSelect">
326                                                         <xsl:with-param name="codes">ah</xsl:with-param>
327                                                 </xsl:call-template>
328                                         </xsl:with-param>
329                                 </xsl:call-template>
330                         </xsl:variable>
331                         <titleInfo type="alternative">
332                                 <title>
333                                         <xsl:value-of select="$titleChop" />
334                                 </title>
335                                 <xsl:call-template name="part"/>
336                         </titleInfo>
337                         <titleInfo type="alternative-nfi">
338                                 <xsl:choose>
339                                         <xsl:when test="@ind1>0">
340                                                 <nonSort>
341                                                         <xsl:value-of select="substring($titleChop,1,@ind1)"/>
342                                                 </nonSort>
343                                                 <title>
344                                                         <xsl:value-of select="substring($titleChop,@ind1+1)"/>
345                                                 </title>
346                                         </xsl:when>
347                                         <xsl:otherwise>
348                                                 <title>
349                                                         <xsl:value-of select="$titleChop" />
350                                                 </title>
351                                         </xsl:otherwise>
352                                 </xsl:choose>
353                                 <xsl:call-template name="part"/>
354                         </titleInfo>
355                 </xsl:for-each>
356                 <xsl:for-each select="marc:datafield[@tag='100']">
357                         <name type="personal">
358                                 <xsl:call-template name="uri" />
359                                 <xsl:call-template name="nameABCDQ"/>
360                                 <xsl:call-template name="affiliation"/>
361                                 <role>
362                                         <roleTerm authority="marcrelator" type="text">creator</roleTerm>
363                                 </role>
364                                 <xsl:call-template name="role"/>
365                         </name>
366                 </xsl:for-each>
367                 <xsl:for-each select="marc:datafield[@tag='110']">
368                         <name type="corporate">
369                                 <xsl:call-template name="uri" />
370                                 <xsl:call-template name="nameABCDN"/>
371                                 <role>
372                                         <roleTerm authority="marcrelator" type="text">creator</roleTerm>
373                                 </role>
374                                 <xsl:call-template name="role"/>
375                         </name>
376                 </xsl:for-each>
377                 <xsl:for-each select="marc:datafield[@tag='111']">
378                         <name type="conference">
379                                 <xsl:call-template name="uri" />
380                                 <xsl:call-template name="nameACDEQ"/>
381                                 <role>
382                                         <roleTerm authority="marcrelator" type="text">creator</roleTerm>
383                                 </role>
384                                 <xsl:call-template name="role"/>
385                         </name>
386                 </xsl:for-each>
387                 <xsl:for-each select="marc:datafield[@tag='700'][not(marc:subfield[@code='t'])]">
388                         <name type="personal">
389                                 <xsl:call-template name="uri" />
390                                 <xsl:call-template name="nameABCDQ"/>
391                                 <xsl:call-template name="affiliation"/>
392                                 <xsl:call-template name="role"/>
393                         </name>
394                 </xsl:for-each>
395                 <xsl:for-each select="marc:datafield[@tag='710'][not(marc:subfield[@code='t'])]">
396                         <name type="corporate">
397                                 <xsl:call-template name="uri" />
398                                 <xsl:call-template name="nameABCDN"/>
399                                 <xsl:call-template name="role"/>
400                         </name>
401                 </xsl:for-each>
402                 <xsl:for-each select="marc:datafield[@tag='711'][not(marc:subfield[@code='t'])]">
403                         <name type="conference">
404                                 <xsl:call-template name="uri" />
405                                 <xsl:call-template name="nameACDEQ"/>
406                                 <xsl:call-template name="role"/>
407                         </name>
408                 </xsl:for-each>
409                 <xsl:for-each select="marc:datafield[@tag='720'][not(marc:subfield[@code='t'])]">
410                         <name>
411                                 <xsl:if test="@ind1=1">
412                                         <xsl:attribute name="type">
413                                                 <xsl:text>personal</xsl:text>
414                                         </xsl:attribute>
415                                 </xsl:if>
416                                 <namePart>
417                                         <xsl:value-of select="marc:subfield[@code='a']"/>
418                                 </namePart>
419                                 <xsl:call-template name="role"/>
420                         </name>
421                 </xsl:for-each>
422                 <typeOfResource>
423                         <xsl:if test="$leader7='c'">
424                                 <xsl:attribute name="collection">yes</xsl:attribute>
425                         </xsl:if>
426                         <xsl:if test="$leader6='d' or $leader6='f' or $leader6='p' or $leader6='t'">
427                                 <xsl:attribute name="manuscript">yes</xsl:attribute>
428                         </xsl:if>
429                         <xsl:choose>
430                                 <xsl:when test="$leader6='a' or $leader6='t'">text</xsl:when>
431                                 <xsl:when test="$leader6='e' or $leader6='f'">cartographic</xsl:when>
432                                 <xsl:when test="$leader6='c' or $leader6='d'">notated music</xsl:when>
433                                 <xsl:when test="$leader6='i'">sound recording-nonmusical</xsl:when>
434                                 <xsl:when test="$leader6='j'">sound recording-musical</xsl:when>
435                                 <xsl:when test="$leader6='k'">still image</xsl:when>
436                                 <xsl:when test="$leader6='g'">moving image</xsl:when>
437                                 <xsl:when test="$leader6='r'">three dimensional object</xsl:when>
438                                 <xsl:when test="$leader6='m'">software, multimedia</xsl:when>
439                                 <xsl:when test="$leader6='p'">mixed material</xsl:when>
440                         </xsl:choose>
441                 </typeOfResource>
442                 <xsl:if test="substring($controlField008,26,1)='d'">
443                         <genre authority="marc">globe</genre>
444                 </xsl:if>
445                 <xsl:if test="marc:controlfield[@tag='007'][substring(text(),1,1)='a'][substring(text(),2,1)='r']">
446                         <genre authority="marc">remote sensing image</genre>
447                 </xsl:if>
448                 <xsl:if test="$typeOf008='MP'">
449                         <xsl:variable name="controlField008-25" select="substring($controlField008,26,1)"></xsl:variable>
450                         <xsl:choose>
451                                 <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']">
452                                         <genre authority="marc">map</genre>
453                                 </xsl:when>
454                                 <xsl:when test="$controlField008-25='e' or marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='d']">
455                                         <genre authority="marc">atlas</genre>
456                                 </xsl:when>
457                         </xsl:choose>
458                 </xsl:if>
459                 <xsl:if test="$typeOf008='SE'">
460                         <xsl:variable name="controlField008-21" select="substring($controlField008,22,1)"></xsl:variable>
461                         <xsl:choose>
462                                 <xsl:when test="$controlField008-21='d'">
463                                         <genre authority="marc">database</genre>
464                                 </xsl:when>
465                                 <xsl:when test="$controlField008-21='l'">
466                                         <genre authority="marc">loose-leaf</genre>
467                                 </xsl:when>
468                                 <xsl:when test="$controlField008-21='m'">
469                                         <genre authority="marc">series</genre>
470                                 </xsl:when>
471                                 <xsl:when test="$controlField008-21='n'">
472                                         <genre authority="marc">newspaper</genre>
473                                 </xsl:when>
474                                 <xsl:when test="$controlField008-21='p'">
475                                         <genre authority="marc">periodical</genre>
476                                 </xsl:when>
477                                 <xsl:when test="$controlField008-21='w'">
478                                         <genre authority="marc">web site</genre>
479                                 </xsl:when>
480                         </xsl:choose>
481                 </xsl:if>
482                 <xsl:if test="$typeOf008='BK' or $typeOf008='SE'">
483                         <xsl:variable name="controlField008-24" select="substring($controlField008,25,4)"></xsl:variable>
484                         <xsl:choose>
485                                 <xsl:when test="contains($controlField008-24,'a')">
486                                         <genre authority="marc">abstract or summary</genre>
487                                 </xsl:when>
488                                 <xsl:when test="contains($controlField008-24,'b')">
489                                         <genre authority="marc">bibliography</genre>
490                                 </xsl:when>
491                                 <xsl:when test="contains($controlField008-24,'c')">
492                                         <genre authority="marc">catalog</genre>
493                                 </xsl:when>
494                                 <xsl:when test="contains($controlField008-24,'d')">
495                                         <genre authority="marc">dictionary</genre>
496                                 </xsl:when>
497                                 <xsl:when test="contains($controlField008-24,'e')">
498                                         <genre authority="marc">encyclopedia</genre>
499                                 </xsl:when>
500                                 <xsl:when test="contains($controlField008-24,'f')">
501                                         <genre authority="marc">handbook</genre>
502                                 </xsl:when>
503                                 <xsl:when test="contains($controlField008-24,'g')">
504                                         <genre authority="marc">legal article</genre>
505                                 </xsl:when>
506                                 <xsl:when test="contains($controlField008-24,'i')">
507                                         <genre authority="marc">index</genre>
508                                 </xsl:when>
509                                 <xsl:when test="contains($controlField008-24,'k')">
510                                         <genre authority="marc">discography</genre>
511                                 </xsl:when>
512                                 <xsl:when test="contains($controlField008-24,'l')">
513                                         <genre authority="marc">legislation</genre>
514                                 </xsl:when>
515                                 <xsl:when test="contains($controlField008-24,'m')">
516                                         <genre authority="marc">theses</genre>
517                                 </xsl:when>
518                                 <xsl:when test="contains($controlField008-24,'n')">
519                                         <genre authority="marc">survey of literature</genre>
520                                 </xsl:when>
521                                 <xsl:when test="contains($controlField008-24,'o')">
522                                         <genre authority="marc">review</genre>
523                                 </xsl:when>
524                                 <xsl:when test="contains($controlField008-24,'p')">
525                                         <genre authority="marc">programmed text</genre>
526                                 </xsl:when>
527                                 <xsl:when test="contains($controlField008-24,'q')">
528                                         <genre authority="marc">filmography</genre>
529                                 </xsl:when>
530                                 <xsl:when test="contains($controlField008-24,'r')">
531                                         <genre authority="marc">directory</genre>
532                                 </xsl:when>
533                                 <xsl:when test="contains($controlField008-24,'s')">
534                                         <genre authority="marc">statistics</genre>
535                                 </xsl:when>
536                                 <xsl:when test="contains($controlField008-24,'t')">
537                                         <genre authority="marc">technical report</genre>
538                                 </xsl:when>
539                                 <xsl:when test="contains($controlField008-24,'v')">
540                                         <genre authority="marc">legal case and case notes</genre>
541                                 </xsl:when>
542                                 <xsl:when test="contains($controlField008-24,'w')">
543                                         <genre authority="marc">law report or digest</genre>
544                                 </xsl:when>
545                                 <xsl:when test="contains($controlField008-24,'z')">
546                                         <genre authority="marc">treaty</genre>
547                                 </xsl:when>
548                         </xsl:choose>
549                         <xsl:variable name="controlField008-29" select="substring($controlField008,30,1)"></xsl:variable>
550                         <xsl:choose>
551                                 <xsl:when test="$controlField008-29='1'">
552                                         <genre authority="marc">conference publication</genre>
553                                 </xsl:when>
554                         </xsl:choose>
555                 </xsl:if>
556                 <xsl:if test="$typeOf008='CF'">
557                         <xsl:variable name="controlField008-26" select="substring($controlField008,27,1)"></xsl:variable>
558                         <xsl:choose>
559                                 <xsl:when test="$controlField008-26='a'">
560                                         <genre authority="marc">numeric data</genre>
561                                 </xsl:when>
562                                 <xsl:when test="$controlField008-26='e'">
563                                         <genre authority="marc">database</genre>
564                                 </xsl:when>
565                                 <xsl:when test="$controlField008-26='f'">
566                                         <genre authority="marc">font</genre>
567                                 </xsl:when>
568                                 <xsl:when test="$controlField008-26='g'">
569                                         <genre authority="marc">game</genre>
570                                 </xsl:when>
571                         </xsl:choose>
572                 </xsl:if>
573                 <xsl:if test="$typeOf008='BK'">
574                         <xsl:if test="substring($controlField008,25,1)='j'">
575                                 <genre authority="marc">patent</genre>
576                         </xsl:if>
577                         <xsl:if test="substring($controlField008,31,1)='1'">
578                                 <genre authority="marc">festschrift</genre>
579                         </xsl:if>
580                         <xsl:variable name="controlField008-34" select="substring($controlField008,35,1)"></xsl:variable>
581                         <xsl:if test="$controlField008-34='a' or $controlField008-34='b' or $controlField008-34='c' or $controlField008-34='d'">
582                                 <genre authority="marc">biography</genre>
583                         </xsl:if>
584                         <xsl:variable name="controlField008-33" select="substring($controlField008,34,1)"></xsl:variable>
585                         <xsl:choose>
586                                 <xsl:when test="$controlField008-33='e'">
587                                         <genre authority="marc">essay</genre>
588                                 </xsl:when>
589                                 <xsl:when test="$controlField008-33='d'">
590                                         <genre authority="marc">drama</genre>
591                                 </xsl:when>
592                                 <xsl:when test="$controlField008-33='c'">
593                                         <genre authority="marc">comic strip</genre>
594                                 </xsl:when>
595                                 <xsl:when test="$controlField008-33='l'">
596                                         <genre authority="marc">fiction</genre>
597                                 </xsl:when>
598                                 <xsl:when test="$controlField008-33='h'">
599                                         <genre authority="marc">humor, satire</genre>
600                                 </xsl:when>
601                                 <xsl:when test="$controlField008-33='i'">
602                                         <genre authority="marc">letter</genre>
603                                 </xsl:when>
604                                 <xsl:when test="$controlField008-33='f'">
605                                         <genre authority="marc">novel</genre>
606                                 </xsl:when>
607                                 <xsl:when test="$controlField008-33='j'">
608                                         <genre authority="marc">short story</genre>
609                                 </xsl:when>
610                                 <xsl:when test="$controlField008-33='s'">
611                                         <genre authority="marc">speech</genre>
612                                 </xsl:when>
613                         </xsl:choose>
614                 </xsl:if>
615                 <xsl:if test="$typeOf008='MU'">
616                         <xsl:variable name="controlField008-30-31" select="substring($controlField008,31,2)"></xsl:variable>
617                         <xsl:if test="contains($controlField008-30-31,'b')">
618                                 <genre authority="marc">biography</genre>
619                         </xsl:if>
620                         <xsl:if test="contains($controlField008-30-31,'c')">
621                                 <genre authority="marc">conference publication</genre>
622                         </xsl:if>
623                         <xsl:if test="contains($controlField008-30-31,'d')">
624                                 <genre authority="marc">drama</genre>
625                         </xsl:if>
626                         <xsl:if test="contains($controlField008-30-31,'e')">
627                                 <genre authority="marc">essay</genre>
628                         </xsl:if>
629                         <xsl:if test="contains($controlField008-30-31,'f')">
630                                 <genre authority="marc">fiction</genre>
631                         </xsl:if>
632                         <xsl:if test="contains($controlField008-30-31,'o')">
633                                 <genre authority="marc">folktale</genre>
634                         </xsl:if>
635                         <xsl:if test="contains($controlField008-30-31,'h')">
636                                 <genre authority="marc">history</genre>
637                         </xsl:if>
638                         <xsl:if test="contains($controlField008-30-31,'k')">
639                                 <genre authority="marc">humor, satire</genre>
640                         </xsl:if>
641                         <xsl:if test="contains($controlField008-30-31,'m')">
642                                 <genre authority="marc">memoir</genre>
643                         </xsl:if>
644                         <xsl:if test="contains($controlField008-30-31,'p')">
645                                 <genre authority="marc">poetry</genre>
646                         </xsl:if>
647                         <xsl:if test="contains($controlField008-30-31,'r')">
648                                 <genre authority="marc">rehearsal</genre>
649                         </xsl:if>
650                         <xsl:if test="contains($controlField008-30-31,'g')">
651                                 <genre authority="marc">reporting</genre>
652                         </xsl:if>
653                         <xsl:if test="contains($controlField008-30-31,'s')">
654                                 <genre authority="marc">sound</genre>
655                         </xsl:if>
656                         <xsl:if test="contains($controlField008-30-31,'l')">
657                                 <genre authority="marc">speech</genre>
658                         </xsl:if>
659                 </xsl:if>
660                 <xsl:if test="$typeOf008='VM'">
661                         <xsl:variable name="controlField008-33" select="substring($controlField008,34,1)"></xsl:variable>
662                         <xsl:choose>
663                                 <xsl:when test="$controlField008-33='a'">
664                                         <genre authority="marc">art original</genre>
665                                 </xsl:when>
666                                 <xsl:when test="$controlField008-33='b'">
667                                         <genre authority="marc">kit</genre>
668                                 </xsl:when>
669                                 <xsl:when test="$controlField008-33='c'">
670                                         <genre authority="marc">art reproduction</genre>
671                                 </xsl:when>
672                                 <xsl:when test="$controlField008-33='d'">
673                                         <genre authority="marc">diorama</genre>
674                                 </xsl:when>
675                                 <xsl:when test="$controlField008-33='f'">
676                                         <genre authority="marc">filmstrip</genre>
677                                 </xsl:when>
678                                 <xsl:when test="$controlField008-33='g'">
679                                         <genre authority="marc">legal article</genre>
680                                 </xsl:when>
681                                 <xsl:when test="$controlField008-33='i'">
682                                         <genre authority="marc">picture</genre>
683                                 </xsl:when>
684                                 <xsl:when test="$controlField008-33='k'">
685                                         <genre authority="marc">graphic</genre>
686                                 </xsl:when>
687                                 <xsl:when test="$controlField008-33='l'">
688                                         <genre authority="marc">technical drawing</genre>
689                                 </xsl:when>
690                                 <xsl:when test="$controlField008-33='m'">
691                                         <genre authority="marc">motion picture</genre>
692                                 </xsl:when>
693                                 <xsl:when test="$controlField008-33='n'">
694                                         <genre authority="marc">chart</genre>
695                                 </xsl:when>
696                                 <xsl:when test="$controlField008-33='o'">
697                                         <genre authority="marc">flash card</genre>
698                                 </xsl:when>
699                                 <xsl:when test="$controlField008-33='p'">
700                                         <genre authority="marc">microscope slide</genre>
701                                 </xsl:when>
702                                 <xsl:when test="$controlField008-33='q' or marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='q']">
703                                         <genre authority="marc">model</genre>
704                                 </xsl:when>
705                                 <xsl:when test="$controlField008-33='r'">
706                                         <genre authority="marc">realia</genre>
707                                 </xsl:when>
708                                 <xsl:when test="$controlField008-33='s'">
709                                         <genre authority="marc">slide</genre>
710                                 </xsl:when>
711                                 <xsl:when test="$controlField008-33='t'">
712                                         <genre authority="marc">transparency</genre>
713                                 </xsl:when>
714                                 <xsl:when test="$controlField008-33='v'">
715                                         <genre authority="marc">videorecording</genre>
716                                 </xsl:when>
717                                 <xsl:when test="$controlField008-33='w'">
718                                         <genre authority="marc">toy</genre>
719                                 </xsl:when>
720                         </xsl:choose>
721                 </xsl:if>
722                 <xsl:for-each select="marc:datafield[@tag=655]">
723                         <genre authority="marc">
724                                 <xsl:attribute name="authority">
725                                         <xsl:value-of select="marc:subfield[@code='2']"/>
726                                 </xsl:attribute>
727                                 <xsl:call-template name="subfieldSelect">
728                                         <xsl:with-param name="codes">abvxyz</xsl:with-param>
729                                         <xsl:with-param name="delimeter">-</xsl:with-param>
730                                 </xsl:call-template>
731                         </genre>
732                 </xsl:for-each>
733                 <originInfo>
734                         <xsl:variable name="MARCpublicationCode" select="normalize-space(substring($controlField008,16,3))"></xsl:variable>
735                         <xsl:if test="translate($MARCpublicationCode,'|','')">
736                                 <place>
737                                         <placeTerm>
738                                                 <xsl:attribute name="type">code</xsl:attribute>
739                                                 <xsl:attribute name="authority">marccountry</xsl:attribute>
740                                                 <xsl:value-of select="$MARCpublicationCode"/>
741                                         </placeTerm>
742                                 </place>
743                         </xsl:if>
744                         <xsl:for-each select="marc:datafield[@tag=044]/marc:subfield[@code='c']">
745                                 <place>
746                                         <placeTerm>
747                                                 <xsl:attribute name="type">code</xsl:attribute>
748                                                 <xsl:attribute name="authority">iso3166</xsl:attribute>
749                                                 <xsl:value-of select="."/>
750                                         </placeTerm>
751                                 </place>
752                         </xsl:for-each>
753                         <xsl:for-each select="marc:datafield[@tag=260]/marc:subfield[@code='a']">
754                                 <place>
755                                         <placeTerm>
756                                                 <xsl:attribute name="type">text</xsl:attribute>
757                                                 <xsl:call-template name="chopPunctuationFront">
758                                                         <xsl:with-param name="chopString">
759                                                                 <xsl:call-template name="chopPunctuation">
760                                                                         <xsl:with-param name="chopString" select="."/>
761                                                                 </xsl:call-template>
762                                                         </xsl:with-param>
763                                                 </xsl:call-template>
764                                         </placeTerm>
765                                 </place>
766                         </xsl:for-each>
767                         <xsl:for-each select="marc:datafield[@tag=046]/marc:subfield[@code='m']">
768                                 <dateValid point="start">
769                                         <xsl:value-of select="."/>
770                                 </dateValid>
771                         </xsl:for-each>
772                         <xsl:for-each select="marc:datafield[@tag=046]/marc:subfield[@code='n']">
773                                 <dateValid point="end">
774                                         <xsl:value-of select="."/>
775                                 </dateValid>
776                         </xsl:for-each>
777                         <xsl:for-each select="marc:datafield[@tag=046]/marc:subfield[@code='j']">
778                                 <dateModified>
779                                         <xsl:value-of select="."/>
780                                 </dateModified>
781                         </xsl:for-each>
782                         <xsl:for-each select="marc:datafield[@tag=260]/marc:subfield[@code='b' or @code='c' or @code='g']">
783                                 <xsl:choose>
784                                         <xsl:when test="@code='b'">
785                                                 <publisher>
786                                                         <xsl:call-template name="chopPunctuation">
787                                                                 <xsl:with-param name="chopString" select="."/>
788                                                                 <xsl:with-param name="punctuation">
789                                                                         <xsl:text>:,;/ </xsl:text>
790                                                                 </xsl:with-param>
791                                                         </xsl:call-template>
792                                                 </publisher>
793                                         </xsl:when>
794                                         <xsl:when test="@code='c'">
795                                                 <dateIssued>
796                                                         <xsl:call-template name="chopPunctuation">
797                                                                 <xsl:with-param name="chopString" select="."/>
798                                                         </xsl:call-template>
799                                                 </dateIssued>
800                                         </xsl:when>
801                                         <xsl:when test="@code='g'">
802                                                 <dateCreated>
803                                                         <xsl:value-of select="."/>
804                                                 </dateCreated>
805                                         </xsl:when>
806                                 </xsl:choose>
807                         </xsl:for-each>
808                         <xsl:variable name="dataField260c">
809                                 <xsl:call-template name="chopPunctuation">
810                                         <xsl:with-param name="chopString" select="marc:datafield[@tag=260]/marc:subfield[@code='c']"></xsl:with-param>
811                                 </xsl:call-template>
812                         </xsl:variable>
813                         <xsl:variable name="controlField008-7-10" select="normalize-space(substring($controlField008, 8, 4))"></xsl:variable>
814                         <xsl:variable name="controlField008-11-14" select="normalize-space(substring($controlField008, 12, 4))"></xsl:variable>
815                         <xsl:variable name="controlField008-6" select="normalize-space(substring($controlField008, 7, 1))"></xsl:variable>
816                         <xsl:if test="$controlField008-6='e' or $controlField008-6='p' or $controlField008-6='r' or $controlField008-6='t' or $controlField008-6='s'">
817                                 <xsl:if test="$controlField008-7-10 and ($controlField008-7-10 != $dataField260c)">
818                                         <dateIssued encoding="marc">
819                                                 <xsl:value-of select="$controlField008-7-10"/>
820                                         </dateIssued>
821                                 </xsl:if>
822                         </xsl:if>
823                         <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'">
824                                 <xsl:if test="$controlField008-7-10">
825                                         <dateIssued encoding="marc" point="start">
826                                                 <xsl:value-of select="$controlField008-7-10"/>
827                                         </dateIssued>
828                                 </xsl:if>
829                         </xsl:if>
830                         <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'">
831                                 <xsl:if test="$controlField008-11-14">
832                                         <dateIssued encoding="marc" point="end">
833                                                 <xsl:value-of select="$controlField008-11-14"/>
834                                         </dateIssued>
835                                 </xsl:if>
836                         </xsl:if>
837                         <xsl:if test="$controlField008-6='q'">
838                                 <xsl:if test="$controlField008-7-10">
839                                         <dateIssued encoding="marc" point="start" qualifier="questionable">
840                                                 <xsl:value-of select="$controlField008-7-10"/>
841                                         </dateIssued>
842                                 </xsl:if>
843                         </xsl:if>
844                         <xsl:if test="$controlField008-6='q'">
845                                 <xsl:if test="$controlField008-11-14">
846                                         <dateIssued encoding="marc" point="end" qualifier="questionable">
847                                                 <xsl:value-of select="$controlField008-11-14"/>
848                                         </dateIssued>
849                                 </xsl:if>
850                         </xsl:if>
851                         <xsl:if test="$controlField008-6='t'">
852                                 <xsl:if test="$controlField008-11-14">
853                                         <copyrightDate encoding="marc">
854                                                 <xsl:value-of select="$controlField008-11-14"/>
855                                         </copyrightDate>
856                                 </xsl:if>
857                         </xsl:if>
858                         <xsl:for-each select="marc:datafield[@tag=033][@ind1=0 or @ind1=1]/marc:subfield[@code='a']">
859                                 <dateCaptured encoding="iso8601">
860                                         <xsl:value-of select="."/>
861                                 </dateCaptured>
862                         </xsl:for-each>
863                         <xsl:for-each select="marc:datafield[@tag=033][@ind1=2]/marc:subfield[@code='a'][1]">
864                                 <dateCaptured encoding="iso8601" point="start">
865                                         <xsl:value-of select="."/>
866                                 </dateCaptured>
867                         </xsl:for-each>
868                         <xsl:for-each select="marc:datafield[@tag=033][@ind1=2]/marc:subfield[@code='a'][2]">
869                                 <dateCaptured encoding="iso8601" point="end">
870                                         <xsl:value-of select="."/>
871                                 </dateCaptured>
872                         </xsl:for-each>
873                         <xsl:for-each select="marc:datafield[@tag=250]/marc:subfield[@code='a']">
874                                 <edition>
875                                         <xsl:value-of select="."/>
876                                 </edition>
877                         </xsl:for-each>
878                         <xsl:for-each select="marc:leader">
879                                 <issuance>
880                                         <xsl:choose>
881                                                 <xsl:when test="$leader7='a' or $leader7='c' or $leader7='d' or $leader7='m'">monographic</xsl:when>
882                                                 <xsl:when test="$leader7='b' or $leader7='i' or $leader7='s'">continuing</xsl:when>
883                                         </xsl:choose>
884                                 </issuance>
885                         </xsl:for-each>
886                         <xsl:for-each select="marc:datafield[@tag=310]|marc:datafield[@tag=321]">
887                                 <frequency>
888                                         <xsl:call-template name="subfieldSelect">
889                                                 <xsl:with-param name="codes">ab</xsl:with-param>
890                                         </xsl:call-template>
891                                 </frequency>
892                         </xsl:for-each>
893                 </originInfo>
894                 <xsl:variable name="controlField008-35-37" select="normalize-space(translate(substring($controlField008,36,3),'|#',''))"></xsl:variable>
895                 <xsl:if test="$controlField008-35-37">
896                         <language>
897                                 <languageTerm authority="iso639-2b" type="code">
898                                         <xsl:value-of select="substring($controlField008,36,3)"/>
899                                 </languageTerm>
900                         </language>
901                 </xsl:if>
902                 <xsl:for-each select="marc:datafield[@tag=041]">
903                         <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']">
904                                 <xsl:variable name="langCodes" select="."/>
905                                 <xsl:choose>
906                                         <xsl:when test="../marc:subfield[@code='2']='rfc3066'">
907                                                 <!-- not stacked but could be repeated -->
908                                                 <xsl:call-template name="rfcLanguages">
909                                                         <xsl:with-param name="nodeNum">
910                                                                 <xsl:value-of select="1"/>
911                                                         </xsl:with-param>
912                                                         <xsl:with-param name="usedLanguages">
913                                                                 <xsl:text></xsl:text>
914                                                         </xsl:with-param>
915                                                         <xsl:with-param name="controlField008-35-37">
916                                                                 <xsl:value-of select="$controlField008-35-37"></xsl:value-of>
917                                                         </xsl:with-param>
918                                                 </xsl:call-template>
919                                         </xsl:when>
920                                         <xsl:otherwise>
921                                                 <!-- iso -->
922                                                 <xsl:variable name="allLanguages">
923                                                         <xsl:copy-of select="$langCodes"></xsl:copy-of>
924                                                 </xsl:variable>
925                                                 <xsl:variable name="currentLanguage">
926                                                         <xsl:value-of select="substring($allLanguages,1,3)"></xsl:value-of>
927                                                 </xsl:variable>
928                                                 <xsl:call-template name="isoLanguage">
929                                                         <xsl:with-param name="currentLanguage">
930                                                                 <xsl:value-of select="substring($allLanguages,1,3)"></xsl:value-of>
931                                                         </xsl:with-param>
932                                                         <xsl:with-param name="remainingLanguages">
933                                                                 <xsl:value-of select="substring($allLanguages,4,string-length($allLanguages)-3)"></xsl:value-of>
934                                                         </xsl:with-param>
935                                                         <xsl:with-param name="usedLanguages">
936                                                                 <xsl:if test="$controlField008-35-37">
937                                                                         <xsl:value-of select="$controlField008-35-37"></xsl:value-of>
938                                                                 </xsl:if>
939                                                         </xsl:with-param>
940                                                 </xsl:call-template>
941                                         </xsl:otherwise>
942                                 </xsl:choose>
943                         </xsl:for-each>
944                 </xsl:for-each>
945                 <xsl:variable name="physicalDescription">
946                         <!--3.2 change tmee 007/11 -->
947                         <xsl:if test="$typeOf008='CF' and marc:controlfield[@tag=007][substring(.,12,1)='a']">
948                                 <digitalOrigin>reformatted digital</digitalOrigin>
949                         </xsl:if>
950                         <xsl:if test="$typeOf008='CF' and marc:controlfield[@tag=007][substring(.,12,1)='b']">
951                                 <digitalOrigin>digitized microfilm</digitalOrigin>
952                         </xsl:if>
953                         <xsl:if test="$typeOf008='CF' and marc:controlfield[@tag=007][substring(.,12,1)='d']">
954                                 <digitalOrigin>digitized other analog</digitalOrigin>
955                         </xsl:if>
956                         <xsl:variable name="controlField008-23" select="substring($controlField008,24,1)"></xsl:variable>
957                         <xsl:variable name="controlField008-29" select="substring($controlField008,30,1)"></xsl:variable>
958                         <xsl:variable name="check008-23">
959                                 <xsl:if test="$typeOf008='BK' or $typeOf008='MU' or $typeOf008='SE' or $typeOf008='MM'">
960                                         <xsl:value-of select="true()"></xsl:value-of>
961                                 </xsl:if>
962                         </xsl:variable>
963                         <xsl:variable name="check008-29">
964                                 <xsl:if test="$typeOf008='MP' or $typeOf008='VM'">
965                                         <xsl:value-of select="true()"></xsl:value-of>
966                                 </xsl:if>
967                         </xsl:variable>
968                         <xsl:choose>
969                                 <xsl:when test="($check008-23 and $controlField008-23='f') or ($check008-29 and $controlField008-29='f')">
970                                         <form authority="marcform">braille</form>
971                                 </xsl:when>
972                                 <xsl:when test="($controlField008-23=' ' and ($leader6='c' or $leader6='d')) or (($typeOf008='BK' or $typeOf008='SE') and ($controlField008-23=' ' or $controlField008='r'))">
973                                         <form authority="marcform">print</form>
974                                 </xsl:when>
975                                 <xsl:when test="$leader6 = 'm' or ($check008-23 and $controlField008-23='s') or ($check008-29 and $controlField008-29='s')">
976                                         <form authority="marcform">electronic</form>
977                                 </xsl:when>
978                                 <xsl:when test="($check008-23 and $controlField008-23='b') or ($check008-29 and $controlField008-29='b')">
979                                         <form authority="marcform">microfiche</form>
980                                 </xsl:when>
981                                 <xsl:when test="($check008-23 and $controlField008-23='a') or ($check008-29 and $controlField008-29='a')">
982                                         <form authority="marcform">microfilm</form>
983                                 </xsl:when>
984                         </xsl:choose>
985                         <!-- 1/04 fix -->
986                         <xsl:if test="marc:datafield[@tag=130]/marc:subfield[@code='h']">
987                                 <form authority="gmd">
988                                         <xsl:call-template name="chopBrackets">
989                                                 <xsl:with-param name="chopString">
990                                                         <xsl:value-of select="marc:datafield[@tag=130]/marc:subfield[@code='h']"></xsl:value-of>
991                                                 </xsl:with-param>
992                                         </xsl:call-template>
993                                 </form>
994                         </xsl:if>
995                         <xsl:if test="marc:datafield[@tag=240]/marc:subfield[@code='h']">
996                                 <form authority="gmd">
997                                         <xsl:call-template name="chopBrackets">
998                                                 <xsl:with-param name="chopString">
999                                                         <xsl:value-of select="marc:datafield[@tag=240]/marc:subfield[@code='h']"></xsl:value-of>
1000                                                 </xsl:with-param>
1001                                         </xsl:call-template>
1002                                 </form>
1003                         </xsl:if>
1004                         <xsl:if test="marc:datafield[@tag=242]/marc:subfield[@code='h']">
1005                                 <form authority="gmd">
1006                                         <xsl:call-template name="chopBrackets">
1007                                                 <xsl:with-param name="chopString">
1008                                                         <xsl:value-of select="marc:datafield[@tag=242]/marc:subfield[@code='h']"></xsl:value-of>
1009                                                 </xsl:with-param>
1010                                         </xsl:call-template>
1011                                 </form>
1012                         </xsl:if>
1013                         <xsl:if test="marc:datafield[@tag=245]/marc:subfield[@code='h']">
1014                                 <form authority="gmd">
1015                                         <xsl:call-template name="chopBrackets">
1016                                                 <xsl:with-param name="chopString">
1017                                                         <xsl:value-of select="marc:datafield[@tag=245]/marc:subfield[@code='h']"></xsl:value-of>
1018                                                 </xsl:with-param>
1019                                         </xsl:call-template>
1020                                 </form>
1021                         </xsl:if>
1022                         <xsl:if test="marc:datafield[@tag=246]/marc:subfield[@code='h']">
1023                                 <form authority="gmd">
1024                                         <xsl:call-template name="chopBrackets">
1025                                                 <xsl:with-param name="chopString">
1026                                                         <xsl:value-of select="marc:datafield[@tag=246]/marc:subfield[@code='h']"></xsl:value-of>
1027                                                 </xsl:with-param>
1028                                         </xsl:call-template>
1029                                 </form>
1030                         </xsl:if>
1031                         <xsl:if test="marc:datafield[@tag=730]/marc:subfield[@code='h']">
1032                                 <form authority="gmd">
1033                                         <xsl:call-template name="chopBrackets">
1034                                                 <xsl:with-param name="chopString">
1035                                                         <xsl:value-of select="marc:datafield[@tag=730]/marc:subfield[@code='h']"></xsl:value-of>
1036                                                 </xsl:with-param>
1037                                         </xsl:call-template>
1038                                 </form>
1039                         </xsl:if>
1040                         <xsl:for-each select="marc:datafield[@tag=256]/marc:subfield[@code='a']">
1041                                 <form>
1042                                         <xsl:value-of select="."></xsl:value-of>
1043                                 </form>
1044                         </xsl:for-each>
1045                         <xsl:for-each select="marc:controlfield[@tag=007][substring(text(),1,1)='c']">
1046                                 <xsl:choose>
1047                                         <xsl:when test="substring(text(),14,1)='a'">
1048                                                 <reformattingQuality>access</reformattingQuality>
1049                                         </xsl:when>
1050                                         <xsl:when test="substring(text(),14,1)='p'">
1051                                                 <reformattingQuality>preservation</reformattingQuality>
1052                                         </xsl:when>
1053                                         <xsl:when test="substring(text(),14,1)='r'">
1054                                                 <reformattingQuality>replacement</reformattingQuality>
1055                                         </xsl:when>
1056                                 </xsl:choose>
1057                         </xsl:for-each>
1058                         <!--3.2 change tmee 007/01 -->
1059                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='b']">
1060                                 <form authority="smd">chip cartridge</form>
1061                         </xsl:if>
1062                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='c']">
1063                                 <form authority="smd">computer optical disc cartridge</form>
1064                         </xsl:if>
1065                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='j']">
1066                                 <form authority="smd">magnetic disc</form>
1067                         </xsl:if>
1068                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='m']">
1069                                 <form authority="smd">magneto-optical disc</form>
1070                         </xsl:if>
1071                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='o']">
1072                                 <form authority="smd">optical disc</form>
1073                         </xsl:if>
1074                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='r']">
1075                                 <form authority="smd">remote</form>
1076                         </xsl:if>
1077                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='a']">
1078                                 <form authority="smd">tape cartridge</form>
1079                         </xsl:if>
1080                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='f']">
1081                                 <form authority="smd">tape cassette</form>
1082                         </xsl:if>
1083                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='h']">
1084                                 <form authority="smd">tape reel</form>
1085                         </xsl:if>
1086
1087                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='d'][substring(text(),2,1)='a']">
1088                                 <form authority="smd">celestial globe</form>
1089                         </xsl:if>
1090                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='d'][substring(text(),2,1)='e']">
1091                                 <form authority="smd">earth moon globe</form>
1092                         </xsl:if>
1093                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='d'][substring(text(),2,1)='b']">
1094                                 <form authority="smd">planetary or lunar globe</form>
1095                         </xsl:if>
1096                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='d'][substring(text(),2,1)='c']">
1097                                 <form authority="smd">terrestrial globe</form>
1098                         </xsl:if>
1099
1100                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='o'][substring(text(),2,1)='o']">
1101                                 <form authority="smd">kit</form>
1102                         </xsl:if>
1103
1104                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='d']">
1105                                 <form authority="smd">atlas</form>
1106                         </xsl:if>
1107                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='g']">
1108                                 <form authority="smd">diagram</form>
1109                         </xsl:if>
1110                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='j']">
1111                                 <form authority="smd">map</form>
1112                         </xsl:if>
1113                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='q']">
1114                                 <form authority="smd">model</form>
1115                         </xsl:if>
1116                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='k']">
1117                                 <form authority="smd">profile</form>
1118                         </xsl:if>
1119                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='r']">
1120                                 <form authority="smd">remote-sensing image</form>
1121                         </xsl:if>
1122                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='s']">
1123                                 <form authority="smd">section</form>
1124                         </xsl:if>
1125                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='y']">
1126                                 <form authority="smd">view</form>
1127                         </xsl:if>
1128
1129                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='a']">
1130                                 <form authority="smd">aperture card</form>
1131                         </xsl:if>
1132                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='e']">
1133                                 <form authority="smd">microfiche</form>
1134                         </xsl:if>
1135                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='f']">
1136                                 <form authority="smd">microfiche cassette</form>
1137                         </xsl:if>
1138                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='b']">
1139                                 <form authority="smd">microfilm cartridge</form>
1140                         </xsl:if>
1141                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='c']">
1142                                 <form authority="smd">microfilm cassette</form>
1143                         </xsl:if>
1144                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='d']">
1145                                 <form authority="smd">microfilm reel</form>
1146                         </xsl:if>
1147                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='g']">
1148                                 <form authority="smd">microopaque</form>
1149                         </xsl:if>
1150
1151                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='m'][substring(text(),2,1)='c']">
1152                                 <form authority="smd">film cartridge</form>
1153                         </xsl:if>
1154                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='m'][substring(text(),2,1)='f']">
1155                                 <form authority="smd">film cassette</form>
1156                         </xsl:if>
1157                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='m'][substring(text(),2,1)='r']">
1158                                 <form authority="smd">film reel</form>
1159                         </xsl:if>
1160
1161                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='n']">
1162                                 <form authority="smd">chart</form>
1163                         </xsl:if>
1164                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='c']">
1165                                 <form authority="smd">collage</form>
1166                         </xsl:if>
1167                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='d']">
1168                                 <form authority="smd">drawing</form>
1169                         </xsl:if>
1170                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='o']">
1171                                 <form authority="smd">flash card</form>
1172                         </xsl:if>
1173                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='e']">
1174                                 <form authority="smd">painting</form>
1175                         </xsl:if>
1176                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='f']">
1177                                 <form authority="smd">photomechanical print</form>
1178                         </xsl:if>
1179                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='g']">
1180                                 <form authority="smd">photonegative</form>
1181                         </xsl:if>
1182                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='h']">
1183                                 <form authority="smd">photoprint</form>
1184                         </xsl:if>
1185                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='i']">
1186                                 <form authority="smd">picture</form>
1187                         </xsl:if>
1188                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='j']">
1189                                 <form authority="smd">print</form>
1190                         </xsl:if>
1191                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='l']">
1192                                 <form authority="smd">technical drawing</form>
1193                         </xsl:if>
1194
1195                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='q'][substring(text(),2,1)='q']">
1196                                 <form authority="smd">notated music</form>
1197                         </xsl:if>
1198
1199                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='d']">
1200                                 <form authority="smd">filmslip</form>
1201                         </xsl:if>
1202                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='c']">
1203                                 <form authority="smd">filmstrip cartridge</form>
1204                         </xsl:if>
1205                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='o']">
1206                                 <form authority="smd">filmstrip roll</form>
1207                         </xsl:if>
1208                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='f']">
1209                                 <form authority="smd">other filmstrip type</form>
1210                         </xsl:if>
1211                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='s']">
1212                                 <form authority="smd">slide</form>
1213                         </xsl:if>
1214                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='t']">
1215                                 <form authority="smd">transparency</form>
1216                         </xsl:if>
1217                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='r'][substring(text(),2,1)='r']">
1218                                 <form authority="smd">remote-sensing image</form>
1219                         </xsl:if>
1220                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='e']">
1221                                 <form authority="smd">cylinder</form>
1222                         </xsl:if>
1223                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='q']">
1224                                 <form authority="smd">roll</form>
1225                         </xsl:if>
1226                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='g']">
1227                                 <form authority="smd">sound cartridge</form>
1228                         </xsl:if>
1229                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='s']">
1230                                 <form authority="smd">sound cassette</form>
1231                         </xsl:if>
1232                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='d']">
1233                                 <form authority="smd">sound disc</form>
1234                         </xsl:if>
1235                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='t']">
1236                                 <form authority="smd">sound-tape reel</form>
1237                         </xsl:if>
1238                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='i']">
1239                                 <form authority="smd">sound-track film</form>
1240                         </xsl:if>
1241                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='w']">
1242                                 <form authority="smd">wire recording</form>
1243                         </xsl:if>
1244
1245                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='f'][substring(text(),2,1)='c']">
1246                                 <form authority="smd">braille</form>
1247                         </xsl:if>
1248                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='f'][substring(text(),2,1)='b']">
1249                                 <form authority="smd">combination</form>
1250                         </xsl:if>
1251                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='f'][substring(text(),2,1)='a']">
1252                                 <form authority="smd">moon</form>
1253                         </xsl:if>
1254                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='f'][substring(text(),2,1)='d']">
1255                                 <form authority="smd">tactile, with no writing system</form>
1256                         </xsl:if>
1257
1258                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='t'][substring(text(),2,1)='c']">
1259                                 <form authority="smd">braille</form>
1260                         </xsl:if>
1261                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='t'][substring(text(),2,1)='b']">
1262                                 <form authority="smd">large print</form>
1263                         </xsl:if>
1264                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='t'][substring(text(),2,1)='a']">
1265                                 <form authority="smd">regular print</form>
1266                         </xsl:if>
1267                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='t'][substring(text(),2,1)='d']">
1268                                 <form authority="smd">text in looseleaf binder</form>
1269                         </xsl:if>
1270
1271                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='v'][substring(text(),2,1)='c']">
1272                                 <form authority="smd">videocartridge</form>
1273                         </xsl:if>
1274                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='v'][substring(text(),2,1)='f']">
1275                                 <form authority="smd">videocassette</form>
1276                         </xsl:if>
1277                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='v'][substring(text(),2,1)='d']">
1278                                 <form authority="smd">videodisc</form>
1279                         </xsl:if>
1280                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='v'][substring(text(),2,1)='r']">
1281                                 <form authority="smd">videoreel</form>
1282                         </xsl:if>
1283
1284                         <xsl:for-each select="marc:datafield[@tag=856]/marc:subfield[@code='q'][string-length(.)>1]">
1285                                 <internetMediaType>
1286                                         <xsl:value-of select="."></xsl:value-of>
1287                                 </internetMediaType>
1288                         </xsl:for-each>
1289                         <xsl:for-each select="marc:datafield[@tag=300]">
1290                                 <extent>
1291                                         <xsl:call-template name="subfieldSelect">
1292                                                 <xsl:with-param name="codes">abce</xsl:with-param>
1293                                         </xsl:call-template>
1294                                 </extent>
1295                         </xsl:for-each>
1296                 </xsl:variable>
1297                 <xsl:if test="string-length(normalize-space($physicalDescription))">
1298                         <physicalDescription>
1299                                 <xsl:copy-of select="$physicalDescription"></xsl:copy-of>
1300                         </physicalDescription>
1301                 </xsl:if>
1302                 <xsl:for-each select="marc:datafield[@tag=520]">
1303                         <abstract>
1304                                 <xsl:call-template name="uri"></xsl:call-template>
1305                                 <xsl:call-template name="subfieldSelect">
1306                                         <xsl:with-param name="codes">ab</xsl:with-param>
1307                                 </xsl:call-template>
1308                         </abstract>
1309                 </xsl:for-each>
1310                 <xsl:for-each select="marc:datafield[@tag=505]">
1311                         <tableOfContents>
1312                                 <xsl:call-template name="uri"></xsl:call-template>
1313                                 <xsl:call-template name="subfieldSelect">
1314                                         <xsl:with-param name="codes">agrt</xsl:with-param>
1315                                 </xsl:call-template>
1316                         </tableOfContents>
1317                 </xsl:for-each>
1318                 <xsl:for-each select="marc:datafield[@tag=521]">
1319                         <targetAudience>
1320                                 <xsl:call-template name="subfieldSelect">
1321                                         <xsl:with-param name="codes">ab</xsl:with-param>
1322                                 </xsl:call-template>
1323                         </targetAudience>
1324                 </xsl:for-each>
1325                 <xsl:if test="$typeOf008='BK' or $typeOf008='CF' or $typeOf008='MU' or $typeOf008='VM'">
1326                         <xsl:variable name="controlField008-22" select="substring($controlField008,23,1)"></xsl:variable>
1327                         <xsl:choose>
1328                                 <!-- 01/04 fix -->
1329                                 <xsl:when test="$controlField008-22='d'">
1330                                         <targetAudience authority="marctarget">adolescent</targetAudience>
1331                                 </xsl:when>
1332                                 <xsl:when test="$controlField008-22='e'">
1333                                         <targetAudience authority="marctarget">adult</targetAudience>
1334                                 </xsl:when>
1335                                 <xsl:when test="$controlField008-22='g'">
1336                                         <targetAudience authority="marctarget">general</targetAudience>
1337                                 </xsl:when>
1338                                 <xsl:when test="$controlField008-22='b' or $controlField008-22='c' or $controlField008-22='j'">
1339                                         <targetAudience authority="marctarget">juvenile</targetAudience>
1340                                 </xsl:when>
1341                                 <xsl:when test="$controlField008-22='a'">
1342                                         <targetAudience authority="marctarget">preschool</targetAudience>
1343                                 </xsl:when>
1344                                 <xsl:when test="$controlField008-22='f'">
1345                                         <targetAudience authority="marctarget">specialized</targetAudience>
1346                                 </xsl:when>
1347                         </xsl:choose>
1348                 </xsl:if>
1349                 <xsl:for-each select="marc:datafield[@tag=245]/marc:subfield[@code='c']">
1350                         <note type="statement of responsibility">
1351                                 <xsl:value-of select="."></xsl:value-of>
1352                         </note>
1353                 </xsl:for-each>
1354                 <xsl:for-each select="marc:datafield[@tag=500]">
1355                         <note>
1356                                 <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
1357                                 <xsl:call-template name="uri"></xsl:call-template>
1358                         </note>
1359                 </xsl:for-each>
1360
1361                 <!--3.2 change tmee additional note fields-->
1362
1363                 <xsl:for-each select="marc:datafield[@tag=502]">
1364                         <note type="thesis">
1365                                 <xsl:call-template name="uri"/>
1366                                 <xsl:variable name="str">
1367                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
1368                                                 <xsl:value-of select="."/>
1369                                                 <xsl:text> </xsl:text>
1370                                         </xsl:for-each>
1371                                 </xsl:variable>
1372                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
1373                         </note>
1374                 </xsl:for-each>
1375
1376                 <xsl:for-each select="marc:datafield[@tag=504]">
1377                         <note type="bibliography">
1378                                 <xsl:call-template name="uri"/>
1379                                 <xsl:variable name="str">
1380                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
1381                                                 <xsl:value-of select="."/>
1382                                                 <xsl:text> </xsl:text>
1383                                         </xsl:for-each>
1384                                 </xsl:variable>
1385                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
1386                         </note>
1387                 </xsl:for-each>
1388
1389                 <xsl:for-each select="marc:datafield[@tag=508]">
1390                         <note type="creation/production credits">
1391                                 <xsl:call-template name="uri"/>
1392                                 <xsl:variable name="str">
1393                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
1394                                                 <xsl:value-of select="."/>
1395                                                 <xsl:text> </xsl:text>
1396                                         </xsl:for-each>
1397                                 </xsl:variable>
1398                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
1399                         </note>
1400                 </xsl:for-each>
1401
1402                 <xsl:for-each select="marc:datafield[@tag=506]">
1403                         <note type="restrictions">
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=510]">
1416                         <note  type="citation/reference">
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
1429                 <xsl:for-each select="marc:datafield[@tag=511]">
1430                         <note type="performers">
1431                                 <xsl:call-template name="uri"></xsl:call-template>
1432                                 <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
1433                         </note>
1434                 </xsl:for-each>
1435                 <xsl:for-each select="marc:datafield[@tag=518]">
1436                         <note type="venue">
1437                                 <xsl:call-template name="uri"></xsl:call-template>
1438                                 <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
1439                         </note>
1440                 </xsl:for-each>
1441
1442                 <xsl:for-each select="marc:datafield[@tag=530]">
1443                         <note  type="additional physical form">
1444                                 <xsl:call-template name="uri"></xsl:call-template>
1445                                 <xsl:variable name="str">
1446                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
1447                                                 <xsl:value-of select="."></xsl:value-of>
1448                                                 <xsl:text> </xsl:text>
1449                                         </xsl:for-each>
1450                                 </xsl:variable>
1451                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
1452                         </note>
1453                 </xsl:for-each>
1454
1455                 <xsl:for-each select="marc:datafield[@tag=533]">
1456                         <note  type="reproduction">
1457                                 <xsl:call-template name="uri"></xsl:call-template>
1458                                 <xsl:variable name="str">
1459                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
1460                                                 <xsl:value-of select="."></xsl:value-of>
1461                                                 <xsl:text> </xsl:text>
1462                                         </xsl:for-each>
1463                                 </xsl:variable>
1464                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
1465                         </note>
1466                 </xsl:for-each>
1467
1468                 <xsl:for-each select="marc:datafield[@tag=534]">
1469                         <note  type="original version">
1470                                 <xsl:call-template name="uri"></xsl:call-template>
1471                                 <xsl:variable name="str">
1472                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
1473                                                 <xsl:value-of select="."></xsl:value-of>
1474                                                 <xsl:text> </xsl:text>
1475                                         </xsl:for-each>
1476                                 </xsl:variable>
1477                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
1478                         </note>
1479                 </xsl:for-each>
1480
1481                 <xsl:for-each select="marc:datafield[@tag=538]">
1482                         <note  type="system details">
1483                                 <xsl:call-template name="uri"></xsl:call-template>
1484                                 <xsl:variable name="str">
1485                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
1486                                                 <xsl:value-of select="."></xsl:value-of>
1487                                                 <xsl:text> </xsl:text>
1488                                         </xsl:for-each>
1489                                 </xsl:variable>
1490                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
1491                         </note>
1492                 </xsl:for-each>
1493
1494                 <xsl:for-each select="marc:datafield[@tag=583]">
1495                         <note type="action">
1496                                 <xsl:call-template name="uri"></xsl:call-template>
1497                                 <xsl:variable name="str">
1498                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
1499                                                 <xsl:value-of select="."></xsl:value-of>
1500                                                 <xsl:text> </xsl:text>
1501                                         </xsl:for-each>
1502                                 </xsl:variable>
1503                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
1504                         </note>
1505                 </xsl:for-each>
1506
1507
1508
1509
1510
1511                 <xsl:for-each select="marc:datafield[@tag=501 or @tag=507 or  @tag=513 or @tag=514 or @tag=515 or @tag=516 or @tag=522 or @tag=524 or @tag=525 or @tag=526 or @tag=535 or @tag=536 or @tag=540 or @tag=541 or @tag=544 or @tag=545 or @tag=546 or @tag=547 or @tag=550 or @tag=552 or @tag=555 or @tag=556 or @tag=561 or @tag=562 or @tag=565 or @tag=567 or @tag=580 or @tag=581 or @tag=584 or @tag=585 or @tag=586]">
1512                         <note>
1513                                 <xsl:call-template name="uri"></xsl:call-template>
1514                                 <xsl:variable name="str">
1515                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
1516                                                 <xsl:value-of select="."></xsl:value-of>
1517                                                 <xsl:text> </xsl:text>
1518                                         </xsl:for-each>
1519                                 </xsl:variable>
1520                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
1521                         </note>
1522                 </xsl:for-each>
1523                 <xsl:for-each select="marc:datafield[@tag=034][marc:subfield[@code='d' or @code='e' or @code='f' or @code='g']]">
1524                         <subject>
1525                                 <cartographics>
1526                                         <coordinates>
1527                                                 <xsl:call-template name="subfieldSelect">
1528                                                         <xsl:with-param name="codes">defg</xsl:with-param>
1529                                                 </xsl:call-template>
1530                                         </coordinates>
1531                                 </cartographics>
1532                         </subject>
1533                 </xsl:for-each>
1534                 <xsl:for-each select="marc:datafield[@tag=043]">
1535                         <subject>
1536                                 <xsl:for-each select="marc:subfield[@code='a' or @code='b' or @code='c']">
1537                                         <geographicCode>
1538                                                 <xsl:attribute name="authority">
1539                                                         <xsl:if test="@code='a'">
1540                                                                 <xsl:text>marcgac</xsl:text>
1541                                                         </xsl:if>
1542                                                         <xsl:if test="@code='b'">
1543                                                                 <xsl:value-of select="following-sibling::marc:subfield[@code=2]"></xsl:value-of>
1544                                                         </xsl:if>
1545                                                         <xsl:if test="@code='c'">
1546                                                                 <xsl:text>iso3166</xsl:text>
1547                                                         </xsl:if>
1548                                                 </xsl:attribute>
1549                                                 <xsl:value-of select="self::marc:subfield"></xsl:value-of>
1550                                         </geographicCode>
1551                                 </xsl:for-each>
1552                         </subject>
1553                 </xsl:for-each>
1554                 <!-- tmee 2006/11/27 -->
1555                 <xsl:for-each select="marc:datafield[@tag=255]">
1556                         <subject>
1557                                 <xsl:for-each select="marc:subfield[@code='a' or @code='b' or @code='c']">
1558                                 <cartographics>
1559                                         <xsl:if test="@code='a'">
1560                                                 <scale>
1561                                                         <xsl:value-of select="."></xsl:value-of>
1562                                                 </scale>
1563                                         </xsl:if>
1564                                         <xsl:if test="@code='b'">
1565                                                 <projection>
1566                                                         <xsl:value-of select="."></xsl:value-of>
1567                                                 </projection>
1568                                         </xsl:if>
1569                                         <xsl:if test="@code='c'">
1570                                                 <coordinates>
1571                                                         <xsl:value-of select="."></xsl:value-of>
1572                                                 </coordinates>
1573                                         </xsl:if>
1574                                 </cartographics>
1575                                 </xsl:for-each>
1576                         </subject>
1577                 </xsl:for-each>
1578
1579                 <xsl:apply-templates select="marc:datafield[653 >= @tag and @tag >= 600]"></xsl:apply-templates>
1580                 <xsl:apply-templates select="marc:datafield[@tag=656]"></xsl:apply-templates>
1581                 <xsl:for-each select="marc:datafield[@tag=752]">
1582                         <subject>
1583                                 <hierarchicalGeographic>
1584                                         <xsl:for-each select="marc:subfield[@code='a']">
1585                                                 <country>
1586                                                         <xsl:call-template name="chopPunctuation">
1587                                                                 <xsl:with-param name="chopString" select="."></xsl:with-param>
1588                                                         </xsl:call-template>
1589                                                 </country>
1590                                         </xsl:for-each>
1591                                         <xsl:for-each select="marc:subfield[@code='b']">
1592                                                 <state>
1593                                                         <xsl:call-template name="chopPunctuation">
1594                                                                 <xsl:with-param name="chopString" select="."></xsl:with-param>
1595                                                         </xsl:call-template>
1596                                                 </state>
1597                                         </xsl:for-each>
1598                                         <xsl:for-each select="marc:subfield[@code='c']">
1599                                                 <county>
1600                                                         <xsl:call-template name="chopPunctuation">
1601                                                                 <xsl:with-param name="chopString" select="."></xsl:with-param>
1602                                                         </xsl:call-template>
1603                                                 </county>
1604                                         </xsl:for-each>
1605                                         <xsl:for-each select="marc:subfield[@code='d']">
1606                                                 <city>
1607                                                         <xsl:call-template name="chopPunctuation">
1608                                                                 <xsl:with-param name="chopString" select="."></xsl:with-param>
1609                                                         </xsl:call-template>
1610                                                 </city>
1611                                         </xsl:for-each>
1612                                 </hierarchicalGeographic>
1613                         </subject>
1614                 </xsl:for-each>
1615                 <xsl:for-each select="marc:datafield[@tag=045][marc:subfield[@code='b']]">
1616                         <subject>
1617                                 <xsl:choose>
1618                                         <xsl:when test="@ind1=2">
1619                                                 <temporal encoding="iso8601" point="start">
1620                                                         <xsl:call-template name="chopPunctuation">
1621                                                                 <xsl:with-param name="chopString">
1622                                                                         <xsl:value-of select="marc:subfield[@code='b'][1]"></xsl:value-of>
1623                                                                 </xsl:with-param>
1624                                                         </xsl:call-template>
1625                                                 </temporal>
1626                                                 <temporal encoding="iso8601" point="end">
1627                                                         <xsl:call-template name="chopPunctuation">
1628                                                                 <xsl:with-param name="chopString">
1629                                                                         <xsl:value-of select="marc:subfield[@code='b'][2]"></xsl:value-of>
1630                                                                 </xsl:with-param>
1631                                                         </xsl:call-template>
1632                                                 </temporal>
1633                                         </xsl:when>
1634                                         <xsl:otherwise>
1635                                                 <xsl:for-each select="marc:subfield[@code='b']">
1636                                                         <temporal encoding="iso8601">
1637                                                                 <xsl:call-template name="chopPunctuation">
1638                                                                         <xsl:with-param name="chopString" select="."></xsl:with-param>
1639                                                                 </xsl:call-template>
1640                                                         </temporal>
1641                                                 </xsl:for-each>
1642                                         </xsl:otherwise>
1643                                 </xsl:choose>
1644                         </subject>
1645                 </xsl:for-each>
1646                 <xsl:for-each select="marc:datafield[@tag=050]">
1647                         <xsl:for-each select="marc:subfield[@code='b']">
1648                                 <classification authority="lcc">
1649                                         <xsl:if test="../marc:subfield[@code='3']">
1650                                                 <xsl:attribute name="displayLabel">
1651                                                         <xsl:value-of select="../marc:subfield[@code='3']"></xsl:value-of>
1652                                                 </xsl:attribute>
1653                                         </xsl:if>
1654                                         <xsl:value-of select="preceding-sibling::marc:subfield[@code='a'][1]"></xsl:value-of>
1655                                         <xsl:text> </xsl:text>
1656                                         <xsl:value-of select="text()"></xsl:value-of>
1657                                 </classification>
1658                         </xsl:for-each>
1659                         <xsl:for-each select="marc:subfield[@code='a'][not(following-sibling::marc:subfield[@code='b'])]">
1660                                 <classification authority="lcc">
1661                                         <xsl:if test="../marc:subfield[@code='3']">
1662                                                 <xsl:attribute name="displayLabel">
1663                                                         <xsl:value-of select="../marc:subfield[@code='3']"></xsl:value-of>
1664                                                 </xsl:attribute>
1665                                         </xsl:if>
1666                                         <xsl:value-of select="text()"></xsl:value-of>
1667                                 </classification>
1668                         </xsl:for-each>
1669                 </xsl:for-each>
1670                 <xsl:for-each select="marc:datafield[@tag=082]">
1671                         <classification authority="ddc">
1672                                 <xsl:if test="marc:subfield[@code='2']">
1673                                         <xsl:attribute name="edition">
1674                                                 <xsl:value-of select="marc:subfield[@code='2']"></xsl:value-of>
1675                                         </xsl:attribute>
1676                                 </xsl:if>
1677                                 <xsl:call-template name="subfieldSelect">
1678                                         <xsl:with-param name="codes">ab</xsl:with-param>
1679                                 </xsl:call-template>
1680                         </classification>
1681                 </xsl:for-each>
1682                 <xsl:for-each select="marc:datafield[@tag=080]">
1683                         <classification authority="udc">
1684                                 <xsl:call-template name="subfieldSelect">
1685                                         <xsl:with-param name="codes">abx</xsl:with-param>
1686                                 </xsl:call-template>
1687                         </classification>
1688                 </xsl:for-each>
1689                 <xsl:for-each select="marc:datafield[@tag=060]">
1690                         <classification authority="nlm">
1691                                 <xsl:call-template name="subfieldSelect">
1692                                         <xsl:with-param name="codes">ab</xsl:with-param>
1693                                 </xsl:call-template>
1694                         </classification>
1695                 </xsl:for-each>
1696                 <xsl:for-each select="marc:datafield[@tag=086][@ind1=0]">
1697                         <classification authority="sudocs">
1698                                 <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
1699                         </classification>
1700                 </xsl:for-each>
1701                 <xsl:for-each select="marc:datafield[@tag=086][@ind1=1]">
1702                         <classification authority="candoc">
1703                                 <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
1704                         </classification>
1705                 </xsl:for-each>
1706                 <xsl:for-each select="marc:datafield[@tag=086]">
1707                         <classification>
1708                                 <xsl:attribute name="authority">
1709                                         <xsl:value-of select="marc:subfield[@code='2']"></xsl:value-of>
1710                                 </xsl:attribute>
1711                                 <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
1712                         </classification>
1713                 </xsl:for-each>
1714                 <xsl:for-each select="marc:datafield[@tag=084]">
1715                         <classification>
1716                                 <xsl:attribute name="authority">
1717                                         <xsl:value-of select="marc:subfield[@code='2']"></xsl:value-of>
1718                                 </xsl:attribute>
1719                                 <xsl:call-template name="subfieldSelect">
1720                                         <xsl:with-param name="codes">ab</xsl:with-param>
1721                                 </xsl:call-template>
1722                         </classification>
1723                 </xsl:for-each>
1724                 <xsl:for-each select="marc:datafield[@tag=440]">
1725                         <relatedItem type="series">
1726                                 <xsl:variable name="titleChop">
1727                                         <xsl:call-template name="chopPunctuation">
1728                                                 <xsl:with-param name="chopString">
1729                                                         <xsl:call-template name="subfieldSelect">
1730                                                                 <xsl:with-param name="codes">av</xsl:with-param>
1731                                                         </xsl:call-template>
1732                                                 </xsl:with-param>
1733                                         </xsl:call-template>
1734                                 </xsl:variable>
1735                                 <titleInfo>
1736                                         <title>
1737                                                 <xsl:value-of select="$titleChop" />
1738                                         </title>
1739                                         <xsl:call-template name="part"></xsl:call-template>
1740                                 </titleInfo>
1741                                 <titleInfo type="nfi">
1742                                         <xsl:choose>
1743                                                 <xsl:when test="@ind2>0">
1744                                                         <nonSort>
1745                                                                 <xsl:value-of select="substring($titleChop,1,@ind2)"/>
1746                                                         </nonSort>
1747                                                         <title>
1748                                                                 <xsl:value-of select="substring($titleChop,@ind2+1)"/>
1749                                                         </title>
1750                                                         <xsl:call-template name="part"/>
1751                                                 </xsl:when>
1752                                                 <xsl:otherwise>
1753                                                         <title>
1754                                                                 <xsl:value-of select="$titleChop" />
1755                                                         </title>
1756                                                 </xsl:otherwise>
1757                                         </xsl:choose>
1758                                         <xsl:call-template name="part"></xsl:call-template>
1759                                 </titleInfo>
1760                         </relatedItem>
1761                 </xsl:for-each>
1762                 <xsl:for-each select="marc:datafield[@tag=490][@ind1=0]">
1763                         <relatedItem type="series">
1764                                 <titleInfo>
1765                                         <title>
1766                                                 <xsl:call-template name="chopPunctuation">
1767                                                         <xsl:with-param name="chopString">
1768                                                                 <xsl:call-template name="subfieldSelect">
1769                                                                         <xsl:with-param name="codes">av</xsl:with-param>
1770                                                                 </xsl:call-template>
1771                                                         </xsl:with-param>
1772                                                 </xsl:call-template>
1773                                         </title>
1774                                         <xsl:call-template name="part"></xsl:call-template>
1775                                 </titleInfo>
1776                         </relatedItem>
1777                 </xsl:for-each>
1778                 <xsl:for-each select="marc:datafield[@tag=510]">
1779                         <relatedItem type="isReferencedBy">
1780                                 <note>
1781                                         <xsl:call-template name="subfieldSelect">
1782                                                 <xsl:with-param name="codes">abcx3</xsl:with-param>
1783                                         </xsl:call-template>
1784                                 </note>
1785                         </relatedItem>
1786                 </xsl:for-each>
1787                 <xsl:for-each select="marc:datafield[@tag=534]">
1788                         <relatedItem type="original">
1789                                 <xsl:call-template name="relatedTitle"></xsl:call-template>
1790                                 <xsl:call-template name="relatedName"></xsl:call-template>
1791                                 <xsl:if test="marc:subfield[@code='b' or @code='c']">
1792                                         <originInfo>
1793                                                 <xsl:for-each select="marc:subfield[@code='c']">
1794                                                         <publisher>
1795                                                                 <xsl:value-of select="."></xsl:value-of>
1796                                                         </publisher>
1797                                                 </xsl:for-each>
1798                                                 <xsl:for-each select="marc:subfield[@code='b']">
1799                                                         <edition>
1800                                                                 <xsl:value-of select="."></xsl:value-of>
1801                                                         </edition>
1802                                                 </xsl:for-each>
1803                                         </originInfo>
1804                                 </xsl:if>
1805                                 <xsl:call-template name="relatedIdentifierISSN"></xsl:call-template>
1806                                 <xsl:for-each select="marc:subfield[@code='z']">
1807                                         <identifier type="isbn">
1808                                                 <xsl:value-of select="."></xsl:value-of>
1809                                         </identifier>
1810                                 </xsl:for-each>
1811                                 <xsl:call-template name="relatedNote"></xsl:call-template>
1812                         </relatedItem>
1813                 </xsl:for-each>
1814                 <xsl:for-each select="marc:datafield[@tag=700][marc:subfield[@code='t']]">
1815                         <relatedItem>
1816                                 <xsl:call-template name="constituentOrRelatedType"></xsl:call-template>
1817                                 <titleInfo>
1818                                         <title>
1819                                                 <xsl:call-template name="chopPunctuation">
1820                                                         <xsl:with-param name="chopString">
1821                                                                 <xsl:call-template name="specialSubfieldSelect">
1822                                                                         <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
1823                                                                         <xsl:with-param name="axis">t</xsl:with-param>
1824                                                                         <xsl:with-param name="afterCodes">g</xsl:with-param>
1825                                                                 </xsl:call-template>
1826                                                         </xsl:with-param>
1827                                                 </xsl:call-template>
1828                                         </title>
1829                                         <xsl:call-template name="part"></xsl:call-template>
1830                                 </titleInfo>
1831                                 <name type="personal">
1832                                         <namePart>
1833                                                 <xsl:call-template name="specialSubfieldSelect">
1834                                                         <xsl:with-param name="anyCodes">aq</xsl:with-param>
1835                                                         <xsl:with-param name="axis">t</xsl:with-param>
1836                                                         <xsl:with-param name="beforeCodes">g</xsl:with-param>
1837                                                 </xsl:call-template>
1838                                         </namePart>
1839                                         <xsl:call-template name="termsOfAddress"></xsl:call-template>
1840                                         <xsl:call-template name="nameDate"></xsl:call-template>
1841                                         <xsl:call-template name="role"></xsl:call-template>
1842                                 </name>
1843                                 <xsl:call-template name="relatedForm"></xsl:call-template>
1844                                 <xsl:call-template name="relatedIdentifierISSN"></xsl:call-template>
1845                         </relatedItem>
1846                 </xsl:for-each>
1847                 <xsl:for-each select="marc:datafield[@tag=710][marc:subfield[@code='t']]">
1848                         <relatedItem>
1849                                 <xsl:call-template name="constituentOrRelatedType"></xsl:call-template>
1850                                 <titleInfo>
1851                                         <title>
1852                                                 <xsl:call-template name="chopPunctuation">
1853                                                         <xsl:with-param name="chopString">
1854                                                                 <xsl:call-template name="specialSubfieldSelect">
1855                                                                         <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
1856                                                                         <xsl:with-param name="axis">t</xsl:with-param>
1857                                                                         <xsl:with-param name="afterCodes">dg</xsl:with-param>
1858                                                                 </xsl:call-template>
1859                                                         </xsl:with-param>
1860                                                 </xsl:call-template>
1861                                         </title>
1862                                         <xsl:call-template name="relatedPartNumName"></xsl:call-template>
1863                                 </titleInfo>
1864                                 <name type="corporate">
1865                                         <xsl:for-each select="marc:subfield[@code='a']">
1866                                                 <namePart>
1867                                                         <xsl:value-of select="."></xsl:value-of>
1868                                                 </namePart>
1869                                         </xsl:for-each>
1870                                         <xsl:for-each select="marc:subfield[@code='b']">
1871                                                 <namePart>
1872                                                         <xsl:value-of select="."></xsl:value-of>
1873                                                 </namePart>
1874                                         </xsl:for-each>
1875                                         <xsl:variable name="tempNamePart">
1876                                                 <xsl:call-template name="specialSubfieldSelect">
1877                                                         <xsl:with-param name="anyCodes">c</xsl:with-param>
1878                                                         <xsl:with-param name="axis">t</xsl:with-param>
1879                                                         <xsl:with-param name="beforeCodes">dgn</xsl:with-param>
1880                                                 </xsl:call-template>
1881                                         </xsl:variable>
1882                                         <xsl:if test="normalize-space($tempNamePart)">
1883                                                 <namePart>
1884                                                         <xsl:value-of select="$tempNamePart"></xsl:value-of>
1885                                                 </namePart>
1886                                         </xsl:if>
1887                                         <xsl:call-template name="role"></xsl:call-template>
1888                                 </name>
1889                                 <xsl:call-template name="relatedForm"></xsl:call-template>
1890                                 <xsl:call-template name="relatedIdentifierISSN"></xsl:call-template>
1891                         </relatedItem>
1892                 </xsl:for-each>
1893                 <xsl:for-each select="marc:datafield[@tag=711][marc:subfield[@code='t']]">
1894                         <relatedItem>
1895                                 <xsl:call-template name="constituentOrRelatedType"></xsl:call-template>
1896                                 <titleInfo>
1897                                         <title>
1898                                                 <xsl:call-template name="chopPunctuation">
1899                                                         <xsl:with-param name="chopString">
1900                                                                 <xsl:call-template name="specialSubfieldSelect">
1901                                                                         <xsl:with-param name="anyCodes">tfklsv</xsl:with-param>
1902                                                                         <xsl:with-param name="axis">t</xsl:with-param>
1903                                                                         <xsl:with-param name="afterCodes">g</xsl:with-param>
1904                                                                 </xsl:call-template>
1905                                                         </xsl:with-param>
1906                                                 </xsl:call-template>
1907                                         </title>
1908                                         <xsl:call-template name="relatedPartNumName"></xsl:call-template>
1909                                 </titleInfo>
1910                                 <name type="conference">
1911                                         <namePart>
1912                                                 <xsl:call-template name="specialSubfieldSelect">
1913                                                         <xsl:with-param name="anyCodes">aqdc</xsl:with-param>
1914                                                         <xsl:with-param name="axis">t</xsl:with-param>
1915                                                         <xsl:with-param name="beforeCodes">gn</xsl:with-param>
1916                                                 </xsl:call-template>
1917                                         </namePart>
1918                                 </name>
1919                                 <xsl:call-template name="relatedForm"></xsl:call-template>
1920                                 <xsl:call-template name="relatedIdentifierISSN"></xsl:call-template>
1921                         </relatedItem>
1922                 </xsl:for-each>
1923                 <xsl:for-each select="marc:datafield[@tag=730][@ind2=2]">
1924                         <relatedItem>
1925                                 <xsl:call-template name="constituentOrRelatedType"></xsl:call-template>
1926                                 <titleInfo>
1927                                         <title>
1928                                                 <xsl:call-template name="chopPunctuation">
1929                                                         <xsl:with-param name="chopString">
1930                                                                 <xsl:call-template name="subfieldSelect">
1931                                                                         <xsl:with-param name="codes">adfgklmorsv</xsl:with-param>
1932                                                                 </xsl:call-template>
1933                                                         </xsl:with-param>
1934                                                 </xsl:call-template>
1935                                         </title>
1936                                         <xsl:call-template name="part"></xsl:call-template>
1937                                 </titleInfo>
1938                                 <xsl:call-template name="relatedForm"></xsl:call-template>
1939                                 <xsl:call-template name="relatedIdentifierISSN"></xsl:call-template>
1940                         </relatedItem>
1941                 </xsl:for-each>
1942                 <xsl:for-each select="marc:datafield[@tag=740][@ind2=2]">
1943                         <relatedItem>
1944                                 <xsl:call-template name="constituentOrRelatedType"></xsl:call-template>
1945                                 <xsl:variable name="titleChop">
1946                                         <xsl:call-template name="chopPunctuation">
1947                                                 <xsl:with-param name="chopString">
1948                                                         <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
1949                                                 </xsl:with-param>
1950                                         </xsl:call-template>
1951                                 </xsl:variable>
1952                                 <titleInfo>
1953                                         <title>
1954                                                 <xsl:value-of select="$titleChop" />
1955                                         </title>
1956                                         <xsl:call-template name="part"></xsl:call-template>
1957                                 </titleInfo>
1958                                 <titleInfo type="nfi">
1959                                         <xsl:choose>
1960                                                 <xsl:when test="@ind1>0">
1961                                                         <nonSort>
1962                                                                 <xsl:value-of select="substring($titleChop,1,@ind1)"/>
1963                                                         </nonSort>
1964                                                         <title>
1965                                                                 <xsl:value-of select="substring($titleChop,@ind1+1)"/>
1966                                                         </title>
1967                                                 </xsl:when>
1968                                                 <xsl:otherwise>
1969                                                         <title>
1970                                                                 <xsl:value-of select="$titleChop" />
1971                                                         </title>
1972                                                 </xsl:otherwise>
1973                                         </xsl:choose>
1974                                         <xsl:call-template name="part"></xsl:call-template>
1975                                 </titleInfo>
1976                                 <xsl:call-template name="relatedForm"></xsl:call-template>
1977                         </relatedItem>
1978                 </xsl:for-each>
1979                 <xsl:for-each select="marc:datafield[@tag=760]|marc:datafield[@tag=762]">
1980                         <relatedItem type="series">
1981                                 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
1982                         </relatedItem>
1983                 </xsl:for-each>
1984                 <xsl:for-each select="marc:datafield[@tag=765]|marc:datafield[@tag=767]|marc:datafield[@tag=777]|marc:datafield[@tag=787]">
1985                         <relatedItem>
1986                                 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
1987                         </relatedItem>
1988                 </xsl:for-each>
1989                 <xsl:for-each select="marc:datafield[@tag=775]">
1990                         <relatedItem type="otherVersion">
1991                                 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
1992                         </relatedItem>
1993                 </xsl:for-each>
1994                 <xsl:for-each select="marc:datafield[@tag=770]|marc:datafield[@tag=774]">