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