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