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