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