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