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