]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xsl/MARC21slim2MODS32.xsl
webstaff: add support for editing authority records
[working/Evergreen.git] / Open-ILS / xsl / MARC21slim2MODS32.xsl
1 <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">
2         <xsl:include href="MARC21slimUtils.xsl"/>
3         <xsl:output encoding="UTF-8" indent="yes" method="xml"/>
4 <!--
5 Revision 1.14 - Fixed template isValid and fields 010, 020, 022, 024, 028, and 037 to output additional identifier elements 
6   with corresponding @type and @invalid eq 'yes' when subfields z or y (in the case of 022) exist in the MARCXML ::: 2007/01/04 17:35:20 cred
7
8 Revision 1.13 - Changed order of output under cartographics to reflect schema  2006/11/28 tmee
9         
10 Revision 1.12 - Updated to reflect MODS 3.2 Mapping  2006/10/11 tmee
11                 
12 Revision 1.11 - The attribute objectPart moved from <languageTerm> to <language>
13       2006/04/08  jrad
14
15 Revision 1.10 MODS 3.1 revisions to language and classification elements  
16                                 (plus ability to find marc:collection embedded in wrapper elements such as SRU zs: wrappers)
17                                 2006/02/06  ggar
18
19 Revision 1.9 subfield $y was added to field 242 2004/09/02 10:57 jrad
20
21 Revision 1.8 Subject chopPunctuation expanded and attribute fixes 2004/08/12 jrad
22
23 Revision 1.7 2004/03/25 08:29 jrad
24
25 Revision 1.6 various validation fixes 2004/02/20 ntra
26
27 Revision 1.5  2003/10/02 16:18:58  ntra
28 MODS2 to MODS3 updates, language unstacking and 
29 de-duping, chopPunctuation expanded
30
31 Revision 1.3  2003/04/03 00:07:19  ntra
32 Revision 1.3 Additional Changes not related to MODS Version 2.0 by ntra
33
34 Revision 1.2  2003/03/24 19:37:42  ckeith
35 Added Log Comment
36
37 -->
38         <xsl:template match="/">
39                 <xsl:choose>
40                         <xsl:when test="//marc:collection">
41                                 <modsCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-2.xsd">
42                                         <xsl:for-each select="//marc:collection/marc:record">
43                                                 <mods version="3.2">
44                                                         <xsl:call-template name="marcRecord"/>
45                                                 </mods>
46                                         </xsl:for-each>
47                                 </modsCollection>
48                         </xsl:when>
49                         <xsl:otherwise>
50                                 <mods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.2" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-2.xsd">
51                                         <xsl:for-each select="//marc:record">
52                                                 <xsl:call-template name="marcRecord"/>
53                                         </xsl:for-each>
54                                 </mods>
55                         </xsl:otherwise>
56                 </xsl:choose>
57         </xsl:template>
58         <xsl:template name="marcRecord">
59                 <xsl:variable name="leader" select="marc:leader"/>
60                 <xsl:variable name="leader6" select="substring($leader,7,1)"/>
61                 <xsl:variable name="leader7" select="substring($leader,8,1)"/>
62                 <xsl:variable name="controlField008" select="marc:controlfield[@tag='008']"/>
63                 <xsl:variable name="typeOf008">
64                         <xsl:choose>
65                                 <xsl:when test="$leader6='a'">
66                                         <xsl:choose>
67                                                 <xsl:when test="$leader7='a' or $leader7='c' or $leader7='d' or $leader7='m'">BK</xsl:when>
68                                                 <xsl:when test="$leader7='b' or $leader7='i' or $leader7='s'">SE</xsl:when>
69                                         </xsl:choose>
70                                 </xsl:when>
71                                 <xsl:when test="$leader6='t'">BK</xsl:when>
72                                 <xsl:when test="$leader6='p'">MM</xsl:when>
73                                 <xsl:when test="$leader6='m'">CF</xsl:when>
74                                 <xsl:when test="$leader6='e' or $leader6='f'">MP</xsl:when>
75                                 <xsl:when test="$leader6='g' or $leader6='k' or $leader6='o' or $leader6='r'">VM</xsl:when>
76                                 <xsl:when test="$leader6='c' or $leader6='d' or $leader6='i' or $leader6='j'">MU</xsl:when>
77                         </xsl:choose>
78                 </xsl:variable>
79                 <xsl:for-each select="marc:datafield[@tag='245']">
80                         <titleInfo>
81                                 <xsl:variable name="title">
82                                         <xsl:choose>
83                                                 <xsl:when test="marc:subfield[@code='b']">
84                                                         <xsl:call-template name="specialSubfieldSelect">
85                                                                 <xsl:with-param name="axis">b</xsl:with-param>
86                                                                 <xsl:with-param name="beforeCodes">afgk</xsl:with-param>
87                                                         </xsl:call-template>
88                                                 </xsl:when>
89                                                 <xsl:otherwise>
90                                                         <xsl:call-template name="subfieldSelect">
91                                                                 <xsl:with-param name="codes">abfgk</xsl:with-param>
92                                                         </xsl:call-template>
93                                                 </xsl:otherwise>
94                                         </xsl:choose>
95                                 </xsl:variable>
96                                 <xsl:variable name="titleChop">
97                                         <xsl:call-template name="chopPunctuation">
98                                                 <xsl:with-param name="chopString">
99                                                         <xsl:value-of select="$title"/>
100                                                 </xsl:with-param>
101                                         </xsl:call-template>
102                                 </xsl:variable>
103                                 <xsl:choose>
104                                         <xsl:when test="@ind2>0">
105                                                 <nonSort>
106                                                         <xsl:value-of select="substring($titleChop,1,@ind2)"/>
107                                                 </nonSort>
108                                                 <title>
109                                                         <xsl:value-of select="substring($titleChop,@ind2+1)"/>
110                                                 </title>
111                                         </xsl:when>
112                                         <xsl:otherwise>
113                                                 <title>
114                                                         <xsl:value-of select="$titleChop"/>
115                                                 </title>
116                                         </xsl:otherwise>
117                                 </xsl:choose>
118                                 <xsl:if test="marc:subfield[@code='b']">
119                                         <subTitle>
120                                                 <xsl:call-template name="chopPunctuation">
121                                                         <xsl:with-param name="chopString">
122                                                                 <xsl:call-template name="specialSubfieldSelect">
123                                                                         <xsl:with-param name="axis">b</xsl:with-param>
124                                                                         <xsl:with-param name="anyCodes">b</xsl:with-param>
125                                                                         <xsl:with-param name="afterCodes">afgk</xsl:with-param>
126                                                                 </xsl:call-template>
127                                                         </xsl:with-param>
128                                                 </xsl:call-template>
129                                         </subTitle>
130                                 </xsl:if>
131                                 <xsl:call-template name="part"></xsl:call-template>
132                         </titleInfo>
133                         <!-- A form of title that ignores non-filing characters; useful
134                                  for not converting "L'Oreal" into "L' Oreal" at index time -->
135                         <titleNonfiling>
136                                 <title>
137                                         <xsl:call-template name="chopPunctuation">
138                                                 <xsl:with-param name="chopString">
139                                                         <xsl:call-template name="subfieldSelect">
140                                                                 <xsl:with-param name="codes">abfgk</xsl:with-param>
141                                                         </xsl:call-template>
142                                                 </xsl:with-param>
143                                         </xsl:call-template>
144                                 </title>
145                                 <xsl:call-template name="part"></xsl:call-template>
146                         </titleNonfiling>
147                         <!-- hybrid of titleInfo and titleNonfiling which will give us a preformatted string (for punctuation)
148                                  but also keep the nonSort stuff in a separate field (for sorting) -->
149                         <titleBrowse>
150                                 <xsl:variable name="titleBrowseChop">
151                                         <xsl:call-template name="chopPunctuation">
152                                                 <xsl:with-param name="chopString">
153                                                         <xsl:call-template name="subfieldSelect">
154                                                                 <xsl:with-param name="codes">abfgk</xsl:with-param>
155                                                         </xsl:call-template>
156                                                 </xsl:with-param>
157                                         </xsl:call-template>
158                                 </xsl:variable>
159                                 <xsl:choose>
160                                         <xsl:when test="@ind2>0">
161                                                 <nonSort>
162                                                         <xsl:value-of select="substring($titleBrowseChop,1,@ind2)"/>
163                                                 </nonSort>
164                                                 <title>
165                                                         <xsl:value-of select="substring($titleBrowseChop,@ind2+1)"/>
166                                                 </title>
167                                         </xsl:when>
168                                         <xsl:otherwise>
169                                                 <title>
170                                                         <xsl:value-of select="$titleBrowseChop"/>
171                                                 </title>
172                                         </xsl:otherwise>
173                                 </xsl:choose>
174                                 <xsl:call-template name="part"></xsl:call-template>
175                         </titleBrowse>
176                 </xsl:for-each>
177                 <xsl:for-each select="marc:datafield[@tag='210']">
178                         <titleInfo type="abbreviated">
179                                 <title>
180                                         <xsl:call-template name="chopPunctuation">
181                                                 <xsl:with-param name="chopString">
182                                                         <xsl:call-template name="subfieldSelect">
183                                                                 <xsl:with-param name="codes">a</xsl:with-param>
184                                                         </xsl:call-template>
185                                                 </xsl:with-param>
186                                         </xsl:call-template>
187                                 </title>
188                                 <xsl:call-template name="subtitle"/>
189                         </titleInfo>
190                 </xsl:for-each>
191                 <xsl:for-each select="marc:datafield[@tag='242']">
192                         <titleInfo type="translated">
193                                 <!--09/01/04 Added subfield $y-->
194                                 <xsl:for-each select="marc:subfield[@code='y']">
195                                         <xsl:attribute name="lang">
196                                                 <xsl:value-of select="text()"/>
197                                         </xsl:attribute>
198                                 </xsl:for-each>
199                                 <title>
200                                         <xsl:call-template name="chopPunctuation">
201                                                 <xsl:with-param name="chopString">
202                                                         <xsl:call-template name="subfieldSelect">
203                                                                 <!-- 1/04 removed $h, b -->
204                                                                 <xsl:with-param name="codes">a</xsl:with-param>
205                                                         </xsl:call-template>
206                                                 </xsl:with-param>
207                                         </xsl:call-template>
208                                 </title>
209                                 <!-- 1/04 fix -->
210                                 <xsl:call-template name="subtitle"/>
211                                 <xsl:call-template name="part"/>
212                         </titleInfo>
213                 </xsl:for-each>
214                 <xsl:for-each select="marc:datafield[@tag='246']">
215                         <titleInfo type="alternative">
216                                 <xsl:for-each select="marc:subfield[@code='i']">
217                                         <xsl:attribute name="displayLabel">
218                                                 <xsl:value-of select="text()"/>
219                                         </xsl:attribute>
220                                 </xsl:for-each>
221                                 <title>
222                                         <xsl:call-template name="chopPunctuation">
223                                                 <xsl:with-param name="chopString">
224                                                         <xsl:call-template name="subfieldSelect">
225                                                                 <!-- 1/04 removed $h, $b -->
226                                                                 <xsl:with-param name="codes">af</xsl:with-param>
227                                                         </xsl:call-template>
228                                                 </xsl:with-param>
229                                         </xsl:call-template>
230                                 </title>
231                                 <xsl:call-template name="subtitle"/>
232                                 <xsl:call-template name="part"/>
233                         </titleInfo>
234                 </xsl:for-each>
235                 <xsl:for-each select="marc:datafield[@tag='130']|marc:datafield[@tag='240']|marc:datafield[@tag='730'][@ind2!='2']">
236                         <titleInfo type="uniform">
237                                 <title>
238                                         <xsl:variable name="str">
239                                                 <xsl:for-each select="marc:subfield">
240                                                         <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'])))">
241                                                                 <xsl:value-of select="text()"/>
242                                                                 <xsl:text> </xsl:text>
243                                                         </xsl:if>
244                                                 </xsl:for-each>
245                                         </xsl:variable>
246                                         <xsl:call-template name="chopPunctuation">
247                                                 <xsl:with-param name="chopString">
248                                                         <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
249                                                 </xsl:with-param>
250                                         </xsl:call-template>
251                                 </title>
252                                 <xsl:call-template name="part"/>
253                         </titleInfo>
254                 </xsl:for-each>
255                 <xsl:for-each select="marc:datafield[@tag='740'][@ind2!='2']">
256                         <titleInfo type="alternative">
257                                 <title>
258                                         <xsl:call-template name="chopPunctuation">
259                                                 <xsl:with-param name="chopString">
260                                                         <xsl:call-template name="subfieldSelect">
261                                                                 <xsl:with-param name="codes">ah</xsl:with-param>
262                                                         </xsl:call-template>
263                                                 </xsl:with-param>
264                                         </xsl:call-template>
265                                 </title>
266                                 <xsl:call-template name="part"/>
267                         </titleInfo>
268                 </xsl:for-each>
269                 <xsl:for-each select="marc:datafield[@tag='100']">
270                         <name type="personal">
271                                 <xsl:call-template name="nameABCDQ"/>
272                                 <xsl:call-template name="affiliation"/>
273                                 <role>
274                                         <roleTerm authority="marcrelator" type="text">creator</roleTerm>
275                                 </role>
276                                 <xsl:call-template name="role"/>
277                         </name>
278                 </xsl:for-each>
279                 <xsl:for-each select="marc:datafield[@tag='110']">
280                         <name type="corporate">
281                                 <xsl:call-template name="nameABCDN"/>
282                                 <role>
283                                         <roleTerm authority="marcrelator" type="text">creator</roleTerm>
284                                 </role>
285                                 <xsl:call-template name="role"/>
286                         </name>
287                 </xsl:for-each>
288                 <xsl:for-each select="marc:datafield[@tag='111']">
289                         <name type="conference">
290                                 <xsl:call-template name="nameACDEQ"/>
291                                 <role>
292                                         <roleTerm authority="marcrelator" type="text">creator</roleTerm>
293                                 </role>
294                                 <xsl:call-template name="role"/>
295                         </name>
296                 </xsl:for-each>
297                 <xsl:for-each select="marc:datafield[@tag='700'][not(marc:subfield[@code='t'])]">
298                         <name type="personal">
299                                 <xsl:call-template name="nameABCDQ"/>
300                                 <xsl:call-template name="affiliation"/>
301                                 <xsl:call-template name="role"/>
302                         </name>
303                 </xsl:for-each>
304                 <xsl:for-each select="marc:datafield[@tag='710'][not(marc:subfield[@code='t'])]">
305                         <name type="corporate">
306                                 <xsl:call-template name="nameABCDN"/>
307                                 <xsl:call-template name="role"/>
308                         </name>
309                 </xsl:for-each>
310                 <xsl:for-each select="marc:datafield[@tag='711'][not(marc:subfield[@code='t'])]">
311                         <name type="conference">
312                                 <xsl:call-template name="nameACDEQ"/>
313                                 <xsl:call-template name="role"/>
314                         </name>
315                 </xsl:for-each>
316                 <xsl:for-each select="marc:datafield[@tag='720'][not(marc:subfield[@code='t'])]">
317                         <name>
318                                 <xsl:if test="@ind1=1">
319                                         <xsl:attribute name="type">
320                                                 <xsl:text>personal</xsl:text>
321                                         </xsl:attribute>
322                                 </xsl:if>
323                                 <namePart>
324                                         <xsl:value-of select="marc:subfield[@code='a']"/>
325                                 </namePart>
326                                 <xsl:call-template name="role"/>
327                         </name>
328                 </xsl:for-each>
329                 <typeOfResource>
330                         <xsl:if test="$leader7='c'">
331                                 <xsl:attribute name="collection">yes</xsl:attribute>
332                         </xsl:if>
333                         <xsl:if test="$leader6='d' or $leader6='f' or $leader6='p' or $leader6='t'">
334                                 <xsl:attribute name="manuscript">yes</xsl:attribute>
335                         </xsl:if>
336                         <xsl:choose>
337                                 <xsl:when test="$leader6='a' or $leader6='t'">text</xsl:when>
338                                 <xsl:when test="$leader6='e' or $leader6='f'">cartographic</xsl:when>
339                                 <xsl:when test="$leader6='c' or $leader6='d'">notated music</xsl:when>
340                                 <xsl:when test="$leader6='i'">sound recording-nonmusical</xsl:when>
341                                 <xsl:when test="$leader6='j'">sound recording-musical</xsl:when>
342                                 <xsl:when test="$leader6='k'">still image</xsl:when>
343                                 <xsl:when test="$leader6='g'">moving image</xsl:when>
344                                 <xsl:when test="$leader6='r'">three dimensional object</xsl:when>
345                                 <xsl:when test="$leader6='m'">software, multimedia</xsl:when>
346                                 <xsl:when test="$leader6='p'">mixed material</xsl:when>
347                         </xsl:choose>
348                 </typeOfResource>
349                 <xsl:if test="substring($controlField008,26,1)='d'">
350                         <genre authority="marc">globe</genre>
351                 </xsl:if>
352                 <xsl:if test="marc:controlfield[@tag='007'][substring(text(),1,1)='a'][substring(text(),2,1)='r']">
353                         <genre authority="marc">remote sensing image</genre>
354                 </xsl:if>
355                 <xsl:if test="$typeOf008='MP'">
356                         <xsl:variable name="controlField008-25" select="substring($controlField008,26,1)"></xsl:variable>
357                         <xsl:choose>
358                                 <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']">
359                                         <genre authority="marc">map</genre>
360                                 </xsl:when>
361                                 <xsl:when test="$controlField008-25='e' or marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='d']">
362                                         <genre authority="marc">atlas</genre>
363                                 </xsl:when>
364                         </xsl:choose>
365                 </xsl:if>
366                 <xsl:if test="$typeOf008='SE'">
367                         <xsl:variable name="controlField008-21" select="substring($controlField008,22,1)"></xsl:variable>
368                         <xsl:choose>
369                                 <xsl:when test="$controlField008-21='d'">
370                                         <genre authority="marc">database</genre>
371                                 </xsl:when>
372                                 <xsl:when test="$controlField008-21='l'">
373                                         <genre authority="marc">loose-leaf</genre>
374                                 </xsl:when>
375                                 <xsl:when test="$controlField008-21='m'">
376                                         <genre authority="marc">series</genre>
377                                 </xsl:when>
378                                 <xsl:when test="$controlField008-21='n'">
379                                         <genre authority="marc">newspaper</genre>
380                                 </xsl:when>
381                                 <xsl:when test="$controlField008-21='p'">
382                                         <genre authority="marc">periodical</genre>
383                                 </xsl:when>
384                                 <xsl:when test="$controlField008-21='w'">
385                                         <genre authority="marc">web site</genre>
386                                 </xsl:when>
387                         </xsl:choose>
388                 </xsl:if>
389                 <xsl:if test="$typeOf008='BK' or $typeOf008='SE'">
390                         <xsl:variable name="controlField008-24" select="substring($controlField008,25,4)"></xsl:variable>
391                         <xsl:choose>
392                                 <xsl:when test="contains($controlField008-24,'a')">
393                                         <genre authority="marc">abstract or summary</genre>
394                                 </xsl:when>
395                                 <xsl:when test="contains($controlField008-24,'b')">
396                                         <genre authority="marc">bibliography</genre>
397                                 </xsl:when>
398                                 <xsl:when test="contains($controlField008-24,'c')">
399                                         <genre authority="marc">catalog</genre>
400                                 </xsl:when>
401                                 <xsl:when test="contains($controlField008-24,'d')">
402                                         <genre authority="marc">dictionary</genre>
403                                 </xsl:when>
404                                 <xsl:when test="contains($controlField008-24,'e')">
405                                         <genre authority="marc">encyclopedia</genre>
406                                 </xsl:when>
407                                 <xsl:when test="contains($controlField008-24,'f')">
408                                         <genre authority="marc">handbook</genre>
409                                 </xsl:when>
410                                 <xsl:when test="contains($controlField008-24,'g')">
411                                         <genre authority="marc">legal article</genre>
412                                 </xsl:when>
413                                 <xsl:when test="contains($controlField008-24,'i')">
414                                         <genre authority="marc">index</genre>
415                                 </xsl:when>
416                                 <xsl:when test="contains($controlField008-24,'k')">
417                                         <genre authority="marc">discography</genre>
418                                 </xsl:when>
419                                 <xsl:when test="contains($controlField008-24,'l')">
420                                         <genre authority="marc">legislation</genre>
421                                 </xsl:when>
422                                 <xsl:when test="contains($controlField008-24,'m')">
423                                         <genre authority="marc">theses</genre>
424                                 </xsl:when>
425                                 <xsl:when test="contains($controlField008-24,'n')">
426                                         <genre authority="marc">survey of literature</genre>
427                                 </xsl:when>
428                                 <xsl:when test="contains($controlField008-24,'o')">
429                                         <genre authority="marc">review</genre>
430                                 </xsl:when>
431                                 <xsl:when test="contains($controlField008-24,'p')">
432                                         <genre authority="marc">programmed text</genre>
433                                 </xsl:when>
434                                 <xsl:when test="contains($controlField008-24,'q')">
435                                         <genre authority="marc">filmography</genre>
436                                 </xsl:when>
437                                 <xsl:when test="contains($controlField008-24,'r')">
438                                         <genre authority="marc">directory</genre>
439                                 </xsl:when>
440                                 <xsl:when test="contains($controlField008-24,'s')">
441                                         <genre authority="marc">statistics</genre>
442                                 </xsl:when>
443                                 <xsl:when test="contains($controlField008-24,'t')">
444                                         <genre authority="marc">technical report</genre>
445                                 </xsl:when>
446                                 <xsl:when test="contains($controlField008-24,'v')">
447                                         <genre authority="marc">legal case and case notes</genre>
448                                 </xsl:when>
449                                 <xsl:when test="contains($controlField008-24,'w')">
450                                         <genre authority="marc">law report or digest</genre>
451                                 </xsl:when>
452                                 <xsl:when test="contains($controlField008-24,'z')">
453                                         <genre authority="marc">treaty</genre>
454                                 </xsl:when>
455                         </xsl:choose>
456                         <xsl:variable name="controlField008-29" select="substring($controlField008,30,1)"></xsl:variable>
457                         <xsl:choose>
458                                 <xsl:when test="$controlField008-29='1'">
459                                         <genre authority="marc">conference publication</genre>
460                                 </xsl:when>
461                         </xsl:choose>
462                 </xsl:if>
463                 <xsl:if test="$typeOf008='CF'">
464                         <xsl:variable name="controlField008-26" select="substring($controlField008,27,1)"></xsl:variable>
465                         <xsl:choose>
466                                 <xsl:when test="$controlField008-26='a'">
467                                         <genre authority="marc">numeric data</genre>
468                                 </xsl:when>
469                                 <xsl:when test="$controlField008-26='e'">
470                                         <genre authority="marc">database</genre>
471                                 </xsl:when>
472                                 <xsl:when test="$controlField008-26='f'">
473                                         <genre authority="marc">font</genre>
474                                 </xsl:when>
475                                 <xsl:when test="$controlField008-26='g'">
476                                         <genre authority="marc">game</genre>
477                                 </xsl:when>
478                         </xsl:choose>
479                 </xsl:if>
480                 <xsl:if test="$typeOf008='BK'">
481                         <xsl:if test="substring($controlField008,25,1)='j'">
482                                 <genre authority="marc">patent</genre>
483                         </xsl:if>
484                         <xsl:if test="substring($controlField008,31,1)='1'">
485                                 <genre authority="marc">festschrift</genre>
486                         </xsl:if>
487                         <xsl:variable name="controlField008-34" select="substring($controlField008,35,1)"></xsl:variable>
488                         <xsl:if test="$controlField008-34='a' or $controlField008-34='b' or $controlField008-34='c' or $controlField008-34='d'">
489                                 <genre authority="marc">biography</genre>
490                         </xsl:if>
491                         <xsl:variable name="controlField008-33" select="substring($controlField008,34,1)"></xsl:variable>
492                         <xsl:choose>
493                                 <xsl:when test="$controlField008-33='e'">
494                                         <genre authority="marc">essay</genre>
495                                 </xsl:when>
496                                 <xsl:when test="$controlField008-33='d'">
497                                         <genre authority="marc">drama</genre>
498                                 </xsl:when>
499                                 <xsl:when test="$controlField008-33='c'">
500                                         <genre authority="marc">comic strip</genre>
501                                 </xsl:when>
502                                 <xsl:when test="$controlField008-33='l'">
503                                         <genre authority="marc">fiction</genre>
504                                 </xsl:when>
505                                 <xsl:when test="$controlField008-33='h'">
506                                         <genre authority="marc">humor, satire</genre>
507                                 </xsl:when>
508                                 <xsl:when test="$controlField008-33='i'">
509                                         <genre authority="marc">letter</genre>
510                                 </xsl:when>
511                                 <xsl:when test="$controlField008-33='f'">
512                                         <genre authority="marc">novel</genre>
513                                 </xsl:when>
514                                 <xsl:when test="$controlField008-33='j'">
515                                         <genre authority="marc">short story</genre>
516                                 </xsl:when>
517                                 <xsl:when test="$controlField008-33='s'">
518                                         <genre authority="marc">speech</genre>
519                                 </xsl:when>
520                         </xsl:choose>
521                 </xsl:if>
522                 <xsl:if test="$typeOf008='MU'">
523                         <xsl:variable name="controlField008-30-31" select="substring($controlField008,31,2)"></xsl:variable>
524                         <xsl:if test="contains($controlField008-30-31,'b')">
525                                 <genre authority="marc">biography</genre>
526                         </xsl:if>
527                         <xsl:if test="contains($controlField008-30-31,'c')">
528                                 <genre authority="marc">conference publication</genre>
529                         </xsl:if>
530                         <xsl:if test="contains($controlField008-30-31,'d')">
531                                 <genre authority="marc">drama</genre>
532                         </xsl:if>
533                         <xsl:if test="contains($controlField008-30-31,'e')">
534                                 <genre authority="marc">essay</genre>
535                         </xsl:if>
536                         <xsl:if test="contains($controlField008-30-31,'f')">
537                                 <genre authority="marc">fiction</genre>
538                         </xsl:if>
539                         <xsl:if test="contains($controlField008-30-31,'o')">
540                                 <genre authority="marc">folktale</genre>
541                         </xsl:if>
542                         <xsl:if test="contains($controlField008-30-31,'h')">
543                                 <genre authority="marc">history</genre>
544                         </xsl:if>
545                         <xsl:if test="contains($controlField008-30-31,'k')">
546                                 <genre authority="marc">humor, satire</genre>
547                         </xsl:if>
548                         <xsl:if test="contains($controlField008-30-31,'m')">
549                                 <genre authority="marc">memoir</genre>
550                         </xsl:if>
551                         <xsl:if test="contains($controlField008-30-31,'p')">
552                                 <genre authority="marc">poetry</genre>
553                         </xsl:if>
554                         <xsl:if test="contains($controlField008-30-31,'r')">
555                                 <genre authority="marc">rehearsal</genre>
556                         </xsl:if>
557                         <xsl:if test="contains($controlField008-30-31,'g')">
558                                 <genre authority="marc">reporting</genre>
559                         </xsl:if>
560                         <xsl:if test="contains($controlField008-30-31,'s')">
561                                 <genre authority="marc">sound</genre>
562                         </xsl:if>
563                         <xsl:if test="contains($controlField008-30-31,'l')">
564                                 <genre authority="marc">speech</genre>
565                         </xsl:if>
566                 </xsl:if>
567                 <xsl:if test="$typeOf008='VM'">
568                         <xsl:variable name="controlField008-33" select="substring($controlField008,34,1)"></xsl:variable>
569                         <xsl:choose>
570                                 <xsl:when test="$controlField008-33='a'">
571                                         <genre authority="marc">art original</genre>
572                                 </xsl:when>
573                                 <xsl:when test="$controlField008-33='b'">
574                                         <genre authority="marc">kit</genre>
575                                 </xsl:when>
576                                 <xsl:when test="$controlField008-33='c'">
577                                         <genre authority="marc">art reproduction</genre>
578                                 </xsl:when>
579                                 <xsl:when test="$controlField008-33='d'">
580                                         <genre authority="marc">diorama</genre>
581                                 </xsl:when>
582                                 <xsl:when test="$controlField008-33='f'">
583                                         <genre authority="marc">filmstrip</genre>
584                                 </xsl:when>
585                                 <xsl:when test="$controlField008-33='g'">
586                                         <genre authority="marc">legal article</genre>
587                                 </xsl:when>
588                                 <xsl:when test="$controlField008-33='i'">
589                                         <genre authority="marc">picture</genre>
590                                 </xsl:when>
591                                 <xsl:when test="$controlField008-33='k'">
592                                         <genre authority="marc">graphic</genre>
593                                 </xsl:when>
594                                 <xsl:when test="$controlField008-33='l'">
595                                         <genre authority="marc">technical drawing</genre>
596                                 </xsl:when>
597                                 <xsl:when test="$controlField008-33='m'">
598                                         <genre authority="marc">motion picture</genre>
599                                 </xsl:when>
600                                 <xsl:when test="$controlField008-33='n'">
601                                         <genre authority="marc">chart</genre>
602                                 </xsl:when>
603                                 <xsl:when test="$controlField008-33='o'">
604                                         <genre authority="marc">flash card</genre>
605                                 </xsl:when>
606                                 <xsl:when test="$controlField008-33='p'">
607                                         <genre authority="marc">microscope slide</genre>
608                                 </xsl:when>
609                                 <xsl:when test="$controlField008-33='q' or marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='q']">
610                                         <genre authority="marc">model</genre>
611                                 </xsl:when>
612                                 <xsl:when test="$controlField008-33='r'">
613                                         <genre authority="marc">realia</genre>
614                                 </xsl:when>
615                                 <xsl:when test="$controlField008-33='s'">
616                                         <genre authority="marc">slide</genre>
617                                 </xsl:when>
618                                 <xsl:when test="$controlField008-33='t'">
619                                         <genre authority="marc">transparency</genre>
620                                 </xsl:when>
621                                 <xsl:when test="$controlField008-33='v'">
622                                         <genre authority="marc">videorecording</genre>
623                                 </xsl:when>
624                                 <xsl:when test="$controlField008-33='w'">
625                                         <genre authority="marc">toy</genre>
626                                 </xsl:when>
627                         </xsl:choose>
628                 </xsl:if>
629                 <xsl:for-each select="marc:datafield[@tag=655]">
630                         <genre authority="marc">
631                                 <xsl:attribute name="authority">
632                                         <xsl:value-of select="marc:subfield[@code='2']"/>
633                                 </xsl:attribute>
634                                 <xsl:call-template name="subfieldSelect">
635                                         <xsl:with-param name="codes">abvxyz</xsl:with-param>
636                                         <xsl:with-param name="delimeter">-</xsl:with-param>
637                                 </xsl:call-template>
638                         </genre>
639                 </xsl:for-each>
640                 <originInfo>
641                         <xsl:variable name="MARCpublicationCode" select="normalize-space(substring($controlField008,16,3))"></xsl:variable>
642                         <xsl:if test="translate($MARCpublicationCode,'|','')">
643                                 <place>
644                                         <placeTerm>
645                                                 <xsl:attribute name="type">code</xsl:attribute>
646                                                 <xsl:attribute name="authority">marccountry</xsl:attribute>
647                                                 <xsl:value-of select="$MARCpublicationCode"/>
648                                         </placeTerm>
649                                 </place>
650                         </xsl:if>
651                         <xsl:for-each select="marc:datafield[@tag=044]/marc:subfield[@code='c']">
652                                 <place>
653                                         <placeTerm>
654                                                 <xsl:attribute name="type">code</xsl:attribute>
655                                                 <xsl:attribute name="authority">iso3166</xsl:attribute>
656                                                 <xsl:value-of select="."/>
657                                         </placeTerm>
658                                 </place>
659                         </xsl:for-each>
660                         <xsl:for-each select="marc:datafield[@tag=260]/marc:subfield[@code='a']">
661                                 <place>
662                                         <placeTerm>
663                                                 <xsl:attribute name="type">text</xsl:attribute>
664                                                 <xsl:call-template name="chopPunctuationFront">
665                                                         <xsl:with-param name="chopString">
666                                                                 <xsl:call-template name="chopPunctuation">
667                                                                         <xsl:with-param name="chopString" select="."/>
668                                                                 </xsl:call-template>
669                                                         </xsl:with-param>
670                                                 </xsl:call-template>
671                                         </placeTerm>
672                                 </place>
673                         </xsl:for-each>
674                         <xsl:for-each select="marc:datafield[@tag=046]/marc:subfield[@code='m']">
675                                 <dateValid point="start">
676                                         <xsl:value-of select="."/>
677                                 </dateValid>
678                         </xsl:for-each>
679                         <xsl:for-each select="marc:datafield[@tag=046]/marc:subfield[@code='n']">
680                                 <dateValid point="end">
681                                         <xsl:value-of select="."/>
682                                 </dateValid>
683                         </xsl:for-each>
684                         <xsl:for-each select="marc:datafield[@tag=046]/marc:subfield[@code='j']">
685                                 <dateModified>
686                                         <xsl:value-of select="."/>
687                                 </dateModified>
688                         </xsl:for-each>
689                         <xsl:for-each select="marc:datafield[@tag=260]/marc:subfield[@code='b' or @code='c' or @code='g']">
690                                 <xsl:choose>
691                                         <xsl:when test="@code='b'">
692                                                 <publisher>
693                                                         <xsl:call-template name="chopPunctuation">
694                                                                 <xsl:with-param name="chopString" select="."/>
695                                                                 <xsl:with-param name="punctuation">
696                                                                         <xsl:text>:,;/ </xsl:text>
697                                                                 </xsl:with-param>
698                                                         </xsl:call-template>
699                                                 </publisher>
700                                         </xsl:when>
701                                         <xsl:when test="@code='c'">
702                                                 <dateIssued>
703                                                         <xsl:call-template name="chopPunctuation">
704                                                                 <xsl:with-param name="chopString" select="."/>
705                                                         </xsl:call-template>
706                                                 </dateIssued>
707                                         </xsl:when>
708                                         <xsl:when test="@code='g'">
709                                                 <dateCreated>
710                                                         <xsl:value-of select="."/>
711                                                 </dateCreated>
712                                         </xsl:when>
713                                 </xsl:choose>
714                         </xsl:for-each>
715                         <xsl:variable name="dataField260c">
716                                 <xsl:call-template name="chopPunctuation">
717                                         <xsl:with-param name="chopString" select="marc:datafield[@tag=260]/marc:subfield[@code='c']"></xsl:with-param>
718                                 </xsl:call-template>
719                         </xsl:variable>
720                         <xsl:variable name="controlField008-7-10" select="normalize-space(substring($controlField008, 8, 4))"></xsl:variable>
721                         <xsl:variable name="controlField008-11-14" select="normalize-space(substring($controlField008, 12, 4))"></xsl:variable>
722                         <xsl:variable name="controlField008-6" select="normalize-space(substring($controlField008, 7, 1))"></xsl:variable>
723                         <xsl:if test="$controlField008-6='e' or $controlField008-6='p' or $controlField008-6='r' or $controlField008-6='t' or $controlField008-6='s'">
724                                 <xsl:if test="$controlField008-7-10 and ($controlField008-7-10 != $dataField260c)">
725                                         <dateIssued encoding="marc">
726                                                 <xsl:value-of select="$controlField008-7-10"/>
727                                         </dateIssued>
728                                 </xsl:if>
729                         </xsl:if>
730                         <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'">
731                                 <xsl:if test="$controlField008-7-10">
732                                         <dateIssued encoding="marc" point="start">
733                                                 <xsl:value-of select="$controlField008-7-10"/>
734                                         </dateIssued>
735                                 </xsl:if>
736                         </xsl:if>
737                         <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'">
738                                 <xsl:if test="$controlField008-11-14">
739                                         <dateIssued encoding="marc" point="end">
740                                                 <xsl:value-of select="$controlField008-11-14"/>
741                                         </dateIssued>
742                                 </xsl:if>
743                         </xsl:if>
744                         <xsl:if test="$controlField008-6='q'">
745                                 <xsl:if test="$controlField008-7-10">
746                                         <dateIssued encoding="marc" point="start" qualifier="questionable">
747                                                 <xsl:value-of select="$controlField008-7-10"/>
748                                         </dateIssued>
749                                 </xsl:if>
750                         </xsl:if>
751                         <xsl:if test="$controlField008-6='q'">
752                                 <xsl:if test="$controlField008-11-14">
753                                         <dateIssued encoding="marc" point="end" qualifier="questionable">
754                                                 <xsl:value-of select="$controlField008-11-14"/>
755                                         </dateIssued>
756                                 </xsl:if>
757                         </xsl:if>
758                         <xsl:if test="$controlField008-6='t'">
759                                 <xsl:if test="$controlField008-11-14">
760                                         <copyrightDate encoding="marc">
761                                                 <xsl:value-of select="$controlField008-11-14"/>
762                                         </copyrightDate>
763                                 </xsl:if>
764                         </xsl:if>
765                         <xsl:for-each select="marc:datafield[@tag=033][@ind1=0 or @ind1=1]/marc:subfield[@code='a']">
766                                 <dateCaptured encoding="iso8601">
767                                         <xsl:value-of select="."/>
768                                 </dateCaptured>
769                         </xsl:for-each>
770                         <xsl:for-each select="marc:datafield[@tag=033][@ind1=2]/marc:subfield[@code='a'][1]">
771                                 <dateCaptured encoding="iso8601" point="start">
772                                         <xsl:value-of select="."/>
773                                 </dateCaptured>
774                         </xsl:for-each>
775                         <xsl:for-each select="marc:datafield[@tag=033][@ind1=2]/marc:subfield[@code='a'][2]">
776                                 <dateCaptured encoding="iso8601" point="end">
777                                         <xsl:value-of select="."/>
778                                 </dateCaptured>
779                         </xsl:for-each>
780                         <xsl:for-each select="marc:datafield[@tag=250]/marc:subfield[@code='a']">
781                                 <edition>
782                                         <xsl:value-of select="."/>
783                                 </edition>
784                         </xsl:for-each>
785                         <xsl:for-each select="marc:leader">
786                                 <issuance>
787                                         <xsl:choose>
788                                                 <xsl:when test="$leader7='a' or $leader7='c' or $leader7='d' or $leader7='m'">monographic</xsl:when>
789                                                 <xsl:when test="$leader7='b' or $leader7='i' or $leader7='s'">continuing</xsl:when>
790                                         </xsl:choose>
791                                 </issuance>
792                         </xsl:for-each>
793                         <xsl:for-each select="marc:datafield[@tag=310]|marc:datafield[@tag=321]">
794                                 <frequency>
795                                         <xsl:call-template name="subfieldSelect">
796                                                 <xsl:with-param name="codes">ab</xsl:with-param>
797                                         </xsl:call-template>
798                                 </frequency>
799                         </xsl:for-each>
800                 </originInfo>
801                 <xsl:variable name="controlField008-35-37" select="normalize-space(translate(substring($controlField008,36,3),'|#',''))"></xsl:variable>
802                 <xsl:if test="$controlField008-35-37">
803                         <language>
804                                 <languageTerm authority="iso639-2b" type="code">
805                                         <xsl:value-of select="substring($controlField008,36,3)"/>
806                                 </languageTerm>
807                         </language>
808                 </xsl:if>
809                 <xsl:for-each select="marc:datafield[@tag=041]">
810                         <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']">
811                                 <xsl:variable name="langCodes" select="."/>
812                                 <xsl:choose>
813                                         <xsl:when test="../marc:subfield[@code='2']='rfc3066'">
814                                                 <!-- not stacked but could be repeated -->
815                                                 <xsl:call-template name="rfcLanguages">
816                                                         <xsl:with-param name="nodeNum">
817                                                                 <xsl:value-of select="1"/>
818                                                         </xsl:with-param>
819                                                         <xsl:with-param name="usedLanguages">
820                                                                 <xsl:text></xsl:text>
821                                                         </xsl:with-param>
822                                                         <xsl:with-param name="controlField008-35-37">
823                                                                 <xsl:value-of select="$controlField008-35-37"></xsl:value-of>
824                                                         </xsl:with-param>
825                                                 </xsl:call-template>
826                                         </xsl:when>
827                                         <xsl:otherwise>
828                                                 <!-- iso -->
829                                                 <xsl:variable name="allLanguages">
830                                                         <xsl:copy-of select="$langCodes"></xsl:copy-of>
831                                                 </xsl:variable>
832                                                 <xsl:variable name="currentLanguage">
833                                                         <xsl:value-of select="substring($allLanguages,1,3)"></xsl:value-of>
834                                                 </xsl:variable>
835                                                 <xsl:call-template name="isoLanguage">
836                                                         <xsl:with-param name="currentLanguage">
837                                                                 <xsl:value-of select="substring($allLanguages,1,3)"></xsl:value-of>
838                                                         </xsl:with-param>
839                                                         <xsl:with-param name="remainingLanguages">
840                                                                 <xsl:value-of select="substring($allLanguages,4,string-length($allLanguages)-3)"></xsl:value-of>
841                                                         </xsl:with-param>
842                                                         <xsl:with-param name="usedLanguages">
843                                                                 <xsl:if test="$controlField008-35-37">
844                                                                         <xsl:value-of select="$controlField008-35-37"></xsl:value-of>
845                                                                 </xsl:if>
846                                                         </xsl:with-param>
847                                                 </xsl:call-template>
848                                         </xsl:otherwise>
849                                 </xsl:choose>
850                         </xsl:for-each>
851                 </xsl:for-each>
852                 <xsl:variable name="physicalDescription">
853                         <!--3.2 change tmee 007/11 -->
854                         <xsl:if test="$typeOf008='CF' and marc:controlfield[@tag=007][substring(.,12,1)='a']">
855                                 <digitalOrigin>reformatted digital</digitalOrigin>
856                         </xsl:if>
857                         <xsl:if test="$typeOf008='CF' and marc:controlfield[@tag=007][substring(.,12,1)='b']">
858                                 <digitalOrigin>digitized microfilm</digitalOrigin>
859                         </xsl:if>
860                         <xsl:if test="$typeOf008='CF' and marc:controlfield[@tag=007][substring(.,12,1)='d']">
861                                 <digitalOrigin>digitized other analog</digitalOrigin>
862                         </xsl:if>
863                         <xsl:variable name="controlField008-23" select="substring($controlField008,24,1)"></xsl:variable>
864                         <xsl:variable name="controlField008-29" select="substring($controlField008,30,1)"></xsl:variable>
865                         <xsl:variable name="check008-23">
866                                 <xsl:if test="$typeOf008='BK' or $typeOf008='MU' or $typeOf008='SE' or $typeOf008='MM'">
867                                         <xsl:value-of select="true()"></xsl:value-of>
868                                 </xsl:if>
869                         </xsl:variable>
870                         <xsl:variable name="check008-29">
871                                 <xsl:if test="$typeOf008='MP' or $typeOf008='VM'">
872                                         <xsl:value-of select="true()"></xsl:value-of>
873                                 </xsl:if>
874                         </xsl:variable>
875                         <xsl:choose>
876                                 <xsl:when test="($check008-23 and $controlField008-23='f') or ($check008-29 and $controlField008-29='f')">
877                                         <form authority="marcform">braille</form>
878                                 </xsl:when>
879                                 <xsl:when test="($controlField008-23=' ' and ($leader6='c' or $leader6='d')) or (($typeOf008='BK' or $typeOf008='SE') and ($controlField008-23=' ' or $controlField008='r'))">
880                                         <form authority="marcform">print</form>
881                                 </xsl:when>
882                                 <xsl:when test="$leader6 = 'm' or ($check008-23 and $controlField008-23='s') or ($check008-29 and $controlField008-29='s')">
883                                         <form authority="marcform">electronic</form>
884                                 </xsl:when>
885                                 <xsl:when test="($check008-23 and $controlField008-23='b') or ($check008-29 and $controlField008-29='b')">
886                                         <form authority="marcform">microfiche</form>
887                                 </xsl:when>
888                                 <xsl:when test="($check008-23 and $controlField008-23='a') or ($check008-29 and $controlField008-29='a')">
889                                         <form authority="marcform">microfilm</form>
890                                 </xsl:when>
891                         </xsl:choose>
892                         <!-- 1/04 fix -->
893                         <xsl:if test="marc:datafield[@tag=130]/marc:subfield[@code='h']">
894                                 <form authority="gmd">
895                                         <xsl:call-template name="chopBrackets">
896                                                 <xsl:with-param name="chopString">
897                                                         <xsl:value-of select="marc:datafield[@tag=130]/marc:subfield[@code='h']"></xsl:value-of>
898                                                 </xsl:with-param>
899                                         </xsl:call-template>
900                                 </form>
901                         </xsl:if>
902                         <xsl:if test="marc:datafield[@tag=240]/marc:subfield[@code='h']">
903                                 <form authority="gmd">
904                                         <xsl:call-template name="chopBrackets">
905                                                 <xsl:with-param name="chopString">
906                                                         <xsl:value-of select="marc:datafield[@tag=240]/marc:subfield[@code='h']"></xsl:value-of>
907                                                 </xsl:with-param>
908                                         </xsl:call-template>
909                                 </form>
910                         </xsl:if>
911                         <xsl:if test="marc:datafield[@tag=242]/marc:subfield[@code='h']">
912                                 <form authority="gmd">
913                                         <xsl:call-template name="chopBrackets">
914                                                 <xsl:with-param name="chopString">
915                                                         <xsl:value-of select="marc:datafield[@tag=242]/marc:subfield[@code='h']"></xsl:value-of>
916                                                 </xsl:with-param>
917                                         </xsl:call-template>
918                                 </form>
919                         </xsl:if>
920                         <xsl:if test="marc:datafield[@tag=245]/marc:subfield[@code='h']">
921                                 <form authority="gmd">
922                                         <xsl:call-template name="chopBrackets">
923                                                 <xsl:with-param name="chopString">
924                                                         <xsl:value-of select="marc:datafield[@tag=245]/marc:subfield[@code='h']"></xsl:value-of>
925                                                 </xsl:with-param>
926                                         </xsl:call-template>
927                                 </form>
928                         </xsl:if>
929                         <xsl:if test="marc:datafield[@tag=246]/marc:subfield[@code='h']">
930                                 <form authority="gmd">
931                                         <xsl:call-template name="chopBrackets">
932                                                 <xsl:with-param name="chopString">
933                                                         <xsl:value-of select="marc:datafield[@tag=246]/marc:subfield[@code='h']"></xsl:value-of>
934                                                 </xsl:with-param>
935                                         </xsl:call-template>
936                                 </form>
937                         </xsl:if>
938                         <xsl:if test="marc:datafield[@tag=730]/marc:subfield[@code='h']">
939                                 <form authority="gmd">
940                                         <xsl:call-template name="chopBrackets">
941                                                 <xsl:with-param name="chopString">
942                                                         <xsl:value-of select="marc:datafield[@tag=730]/marc:subfield[@code='h']"></xsl:value-of>
943                                                 </xsl:with-param>
944                                         </xsl:call-template>
945                                 </form>
946                         </xsl:if>
947                         <xsl:for-each select="marc:datafield[@tag=256]/marc:subfield[@code='a']">
948                                 <form>
949                                         <xsl:value-of select="."></xsl:value-of>
950                                 </form>
951                         </xsl:for-each>
952                         <xsl:for-each select="marc:controlfield[@tag=007][substring(text(),1,1)='c']">
953                                 <xsl:choose>
954                                         <xsl:when test="substring(text(),14,1)='a'">
955                                                 <reformattingQuality>access</reformattingQuality>
956                                         </xsl:when>
957                                         <xsl:when test="substring(text(),14,1)='p'">
958                                                 <reformattingQuality>preservation</reformattingQuality>
959                                         </xsl:when>
960                                         <xsl:when test="substring(text(),14,1)='r'">
961                                                 <reformattingQuality>replacement</reformattingQuality>
962                                         </xsl:when>
963                                 </xsl:choose>
964                         </xsl:for-each>
965                         <!--3.2 change tmee 007/01 -->
966                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='b']">
967                                 <form authority="smd">chip cartridge</form>
968                         </xsl:if>
969                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='c']">
970                                 <form authority="smd">computer optical disc cartridge</form>
971                         </xsl:if>
972                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='j']">
973                                 <form authority="smd">magnetic disc</form>
974                         </xsl:if>
975                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='m']">
976                                 <form authority="smd">magneto-optical disc</form>
977                         </xsl:if>
978                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='o']">
979                                 <form authority="smd">optical disc</form>
980                         </xsl:if>
981                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='r']">
982                                 <form authority="smd">remote</form>
983                         </xsl:if>
984                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='a']">
985                                 <form authority="smd">tape cartridge</form>
986                         </xsl:if>
987                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='f']">
988                                 <form authority="smd">tape cassette</form>
989                         </xsl:if>
990                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='h']">
991                                 <form authority="smd">tape reel</form>
992                         </xsl:if>
993                         
994                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='d'][substring(text(),2,1)='a']">
995                                 <form authority="smd">celestial globe</form>
996                         </xsl:if>
997                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='d'][substring(text(),2,1)='e']">
998                                 <form authority="smd">earth moon globe</form>
999                         </xsl:if>
1000                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='d'][substring(text(),2,1)='b']">
1001                                 <form authority="smd">planetary or lunar globe</form>
1002                         </xsl:if>
1003                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='d'][substring(text(),2,1)='c']">
1004                                 <form authority="smd">terrestrial globe</form>
1005                         </xsl:if>
1006                         
1007                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='o'][substring(text(),2,1)='o']">
1008                                 <form authority="smd">kit</form>
1009                         </xsl:if>
1010                         
1011                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='d']">
1012                                 <form authority="smd">atlas</form>
1013                         </xsl:if>
1014                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='g']">
1015                                 <form authority="smd">diagram</form>
1016                         </xsl:if>
1017                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='j']">
1018                                 <form authority="smd">map</form>
1019                         </xsl:if>
1020                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='q']">
1021                                 <form authority="smd">model</form>
1022                         </xsl:if>
1023                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='k']">
1024                                 <form authority="smd">profile</form>
1025                         </xsl:if>
1026                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='r']">
1027                                 <form authority="smd">remote-sensing image</form>
1028                         </xsl:if>
1029                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='s']">
1030                                 <form authority="smd">section</form>
1031                         </xsl:if>
1032                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='y']">
1033                                 <form authority="smd">view</form>
1034                         </xsl:if>
1035                         
1036                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='a']">
1037                                 <form authority="smd">aperture card</form>
1038                         </xsl:if>
1039                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='e']">
1040                                 <form authority="smd">microfiche</form>
1041                         </xsl:if>
1042                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='f']">
1043                                 <form authority="smd">microfiche cassette</form>
1044                         </xsl:if>
1045                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='b']">
1046                                 <form authority="smd">microfilm cartridge</form>
1047                         </xsl:if>
1048                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='c']">
1049                                 <form authority="smd">microfilm cassette</form>
1050                         </xsl:if>
1051                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='d']">
1052                                 <form authority="smd">microfilm reel</form>
1053                         </xsl:if>
1054                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='g']">
1055                                 <form authority="smd">microopaque</form>
1056                         </xsl:if>
1057                         
1058                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='m'][substring(text(),2,1)='c']">
1059                                 <form authority="smd">film cartridge</form>
1060                         </xsl:if>
1061                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='m'][substring(text(),2,1)='f']">
1062                                 <form authority="smd">film cassette</form>
1063                         </xsl:if>
1064                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='m'][substring(text(),2,1)='r']">
1065                                 <form authority="smd">film reel</form>
1066                         </xsl:if>
1067                         
1068                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='n']">
1069                                 <form authority="smd">chart</form>
1070                         </xsl:if>
1071                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='c']">
1072                                 <form authority="smd">collage</form>
1073                         </xsl:if>
1074                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='d']">
1075                                 <form authority="smd">drawing</form>
1076                         </xsl:if>
1077                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='o']">
1078                                 <form authority="smd">flash card</form>
1079                         </xsl:if>
1080                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='e']">
1081                                 <form authority="smd">painting</form>
1082                         </xsl:if>
1083                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='f']">
1084                                 <form authority="smd">photomechanical print</form>
1085                         </xsl:if>
1086                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='g']">
1087                                 <form authority="smd">photonegative</form>
1088                         </xsl:if>
1089                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='h']">
1090                                 <form authority="smd">photoprint</form>
1091                         </xsl:if>
1092                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='i']">
1093                                 <form authority="smd">picture</form>
1094                         </xsl:if>
1095                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='j']">
1096                                 <form authority="smd">print</form>
1097                         </xsl:if>
1098                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='l']">
1099                                 <form authority="smd">technical drawing</form>
1100                         </xsl:if>
1101                         
1102                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='q'][substring(text(),2,1)='q']">
1103                                 <form authority="smd">notated music</form>
1104                         </xsl:if>
1105                         
1106                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='d']">
1107                                 <form authority="smd">filmslip</form>
1108                         </xsl:if>
1109                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='c']">
1110                                 <form authority="smd">filmstrip cartridge</form>
1111                         </xsl:if>
1112                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='o']">
1113                                 <form authority="smd">filmstrip roll</form>
1114                         </xsl:if>
1115                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='f']">
1116                                 <form authority="smd">other filmstrip type</form>
1117                         </xsl:if>
1118                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='s']">
1119                                 <form authority="smd">slide</form>
1120                         </xsl:if>
1121                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='t']">
1122                                 <form authority="smd">transparency</form>
1123                         </xsl:if>
1124                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='r'][substring(text(),2,1)='r']">
1125                                 <form authority="smd">remote-sensing image</form>
1126                         </xsl:if>
1127                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='e']">
1128                                 <form authority="smd">cylinder</form>
1129                         </xsl:if>
1130                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='q']">
1131                                 <form authority="smd">roll</form>
1132                         </xsl:if>
1133                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='g']">
1134                                 <form authority="smd">sound cartridge</form>
1135                         </xsl:if>
1136                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='s']">
1137                                 <form authority="smd">sound cassette</form>
1138                         </xsl:if>
1139                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='d']">
1140                                 <form authority="smd">sound disc</form>
1141                         </xsl:if>
1142                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='t']">
1143                                 <form authority="smd">sound-tape reel</form>
1144                         </xsl:if>
1145                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='i']">
1146                                 <form authority="smd">sound-track film</form>
1147                         </xsl:if>
1148                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='w']">
1149                                 <form authority="smd">wire recording</form>
1150                         </xsl:if>
1151                         
1152                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='f'][substring(text(),2,1)='c']">
1153                                 <form authority="smd">braille</form>
1154                         </xsl:if>
1155                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='f'][substring(text(),2,1)='b']">
1156                                 <form authority="smd">combination</form>
1157                         </xsl:if>
1158                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='f'][substring(text(),2,1)='a']">
1159                                 <form authority="smd">moon</form>
1160                         </xsl:if>
1161                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='f'][substring(text(),2,1)='d']">
1162                                 <form authority="smd">tactile, with no writing system</form>
1163                         </xsl:if>
1164                         
1165                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='t'][substring(text(),2,1)='c']">
1166                                 <form authority="smd">braille</form>
1167                         </xsl:if>
1168                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='t'][substring(text(),2,1)='b']">
1169                                 <form authority="smd">large print</form>
1170                         </xsl:if>
1171                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='t'][substring(text(),2,1)='a']">
1172                                 <form authority="smd">regular print</form>
1173                         </xsl:if>
1174                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='t'][substring(text(),2,1)='d']">
1175                                 <form authority="smd">text in looseleaf binder</form>
1176                         </xsl:if>
1177                         
1178                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='v'][substring(text(),2,1)='c']">
1179                                 <form authority="smd">videocartridge</form>
1180                         </xsl:if>
1181                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='v'][substring(text(),2,1)='f']">
1182                                 <form authority="smd">videocassette</form>
1183                         </xsl:if>
1184                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='v'][substring(text(),2,1)='d']">
1185                                 <form authority="smd">videodisc</form>
1186                         </xsl:if>
1187                         <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='v'][substring(text(),2,1)='r']">
1188                                 <form authority="smd">videoreel</form>
1189                         </xsl:if>
1190                         
1191                         <xsl:for-each select="marc:datafield[@tag=856]/marc:subfield[@code='q'][string-length(.)>1]">
1192                                 <internetMediaType>
1193                                         <xsl:value-of select="."></xsl:value-of>
1194                                 </internetMediaType>
1195                         </xsl:for-each>
1196                         <xsl:for-each select="marc:datafield[@tag=300]">
1197                                 <extent>
1198                                         <xsl:call-template name="subfieldSelect">
1199                                                 <xsl:with-param name="codes">abce</xsl:with-param>
1200                                         </xsl:call-template>
1201                                 </extent>
1202                         </xsl:for-each>
1203                 </xsl:variable>
1204                 <xsl:if test="string-length(normalize-space($physicalDescription))">
1205                         <physicalDescription>
1206                                 <xsl:copy-of select="$physicalDescription"></xsl:copy-of>
1207                         </physicalDescription>
1208                 </xsl:if>
1209                 <xsl:for-each select="marc:datafield[@tag=520]">
1210                         <abstract>
1211                                 <xsl:call-template name="uri"></xsl:call-template>
1212                                 <xsl:call-template name="subfieldSelect">
1213                                         <xsl:with-param name="codes">ab</xsl:with-param>
1214                                 </xsl:call-template>
1215                         </abstract>
1216                 </xsl:for-each>
1217                 <xsl:for-each select="marc:datafield[@tag=505]">
1218                         <tableOfContents>
1219                                 <xsl:call-template name="uri"></xsl:call-template>
1220                                 <xsl:call-template name="subfieldSelect">
1221                                         <xsl:with-param name="codes">agrt</xsl:with-param>
1222                                 </xsl:call-template>
1223                         </tableOfContents>
1224                 </xsl:for-each>
1225                 <xsl:for-each select="marc:datafield[@tag=521]">
1226                         <targetAudience>
1227                                 <xsl:call-template name="subfieldSelect">
1228                                         <xsl:with-param name="codes">ab</xsl:with-param>
1229                                 </xsl:call-template>
1230                         </targetAudience>
1231                 </xsl:for-each>
1232                 <xsl:if test="$typeOf008='BK' or $typeOf008='CF' or $typeOf008='MU' or $typeOf008='VM'">
1233                         <xsl:variable name="controlField008-22" select="substring($controlField008,23,1)"></xsl:variable>
1234                         <xsl:choose>
1235                                 <!-- 01/04 fix -->
1236                                 <xsl:when test="$controlField008-22='d'">
1237                                         <targetAudience authority="marctarget">adolescent</targetAudience>
1238                                 </xsl:when>
1239                                 <xsl:when test="$controlField008-22='e'">
1240                                         <targetAudience authority="marctarget">adult</targetAudience>
1241                                 </xsl:when>
1242                                 <xsl:when test="$controlField008-22='g'">
1243                                         <targetAudience authority="marctarget">general</targetAudience>
1244                                 </xsl:when>
1245                                 <xsl:when test="$controlField008-22='b' or $controlField008-22='c' or $controlField008-22='j'">
1246                                         <targetAudience authority="marctarget">juvenile</targetAudience>
1247                                 </xsl:when>
1248                                 <xsl:when test="$controlField008-22='a'">
1249                                         <targetAudience authority="marctarget">preschool</targetAudience>
1250                                 </xsl:when>
1251                                 <xsl:when test="$controlField008-22='f'">
1252                                         <targetAudience authority="marctarget">specialized</targetAudience>
1253                                 </xsl:when>
1254                         </xsl:choose>
1255                 </xsl:if>
1256                 <xsl:for-each select="marc:datafield[@tag=245]/marc:subfield[@code='c']">
1257                         <note type="statement of responsibility">
1258                                 <xsl:value-of select="."></xsl:value-of>
1259                         </note>
1260                 </xsl:for-each>
1261                 <xsl:for-each select="marc:datafield[@tag=500]">
1262                         <note>
1263                                 <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
1264                                 <xsl:call-template name="uri"></xsl:call-template>
1265                         </note>
1266                 </xsl:for-each>
1267                 
1268                 <!--3.2 change tmee additional note fields-->
1269                 
1270                 <xsl:for-each select="marc:datafield[@tag=506]">
1271                         <note type="restrictions">
1272                                 <xsl:call-template name="uri"></xsl:call-template>
1273                                 <xsl:variable name="str">
1274                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
1275                                                 <xsl:value-of select="."></xsl:value-of>
1276                                                 <xsl:text> </xsl:text>
1277                                         </xsl:for-each>
1278                                 </xsl:variable>
1279                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
1280                         </note>
1281                 </xsl:for-each>
1282                 
1283                 <xsl:for-each select="marc:datafield[@tag=510]">
1284                         <note  type="citation/reference">
1285                                 <xsl:call-template name="uri"></xsl:call-template>
1286                                 <xsl:variable name="str">
1287                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
1288                                                 <xsl:value-of select="."></xsl:value-of>
1289                                                 <xsl:text> </xsl:text>
1290                                         </xsl:for-each>
1291                                 </xsl:variable>
1292                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
1293                         </note>
1294                 </xsl:for-each>
1295                 
1296                         
1297                 <xsl:for-each select="marc:datafield[@tag=511]">
1298                         <note type="performers">
1299                                 <xsl:call-template name="uri"></xsl:call-template>
1300                                 <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
1301                         </note>
1302                 </xsl:for-each>
1303                 <xsl:for-each select="marc:datafield[@tag=518]">
1304                         <note type="venue">
1305                                 <xsl:call-template name="uri"></xsl:call-template>
1306                                 <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
1307                         </note>
1308                 </xsl:for-each>
1309                 
1310                 <xsl:for-each select="marc:datafield[@tag=530]">
1311                         <note  type="additional physical form">
1312                                 <xsl:call-template name="uri"></xsl:call-template>
1313                                 <xsl:variable name="str">
1314                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
1315                                                 <xsl:value-of select="."></xsl:value-of>
1316                                                 <xsl:text> </xsl:text>
1317                                         </xsl:for-each>
1318                                 </xsl:variable>
1319                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
1320                         </note>
1321                 </xsl:for-each>
1322                 
1323                 <xsl:for-each select="marc:datafield[@tag=533]">
1324                         <note  type="reproduction">
1325                                 <xsl:call-template name="uri"></xsl:call-template>
1326                                 <xsl:variable name="str">
1327                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
1328                                                 <xsl:value-of select="."></xsl:value-of>
1329                                                 <xsl:text> </xsl:text>
1330                                         </xsl:for-each>
1331                                 </xsl:variable>
1332                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
1333                         </note>
1334                 </xsl:for-each>
1335                 
1336                 <xsl:for-each select="marc:datafield[@tag=534]">
1337                         <note  type="original version">
1338                                 <xsl:call-template name="uri"></xsl:call-template>
1339                                 <xsl:variable name="str">
1340                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
1341                                                 <xsl:value-of select="."></xsl:value-of>
1342                                                 <xsl:text> </xsl:text>
1343                                         </xsl:for-each>
1344                                 </xsl:variable>
1345                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
1346                         </note>
1347                 </xsl:for-each>
1348                 
1349                 <xsl:for-each select="marc:datafield[@tag=538]">
1350                         <note  type="system details">
1351                                 <xsl:call-template name="uri"></xsl:call-template>
1352                                 <xsl:variable name="str">
1353                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
1354                                                 <xsl:value-of select="."></xsl:value-of>
1355                                                 <xsl:text> </xsl:text>
1356                                         </xsl:for-each>
1357                                 </xsl:variable>
1358                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
1359                         </note>
1360                 </xsl:for-each>
1361                 
1362                 <xsl:for-each select="marc:datafield[@tag=583]">
1363                         <note type="action">
1364                                 <xsl:call-template name="uri"></xsl:call-template>
1365                                 <xsl:variable name="str">
1366                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
1367                                                 <xsl:value-of select="."></xsl:value-of>
1368                                                 <xsl:text> </xsl:text>
1369                                         </xsl:for-each>
1370                                 </xsl:variable>
1371                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
1372                         </note>
1373                 </xsl:for-each>
1374                 
1375
1376                 
1377                 
1378                 
1379                 <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]">
1380                         <note>
1381                                 <xsl:call-template name="uri"></xsl:call-template>
1382                                 <xsl:variable name="str">
1383                                         <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
1384                                                 <xsl:value-of select="."></xsl:value-of>
1385                                                 <xsl:text> </xsl:text>
1386                                         </xsl:for-each>
1387                                 </xsl:variable>
1388                                 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
1389                         </note>
1390                 </xsl:for-each>
1391                 <xsl:for-each select="marc:datafield[@tag=034][marc:subfield[@code='d' or @code='e' or @code='f' or @code='g']]">
1392                         <subject>
1393                                 <cartographics>
1394                                         <coordinates>
1395                                                 <xsl:call-template name="subfieldSelect">
1396                                                         <xsl:with-param name="codes">defg</xsl:with-param>
1397                                                 </xsl:call-template>
1398                                         </coordinates>
1399                                 </cartographics>
1400                         </subject>
1401                 </xsl:for-each>
1402                 <xsl:for-each select="marc:datafield[@tag=043]">
1403                         <subject>
1404                                 <xsl:for-each select="marc:subfield[@code='a' or @code='b' or @code='c']">
1405                                         <geographicCode>
1406                                                 <xsl:attribute name="authority">
1407                                                         <xsl:if test="@code='a'">
1408                                                                 <xsl:text>marcgac</xsl:text>
1409                                                         </xsl:if>
1410                                                         <xsl:if test="@code='b'">
1411                                                                 <xsl:value-of select="following-sibling::marc:subfield[@code=2]"></xsl:value-of>
1412                                                         </xsl:if>
1413                                                         <xsl:if test="@code='c'">
1414                                                                 <xsl:text>iso3166</xsl:text>
1415                                                         </xsl:if>
1416                                                 </xsl:attribute>
1417                                                 <xsl:value-of select="self::marc:subfield"></xsl:value-of>
1418                                         </geographicCode>
1419                                 </xsl:for-each>
1420                         </subject>
1421                 </xsl:for-each>
1422                 <!-- tmee 2006/11/27 -->
1423                 <xsl:for-each select="marc:datafield[@tag=255]">
1424                         <subject>
1425                                 <xsl:for-each select="marc:subfield[@code='a' or @code='b' or @code='c']">
1426                                 <cartographics>
1427                                         <xsl:if test="@code='a'">
1428                                                 <scale>
1429                                                         <xsl:value-of select="."></xsl:value-of>
1430                                                 </scale>
1431                                         </xsl:if>
1432                                         <xsl:if test="@code='b'">
1433                                                 <projection>
1434                                                         <xsl:value-of select="."></xsl:value-of>
1435                                                 </projection>
1436                                         </xsl:if>
1437                                         <xsl:if test="@code='c'">
1438                                                 <coordinates>
1439                                                         <xsl:value-of select="."></xsl:value-of>
1440                                                 </coordinates>
1441                                         </xsl:if>
1442                                 </cartographics>
1443                                 </xsl:for-each>
1444                         </subject>
1445                 </xsl:for-each>
1446                                 
1447                 <xsl:apply-templates select="marc:datafield[653 >= @tag and @tag >= 600]"></xsl:apply-templates>
1448                 <xsl:apply-templates select="marc:datafield[@tag=656]"></xsl:apply-templates>
1449                 <xsl:for-each select="marc:datafield[@tag=752]">
1450                         <subject>
1451                                 <hierarchicalGeographic>
1452                                         <xsl:for-each select="marc:subfield[@code='a']">
1453                                                 <country>
1454                                                         <xsl:call-template name="chopPunctuation">
1455                                                                 <xsl:with-param name="chopString" select="."></xsl:with-param>
1456                                                         </xsl:call-template>
1457                                                 </country>
1458                                         </xsl:for-each>
1459                                         <xsl:for-each select="marc:subfield[@code='b']">
1460                                                 <state>
1461                                                         <xsl:call-template name="chopPunctuation">
1462                                                                 <xsl:with-param name="chopString" select="."></xsl:with-param>
1463                                                         </xsl:call-template>
1464                                                 </state>
1465                                         </xsl:for-each>
1466                                         <xsl:for-each select="marc:subfield[@code='c']">
1467                                                 <county>
1468                                                         <xsl:call-template name="chopPunctuation">
1469                                                                 <xsl:with-param name="chopString" select="."></xsl:with-param>
1470                                                         </xsl:call-template>
1471                                                 </county>
1472                                         </xsl:for-each>
1473                                         <xsl:for-each select="marc:subfield[@code='d']">
1474                                                 <city>
1475                                                         <xsl:call-template name="chopPunctuation">
1476                                                                 <xsl:with-param name="chopString" select="."></xsl:with-param>
1477                                                         </xsl:call-template>
1478                                                 </city>
1479                                         </xsl:for-each>
1480                                 </hierarchicalGeographic>
1481                         </subject>
1482                 </xsl:for-each>
1483                 <xsl:for-each select="marc:datafield[@tag=045][marc:subfield[@code='b']]">
1484                         <subject>
1485                                 <xsl:choose>
1486                                         <xsl:when test="@ind1=2">
1487                                                 <temporal encoding="iso8601" point="start">
1488                                                         <xsl:call-template name="chopPunctuation">
1489                                                                 <xsl:with-param name="chopString">
1490                                                                         <xsl:value-of select="marc:subfield[@code='b'][1]"></xsl:value-of>
1491                                                                 </xsl:with-param>
1492                                                         </xsl:call-template>
1493                                                 </temporal>
1494                                                 <temporal encoding="iso8601" point="end">
1495                                                         <xsl:call-template name="chopPunctuation">
1496                                                                 <xsl:with-param name="chopString">
1497                                                                         <xsl:value-of select="marc:subfield[@code='b'][2]"></xsl:value-of>
1498                                                                 </xsl:with-param>
1499                                                         </xsl:call-template>
1500                                                 </temporal>
1501                                         </xsl:when>
1502                                         <xsl:otherwise>
1503                                                 <xsl:for-each select="marc:subfield[@code='b']">
1504                                                         <temporal encoding="iso8601">
1505                                                                 <xsl:call-template name="chopPunctuation">
1506                                                                         <xsl:with-param name="chopString" select="."></xsl:with-param>
1507                                                                 </xsl:call-template>
1508                                                         </temporal>
1509                                                 </xsl:for-each>
1510                                         </xsl:otherwise>
1511                                 </xsl:choose>
1512                         </subject>
1513                 </xsl:for-each>
1514                 <xsl:for-each select="marc:datafield[@tag=050]">
1515                         <xsl:for-each select="marc:subfield[@code='b']">
1516                                 <classification authority="lcc">
1517                                         <xsl:if test="../marc:subfield[@code='3']">
1518                                                 <xsl:attribute name="displayLabel">
1519                                                         <xsl:value-of select="../marc:subfield[@code='3']"></xsl:value-of>
1520                                                 </xsl:attribute>
1521                                         </xsl:if>
1522                                         <xsl:value-of select="preceding-sibling::marc:subfield[@code='a'][1]"></xsl:value-of>
1523                                         <xsl:text> </xsl:text>
1524                                         <xsl:value-of select="text()"></xsl:value-of>
1525                                 </classification>
1526                         </xsl:for-each>
1527                         <xsl:for-each select="marc:subfield[@code='a'][not(following-sibling::marc:subfield[@code='b'])]">
1528                                 <classification authority="lcc">
1529                                         <xsl:if test="../marc:subfield[@code='3']">
1530                                                 <xsl:attribute name="displayLabel">
1531                                                         <xsl:value-of select="../marc:subfield[@code='3']"></xsl:value-of>
1532                                                 </xsl:attribute>
1533                                         </xsl:if>
1534                                         <xsl:value-of select="text()"></xsl:value-of>
1535                                 </classification>
1536                         </xsl:for-each>
1537                 </xsl:for-each>
1538                 <xsl:for-each select="marc:datafield[@tag=082]">
1539                         <classification authority="ddc">
1540                                 <xsl:if test="marc:subfield[@code='2']">
1541                                         <xsl:attribute name="edition">
1542                                                 <xsl:value-of select="marc:subfield[@code='2']"></xsl:value-of>
1543                                         </xsl:attribute>
1544                                 </xsl:if>
1545                                 <xsl:call-template name="subfieldSelect">
1546                                         <xsl:with-param name="codes">ab</xsl:with-param>
1547                                 </xsl:call-template>
1548                         </classification>
1549                 </xsl:for-each>
1550                 <xsl:for-each select="marc:datafield[@tag=080]">
1551                         <classification authority="udc">
1552                                 <xsl:call-template name="subfieldSelect">
1553                                         <xsl:with-param name="codes">abx</xsl:with-param>
1554                                 </xsl:call-template>
1555                         </classification>
1556                 </xsl:for-each>
1557                 <xsl:for-each select="marc:datafield[@tag=060]">
1558                         <classification authority="nlm">
1559                                 <xsl:call-template name="subfieldSelect">
1560                                         <xsl:with-param name="codes">ab</xsl:with-param>
1561                                 </xsl:call-template>
1562                         </classification>
1563                 </xsl:for-each>
1564                 <xsl:for-each select="marc:datafield[@tag=086][@ind1=0]">
1565                         <classification authority="sudocs">
1566                                 <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
1567                         </classification>
1568                 </xsl:for-each>
1569                 <xsl:for-each select="marc:datafield[@tag=086][@ind1=1]">
1570                         <classification authority="candoc">
1571                                 <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
1572                         </classification>
1573                 </xsl:for-each>
1574                 <xsl:for-each select="marc:datafield[@tag=086]">
1575                         <classification>
1576                                 <xsl:attribute name="authority">
1577                                         <xsl:value-of select="marc:subfield[@code='2']"></xsl:value-of>
1578                                 </xsl:attribute>
1579                                 <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
1580                         </classification>
1581                 </xsl:for-each>
1582                 <xsl:for-each select="marc:datafield[@tag=084]">
1583                         <classification>
1584                                 <xsl:attribute name="authority">
1585                                         <xsl:value-of select="marc:subfield[@code='2']"></xsl:value-of>
1586                                 </xsl:attribute>
1587                                 <xsl:call-template name="subfieldSelect">
1588                                         <xsl:with-param name="codes">ab</xsl:with-param>
1589                                 </xsl:call-template>
1590                         </classification>
1591                 </xsl:for-each>
1592                 <xsl:for-each select="marc:datafield[@tag=440]">
1593                         <relatedItem type="series">
1594                                 <titleInfo>
1595                                         <title>
1596                                                 <xsl:call-template name="chopPunctuation">
1597                                                         <xsl:with-param name="chopString">
1598                                                                 <xsl:call-template name="subfieldSelect">
1599                                                                         <xsl:with-param name="codes">av</xsl:with-param>
1600                                                                 </xsl:call-template>
1601                                                         </xsl:with-param>
1602                                                 </xsl:call-template>
1603                                         </title>
1604                                         <xsl:call-template name="part"></xsl:call-template>
1605                                 </titleInfo>
1606                         </relatedItem>
1607                 </xsl:for-each>
1608                 <xsl:for-each select="marc:datafield[@tag=490][@ind1=0]">
1609                         <relatedItem type="series">
1610                                 <titleInfo>
1611                                         <title>
1612                                                 <xsl:call-template name="chopPunctuation">
1613                                                         <xsl:with-param name="chopString">
1614                                                                 <xsl:call-template name="subfieldSelect">
1615                                                                         <xsl:with-param name="codes">av</xsl:with-param>
1616                                                                 </xsl:call-template>
1617                                                         </xsl:with-param>
1618                                                 </xsl:call-template>
1619                                         </title>
1620                                         <xsl:call-template name="part"></xsl:call-template>
1621                                 </titleInfo>
1622                         </relatedItem>
1623                 </xsl:for-each>
1624                 <xsl:for-each select="marc:datafield[@tag=510]">
1625                         <relatedItem type="isReferencedBy">
1626                                 <note>
1627                                         <xsl:call-template name="subfieldSelect">
1628                                                 <xsl:with-param name="codes">abcx3</xsl:with-param>
1629                                         </xsl:call-template>
1630                                 </note>
1631                         </relatedItem>
1632                 </xsl:for-each>
1633                 <xsl:for-each select="marc:datafield[@tag=534]">
1634                         <relatedItem type="original">
1635                                 <xsl:call-template name="relatedTitle"></xsl:call-template>
1636                                 <xsl:call-template name="relatedName"></xsl:call-template>
1637                                 <xsl:if test="marc:subfield[@code='b' or @code='c']">
1638                                         <originInfo>
1639                                                 <xsl:for-each select="marc:subfield[@code='c']">
1640                                                         <publisher>
1641                                                                 <xsl:value-of select="."></xsl:value-of>
1642                                                         </publisher>
1643                                                 </xsl:for-each>
1644                                                 <xsl:for-each select="marc:subfield[@code='b']">
1645                                                         <edition>
1646                                                                 <xsl:value-of select="."></xsl:value-of>
1647                                                         </edition>
1648                                                 </xsl:for-each>
1649                                         </originInfo>
1650                                 </xsl:if>
1651                                 <xsl:call-template name="relatedIdentifierISSN"></xsl:call-template>
1652                                 <xsl:for-each select="marc:subfield[@code='z']">
1653                                         <identifier type="isbn">
1654                                                 <xsl:value-of select="."></xsl:value-of>
1655                                         </identifier>
1656                                 </xsl:for-each>
1657                                 <xsl:call-template name="relatedNote"></xsl:call-template>
1658                         </relatedItem>
1659                 </xsl:for-each>
1660                 <xsl:for-each select="marc:datafield[@tag=700][marc:subfield[@code='t']]">
1661                         <relatedItem>
1662                                 <xsl:call-template name="constituentOrRelatedType"></xsl:call-template>
1663                                 <titleInfo>
1664                                         <title>
1665                                                 <xsl:call-template name="chopPunctuation">
1666                                                         <xsl:with-param name="chopString">
1667                                                                 <xsl:call-template name="specialSubfieldSelect">
1668                                                                         <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
1669                                                                         <xsl:with-param name="axis">t</xsl:with-param>
1670                                                                         <xsl:with-param name="afterCodes">g</xsl:with-param>
1671                                                                 </xsl:call-template>
1672                                                         </xsl:with-param>
1673                                                 </xsl:call-template>
1674                                         </title>
1675                                         <xsl:call-template name="part"></xsl:call-template>
1676                                 </titleInfo>
1677                                 <name type="personal">
1678                                         <namePart>
1679                                                 <xsl:call-template name="specialSubfieldSelect">
1680                                                         <xsl:with-param name="anyCodes">aq</xsl:with-param>
1681                                                         <xsl:with-param name="axis">t</xsl:with-param>
1682                                                         <xsl:with-param name="beforeCodes">g</xsl:with-param>
1683                                                 </xsl:call-template>
1684                                         </namePart>
1685                                         <xsl:call-template name="termsOfAddress"></xsl:call-template>
1686                                         <xsl:call-template name="nameDate"></xsl:call-template>
1687                                         <xsl:call-template name="role"></xsl:call-template>
1688                                 </name>
1689                                 <xsl:call-template name="relatedForm"></xsl:call-template>
1690                                 <xsl:call-template name="relatedIdentifierISSN"></xsl:call-template>
1691                         </relatedItem>
1692                 </xsl:for-each>
1693                 <xsl:for-each select="marc:datafield[@tag=710][marc:subfield[@code='t']]">
1694                         <relatedItem>
1695                                 <xsl:call-template name="constituentOrRelatedType"></xsl:call-template>
1696                                 <titleInfo>
1697                                         <title>
1698                                                 <xsl:call-template name="chopPunctuation">
1699                                                         <xsl:with-param name="chopString">
1700                                                                 <xsl:call-template name="specialSubfieldSelect">
1701                                                                         <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
1702                                                                         <xsl:with-param name="axis">t</xsl:with-param>
1703                                                                         <xsl:with-param name="afterCodes">dg</xsl:with-param>
1704                                                                 </xsl:call-template>
1705                                                         </xsl:with-param>
1706                                                 </xsl:call-template>
1707                                         </title>
1708                                         <xsl:call-template name="relatedPartNumName"></xsl:call-template>
1709                                 </titleInfo>
1710                                 <name type="corporate">
1711                                         <xsl:for-each select="marc:subfield[@code='a']">
1712                                                 <namePart>
1713                                                         <xsl:value-of select="."></xsl:value-of>
1714                                                 </namePart>
1715                                         </xsl:for-each>
1716                                         <xsl:for-each select="marc:subfield[@code='b']">
1717                                                 <namePart>
1718                                                         <xsl:value-of select="."></xsl:value-of>
1719                                                 </namePart>
1720                                         </xsl:for-each>
1721                                         <xsl:variable name="tempNamePart">
1722                                                 <xsl:call-template name="specialSubfieldSelect">
1723                                                         <xsl:with-param name="anyCodes">c</xsl:with-param>
1724                                                         <xsl:with-param name="axis">t</xsl:with-param>
1725                                                         <xsl:with-param name="beforeCodes">dgn</xsl:with-param>
1726                                                 </xsl:call-template>
1727                                         </xsl:variable>
1728                                         <xsl:if test="normalize-space($tempNamePart)">
1729                                                 <namePart>
1730                                                         <xsl:value-of select="$tempNamePart"></xsl:value-of>
1731                                                 </namePart>
1732                                         </xsl:if>
1733                                         <xsl:call-template name="role"></xsl:call-template>
1734                                 </name>
1735                                 <xsl:call-template name="relatedForm"></xsl:call-template>
1736                                 <xsl:call-template name="relatedIdentifierISSN"></xsl:call-template>
1737                         </relatedItem>
1738                 </xsl:for-each>
1739                 <xsl:for-each select="marc:datafield[@tag=711][marc:subfield[@code='t']]">
1740                         <relatedItem>
1741                                 <xsl:call-template name="constituentOrRelatedType"></xsl:call-template>
1742                                 <titleInfo>
1743                                         <title>
1744                                                 <xsl:call-template name="chopPunctuation">
1745                                                         <xsl:with-param name="chopString">
1746                                                                 <xsl:call-template name="specialSubfieldSelect">
1747                                                                         <xsl:with-param name="anyCodes">tfklsv</xsl:with-param>
1748                                                                         <xsl:with-param name="axis">t</xsl:with-param>
1749                                                                         <xsl:with-param name="afterCodes">g</xsl:with-param>
1750                                                                 </xsl:call-template>
1751                                                         </xsl:with-param>
1752                                                 </xsl:call-template>
1753                                         </title>
1754                                         <xsl:call-template name="relatedPartNumName"></xsl:call-template>
1755                                 </titleInfo>
1756                                 <name type="conference">
1757                                         <namePart>
1758                                                 <xsl:call-template name="specialSubfieldSelect">
1759                                                         <xsl:with-param name="anyCodes">aqdc</xsl:with-param>
1760                                                         <xsl:with-param name="axis">t</xsl:with-param>
1761                                                         <xsl:with-param name="beforeCodes">gn</xsl:with-param>
1762                                                 </xsl:call-template>
1763                                         </namePart>
1764                                 </name>
1765                                 <xsl:call-template name="relatedForm"></xsl:call-template>
1766                                 <xsl:call-template name="relatedIdentifierISSN"></xsl:call-template>
1767                         </relatedItem>
1768                 </xsl:for-each>
1769                 <xsl:for-each select="marc:datafield[@tag=730][@ind2=2]">
1770                         <relatedItem>
1771                                 <xsl:call-template name="constituentOrRelatedType"></xsl:call-template>
1772                                 <titleInfo>
1773                                         <title>
1774                                                 <xsl:call-template name="chopPunctuation">
1775                                                         <xsl:with-param name="chopString">
1776                                                                 <xsl:call-template name="subfieldSelect">
1777                                                                         <xsl:with-param name="codes">adfgklmorsv</xsl:with-param>
1778                                                                 </xsl:call-template>
1779                                                         </xsl:with-param>
1780                                                 </xsl:call-template>
1781                                         </title>
1782                                         <xsl:call-template name="part"></xsl:call-template>
1783                                 </titleInfo>
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=740][@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:value-of select="marc:subfield[@code='a']"></xsl:value-of>
1796                                                         </xsl:with-param>
1797                                                 </xsl:call-template>
1798                                         </title>
1799                                         <xsl:call-template name="part"></xsl:call-template>
1800                                 </titleInfo>
1801                                 <xsl:call-template name="relatedForm"></xsl:call-template>
1802                         </relatedItem>
1803                 </xsl:for-each>
1804                 <xsl:for-each select="marc:datafield[@tag=760]|marc:datafield[@tag=762]">
1805                         <relatedItem type="series">
1806                                 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
1807                         </relatedItem>
1808                 </xsl:for-each>
1809                 <xsl:for-each select="marc:datafield[@tag=765]|marc:datafield[@tag=767]|marc:datafield[@tag=777]|marc:datafield[@tag=787]">
1810                         <relatedItem>
1811                                 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
1812                         </relatedItem>
1813                 </xsl:for-each>
1814                 <xsl:for-each select="marc:datafield[@tag=775]">
1815                         <relatedItem type="otherVersion">
1816                                 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
1817                         </relatedItem>
1818                 </xsl:for-each>
1819                 <xsl:for-each select="marc:datafield[@tag=770]|marc:datafield[@tag=774]">
1820                         <relatedItem type="constituent">
1821                                 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
1822                         </relatedItem>
1823                 </xsl:for-each>
1824                 <xsl:for-each select="marc:datafield[@tag=772]|marc:datafield[@tag=773]">
1825                         <relatedItem type="host">
1826                                 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
1827                         </relatedItem>
1828                 </xsl:for-each>
1829                 <xsl:for-each select="marc:datafield[@tag=776]">
1830                         <relatedItem type="otherFormat">
1831                                 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
1832                         </relatedItem>
1833                 </xsl:for-each>
1834                 <xsl:for-each select="marc:datafield[@tag=780]">
1835                         <relatedItem type="preceding">
1836                                 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
1837                         </relatedItem>
1838                 </xsl:for-each>
1839                 <xsl:for-each select="marc:datafield[@tag=785]">
1840                         <relatedItem type="succeeding">
1841                                 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
1842                         </relatedItem>
1843                 </xsl:for-each>
1844                 <xsl:for-each select="marc:datafield[@tag=786]">
1845                         <relatedItem type="original">
1846                                 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
1847                         </relatedItem>
1848                 </xsl:for-each>
1849                 <xsl:for-each select="marc:datafield[@tag=800]">
1850                         <relatedItem type="series">
1851                                 <titleInfo>
1852                                         <title>
1853                                                 <xsl:call-template name="chopPunctuation">
1854                                                         <xsl:with-param name="chopString">
1855                                                                 <xsl:call-template name="specialSubfieldSelect">
1856                                                                         <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
1857                                                                         <xsl:with-param name="axis">t</xsl:with-param>
1858                                                                         <xsl:with-param name="afterCodes">g</xsl:with-param>
1859                                                                 </xsl:call-template>
1860                                                         </xsl:with-param>
1861                                                 </xsl:call-template>
1862                                         </title>
1863                                         <xsl:call-template name="part"></xsl:call-template>
1864                                 </titleInfo>
1865                                 <name type="personal">
1866                                         <namePart>
1867                                                 <xsl:call-template name="chopPunctuation">
1868                                                         <xsl:with-param name="chopString">
1869                                                                 <xsl:call-template name="specialSubfieldSelect">
1870                                                                         <xsl:with-param name="anyCodes">aq</xsl:with-param>
1871                                                                         <xsl:with-param name="axis">t</xsl:with-param>
1872                                                                         <xsl:with-param name="beforeCodes">g</xsl:with-param>
1873                                                                 </xsl:call-template>
1874                                                         </xsl:with-param>
1875                                                 </xsl:call-template>
1876                                         </namePart>
1877                                         <xsl:call-template name="termsOfAddress"></xsl:call-template>
1878                                         <xsl:call-template name="nameDate"></xsl:call-template>
1879                                         <xsl:call-template name="role"></xsl:call-template>
1880                                 </name>
1881                                 <xsl:call-template name="relatedForm"></xsl:call-template>
1882                         </relatedItem>
1883                 </xsl:for-each>
1884                 <xsl:for-each select="marc:datafield[@tag=810]">
1885                         <relatedItem type="series">
1886                                 <titleInfo>
1887                                         <title>
1888                                                 <xsl:call-template name="chopPunctuation">
1889                                                         <xsl:with-param name="chopString">
1890                                                                 <xsl:call-template name="specialSubfieldSelect">
1891                                                                         <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
1892                                                                         <xsl:with-param name="axis">t</xsl:with-param>
1893                                                                         <xsl:with-param name="afterCodes">dg</xsl:with-param>
1894                                                                 </xsl:call-template>
1895                                                         </xsl:with-param>
1896                                                 </xsl:call-template>
1897                                         </title>
1898                                         <xsl:call-template name="relatedPartNumName"></xsl:call-template>
1899                                 </titleInfo>
1900                                 <name type="corporate">
1901                                         <xsl:for-each select="marc:subfield[@code='a']">
1902                                                 <namePart>
1903                                                         <xsl:value-of select="."></xsl:value-of>
1904                                                 </namePart>
1905                                         </xsl:for-each>
1906                                         <xsl:for-each select="marc:subfield[@code='b']">
1907                                                 <namePart>
1908                                                         <xsl:value-of select="."></xsl:value-of>
1909                                                 </namePart>
1910                                         </xsl:for-each>
1911                                         <namePart>
1912                                                 <xsl:call-template name="specialSubfieldSelect">
1913                                                         <xsl:with-param name="anyCodes">c</xsl:with-param>
1914                                                         <xsl:with-param name="axis">t</xsl:with-param>
1915                                                         <xsl:with-param name="beforeCodes">dgn</xsl:with-param>
1916                                                 </xsl:call-template>
1917                                         </namePart>
1918                                         <xsl:call-template name="role"></xsl:call-template>
1919                                 </name>
1920                                 <xsl:call-template name="relatedForm"></xsl:call-template>
1921                         </relatedItem>
1922                 </xsl:for-each>
1923                 <xsl:for-each select="marc:datafield[@tag=811]">
1924                         <relatedItem type="series">
1925                                 <titleInfo>
1926                                         <title>
1927                                                 <xsl:call-template name="chopPunctuation">
1928                                                         <xsl:with-param name="chopString">
1929                                                                 <xsl:call-template name="specialSubfieldSelect">
1930                                                                         <xsl:with-param name="anyCodes">tfklsv</xsl:with-param>
1931                                                                         <xsl:with-param name="axis">t</xsl:with-param>
1932                                                                         <xsl:with-param name="afterCodes">g</xsl:with-param>
1933                                                                 </xsl:call-template>
1934                                                         </xsl:with-param>
1935                                                 </xsl:call-template>
1936                                         </title>
1937                                         <xsl:call-template name="relatedPartNumName"/>
1938                                 </titleInfo>
1939                                 <name type="conference">
1940                                         <namePart>
1941                                                 <xsl:call-template name="specialSubfieldSelect">
1942                                                         <xsl:with-param name="anyCodes">aqdc</xsl:with-param>
1943                                                         <xsl:with-param name="axis">t</xsl:with-param>
1944                                                         <xsl:with-param name="beforeCodes">gn</xsl:with-param>
1945                                                 </xsl:call-template>
1946                                         </namePart>
1947                                         <xsl:call-template name="role"/>
1948                                 </name>
1949                                 <xsl:call-template name="relatedForm"/>
1950                         </relatedItem>
1951                 </xsl:for-each>
1952                 <xsl:for-each select="marc:datafield[@tag='830']">
1953                         <relatedItem type="series">
1954                                 <titleInfo>
1955                                         <title>
1956                                                 <xsl:call-template name="chopPunctuation">
1957                                                         <xsl:with-param name="chopString">
1958                                                                 <xsl:call-template name="subfieldSelect">
1959                                                                         <xsl:with-param name="codes">adfgklmorsv</xsl:with-param>
1960                                                                 </xsl:call-template>
1961                                                         </xsl:with-param>
1962                                                 </xsl:call-template>
1963                                         </title>
1964                                         <xsl:call-template name="part"/>
1965                                 </titleInfo>
1966                                 <xsl:call-template name="relatedForm"/>
1967                         </relatedItem>
1968                 </xsl:for-each>
1969                 <xsl:for-each select="marc:datafield[@tag='856'][@ind2='2']/marc:subfield[@code='q']">
1970                         <relatedItem>
1971                                 <internetMediaType>
1972                                         <xsl:value-of select="."/>
1973                                 </internetMediaType>
1974                         </relatedItem>
1975                 </xsl:for-each>
1976                 <xsl:for-each select="marc:datafield[@tag='020']">
1977                         <xsl:call-template name="isInvalid">
1978                                 <xsl:with-param name="type">isbn</xsl:with-param>
1979                         </xsl:call-template>
1980                         <xsl:if test="marc:subfield[@code='a']">
1981                                 <identifier type="isbn">
1982                                         <xsl:value-of select="marc:subfield[@code='a']"/>
1983                                 </identifier>
1984                         </xsl:if>
1985                 </xsl:for-each>
1986                 <xsl:for-each select="marc:datafield[@tag='024'][@ind1='0']">
1987                         <xsl:call-template name="isInvalid">
1988                                 <xsl:with-param name="type">isrc</xsl:with-param>
1989                         </xsl:call-template>
1990                         <xsl:if test="marc:subfield[@code='a']">
1991                                 <identifier type="isrc">
1992                                         <xsl:value-of select="marc:subfield[@code='a']"/>
1993                                 </identifier>
1994                         </xsl:if>
1995                 </xsl:for-each>
1996                 <xsl:for-each select="marc:datafield[@tag='024'][@ind1='2']">
1997                         <xsl:call-template name="isInvalid">
1998                                 <xsl:with-param name="type">ismn</xsl:with-param>
1999                         </xsl:call-template>
2000                         <xsl:if test="marc:subfield[@code='a']">
2001                                 <identifier type="ismn">
2002                                         <xsl:value-of select="marc:subfield[@code='a']"/>
2003                                 </identifier>
2004                         </xsl:if>
2005                 </xsl:for-each>
2006                 <xsl:for-each select="marc:datafield[@tag='024'][@ind1='4']">
2007                         <xsl:call-template name="isInvalid">
2008                                 <xsl:with-param name="type">sici</xsl:with-param>
2009                         </xsl:call-template>
2010                         <identifier type="sici">
2011                                 <xsl:call-template name="subfieldSelect">
2012                                         <xsl:with-param name="codes">ab</xsl:with-param>
2013                                 </xsl:call-template>
2014                         </identifier>
2015                 </xsl:for-each>
2016                 <xsl:for-each select="marc:datafield[@tag='022']">
2017                         <xsl:call-template name="isInvalid">
2018                                 <xsl:with-param name="type">issn</xsl:with-param>
2019                         </xsl:call-template>
2020                         <identifier type="issn">
2021                                 <xsl:value-of select="marc:subfield[@code='a']"/>
2022                         </identifier>
2023                 </xsl:for-each>
2024                 <xsl:for-each select="marc:datafield[@tag='010']">
2025                         <xsl:call-template name="isInvalid">
2026                                 <xsl:with-param name="type">lccn</xsl:with-param>
2027                         </xsl:call-template>
2028                         <identifier type="lccn">
2029                                 <xsl:value-of select="normalize-space(marc:subfield[@code='a'])"/>
2030                         </identifier>
2031                 </xsl:for-each>
2032                 <xsl:for-each select="marc:datafield[@tag='028']">
2033                         <identifier>
2034                                 <xsl:attribute name="type">
2035                                         <xsl:choose>
2036                                                 <xsl:when test="@ind1='0'">issue number</xsl:when>
2037                                                 <xsl:when test="@ind1='1'">matrix number</xsl:when>
2038                                                 <xsl:when test="@ind1='2'">music plate</xsl:when>
2039                                                 <xsl:when test="@ind1='3'">music publisher</xsl:when>
2040                                                 <xsl:when test="@ind1='4'">videorecording identifier</xsl:when>
2041                                         </xsl:choose>
2042                                 </xsl:attribute>
2043                                 <!--<xsl:call-template name="isInvalid"/>--> <!-- no $z in 028 -->
2044                                 <xsl:call-template name="subfieldSelect">
2045                                         <xsl:with-param name="codes">
2046                                                 <xsl:choose>
2047                                                         <xsl:when test="@ind1='0'">ba</xsl:when>
2048                                                         <xsl:otherwise>ab</xsl:otherwise>
2049                                                 </xsl:choose>
2050                                         </xsl:with-param>
2051                                 </xsl:call-template>
2052                         </identifier>
2053                 </xsl:for-each>
2054                 <xsl:for-each select="marc:datafield[@tag='037']">
2055                         <identifier type="stock number">
2056                                 <!--<xsl:call-template name="isInvalid"/>--> <!-- no $z in 037 -->
2057                                 <xsl:call-template name="subfieldSelect">
2058                                         <xsl:with-param name="codes">ab</xsl:with-param>
2059                                 </xsl:call-template>
2060                         </identifier>
2061                 </xsl:for-each>
2062                 <xsl:for-each select="marc:datafield[@tag='856'][marc:subfield[@code='u']]">
2063                         <identifier>
2064                                 <xsl:attribute name="type">
2065                                         <xsl:choose>
2066                                                 <xsl:when test="starts-with(marc:subfield[@code='u'],'urn:doi') or starts-with(marc:subfield[@code='u'],'doi')">doi</xsl:when>
2067                                                 <xsl:when test="starts-with(marc:subfield[@code='u'],'urn:hdl') or starts-with(marc:subfield[@code='u'],'hdl') or starts-with(marc:subfield[@code='u'],'http://hdl.loc.gov')">hdl</xsl:when>
2068                                                 <xsl:otherwise>uri</xsl:otherwise>
2069                                         </xsl:choose>
2070                                 </xsl:attribute>
2071                                 <xsl:choose>
2072                                         <xsl:when test="starts-with(marc:subfield[@code='u'],'urn:hdl') or starts-with(marc:subfield[@code='u'],'hdl') or starts-with(marc:subfield[@code='u'],'http://hdl.loc.gov') ">
2073                                                 <xsl:value-of select="concat('hdl:',substring-after(marc:subfield[@code='u'],'http://hdl.loc.gov/'))"></xsl:value-of>
2074                                         </xsl:when>
2075                                         <xsl:otherwise>
2076                                                 <xsl:value-of select="marc:subfield[@code='u']"></xsl:value-of>
2077                                         </xsl:otherwise>
2078                                 </xsl:choose>
2079                         </identifier>
2080                         <xsl:if test="starts-with(marc:subfield[@code='u'],'urn:hdl') or starts-with(marc:subfield[@code='u'],'hdl')">
2081                                 <identifier type="hdl">
2082                                         <xsl:if test="marc:subfield[@code='y' or @code='3' or @code='z']">
2083                                                 <xsl:attribute name="displayLabel">
2084                                                         <xsl:call-template name="subfieldSelect">
2085                                                                 <xsl:with-param name="codes">y3z</xsl:with-param>
2086                                                         </xsl:call-template>
2087                                                 </xsl:attribute>
2088                                         </xsl:if>
2089                                         <xsl:value-of select="concat('hdl:',substring-after(marc:subfield[@code='u'],'http://hdl.loc.gov/'))"></xsl:value-of>
2090                                 </identifier>
2091                         </xsl:if>
2092                 </xsl:for-each>
2093                 <xsl:for-each select="marc:datafield[@tag=024][@ind1=1]">
2094                         <identifier type="upc">
2095                                 <xsl:call-template name="isInvalid"/>
2096                                 <xsl:value-of select="marc:subfield[@code='a']"/>
2097                         </identifier>
2098                 </xsl:for-each>
2099                 <!-- 1/04 fix added $y -->
2100                 <xsl:for-each select="marc:datafield[@tag=856][marc:subfield[@code='u']]">
2101                         <location>
2102                                 <url>
2103                                         <xsl:if test="marc:subfield[@code='y' or @code='3']">
2104                                                 <xsl:attribute name="displayLabel">
2105                                                         <xsl:call-template name="subfieldSelect">
2106                                                                 <xsl:with-param name="codes">y3</xsl:with-param>
2107                                                         </xsl:call-template>
2108                                                 </xsl:attribute>
2109                                         </xsl:if>
2110                                         <xsl:if test="marc:subfield[@code='z' ]">
2111                                                 <xsl:attribute name="note">
2112                                                         <xsl:call-template name="subfieldSelect">
2113                                                                 <xsl:with-param name="codes">z</xsl:with-param>
2114                                                         </xsl:call-template>
2115                                                 </xsl:attribute>
2116                                         </xsl:if>
2117                                         <xsl:value-of select="marc:subfield[@code='u']"></xsl:value-of>
2118
2119                                 </url>
2120                         </location>
2121                 </xsl:for-each>
2122                         
2123                         <!-- 3.2 change tmee 856z  -->
2124
2125                 
2126                 <xsl:for-each select="marc:datafield[@tag=852]">
2127                         <location>
2128                                 <physicalLocation>
2129                                         <xsl:call-template name="displayLabel"></xsl:call-template>
2130                                         <xsl:call-template name="subfieldSelect">
2131                                                 <xsl:with-param name="codes">abje</xsl:with-param>
2132                                         </xsl:call-template>
2133                                 </physicalLocation>
2134                         </location>
2135                 </xsl:for-each>
2136                 <xsl:for-each select="marc:datafield[@tag=506]">
2137                         <accessCondition type="restrictionOnAccess">
2138                                 <xsl:call-template name="subfieldSelect">
2139                                         <xsl:with-param name="codes">abcd35</xsl:with-param>
2140                                 </xsl:call-template>
2141                         </accessCondition>
2142                 </xsl:for-each>
2143                 <xsl:for-each select="marc:datafield[@tag=540]">
2144                         <accessCondition type="useAndReproduction">
2145                                 <xsl:call-template name="subfieldSelect">
2146                                         <xsl:with-param name="codes">abcde35</xsl:with-param>
2147                                 </xsl:call-template>
2148                         </accessCondition>
2149                 </xsl:for-each>
2150                 <recordInfo>
2151                         <xsl:for-each select="marc:datafield[@tag=040]">
2152                                 <recordContentSource authority="marcorg">
2153                                         <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
2154                                 </recordContentSource>
2155                         </xsl:for-each>
2156                         <xsl:for-each select="marc:controlfield[@tag=008]">
2157                                 <recordCreationDate encoding="marc">
2158                                         <xsl:value-of select="substring(.,1,6)"></xsl:value-of>
2159                                 </recordCreationDate>
2160                         </xsl:for-each>
2161                         <xsl:for-each select="marc:controlfield[@tag=005]">
2162                                 <recordChangeDate encoding="iso8601">
2163                                         <xsl:value-of select="."></xsl:value-of>
2164                                 </recordChangeDate>
2165                         </xsl:for-each>
2166                         <xsl:for-each select="marc:controlfield[@tag=001]">
2167                                 <recordIdentifier>
2168                                         <xsl:if test="../marc:controlfield[@tag=003]">
2169                                                 <xsl:attribute name="source">
2170                                                         <xsl:value-of select="../marc:controlfield[@tag=003]"></xsl:value-of>
2171                                                 </xsl:attribute>
2172                                         </xsl:if>
2173                                         <xsl:value-of select="."></xsl:value-of>
2174                                 </recordIdentifier>
2175                         </xsl:for-each>
2176                         <xsl:for-each select="marc:datafield[@tag=040]/marc:subfield[@code='b']">
2177                                 <languageOfCataloging>
2178                                         <languageTerm authority="iso639-2b" type="code">
2179                                                 <xsl:value-of select="."></xsl:value-of>
2180                                         </languageTerm>
2181                                 </languageOfCataloging>
2182                         </xsl:for-each>
2183                 </recordInfo>
2184         </xsl:template>
2185         <xsl:template name="displayForm">
2186                 <xsl:for-each select="marc:subfield[@code='c']">
2187                         <displayForm>
2188                                 <xsl:value-of select="."></xsl:value-of>
2189                         </displayForm>
2190                 </xsl:for-each>
2191         </xsl:template>
2192         <xsl:template name="affiliation">
2193                 <xsl:for-each select="marc:subfield[@code='u']">
2194                         <affiliation>
2195                                 <xsl:value-of select="."></xsl:value-of>
2196                         </affiliation>
2197                 </xsl:for-each>
2198         </xsl:template>
2199         <xsl:template name="uri">
2200                 <xsl:for-each select="marc:subfield[@code='u']">
2201                         <xsl:attribute name="xlink:href">
2202                                 <xsl:value-of select="."></xsl:value-of>
2203                         </xsl:attribute>
2204                 </xsl:for-each>
2205         </xsl:template>
2206         <xsl:template name="role">
2207                 <xsl:for-each select="marc:subfield[@code='e']">
2208                         <role>
2209                                 <roleTerm type="text">
2210                                         <xsl:value-of select="."></xsl:value-of>
2211                                 </roleTerm>
2212                         </role>
2213                 </xsl:for-each>
2214                 <xsl:for-each select="marc:subfield[@code='4']">
2215                         <role>
2216                                 <roleTerm authority="marcrelator" type="code">
2217                                         <xsl:value-of select="."></xsl:value-of>
2218                                 </roleTerm>
2219                         </role>
2220                 </xsl:for-each>
2221         </xsl:template>
2222         <xsl:template name="part">
2223                 <xsl:variable name="partNumber">
2224                         <xsl:call-template name="specialSubfieldSelect">
2225                                 <xsl:with-param name="axis">n</xsl:with-param>
2226                                 <xsl:with-param name="anyCodes">n</xsl:with-param>
2227                                 <xsl:with-param name="afterCodes">fgkdlmor</xsl:with-param>
2228                         </xsl:call-template>
2229                 </xsl:variable>
2230                 <xsl:variable name="partName">
2231                         <xsl:call-template name="specialSubfieldSelect">
2232                                 <xsl:with-param name="axis">p</xsl:with-param>
2233                                 <xsl:with-param name="anyCodes">p</xsl:with-param>
2234                                 <xsl:with-param name="afterCodes">fgkdlmor</xsl:with-param>
2235                         </xsl:call-template>
2236                 </xsl:variable>
2237                 <xsl:if test="string-length(normalize-space($partNumber))">
2238                         <partNumber>
2239                                 <xsl:call-template name="chopPunctuation">
2240                                         <xsl:with-param name="chopString" select="$partNumber"></xsl:with-param>
2241                                 </xsl:call-template>
2242                         </partNumber>
2243                 </xsl:if>
2244                 <xsl:if test="string-length(normalize-space($partName))">
2245                         <partName>
2246                                 <xsl:call-template name="chopPunctuation">
2247                                         <xsl:with-param name="chopString" select="$partName"></xsl:with-param>
2248                                 </xsl:call-template>
2249                         </partName>
2250                 </xsl:if>
2251         </xsl:template>
2252         <xsl:template name="relatedPart">
2253                 <xsl:if test="@tag=773">
2254                         <xsl:for-each select="marc:subfield[@code='g']">
2255                                 <part>
2256                                         <text>
2257                                                 <xsl:value-of select="."></xsl:value-of>
2258                                         </text>
2259                                 </part>
2260                         </xsl:for-each>
2261                         <xsl:for-each select="marc:subfield[@code='q']">
2262                                 <part>
2263                                         <xsl:call-template name="parsePart"></xsl:call-template>
2264                                 </part>
2265                         </xsl:for-each>
2266                 </xsl:if>
2267         </xsl:template>
2268         <xsl:template name="relatedPartNumName">
2269                 <xsl:variable name="partNumber">
2270                         <xsl:call-template name="specialSubfieldSelect">
2271                                 <xsl:with-param name="axis">g</xsl:with-param>
2272                                 <xsl:with-param name="anyCodes">g</xsl:with-param>
2273                                 <xsl:with-param name="afterCodes">pst</xsl:with-param>
2274                         </xsl:call-template>
2275                 </xsl:variable>
2276                 <xsl:variable name="partName">
2277                         <xsl:call-template name="specialSubfieldSelect">
2278                                 <xsl:with-param name="axis">p</xsl:with-param>
2279                                 <xsl:with-param name="anyCodes">p</xsl:with-param>
2280                                 <xsl:with-param name="afterCodes">fgkdlmor</xsl:with-param>
2281                         </xsl:call-template>
2282                 </xsl:variable>
2283                 <xsl:if test="string-length(normalize-space($partNumber))">
2284                         <partNumber>
2285                                 <xsl:value-of select="$partNumber"></xsl:value-of>
2286                         </partNumber>
2287                 </xsl:if>
2288                 <xsl:if test="string-length(normalize-space($partName))">
2289                         <partName>
2290                                 <xsl:value-of select="$partName"></xsl:value-of>
2291                         </partName>
2292                 </xsl:if>
2293         </xsl:template>
2294         <xsl:template name="relatedName">
2295                 <xsl:for-each select="marc:subfield[@code='a']">
2296                         <name>
2297                                 <namePart>
2298                                         <xsl:value-of select="."></xsl:value-of>
2299                                 </namePart>
2300                         </name>
2301                 </xsl:for-each>
2302         </xsl:template>
2303         <xsl:template name="relatedForm">
2304                 <xsl:for-each select="marc:subfield[@code='h']">
2305                         <physicalDescription>
2306                                 <form>
2307                                         <xsl:value-of select="."></xsl:value-of>
2308                                 </form>
2309                         </physicalDescription>
2310                 </xsl:for-each>
2311         </xsl:template>
2312         <xsl:template name="relatedExtent">
2313                 <xsl:for-each select="marc:subfield[@code='h']">
2314                         <physicalDescription>
2315                                 <extent>
2316                                         <xsl:value-of select="."></xsl:value-of>
2317                                 </extent>
2318                         </physicalDescription>
2319                 </xsl:for-each>
2320         </xsl:template>
2321         <xsl:template name="relatedNote">
2322                 <xsl:for-each select="marc:subfield[@code='n']">
2323                         <note>
2324                                 <xsl:value-of select="."></xsl:value-of>
2325                         </note>
2326                 </xsl:for-each>
2327         </xsl:template>
2328         <xsl:template name="relatedSubject">
2329                 <xsl:for-each select="marc:subfield[@code='j']">
2330                         <subject>
2331                                 <temporal encoding="iso8601">
2332                                         <xsl:call-template name="chopPunctuation">
2333                                                 <xsl:with-param name="chopString" select="."></xsl:with-param>
2334                                         </xsl:call-template>
2335                                 </temporal>
2336                         </subject>
2337                 </xsl:for-each>
2338         </xsl:template>
2339         <xsl:template name="relatedIdentifierISSN">
2340                 <xsl:for-each select="marc:subfield[@code='x']">
2341                         <identifier type="issn">
2342                                 <xsl:value-of select="."></xsl:value-of>
2343                         </identifier>
2344                 </xsl:for-each>
2345         </xsl:template>
2346         <xsl:template name="relatedIdentifierLocal">
2347                 <xsl:for-each select="marc:subfield[@code='w']">
2348                         <identifier type="local">
2349                                 <xsl:value-of select="."></xsl:value-of>
2350                         </identifier>
2351                 </xsl:for-each>
2352         </xsl:template>
2353         <xsl:template name="relatedIdentifier">
2354                 <xsl:for-each select="marc:subfield[@code='o']">
2355                         <identifier>
2356                                 <xsl:value-of select="."></xsl:value-of>
2357                         </identifier>
2358                 </xsl:for-each>
2359         </xsl:template>
2360         <xsl:template name="relatedItem76X-78X">
2361                 <xsl:call-template name="displayLabel"></xsl:call-template>
2362                 <xsl:call-template name="relatedTitle76X-78X"></xsl:call-template>
2363                 <xsl:call-template name="relatedName"></xsl:call-template>
2364                 <xsl:call-template name="relatedOriginInfo"></xsl:call-template>
2365                 <xsl:call-template name="relatedLanguage"></xsl:call-template>
2366                 <xsl:call-template name="relatedExtent"></xsl:call-template>
2367                 <xsl:call-template name="relatedNote"></xsl:call-template>
2368                 <xsl:call-template name="relatedSubject"></xsl:call-template>
2369                 <xsl:call-template name="relatedIdentifier"></xsl:call-template>
2370                 <xsl:call-template name="relatedIdentifierISSN"></xsl:call-template>
2371                 <xsl:call-template name="relatedIdentifierLocal"></xsl:call-template>
2372                 <xsl:call-template name="relatedPart"></xsl:call-template>
2373         </xsl:template>
2374         <xsl:template name="subjectGeographicZ">
2375                 <geographic>
2376                         <xsl:call-template name="chopPunctuation">
2377                                 <xsl:with-param name="chopString" select="."></xsl:with-param>
2378                         </xsl:call-template>
2379                 </geographic>
2380         </xsl:template>
2381         <xsl:template name="subjectTemporalY">
2382                 <temporal>
2383                         <xsl:call-template name="chopPunctuation">
2384                                 <xsl:with-param name="chopString" select="."></xsl:with-param>
2385                         </xsl:call-template>
2386                 </temporal>
2387         </xsl:template>
2388         <xsl:template name="subjectTopic">
2389                 <topic>
2390                         <xsl:call-template name="chopPunctuation">
2391                                 <xsl:with-param name="chopString" select="."></xsl:with-param>
2392                         </xsl:call-template>
2393                 </topic>
2394         </xsl:template> 
2395         <!-- 3.2 change tmee 6xx $v genre -->
2396         <xsl:template name="subjectGenre">
2397                 <genre>
2398                         <xsl:call-template name="chopPunctuation">
2399                                 <xsl:with-param name="chopString" select="."></xsl:with-param>
2400                         </xsl:call-template>
2401                 </genre>
2402         </xsl:template>
2403         
2404         <xsl:template name="nameABCDN">
2405                 <xsl:for-each select="marc:subfield[@code='a']">
2406                         <namePart>
2407                                 <xsl:call-template name="chopPunctuation">
2408                                         <xsl:with-param name="chopString" select="."></xsl:with-param>
2409                                 </xsl:call-template>
2410                         </namePart>
2411                 </xsl:for-each>
2412                 <xsl:for-each select="marc:subfield[@code='b']">
2413                         <namePart>
2414                                 <xsl:value-of select="."></xsl:value-of>
2415                         </namePart>
2416                 </xsl:for-each>
2417                 <xsl:if test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">
2418                         <namePart>
2419                                 <xsl:call-template name="subfieldSelect">
2420                                         <xsl:with-param name="codes">cdn</xsl:with-param>
2421                                 </xsl:call-template>
2422                         </namePart>
2423                 </xsl:if>
2424         </xsl:template>
2425         <xsl:template name="nameABCDQ">
2426                 <namePart>
2427                         <xsl:call-template name="chopPunctuation">
2428                                 <xsl:with-param name="chopString">
2429                                         <xsl:call-template name="subfieldSelect">
2430                                                 <xsl:with-param name="codes">aq</xsl:with-param>
2431                                         </xsl:call-template>
2432                                 </xsl:with-param>
2433                                 <xsl:with-param name="punctuation">
2434                                         <xsl:text>:,;/ </xsl:text>
2435                                 </xsl:with-param>
2436                         </xsl:call-template>
2437                 </namePart>
2438                 <xsl:call-template name="termsOfAddress"></xsl:call-template>
2439                 <xsl:call-template name="nameDate"></xsl:call-template>
2440         </xsl:template>
2441         <xsl:template name="nameACDEQ">
2442                 <namePart>
2443                         <xsl:call-template name="subfieldSelect">
2444                                 <xsl:with-param name="codes">acdeq</xsl:with-param>
2445                         </xsl:call-template>
2446                 </namePart>
2447         </xsl:template>
2448         <xsl:template name="constituentOrRelatedType">
2449                 <xsl:if test="@ind2=2">
2450                         <xsl:attribute name="type">constituent</xsl:attribute>
2451                 </xsl:if>
2452         </xsl:template>
2453         <xsl:template name="relatedTitle">
2454                 <xsl:for-each select="marc:subfield[@code='t']">
2455                         <titleInfo>
2456                                 <title>
2457                                         <xsl:call-template name="chopPunctuation">
2458                                                 <xsl:with-param name="chopString">
2459                                                         <xsl:value-of select="."></xsl:value-of>
2460                                                 </xsl:with-param>
2461                                         </xsl:call-template>
2462                                 </title>
2463                         </titleInfo>
2464                 </xsl:for-each>
2465         </xsl:template>
2466         <xsl:template name="relatedTitle76X-78X">
2467                 <xsl:for-each select="marc:subfield[@code='t']">
2468                         <titleInfo>
2469                                 <title>
2470                                         <xsl:call-template name="chopPunctuation">
2471                                                 <xsl:with-param name="chopString">
2472                                                         <xsl:value-of select="."></xsl:value-of>
2473                                                 </xsl:with-param>
2474                                         </xsl:call-template>
2475                                 </title>
2476                                 <xsl:if test="marc:datafield[@tag!=773]and marc:subfield[@code='g']">
2477                                         <xsl:call-template name="relatedPartNumName"></xsl:call-template>
2478                                 </xsl:if>
2479                         </titleInfo>
2480                 </xsl:for-each>
2481                 <xsl:for-each select="marc:subfield[@code='p']">
2482                         <titleInfo type="abbreviated">
2483                                 <title>
2484                                         <xsl:call-template name="chopPunctuation">
2485                                                 <xsl:with-param name="chopString">
2486                                                         <xsl:value-of select="."></xsl:value-of>
2487                                                 </xsl:with-param>
2488                                         </xsl:call-template>
2489                                 </title>
2490                                 <xsl:if test="marc:datafield[@tag!=773]and marc:subfield[@code='g']">
2491                                         <xsl:call-template name="relatedPartNumName"></xsl:call-template>
2492                                 </xsl:if>
2493                         </titleInfo>
2494                 </xsl:for-each>
2495                 <xsl:for-each select="marc:subfield[@code='s']">
2496                         <titleInfo type="uniform">
2497                                 <title>
2498                                         <xsl:call-template name="chopPunctuation">
2499                                                 <xsl:with-param name="chopString">
2500                                                         <xsl:value-of select="."></xsl:value-of>
2501                                                 </xsl:with-param>
2502                                         </xsl:call-template>
2503                                 </title>
2504                                 <xsl:if test="marc:datafield[@tag!=773]and marc:subfield[@code='g']">
2505                                         <xsl:call-template name="relatedPartNumName"></xsl:call-template>
2506                                 </xsl:if>
2507                         </titleInfo>
2508                 </xsl:for-each>
2509         </xsl:template>
2510         <xsl:template name="relatedOriginInfo">
2511                 <xsl:if test="marc:subfield[@code='b' or @code='d'] or marc:subfield[@code='f']">
2512                         <originInfo>
2513                                 <xsl:if test="@tag=775">
2514                                         <xsl:for-each select="marc:subfield[@code='f']">
2515                                                 <place>
2516                                                         <placeTerm>
2517                                                                 <xsl:attribute name="type">code</xsl:attribute>
2518                                                                 <xsl:attribute name="authority">marcgac</xsl:attribute>
2519                                                                 <xsl:value-of select="."></xsl:value-of>
2520                                                         </placeTerm>
2521                                                 </place>
2522                                         </xsl:for-each>
2523                                 </xsl:if>
2524                                 <xsl:for-each select="marc:subfield[@code='d']">
2525                                         <publisher>
2526                                                 <xsl:value-of select="."></xsl:value-of>
2527                                         </publisher>
2528                                 </xsl:for-each>
2529                                 <xsl:for-each select="marc:subfield[@code='b']">
2530                                         <edition>
2531                                                 <xsl:value-of select="."></xsl:value-of>
2532                                         </edition>
2533                                 </xsl:for-each>
2534                         </originInfo>
2535                 </xsl:if>
2536         </xsl:template>
2537         <xsl:template name="relatedLanguage">
2538                 <xsl:for-each select="marc:subfield[@code='e']">
2539                         <xsl:call-template name="getLanguage">
2540                                 <xsl:with-param name="langString">
2541                                         <xsl:value-of select="."></xsl:value-of>
2542                                 </xsl:with-param>
2543                         </xsl:call-template>
2544                 </xsl:for-each>
2545         </xsl:template>
2546         <xsl:template name="nameDate">
2547                 <xsl:for-each select="marc:subfield[@code='d']">
2548                         <namePart type="date">
2549                                 <xsl:call-template name="chopPunctuation">
2550                                         <xsl:with-param name="chopString" select="."></xsl:with-param>
2551                                 </xsl:call-template>
2552                         </namePart>
2553                 </xsl:for-each>
2554         </xsl:template>
2555         <xsl:template name="subjectAuthority">
2556                 <xsl:if test="@ind2!=4">
2557                         <xsl:if test="@ind2!=' '">
2558                                 <xsl:if test="@ind2!=8">
2559                                         <xsl:if test="@ind2!=9">
2560                                                 <xsl:attribute name="authority">
2561                                                         <xsl:choose>
2562                                                                 <xsl:when test="@ind2=0">lcsh</xsl:when>
2563                                                                 <xsl:when test="@ind2=1">lcshac</xsl:when>
2564                                                                 <xsl:when test="@ind2=2">mesh</xsl:when>
2565                                                                 <!-- 1/04 fix -->
2566                                                                 <xsl:when test="@ind2=3">nal</xsl:when>
2567                                                                 <xsl:when test="@ind2=5">csh</xsl:when>
2568                                                                 <xsl:when test="@ind2=6">rvm</xsl:when>
2569                                                                 <xsl:when test="@ind2=7">
2570                                                                         <xsl:value-of select="marc:subfield[@code='2']"></xsl:value-of>
2571                                                                 </xsl:when>
2572                                                         </xsl:choose>
2573                                                 </xsl:attribute>
2574                                         </xsl:if>
2575                                 </xsl:if>
2576                         </xsl:if>
2577                 </xsl:if>
2578         </xsl:template>
2579         <xsl:template name="subjectAnyOrder">
2580                 <xsl:for-each select="marc:subfield[@code='v' or @code='x' or @code='y' or @code='z']">
2581                         <xsl:choose>
2582                                 <xsl:when test="@code='v'">
2583                                         <xsl:call-template name="subjectGenre"></xsl:call-template>
2584                                 </xsl:when>
2585                                 <xsl:when test="@code='x'">
2586                                         <xsl:call-template name="subjectTopic"></xsl:call-template>
2587                                 </xsl:when>
2588                                 <xsl:when test="@code='y'">
2589                                         <xsl:call-template name="subjectTemporalY"></xsl:call-template>
2590                                 </xsl:when>
2591                                 <xsl:when test="@code='z'">
2592                                         <xsl:call-template name="subjectGeographicZ"></xsl:call-template>
2593                                 </xsl:when>
2594                         </xsl:choose>
2595                 </xsl:for-each>
2596         </xsl:template>
2597         <xsl:template name="specialSubfieldSelect">
2598                 <xsl:param name="anyCodes"></xsl:param>
2599                 <xsl:param name="axis"></xsl:param>
2600                 <xsl:param name="beforeCodes"></xsl:param>
2601                 <xsl:param name="afterCodes"></xsl:param>
2602                 <xsl:variable name="str">
2603                         <xsl:for-each select="marc:subfield">
2604                                 <xsl:if test="contains($anyCodes, @code)      or (contains($beforeCodes,@code) and following-sibling::marc:subfield[@code=$axis])      or (contains($afterCodes,@code) and preceding-sibling::marc:subfield[@code=$axis])">
2605                                         <xsl:value-of select="text()"></xsl:value-of>
2606                                         <xsl:text> </xsl:text>
2607                                 </xsl:if>
2608                         </xsl:for-each>
2609                 </xsl:variable>
2610                 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
2611         </xsl:template>
2612         
2613         <!-- 3.2 change tmee 6xx $v genre -->
2614         <xsl:template match="marc:datafield[@tag=600]">
2615                 <subject>
2616                         <xsl:call-template name="subjectAuthority"></xsl:call-template>
2617                         <name type="personal">
2618                                 <namePart>
2619                                         <xsl:call-template name="chopPunctuation">
2620                                                 <xsl:with-param name="chopString">
2621                                                         <xsl:call-template name="subfieldSelect">
2622                                                                 <xsl:with-param name="codes">aq</xsl:with-param>
2623                                                         </xsl:call-template>
2624                                                 </xsl:with-param>
2625                                         </xsl:call-template>
2626                                 </namePart>
2627                                 <xsl:call-template name="termsOfAddress"></xsl:call-template>
2628                                 <xsl:call-template name="nameDate"></xsl:call-template>
2629                                 <xsl:call-template name="affiliation"></xsl:call-template>
2630                                 <xsl:call-template name="role"></xsl:call-template>
2631                         </name>
2632                         <xsl:call-template name="subjectAnyOrder"></xsl:call-template>
2633                 </subject>
2634         </xsl:template>
2635         <xsl:template match="marc:datafield[@tag=610]">
2636                 <subject>
2637                         <xsl:call-template name="subjectAuthority"></xsl:call-template>
2638                         <name type="corporate">
2639                                 <xsl:for-each select="marc:subfield[@code='a']">
2640                                         <namePart>
2641                                                 <xsl:value-of select="."></xsl:value-of>
2642                                         </namePart>
2643                                 </xsl:for-each>
2644                                 <xsl:for-each select="marc:subfield[@code='b']">
2645                                         <namePart>
2646                                                 <xsl:value-of select="."></xsl:value-of>
2647                                         </namePart>
2648                                 </xsl:for-each>
2649                                 <xsl:if test="marc:subfield[@code='c' or @code='d' or @code='n' or @code='p']">
2650                                         <namePart>
2651                                                 <xsl:call-template name="subfieldSelect">
2652                                                         <xsl:with-param name="codes">cdnp</xsl:with-param>
2653                                                 </xsl:call-template>
2654                                         </namePart>
2655                                 </xsl:if>
2656                                 <xsl:call-template name="role"></xsl:call-template>
2657                         </name>
2658                         <xsl:call-template name="subjectAnyOrder"></xsl:call-template>
2659                 </subject>
2660         </xsl:template>
2661         <xsl:template match="marc:datafield[@tag=611]">
2662                 <subject>
2663                         <xsl:call-template name="subjectAuthority"></xsl:call-template>
2664                         <name type="conference">
2665                                 <namePart>
2666                                         <xsl:call-template name="subfieldSelect">
2667                                                 <xsl:with-param name="codes">abcdeqnp</xsl:with-param>
2668                                         </xsl:call-template>
2669                                 </namePart>
2670                                 <xsl:for-each select="marc:subfield[@code='4']">
2671                                         <role>
2672                                                 <roleTerm authority="marcrelator" type="code">
2673                                                         <xsl:value-of select="."></xsl:value-of>
2674                                                 </roleTerm>
2675                                         </role>
2676                                 </xsl:for-each>
2677                         </name>
2678                         <xsl:call-template name="subjectAnyOrder"></xsl:call-template>
2679                 </subject>
2680         </xsl:template>
2681         <xsl:template match="marc:datafield[@tag=630]">
2682                 <subject>
2683                         <xsl:call-template name="subjectAuthority"></xsl:call-template>
2684                         <titleInfo>
2685                                 <title>
2686                                         <xsl:call-template name="chopPunctuation">
2687                                                 <xsl:with-param name="chopString">
2688                                                         <xsl:call-template name="subfieldSelect">
2689                                                                 <xsl:with-param name="codes">adfhklor</xsl:with-param>
2690                                                         </xsl:call-template>
2691                                                 </xsl:with-param>
2692                                         </xsl:call-template>
2693                                         <xsl:call-template name="part"></xsl:call-template>
2694                                 </title>
2695                         </titleInfo>
2696                         <xsl:call-template name="subjectAnyOrder"></xsl:call-template>
2697                 </subject>
2698         </xsl:template>
2699         <xsl:template match="marc:datafield[@tag=650]">
2700                 <subject>
2701                         <xsl:call-template name="subjectAuthority"></xsl:call-template>
2702                         <topic>
2703                                 <xsl:call-template name="chopPunctuation">
2704                                         <xsl:with-param name="chopString">
2705                                                 <xsl:call-template name="subfieldSelect">
2706                                                         <xsl:with-param name="codes">abcd</xsl:with-param>
2707                                                 </xsl:call-template>
2708                                         </xsl:with-param>
2709                                 </xsl:call-template>
2710                         </topic>
2711                         <xsl:call-template name="subjectAnyOrder"></xsl:call-template>
2712                 </subject>
2713         </xsl:template>
2714         <xsl:template match="marc:datafield[@tag=651]">
2715                 <subject>
2716                         <xsl:call-template name="subjectAuthority"></xsl:call-template>
2717                         <xsl:for-each select="marc:subfield[@code='a']">
2718                                 <geographic>
2719                                         <xsl:call-template name="chopPunctuation">
2720                                                 <xsl:with-param name="chopString" select="."></xsl:with-param>
2721                                         </xsl:call-template>
2722                                 </geographic>
2723                         </xsl:for-each>
2724                         <xsl:call-template name="subjectAnyOrder"></xsl:call-template>
2725                 </subject>
2726         </xsl:template>
2727         <xsl:template match="marc:datafield[@tag=653]">
2728                 <subject>
2729                         <xsl:for-each select="marc:subfield[@code='a']">
2730                                 <topic>
2731                                         <xsl:value-of select="."></xsl:value-of>
2732                                 </topic>
2733                         </xsl:for-each>
2734                 </subject>
2735         </xsl:template>
2736         <xsl:template match="marc:datafield[@tag=656]">
2737                 <subject>
2738                         <xsl:if test="marc:subfield[@code=2]">
2739                                 <xsl:attribute name="authority">
2740                                         <xsl:value-of select="marc:subfield[@code=2]"></xsl:value-of>
2741                                 </xsl:attribute>
2742                         </xsl:if>
2743                         <occupation>
2744                                 <xsl:call-template name="chopPunctuation">
2745                                         <xsl:with-param name="chopString">
2746                                                 <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
2747                                         </xsl:with-param>
2748                                 </xsl:call-template>
2749                         </occupation>
2750                 </subject>
2751         </xsl:template>
2752         <xsl:template name="termsOfAddress">
2753                 <xsl:if test="marc:subfield[@code='b' or @code='c']">
2754                         <namePart type="termsOfAddress">
2755                                 <xsl:call-template name="chopPunctuation">
2756                                         <xsl:with-param name="chopString">
2757                                                 <xsl:call-template name="subfieldSelect">
2758                                                         <xsl:with-param name="codes">bc</xsl:with-param>
2759                                                 </xsl:call-template>
2760                                         </xsl:with-param>
2761                                 </xsl:call-template>
2762                         </namePart>
2763                 </xsl:if>
2764         </xsl:template>
2765         <xsl:template name="displayLabel">
2766                 <xsl:if test="marc:subfield[@code='i']">
2767                         <xsl:attribute name="displayLabel">
2768                                 <xsl:value-of select="marc:subfield[@code='i']"></xsl:value-of>
2769                         </xsl:attribute>
2770                 </xsl:if>
2771                 <xsl:if test="marc:subfield[@code='3']">
2772                         <xsl:attribute name="displayLabel">
2773                                 <xsl:value-of select="marc:subfield[@code='3']"></xsl:value-of>
2774                         </xsl:attribute>
2775                 </xsl:if>
2776         </xsl:template>
2777         <xsl:template name="isInvalid">
2778                 <xsl:param name="type"/>
2779                 <xsl:if test="marc:subfield[@code='z'] or marc:subfield[@code='y']">
2780                         <identifier>
2781                                 <xsl:attribute name="type">
2782                                         <xsl:value-of select="$type"/>
2783                                 </xsl:attribute>
2784                                 <xsl:attribute name="invalid">
2785                                         <xsl:text>yes</xsl:text>
2786                                 </xsl:attribute>
2787                                 <xsl:if test="marc:subfield[@code='z']">
2788                                         <xsl:value-of select="marc:subfield[@code='z']"/>
2789                                 </xsl:if>
2790                                 <xsl:if test="marc:subfield[@code='y']">
2791                                         <xsl:value-of select="marc:subfield[@code='y']"/>
2792                                 </xsl:if>
2793                         </identifier>
2794                 </xsl:if>
2795         </xsl:template>
2796         <xsl:template name="subtitle">
2797                 <xsl:if test="marc:subfield[@code='b']">
2798                         <subTitle>
2799                                 <xsl:call-template name="chopPunctuation">
2800                                         <xsl:with-param name="chopString">
2801                                                 <xsl:value-of select="marc:subfield[@code='b']"/>
2802                                                 <!--<xsl:call-template name="subfieldSelect">
2803                                                         <xsl:with-param name="codes">b</xsl:with-param>                                                                 
2804                                                 </xsl:call-template>-->
2805                                         </xsl:with-param>
2806                                 </xsl:call-template>
2807                         </subTitle>
2808                 </xsl:if>
2809         </xsl:template>
2810         <xsl:template name="script">
2811                 <xsl:param name="scriptCode"></xsl:param>
2812                 <xsl:attribute name="script">
2813                         <xsl:choose>
2814                                 <xsl:when test="$scriptCode='(3'">Arabic</xsl:when>
2815                                 <xsl:when test="$scriptCode='(B'">Latin</xsl:when>
2816                                 <xsl:when test="$scriptCode='$1'">Chinese, Japanese, Korean</xsl:when>
2817                                 <xsl:when test="$scriptCode='(N'">Cyrillic</xsl:when>
2818                                 <xsl:when test="$scriptCode='(2'">Hebrew</xsl:when>
2819                                 <xsl:when test="$scriptCode='(S'">Greek</xsl:when>
2820                         </xsl:choose>
2821                 </xsl:attribute>
2822         </xsl:template>
2823         <xsl:template name="parsePart">
2824                 <!-- assumes 773$q= 1:2:3<4
2825                      with up to 3 levels and one optional start page
2826                 -->
2827                 <xsl:variable name="level1">
2828                         <xsl:choose>
2829                                 <xsl:when test="contains(text(),':')">
2830                                         <!-- 1:2 -->
2831                                         <xsl:value-of select="substring-before(text(),':')"></xsl:value-of>
2832                                 </xsl:when>
2833                                 <xsl:when test="not(contains(text(),':'))">
2834                                         <!-- 1 or 1<3 -->
2835                                         <xsl:if test="contains(text(),'&lt;')">
2836                                                 <!-- 1<3 -->
2837                                                 <xsl:value-of select="substring-before(text(),'&lt;')"></xsl:value-of>
2838                                         </xsl:if>
2839                                         <xsl:if test="not(contains(text(),'&lt;'))">
2840                                                 <!-- 1 -->
2841                                                 <xsl:value-of select="text()"></xsl:value-of>
2842                                         </xsl:if>
2843                                 </xsl:when>
2844                         </xsl:choose>
2845                 </xsl:variable>
2846                 <xsl:variable name="sici2">
2847                         <xsl:choose>
2848                                 <xsl:when test="starts-with(substring-after(text(),$level1),':')">
2849                                         <xsl:value-of select="substring(substring-after(text(),$level1),2)"></xsl:value-of>
2850                                 </xsl:when>
2851                                 <xsl:otherwise>
2852                                         <xsl:value-of select="substring-after(text(),$level1)"></xsl:value-of>
2853                                 </xsl:otherwise>
2854                         </xsl:choose>
2855                 </xsl:variable>
2856                 <xsl:variable name="level2">
2857                         <xsl:choose>
2858                                 <xsl:when test="contains($sici2,':')">
2859                                         <!--  2:3<4  -->
2860                                         <xsl:value-of select="substring-before($sici2,':')"></xsl:value-of>
2861                                 </xsl:when>
2862                                 <xsl:when test="contains($sici2,'&lt;')">
2863                                         <!-- 1: 2<4 -->
2864                                         <xsl:value-of select="substring-before($sici2,'&lt;')"></xsl:value-of>
2865                                 </xsl:when>
2866                                 <xsl:otherwise>
2867                                         <xsl:value-of select="$sici2"></xsl:value-of>
2868                                         <!-- 1:2 -->
2869                                 </xsl:otherwise>
2870                         </xsl:choose>
2871                 </xsl:variable>
2872                 <xsl:variable name="sici3">
2873                         <xsl:choose>
2874                                 <xsl:when test="starts-with(substring-after($sici2,$level2),':')">
2875                                         <xsl:value-of select="substring(substring-after($sici2,$level2),2)"></xsl:value-of>
2876                                 </xsl:when>
2877                                 <xsl:otherwise>
2878                                         <xsl:value-of select="substring-after($sici2,$level2)"></xsl:value-of>
2879                                 </xsl:otherwise>
2880                         </xsl:choose>
2881                 </xsl:variable>
2882                 <xsl:variable name="level3">
2883                         <xsl:choose>
2884                                 <xsl:when test="contains($sici3,'&lt;')">
2885                                         <!-- 2<4 -->
2886                                         <xsl:value-of select="substring-before($sici3,'&lt;')"></xsl:value-of>
2887                                 </xsl:when>
2888                                 <xsl:otherwise>
2889                                         <xsl:value-of select="$sici3"></xsl:value-of>
2890                                         <!-- 3 -->
2891                                 </xsl:otherwise>
2892                         </xsl:choose>
2893                 </xsl:variable>
2894                 <xsl:variable name="page">
2895                         <xsl:if test="contains(text(),'&lt;')">
2896                                 <xsl:value-of select="substring-after(text(),'&lt;')"></xsl:value-of>
2897                         </xsl:if>
2898                 </xsl:variable>
2899                 <xsl:if test="$level1">
2900                         <detail level="1">
2901                                 <number>
2902                                         <xsl:value-of select="$level1"></xsl:value-of>
2903                                 </number>
2904                         </detail>
2905                 </xsl:if>
2906                 <xsl:if test="$level2">
2907                         <detail level="2">
2908                                 <number>
2909                                         <xsl:value-of select="$level2"></xsl:value-of>
2910                                 </number>
2911                         </detail>
2912                 </xsl:if>
2913                 <xsl:if test="$level3">
2914                         <detail level="3">
2915                                 <number>
2916                                         <xsl:value-of select="$level3"></xsl:value-of>
2917                                 </number>
2918                         </detail>
2919                 </xsl:if>
2920                 <xsl:if test="$page">
2921                         <extent unit="page">
2922                                 <start>
2923                                         <xsl:value-of select="$page"></xsl:value-of>
2924                                 </start>
2925                         </extent>
2926                 </xsl:if>
2927         </xsl:template>
2928         <xsl:template name="getLanguage">
2929                 <xsl:param name="langString"></xsl:param>
2930                 <xsl:param name="controlField008-35-37"></xsl:param>
2931                 <xsl:variable name="length" select="string-length($langString)"></xsl:variable>
2932                 <xsl:choose>
2933                         <xsl:when test="$length=0"></xsl:when>
2934                         <xsl:when test="$controlField008-35-37=substring($langString,1,3)">
2935                                 <xsl:call-template name="getLanguage">
2936                                         <xsl:with-param name="langString" select="substring($langString,4,$length)"></xsl:with-param>
2937                                         <xsl:with-param name="controlField008-35-37" select="$controlField008-35-37"></xsl:with-param>
2938                                 </xsl:call-template>
2939                         </xsl:when>
2940                         <xsl:otherwise>
2941                                 <language>
2942                                         <languageTerm authority="iso639-2b" type="code">
2943                                                 <xsl:value-of select="substring($langString,1,3)"></xsl:value-of>
2944                                         </languageTerm>
2945                                 </language>
2946                                 <xsl:call-template name="getLanguage">
2947                                         <xsl:with-param name="langString" select="substring($langString,4,$length)"></xsl:with-param>
2948                                         <xsl:with-param name="controlField008-35-37" select="$controlField008-35-37"></xsl:with-param>
2949                                 </xsl:call-template>
2950                         </xsl:otherwise>
2951                 </xsl:choose>
2952         </xsl:template>
2953         <xsl:template name="isoLanguage">
2954                 <xsl:param name="currentLanguage"></xsl:param>
2955                 <xsl:param name="usedLanguages"></xsl:param>
2956                 <xsl:param name="remainingLanguages"></xsl:param>
2957                 <xsl:choose>
2958                         <xsl:when test="string-length($currentLanguage)=0"></xsl:when>
2959                         <xsl:when test="not(contains($usedLanguages, $currentLanguage))">
2960                                 <language>
2961                                         <xsl:if test="@code!='a'">
2962                                                 <xsl:attribute name="objectPart">
2963                                                         <xsl:choose>
2964                                                                 <xsl:when test="@code='b'">summary or subtitle</xsl:when>
2965                                                                 <xsl:when test="@code='d'">sung or spoken text</xsl:when>
2966                                                                 <xsl:when test="@code='e'">libretto</xsl:when>
2967                                                                 <xsl:when test="@code='f'">table of contents</xsl:when>
2968                                                                 <xsl:when test="@code='g'">accompanying material</xsl:when>
2969                                                                 <xsl:when test="@code='h'">translation</xsl:when>
2970                                                         </xsl:choose>
2971                                                 </xsl:attribute>
2972                                         </xsl:if>
2973                                         <languageTerm authority="iso639-2b" type="code">
2974                                                 <xsl:value-of select="$currentLanguage"></xsl:value-of>
2975                                         </languageTerm>
2976                                 </language>
2977                                 <xsl:call-template name="isoLanguage">
2978                                         <xsl:with-param name="currentLanguage">
2979                                                 <xsl:value-of select="substring($remainingLanguages,1,3)"></xsl:value-of>
2980                                         </xsl:with-param>
2981                                         <xsl:with-param name="usedLanguages">
2982                                                 <xsl:value-of select="concat($usedLanguages,$currentLanguage)"></xsl:value-of>
2983                                         </xsl:with-param>
2984                                         <xsl:with-param name="remainingLanguages">
2985                                                 <xsl:value-of select="substring($remainingLanguages,4,string-length($remainingLanguages))"></xsl:value-of>
2986                                         </xsl:with-param>
2987                                 </xsl:call-template>
2988                         </xsl:when>
2989                         <xsl:otherwise>
2990                                 <xsl:call-template name="isoLanguage">
2991                                         <xsl:with-param name="currentLanguage">
2992                                                 <xsl:value-of select="substring($remainingLanguages,1,3)"></xsl:value-of>
2993                                         </xsl:with-param>
2994                                         <xsl:with-param name="usedLanguages">
2995                                                 <xsl:value-of select="concat($usedLanguages,$currentLanguage)"></xsl:value-of>
2996                                         </xsl:with-param>
2997                                         <xsl:with-param name="remainingLanguages">
2998                                                 <xsl:value-of select="substring($remainingLanguages,4,string-length($remainingLanguages))"></xsl:value-of>
2999                                         </xsl:with-param>
3000                                 </xsl:call-template>
3001                         </xsl:otherwise>
3002                 </xsl:choose>
3003         </xsl:template>
3004         <xsl:template name="chopBrackets">
3005                 <xsl:param name="chopString"></xsl:param>
3006                 <xsl:variable name="string">
3007                         <xsl:call-template name="chopPunctuation">
3008                                 <xsl:with-param name="chopString" select="$chopString"></xsl:with-param>
3009                         </xsl:call-template>
3010                 </xsl:variable>
3011                 <xsl:if test="substring($string, 1,1)='['">
3012                         <xsl:value-of select="substring($string,2, string-length($string)-2)"></xsl:value-of>
3013                 </xsl:if>
3014                 <xsl:if test="substring($string, 1,1)!='['">
3015                         <xsl:value-of select="$string"></xsl:value-of>
3016                 </xsl:if>
3017         </xsl:template>
3018         <xsl:template name="rfcLanguages">
3019                 <xsl:param name="nodeNum"></xsl:param>
3020                 <xsl:param name="usedLanguages"></xsl:param>
3021                 <xsl:param name="controlField008-35-37"></xsl:param>
3022                 <xsl:variable name="currentLanguage" select="."></xsl:variable>
3023                 <xsl:choose>
3024                         <xsl:when test="not($currentLanguage)"></xsl:when>
3025                         <xsl:when test="$currentLanguage!=$controlField008-35-37 and $currentLanguage!='rfc3066'">
3026                                 <xsl:if test="not(contains($usedLanguages,$currentLanguage))">
3027                                         <language>
3028                                                 <xsl:if test="@code!='a'">
3029                                                         <xsl:attribute name="objectPart">
3030                                                                 <xsl:choose>
3031                                                                         <xsl:when test="@code='b'">summary or subtitle</xsl:when>
3032                                                                         <xsl:when test="@code='d'">sung or spoken text</xsl:when>
3033                                                                         <xsl:when test="@code='e'">libretto</xsl:when>
3034                                                                         <xsl:when test="@code='f'">table of contents</xsl:when>
3035                                                                         <xsl:when test="@code='g'">accompanying material</xsl:when>
3036                                                                         <xsl:when test="@code='h'">translation</xsl:when>
3037                                                                 </xsl:choose>
3038                                                         </xsl:attribute>
3039                                                 </xsl:if>
3040                                                 <languageTerm authority="rfc3066" type="code">
3041                                                         <xsl:value-of select="$currentLanguage"/>
3042                                                 </languageTerm>
3043                                         </language>
3044                                 </xsl:if>
3045                         </xsl:when>
3046                         <xsl:otherwise>
3047                         </xsl:otherwise>
3048                 </xsl:choose>
3049         </xsl:template>
3050 </xsl:stylesheet>