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