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