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