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