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