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