Fix Metaproxy stops logging after check config failed MP-590
[metaproxy-moved-to-github.git] / xml / xslt / MARC21slim2MADS.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <xsl:stylesheet version="1.0" xmlns="http://www.loc.gov/mods/v3" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="marc">
3   
4   <xsl:include href="http://www.loc.gov/marcxml/xslt/MARC21slimUtils.xsl"/>
5   <xsl:output method="xml" indent="yes" encoding="UTF-8"/>
6
7   <!--
8       adapted from MARC21Slim2MODS3.xsl ntra 7/6/05
9       revised rsg/jer 11/29/05
10   -->
11
12   <!-- authority attribute defaults to 'naf' if not set using this authority parameter, for <authority> descriptors: name, titleInfo, geographic -->
13   <xsl:param name="authority"/>
14   <xsl:variable name="auth">
15     <xsl:choose>
16       <xsl:when test="$authority">
17         <xsl:value-of select="$authority"/>
18       </xsl:when>
19       <xsl:otherwise>naf</xsl:otherwise>
20     </xsl:choose>
21   </xsl:variable>
22   <xsl:variable name="controlField008-11" select="substring(descendant-or-self::marc:controlfield[@tag=008],12,1)"/>
23   <xsl:variable name="controlField008-14" select="substring(descendant-or-self::marc:controlfield[@tag=008],15,1)"/>
24   <xsl:template match="/">
25     <xsl:choose>
26       <xsl:when test="descendant-or-self::marc:collection">
27         <madsCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/mads http://www.loc.gov/standards/mads/mads.xsd">
28           <xsl:for-each select="descendant-or-self::marc:collection/marc:record">
29             <mads version="beta">
30               <xsl:call-template name="marcRecord"/>
31             </mads>
32           </xsl:for-each>
33         </madsCollection>
34       </xsl:when>
35       <xsl:otherwise>
36         <mads version="beta" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/mads http://www.loc.gov/standards/mads/mads.xsd">
37           <xsl:for-each select="descendant-or-self::marc:record">
38             <xsl:call-template name="marcRecord"/>
39           </xsl:for-each>
40         </mads>
41       </xsl:otherwise>
42     </xsl:choose>
43   </xsl:template>
44
45   <xsl:template name="marcRecord">              
46     <xsl:if test="contains(marc:datafield[@tag='035'],'tea2003000479')">
47
48     </xsl:if>           
49     <authority>
50       <xsl:apply-templates select="marc:datafield[100 &lt;= @tag  and @tag &lt; 200]"/>
51     </authority>
52     <!-- related -->
53     <xsl:apply-templates select="marc:datafield[500 &lt;= @tag and @tag &lt;= 585]|marc:datafield[700 &lt;= @tag and @tag &lt;= 785]"/>
54
55     <!-- variant -->
56     <xsl:apply-templates select="marc:datafield[400 &lt;= @tag and @tag &lt;= 485]"/>
57     <!-- notes -->
58     <xsl:apply-templates select="marc:datafield[667 &lt;= @tag and @tag &lt;= 688]"/>
59     <!-- url -->
60     <xsl:apply-templates select="marc:datafield[@tag=856]"/>
61     <recordInfo>
62       <xsl:apply-templates select="marc:datafield[@tag=010]"/>
63       <xsl:apply-templates select="marc:datafield[@tag=024]"/>
64       <xsl:apply-templates select="marc:datafield[@tag=040]/marc:subfield[@code='a']"/>
65       <xsl:apply-templates select="marc:controlfield[@tag=008]"/>
66       <xsl:apply-templates select="marc:controlfield[@tag=005]"/>
67       <xsl:apply-templates select="marc:controlfield[@tag=001]"/>
68       <xsl:apply-templates select="marc:datafield[@tag=040]/marc:subfield[@code='b']"/>
69     </recordInfo>
70   </xsl:template>
71
72   <!-- start of secondary templates -->
73
74   <!-- ======== xlink ======== -->
75
76    <!-- <xsl:template name="uri"> 
77     <xsl:for-each select="marc:subfield[@code='0']">
78       <xsl:attribute name="xlink:href">
79         <xsl:value-of select="."/>
80       </xsl:attribute>
81     </xsl:for-each>
82      </xsl:template> 
83    -->
84   <xsl:template match="marc:subfield[@code='i']">
85     <xsl:attribute name="type">
86       <xsl:value-of select="."/>
87     </xsl:attribute>
88   </xsl:template>
89
90   <xsl:template name="role">
91     <xsl:for-each select="marc:subfield[@code='e']">
92       <role>
93         <roleTerm type="text">
94           <xsl:value-of select="."/>
95         </roleTerm>
96       </role>
97     </xsl:for-each>
98   </xsl:template>
99
100   <xsl:template name="part">
101     <xsl:variable name="partNumber">
102       <xsl:call-template name="specialSubfieldSelect">
103         <xsl:with-param name="axis">n</xsl:with-param>
104         <xsl:with-param name="anyCodes">n</xsl:with-param>
105         <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
106       </xsl:call-template>
107     </xsl:variable>
108     <xsl:variable name="partName">
109       <xsl:call-template name="specialSubfieldSelect">
110         <xsl:with-param name="axis">p</xsl:with-param>
111         <xsl:with-param name="anyCodes">p</xsl:with-param>
112         <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
113       </xsl:call-template>
114     </xsl:variable>
115     <xsl:if test="string-length(normalize-space($partNumber))">
116       <partNumber>
117         <xsl:call-template name="chopPunctuation">
118           <xsl:with-param name="chopString" select="$partNumber"/>
119         </xsl:call-template>
120       </partNumber>
121     </xsl:if>
122     <xsl:if test="string-length(normalize-space($partName))">
123       <partName>
124         <xsl:call-template name="chopPunctuation">
125           <xsl:with-param name="chopString" select="$partName"/>
126         </xsl:call-template>
127       </partName>
128     </xsl:if>
129   </xsl:template>
130
131   <xsl:template name="nameABCDN">
132     <xsl:for-each select="marc:subfield[@code='a']">
133       <namePart>
134         <xsl:call-template name="chopPunctuation">
135           <xsl:with-param name="chopString" select="."/>
136         </xsl:call-template>
137       </namePart>
138     </xsl:for-each>
139     <xsl:for-each select="marc:subfield[@code='b']">
140       <namePart>
141         <xsl:value-of select="."/>
142       </namePart>
143     </xsl:for-each>
144     <xsl:if test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">
145       <namePart>
146         <xsl:call-template name="subfieldSelect">
147           <xsl:with-param name="codes">cdn</xsl:with-param>
148         </xsl:call-template>
149       </namePart>
150     </xsl:if>
151   </xsl:template>
152
153   <xsl:template name="nameABCDQ">
154     <namePart>
155       <xsl:call-template name="chopPunctuation">
156         <xsl:with-param name="chopString">
157           <xsl:call-template name="subfieldSelect">
158             <xsl:with-param name="codes">aq</xsl:with-param>
159           </xsl:call-template>
160         </xsl:with-param>
161       </xsl:call-template>
162     </namePart>
163     <xsl:call-template name="termsOfAddress"/>
164     <xsl:call-template name="nameDate"/>
165   </xsl:template>
166
167   <xsl:template name="nameACDENQ">
168     <namePart>
169       <xsl:call-template name="subfieldSelect">
170         <xsl:with-param name="codes">acdenq</xsl:with-param>
171       </xsl:call-template>
172     </namePart>
173   </xsl:template>
174
175   <xsl:template name="nameDate">
176     <xsl:for-each select="marc:subfield[@code='d']">
177       <namePart type="date">
178         <xsl:call-template name="chopPunctuation">
179           <xsl:with-param name="chopString" select="."/>
180         </xsl:call-template>
181       </namePart>
182     </xsl:for-each>
183   </xsl:template>
184
185   <xsl:template name="specialSubfieldSelect">
186     <xsl:param name="anyCodes"/>
187     <xsl:param name="axis"/>
188     <xsl:param name="beforeCodes"/>
189     <xsl:param name="afterCodes"/>
190     <xsl:variable name="str">
191       <xsl:for-each select="marc:subfield">
192         <xsl:if test="contains($anyCodes, @code)      or (contains($beforeCodes,@code) and following-sibling::marc:subfield[@code=$axis])      or (contains($afterCodes,@code) and preceding-sibling::marc:subfield[@code=$axis])">
193           <xsl:value-of select="text()"/>
194           <xsl:text> </xsl:text>
195         </xsl:if>
196       </xsl:for-each>
197     </xsl:variable>
198     <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
199   </xsl:template>
200
201   <xsl:template name="termsOfAddress">
202     <xsl:if test="marc:subfield[@code='b' or @code='c']">
203       <namePart type="termsOfAddress">
204         <xsl:call-template name="chopPunctuation">
205           <xsl:with-param name="chopString">
206             <xsl:call-template name="subfieldSelect">
207               <xsl:with-param name="codes">bc</xsl:with-param>
208             </xsl:call-template>
209           </xsl:with-param>
210         </xsl:call-template>
211       </namePart>
212     </xsl:if>
213   </xsl:template>
214
215   <xsl:template name="displayLabel">
216     <xsl:if test="marc:subfield[@code='z']">
217       <xsl:attribute name="displayLabel">
218         <xsl:value-of select="marc:subfield[@code='z']"/>
219       </xsl:attribute>
220     </xsl:if>
221     <xsl:if test="marc:subfield[@code='3']">
222       <xsl:attribute name="displayLabel">
223         <xsl:value-of select="marc:subfield[@code='3']"/>
224       </xsl:attribute>
225     </xsl:if>
226   </xsl:template>
227
228   <xsl:template name="isInvalid">
229     <xsl:if test="marc:subfield[@code='z']">
230       <xsl:attribute name="invalid">yes</xsl:attribute>
231     </xsl:if>
232   </xsl:template>
233
234   <xsl:template name="sub2Attribute">
235     <!-- 024 -->
236     <xsl:if test="marc:subfield[@code='2']">
237       <xsl:attribute name="type">
238         <xsl:value-of select="marc:subfield[@code='2']"/>
239       </xsl:attribute>
240     </xsl:if>
241   </xsl:template>
242   <xsl:template match="marc:controlfield[@tag=001]">
243     <recordIdentifier>
244       <xsl:if test="../marc:controlfield[@tag=003]">
245         <xsl:attribute name="source">
246           <xsl:value-of select="../marc:controlfield[@tag=003]"/>
247         </xsl:attribute>
248       </xsl:if>
249       <xsl:value-of select="."/>
250     </recordIdentifier>
251   </xsl:template>
252
253   <xsl:template match="marc:controlfield[@tag=005]">
254     <recordChangeDate encoding="iso8601">
255       <xsl:value-of select="."/>
256     </recordChangeDate>
257   </xsl:template>
258
259   <xsl:template match="marc:controlfield[@tag=008]">
260     <recordCreationDate encoding="marc">
261       <xsl:value-of select="substring(.,1,6)"/>
262     </recordCreationDate>
263   </xsl:template>
264
265   <xsl:template match="marc:datafield[@tag=010]">
266     <identifier>
267       <xsl:call-template name="isInvalid"/>
268       <xsl:call-template name="sub2Attribute"/>
269       <xsl:value-of select="marc:subfield[@code='a']"/>
270     </identifier>
271   </xsl:template>
272
273   <xsl:template match="marc:datafield[@tag=024]">
274     <identifier>
275       <xsl:call-template name="isInvalid"/>
276       <xsl:call-template name="sub2Attribute"/>
277       <xsl:value-of select="marc:subfield[@code='a']"/>
278     </identifier>
279   </xsl:template>
280
281   <xsl:template match="marc:datafield[@tag=040]/marc:subfield[@code='a']">
282     <recordContentSource authority="marcorg">
283       <xsl:value-of select="."/>
284     </recordContentSource>
285   </xsl:template>
286
287   <xsl:template match="marc:datafield[@tag=040]/marc:subfield[@code='b']">
288     <languageOfCataloging>
289       <languageTerm authority="iso639-2b" type="code">
290         <xsl:value-of select="."/>
291       </languageTerm>
292     </languageOfCataloging>
293   </xsl:template>
294   
295   <!-- ========== names  ========== -->
296   <xsl:template match="marc:datafield[@tag=100]">
297     <name type="personal">                      
298       <xsl:call-template name="setAuthority"/>
299       <xsl:call-template name="nameABCDQ"/>
300       <xsl:call-template name="role"/>          
301     </name>
302     <xsl:apply-templates select="*[marc:subfield[not(contains('abcdeq',@code))]]"/>
303     <xsl:call-template name="title"/>
304     <xsl:apply-templates/>
305   </xsl:template>
306
307   <xsl:template match="marc:datafield[@tag=110]">
308     <name type="corporate">
309       <xsl:call-template name="setAuthority"/>
310       <xsl:call-template name="nameABCDN"/>
311       <xsl:call-template name="role"/>
312     </name>
313     <xsl:apply-templates/>
314   </xsl:template>
315
316   <xsl:template match="marc:datafield[@tag=111]">
317     <name type="conference">
318       <xsl:call-template name="setAuthority"/>                  
319       <xsl:call-template name="nameACDENQ"/>
320     </name>
321     <xsl:apply-templates/>
322   </xsl:template>
323
324   <xsl:template match="marc:datafield[@tag=400]">
325     <variant>
326       <xsl:call-template name="variantTypeAttribute"/>
327       <name type="personal">
328         <xsl:call-template name="nameABCDQ"/>
329         <xsl:call-template name="role"/>
330       </name>
331       <xsl:apply-templates/>
332       <xsl:call-template name="title"/>
333     </variant>
334   </xsl:template>
335
336   <xsl:template match="marc:datafield[@tag=410]">
337     <variant>
338       <xsl:call-template name="variantTypeAttribute"/>
339       <name type="corporate">
340         <xsl:call-template name="nameABCDN"/>
341         <xsl:call-template name="role"/>                                
342       </name>
343       <xsl:apply-templates/>
344     </variant>
345   </xsl:template>
346
347   <xsl:template match="marc:datafield[@tag=411]">
348     <variant>
349       <xsl:call-template name="variantTypeAttribute"/>
350       <name type="conference">
351         <xsl:call-template name="nameACDENQ"/>
352       </name>
353       <xsl:apply-templates/>
354     </variant>
355   </xsl:template>
356
357   <xsl:template match="marc:datafield[@tag=500]|marc:datafield[@tag=700]">
358     <related>
359       <xsl:call-template name="relatedTypeAttribute"/>
360       <!-- <xsl:call-template name="uri"/> -->          
361       <name type="personal">
362         <xsl:call-template name="setAuthority"/>                                                                
363         <xsl:call-template name="nameABCDQ"/>
364         <xsl:call-template name="role"/>                                
365       </name>
366       <xsl:call-template name="title"/>
367       <xsl:apply-templates/>
368     </related>
369   </xsl:template>
370
371   <xsl:template match="marc:datafield[@tag=510]|marc:datafield[@tag=710]">
372     <related>
373       <xsl:call-template name="relatedTypeAttribute"/>
374       <!-- <xsl:call-template name="uri"/> -->
375       <name type="corporate">
376         <xsl:call-template name="setAuthority"/>
377         <xsl:call-template name="nameABCDN"/>
378         <xsl:call-template name="role"/>
379       </name>
380       <xsl:apply-templates/>
381     </related>
382   </xsl:template>
383
384   <xsl:template match="marc:datafield[@tag=511]|marc:datafield[@tag=711]">
385     <related>
386       <xsl:call-template name="relatedTypeAttribute"/>
387       <!-- <xsl:call-template name="uri"/> -->
388       <name type="conference">
389         <xsl:call-template name="setAuthority"/>
390         <xsl:call-template name="nameACDENQ"/>
391       </name>
392       <xsl:apply-templates/>
393     </related>
394   </xsl:template>
395
396   <!-- ========== titles  ========== -->
397   <xsl:template match="marc:datafield[@tag=130]">
398     <xsl:call-template name="uniform-title"/>
399     <xsl:apply-templates/>
400   </xsl:template>
401
402   <xsl:template match="marc:datafield[@tag=430]">
403     <variant>
404       <xsl:call-template name="variantTypeAttribute"/>
405       <xsl:call-template name="uniform-title"/>
406       <xsl:apply-templates/>
407     </variant>
408   </xsl:template>
409
410   <xsl:template match="marc:datafield[@tag=530]|marc:datafield[@tag=730]">
411     <related>
412       <xsl:call-template name="relatedTypeAttribute"/>                  
413       <xsl:call-template name="uniform-title"/>
414       <xsl:apply-templates/>
415     </related>
416   </xsl:template>
417
418   <xsl:template name="title">
419     <titleInfo>
420       <xsl:call-template name="setAuthority"/>
421       <title>
422         <xsl:variable name="str">
423           <xsl:for-each select="marc:subfield">
424             <xsl:if test="(contains('tfghklmors',@code) )">
425               <xsl:value-of select="text()"/>
426               <xsl:text> </xsl:text>
427             </xsl:if>
428           </xsl:for-each>
429         </xsl:variable>
430
431         <xsl:call-template name="chopPunctuation">
432           <xsl:with-param name="chopString">
433             <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
434           </xsl:with-param>
435         </xsl:call-template>
436       </title>
437       <xsl:call-template name="part"/>
438       <!-- <xsl:call-template name="uri"/> -->
439     </titleInfo>
440   </xsl:template>
441
442   <xsl:template name="uniform-title">
443     <titleInfo>
444       <xsl:call-template name="setAuthority"/>
445       <title>
446         <xsl:variable name="str">
447           <xsl:for-each select="marc:subfield">
448             <xsl:if test="(contains('adfghklmors',@code) )">
449               <xsl:value-of select="text()"/>
450               <xsl:text> </xsl:text>
451             </xsl:if>
452           </xsl:for-each>
453         </xsl:variable>
454
455         <xsl:call-template name="chopPunctuation">
456           <xsl:with-param name="chopString">
457             <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
458           </xsl:with-param>
459         </xsl:call-template>
460       </title>
461       <xsl:call-template name="part"/>
462       <!-- <xsl:call-template name="uri"/> -->
463     </titleInfo>
464   </xsl:template>
465
466
467   <!-- ========== topics  ========== -->
468   <xsl:template match="marc:subfield[@code='x']">               
469     <topic>
470       <xsl:call-template name="chopPunctuation">
471         <xsl:with-param name="chopString">
472           <xsl:value-of select="."/>
473         </xsl:with-param>
474       </xsl:call-template>
475     </topic>
476   </xsl:template>
477   
478   <xsl:template match="marc:datafield[@tag=150][marc:subfield[@code='a' or @code='b']]|marc:datafield[@tag=180][marc:subfield[@code='x']]">
479     <xsl:call-template name="topic"/>
480   </xsl:template>
481
482   <xsl:template match="marc:datafield[@tag=450][marc:subfield[@code='a' or @code='b']]|marc:datafield[@tag=480][marc:subfield[@code='x']]">
483     <variant>
484       <xsl:call-template name="variantTypeAttribute"/>
485       <xsl:call-template name="topic"/>
486     </variant>
487   </xsl:template>
488   
489   <xsl:template match="marc:datafield[@tag=550 or @tag=750][marc:subfield[@code='a' or @code='b']]">
490     <related>                   
491       <xsl:call-template name="relatedTypeAttribute"/>
492       <!-- <xsl:call-template name="uri"/> -->
493       <xsl:call-template name="topic"/>
494     </related>
495   </xsl:template> 
496
497   <xsl:template name="topic">
498     <topic>                             
499       <xsl:if test="@tag=550 or @tag=750">
500         <xsl:call-template name="subfieldSelect">
501           <xsl:with-param name="codes">ab</xsl:with-param>
502         </xsl:call-template>
503       </xsl:if>
504       <xsl:call-template name="setAuthority"/>
505       <xsl:call-template name="chopPunctuation">
506         <xsl:with-param name="chopString">
507           <xsl:choose>
508             <xsl:when test="@tag=180 or @tag=480 or @tag=580 or @tag=780">
509               <xsl:apply-templates select="marc:subfield[@code='x']"/>
510             </xsl:when>
511             <xsl:otherwise>
512               <xsl:call-template name="subfieldSelect">
513                 <xsl:with-param name="codes">ab</xsl:with-param>
514               </xsl:call-template>
515             </xsl:otherwise>
516           </xsl:choose>
517         </xsl:with-param>
518       </xsl:call-template>
519     </topic>
520     <xsl:apply-templates/>
521   </xsl:template>
522
523   <!-- ========= temporals  ========== -->
524
525   <xsl:template match="marc:subfield[@code='y']">
526     <temporal>
527       <xsl:call-template name="chopPunctuation">
528         <xsl:with-param name="chopString">
529           <xsl:value-of select="."/>
530         </xsl:with-param>
531       </xsl:call-template>
532     </temporal>
533   </xsl:template>
534   
535   <xsl:template match="marc:datafield[@tag=148][marc:subfield[@code='a']]|marc:datafield[@tag=182 ][marc:subfield[@code='y']]">
536     <xsl:call-template name="temporal"/>
537   </xsl:template>
538
539   <xsl:template match="marc:datafield[@tag=448][marc:subfield[@code='a']]|marc:datafield[@tag=482][marc:subfield[@code='y']]">
540     <variant>
541       <xsl:call-template name="variantTypeAttribute"/>
542       <xsl:call-template name="temporal"/>
543     </variant>
544   </xsl:template>
545   
546   <xsl:template match="marc:datafield[@tag=548 or @tag=748][marc:subfield[@code='a']]|marc:datafield[@tag=582 or @tag=782][marc:subfield[@code='y']]">
547     <related>
548       <xsl:call-template name="relatedTypeAttribute"/>
549       <!-- <xsl:call-template name="uri"/> -->
550       <xsl:call-template name="temporal"/>
551     </related>
552   </xsl:template>
553   
554   <xsl:template name="temporal">
555     <temporal>
556       <xsl:if test="@tag=548 or @tag=748">
557         <xsl:value-of select="marc:subfield[@code='a']"/>
558       </xsl:if>
559       <xsl:call-template name="setAuthority"/>
560       <xsl:call-template name="chopPunctuation">
561         <xsl:with-param name="chopString">
562           <xsl:choose>
563             <xsl:when test="@tag=182 or @tag=482 or @tag=582 or @tag=782">
564               <xsl:apply-templates select="marc:subfield[@code='y']"/>
565             </xsl:when>
566             <xsl:otherwise>
567               <xsl:value-of select="marc:subfield[@code='a']"/>
568             </xsl:otherwise>
569           </xsl:choose> 
570         </xsl:with-param>
571       </xsl:call-template>
572     </temporal>
573     <xsl:apply-templates/>
574   </xsl:template>
575
576   <!-- ========== genre  ========== -->
577   <xsl:template match="marc:subfield[@code='v']">
578     <genre>
579       <xsl:call-template name="chopPunctuation">
580         <xsl:with-param name="chopString">
581           <xsl:value-of select="."/>
582         </xsl:with-param>
583       </xsl:call-template>
584     </genre>
585   </xsl:template>
586
587   <xsl:template match="marc:datafield[@tag=155][marc:subfield[@code='a']]|marc:datafield[@tag=185][marc:subfield[@code='v']]">
588     <xsl:call-template name="genre"/>
589   </xsl:template>
590
591   <xsl:template match="marc:datafield[@tag=455][marc:subfield[@code='a']]|marc:datafield[@tag=485 ][marc:subfield[@code='v']]">
592     <variant>
593       <xsl:call-template name="variantTypeAttribute"/>
594       <xsl:call-template name="genre"/>
595     </variant>
596   </xsl:template>
597
598   <xsl:template match="marc:datafield[@tag=555]">
599     <related>
600       <xsl:call-template name="relatedTypeAttribute"/>
601       <!-- <xsl:call-template name="uri"/> -->
602       <xsl:call-template name="genre"/>
603     </related>
604   </xsl:template>
605
606   <xsl:template match="marc:datafield[@tag=555 or @tag=755][marc:subfield[@code='a']]|marc:datafield[@tag=585][marc:subfield[@code='v']]">
607     <related>
608       <xsl:call-template name="relatedTypeAttribute"/>
609       <xsl:call-template name="genre"/>
610     </related>
611   </xsl:template>
612
613   <xsl:template name="genre">
614     <genre>
615       <xsl:if test="@tag=555">
616         <xsl:value-of select="marc:subfield[@code='a']"/>
617       </xsl:if>
618       <xsl:call-template name="setAuthority"/>
619       <xsl:call-template name="chopPunctuation">
620         <xsl:with-param name="chopString">
621           <xsl:choose>
622             <xsl:when test="@tag=185 or @tag=485 or @tag=585">
623               <xsl:apply-templates select="marc:subfield[@code='v']"/>
624             </xsl:when>
625             <xsl:otherwise>
626               <xsl:value-of select="marc:subfield[@code='a']"/>
627             </xsl:otherwise>
628           </xsl:choose>
629         </xsl:with-param>
630       </xsl:call-template>                                      
631     </genre>
632     <xsl:apply-templates/>
633   </xsl:template> 
634   
635   <!-- ========= geographic  ========== -->
636   <xsl:template match="marc:subfield[@code='z']">
637     <geographic>
638       <xsl:call-template name="chopPunctuation">
639         <xsl:with-param name="chopString">
640           <xsl:value-of select="."/>
641         </xsl:with-param>
642       </xsl:call-template>
643     </geographic>
644   </xsl:template>
645
646   <xsl:template name="geographic">              
647     <geographic>                                        
648       <xsl:if test="@tag=551">
649         <xsl:value-of select="marc:subfield[@code='a']"/>
650       </xsl:if> 
651       <xsl:call-template name="setAuthority"/>
652       <xsl:call-template name="chopPunctuation">
653         <xsl:with-param name="chopString">
654           <xsl:choose>
655             <xsl:when test="@tag=181 or @tag=481 or @tag=581">
656               <xsl:apply-templates select="marc:subfield[@code='z']"/>
657             </xsl:when>
658             <xsl:otherwise>
659               <xsl:value-of select="marc:subfield[@code='a']"/>
660             </xsl:otherwise>
661           </xsl:choose>
662         </xsl:with-param>
663       </xsl:call-template>                                              
664     </geographic>
665     <xsl:apply-templates/>
666   </xsl:template>
667
668   <xsl:template match="marc:datafield[@tag=151][marc:subfield[@code='a']]|marc:datafield[@tag=181][marc:subfield[@code='z']]">
669     <xsl:call-template name="geographic"/>
670   </xsl:template>
671
672   <xsl:template match="marc:datafield[@tag=451][marc:subfield[@code='a']]|marc:datafield[@tag=481][marc:subfield[@code='z']]">
673     <variant>
674       <xsl:call-template name="variantTypeAttribute"/>
675       <xsl:call-template name="geographic"/>                    
676     </variant>
677   </xsl:template>
678
679   <xsl:template match="marc:datafield[@tag=551]|marc:datafield[@tag=581][marc:subfield[@code='z']]">
680     <related>
681       <xsl:call-template name="relatedTypeAttribute"/>
682       <!-- <xsl:call-template name="uri"/> -->
683       <xsl:call-template name="geographic"/>
684     </related>
685   </xsl:template>
686
687   <xsl:template match="marc:datafield[@tag=580]">
688     <related>
689       <xsl:call-template name="relatedTypeAttribute"/>
690       <xsl:apply-templates/>
691     </related>
692   </xsl:template>
693
694   <xsl:template match="marc:datafield[@tag=751][marc:subfield[@code='z']]|marc:datafield[@tag=781][marc:subfield[@code='z']]">
695     <related>
696       <xsl:call-template name="relatedTypeAttribute"/>
697       <xsl:call-template name="geographic"/>    
698     </related>
699   </xsl:template>
700
701   <xsl:template match="marc:datafield[@tag=755]">
702     <related>
703       <xsl:call-template name="relatedTypeAttribute"/>
704       <xsl:call-template name="genre"/> 
705       <xsl:call-template name="setAuthority"/>
706       <xsl:apply-templates/>
707     </related>
708   </xsl:template> 
709
710   <xsl:template match="marc:datafield[@tag=780]">
711     <related>
712       <xsl:call-template name="relatedTypeAttribute"/>
713       <xsl:apply-templates/>
714     </related>
715   </xsl:template>
716
717   <xsl:template match="marc:datafield[@tag=785]">
718     <related>
719       <xsl:call-template name="relatedTypeAttribute"/>
720       <xsl:apply-templates/>
721     </related>
722   </xsl:template>
723
724   <!-- ========== notes  ========== -->
725   <xsl:template match="marc:datafield[667 &lt;= @tag and @tag &lt;= 688]">
726     <note>
727       <xsl:choose>
728         <xsl:when test="@tag=667">
729           <xsl:attribute name="type">nonpublic</xsl:attribute>
730         </xsl:when>
731         <xsl:when test="@tag=670">
732           <xsl:attribute name="type">source</xsl:attribute>
733         </xsl:when>
734         <xsl:when test="@tag=675">
735           <xsl:attribute name="type">notFound</xsl:attribute>
736         </xsl:when>
737         <xsl:when test="@tag=678">
738           <xsl:attribute name="type">history</xsl:attribute>
739         </xsl:when>
740         <xsl:when test="@tag=681">
741           <xsl:attribute name="type">subject example</xsl:attribute>
742         </xsl:when>
743         <xsl:when test="@tag=682">
744           <xsl:attribute name="type">deleted heading information</xsl:attribute>
745         </xsl:when>
746         <xsl:when test="@tag=688">
747           <xsl:attribute name="type">application history</xsl:attribute>
748         </xsl:when>
749       </xsl:choose>
750       <xsl:call-template name="chopPunctuation">
751         <xsl:with-param name="chopString">
752           <xsl:choose>
753             <xsl:when test="@tag=667 or @tag=675">
754               <xsl:value-of select="marc:subfield[@code='a']"/>
755             </xsl:when>
756             <xsl:when test="@tag=670 or @tag=678">
757               <xsl:call-template name="subfieldSelect">
758                 <xsl:with-param name="codes">ab</xsl:with-param>
759               </xsl:call-template>
760             </xsl:when>
761             <xsl:when test="680 &lt;= @tag and @tag &lt;=688">
762               <xsl:call-template name="subfieldSelect">
763                 <xsl:with-param name="codes">ai</xsl:with-param>
764               </xsl:call-template>
765             </xsl:when>
766           </xsl:choose>
767         </xsl:with-param>
768       </xsl:call-template>
769     </note>
770   </xsl:template>
771   <!-- ========== url  ========== -->
772   <xsl:template match="marc:datafield[@tag=856][marc:subfield[@code='u']]">
773     <url>
774       <xsl:if test="marc:subfield[@code='z' or @code='3']">
775         <xsl:attribute name="displayLabel">
776           <xsl:call-template name="subfieldSelect">
777             <xsl:with-param name="codes">z3</xsl:with-param>
778           </xsl:call-template>
779         </xsl:attribute>
780       </xsl:if>
781       <xsl:value-of select="marc:subfield[@code='u']"/>
782     </url>
783   </xsl:template>
784
785   <xsl:template name="relatedTypeAttribute">
786     <xsl:choose>
787       <xsl:when test="@tag=500 or @tag=510 or @tag=511 or @tag=548 or @tag=550 or @tag=551 or @tag=555 or @tag=580 or @tag=581 or @tag=582 or @tag=585">
788         <xsl:if test="substring(marc:subfield[@code='w'],1,1)='a'">
789           <xsl:attribute name="type">earlier</xsl:attribute>
790         </xsl:if>
791         <xsl:if test="substring(marc:subfield[@code='w'],1,1)='b'">
792           <xsl:attribute name="type">later</xsl:attribute>
793         </xsl:if>
794         <xsl:if test="substring(marc:subfield[@code='w'],1,1)='t'">
795           <xsl:attribute name="type">parentOrg</xsl:attribute>
796         </xsl:if>
797         <xsl:if test="substring(marc:subfield[@code='w'],1,1)='g'">
798           <xsl:attribute name="type">broader</xsl:attribute>
799         </xsl:if>
800         <xsl:if test="substring(marc:subfield[@code='w'],1,1)='h'">
801           <xsl:attribute name="type">narrower</xsl:attribute>
802         </xsl:if>
803         <xsl:if test="contains('fin|', substring(marc:subfield[@code='w'],1,1))">
804           <xsl:attribute name="type">other</xsl:attribute>
805         </xsl:if>
806       </xsl:when>
807       <xsl:when test="@tag=530 or @tag=730">
808         <xsl:attribute name="type">other</xsl:attribute>
809       </xsl:when>
810       <xsl:otherwise>
811         <!-- 7xx -->
812         <xsl:attribute name="type">equivalent</xsl:attribute>
813       </xsl:otherwise>
814     </xsl:choose>
815     <xsl:apply-templates select="marc:subfield[@code='i']"/>
816   </xsl:template>
817
818   <xsl:template name="variantTypeAttribute">
819     <xsl:choose>
820       <xsl:when test="@tag=400 or @tag=410 or @tag=411 or @tag=451 or @tag=455 or @tag=480 or @tag=481 or @tag=482 or @tag=485">
821         <xsl:if test="substring(marc:subfield[@code='w'],1,1)='d'">
822           <xsl:attribute name="type">acronym</xsl:attribute>
823         </xsl:if>
824         <xsl:if test="contains('fit', substring(marc:subfield[@code='w'],1,1))">
825           <xsl:attribute name="type">other</xsl:attribute>
826         </xsl:if>
827       </xsl:when>
828       <xsl:otherwise>
829         <!-- 430  -->
830         <xsl:attribute name="type">other</xsl:attribute>
831       </xsl:otherwise>
832     </xsl:choose>
833     <xsl:apply-templates select="marc:subfield[@code='i']"/>
834   </xsl:template>
835   <xsl:template name="setAuthority">
836     <xsl:choose>
837       <!-- can be called from the datafield or subfield level, so "..//@tag" means
838            the tag can be at the subfield's parent level or at the datafields own level -->
839       <xsl:when test="ancestor-or-self::marc:datafield/@tag=100 and (@ind1=0 or @ind1=1) and $controlField008-11='a' and $controlField008-14='a'">   
840         <xsl:attribute name="authority"><xsl:text>naf</xsl:text></xsl:attribute>
841       </xsl:when>
842       <xsl:when test="ancestor-or-self::marc:datafield/@tag=100 and (@ind1=0 or @ind1=1) and $controlField008-11='a' and $controlField008-14='b'">   
843         <xsl:attribute name="authority"><xsl:text>lcsh</xsl:text></xsl:attribute>
844       </xsl:when>
845       <xsl:when test="ancestor-or-self::marc:datafield/@tag=100 and (@ind1=0 or @ind1=1) and $controlField008-11='k'">   
846         <xsl:attribute name="authority"><xsl:text>lacnaf</xsl:text></xsl:attribute>
847       </xsl:when>   
848       <xsl:when test="ancestor-or-self::marc:datafield/@tag=100 and @ind1=3 and $controlField008-11='a' and $controlField008-14='b'">
849         <xsl:attribute name="authority"><xsl:text>lcsh</xsl:text></xsl:attribute>
850       </xsl:when>   
851       <xsl:when test="ancestor-or-self::marc:datafield/@tag=100 and @ind1=3 and $controlField008-11='k' and $controlField008-14='b'">
852         <xsl:attribute name="authority">cash</xsl:attribute>
853       </xsl:when>
854       <xsl:when test="ancestor-or-self::marc:datafield/@tag=110 and $controlField008-11='a' and $controlField008-14='a'">
855         <xsl:attribute name="authority">naf</xsl:attribute>
856       </xsl:when>
857       <xsl:when test="ancestor-or-self::marc:datafield/@tag=110 and $controlField008-11='a' and $controlField008-14='b'">
858         <xsl:attribute name="authority">lcsh</xsl:attribute>
859       </xsl:when>
860       <xsl:when test="ancestor-or-self::marc:datafield/@tag=110 and $controlField008-11='k' and $controlField008-14='a'">
861         <xsl:attribute name="authority"><xsl:text>lacnaf</xsl:text></xsl:attribute>
862       </xsl:when>
863       <xsl:when test="ancestor-or-self::marc:datafield/@tag=110 and $controlField008-11='k' and $controlField008-14='b'">
864         <xsl:attribute name="authority"><xsl:text>cash</xsl:text></xsl:attribute>
865       </xsl:when>
866       <xsl:when test="100 &lt;= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag &lt;= 155 and $controlField008-11='b'">
867         <xsl:attribute name="authority"><xsl:text>lcshcl</xsl:text></xsl:attribute>
868       </xsl:when>   
869       <xsl:when test="(ancestor-or-self::marc:datafield/@tag=100 or ancestor-or-self::marc:datafield/@tag=110 or ancestor-or-self::marc:datafield/@tag=111 or ancestor-or-self::marc:datafield/@tag=130 or ancestor-or-self::marc:datafield/@tag=151) and $controlField008-11='c'">
870         <xsl:attribute name="authority"><xsl:text>nlmnaf</xsl:text></xsl:attribute>
871       </xsl:when>   
872       <xsl:when test="(ancestor-or-self::marc:datafield/@tag=100 or ancestor-or-self::marc:datafield/@tag=110 or ancestor-or-self::marc:datafield/@tag=111 or ancestor-or-self::marc:datafield/@tag=130 or ancestor-or-self::marc:datafield/@tag=151) and $controlField008-11='d'">   
873         <xsl:attribute name="authority"><xsl:text>nalnaf</xsl:text></xsl:attribute>
874       </xsl:when>   
875       <xsl:when test="100 &lt;= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag &lt;= 155 and $controlField008-11='r'">
876         <xsl:attribute name="authority"><xsl:text>aat</xsl:text></xsl:attribute>
877       </xsl:when>
878       <xsl:when test="100 &lt;= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag &lt;= 155 and $controlField008-11='s'">
879         <xsl:attribute name="authority">sears</xsl:attribute>
880       </xsl:when>
881       <xsl:when test="100 &lt;= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag &lt;= 155 and $controlField008-11='v'">
882         <xsl:attribute name="authority">rvm</xsl:attribute>
883       </xsl:when>
884       <xsl:when test="100 &lt;= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag &lt;= 155 and $controlField008-11='z'">
885         <xsl:attribute name="authority"><xsl:value-of select="../marc:datafield[ancestor-or-self::marc:datafield/@tag=040]/marc:subfield[@code='f']"/></xsl:attribute>
886       </xsl:when>
887       <xsl:when test="(ancestor-or-self::marc:datafield/@tag=111 or ancestor-or-self::marc:datafield/@tag=130) and $controlField008-11='a' and $controlField008-14='a'">
888         <xsl:attribute name="authority"><xsl:text>naf</xsl:text></xsl:attribute>
889       </xsl:when>
890       <xsl:when test="(ancestor-or-self::marc:datafield/@tag=111 or ancestor-or-self::marc:datafield/@tag=130) and $controlField008-11='a' and $controlField008-14='b'">
891         <xsl:attribute name="authority"><xsl:text>lcsh</xsl:text></xsl:attribute>
892       </xsl:when>
893       <xsl:when test="(ancestor-or-self::marc:datafield/@tag=111 or ancestor-or-self::marc:datafield/@tag=130) and $controlField008-11='k' ">
894         <xsl:attribute name="authority"><xsl:text>lacnaf</xsl:text></xsl:attribute>
895       </xsl:when>
896       <xsl:when test="(ancestor-or-self::marc:datafield/@tag=148 or ancestor-or-self::marc:datafield/@tag=150  or ancestor-or-self::marc:datafield/@tag=155) and $controlField008-11='a' ">
897         <xsl:attribute name="authority"><xsl:text>lcsh</xsl:text></xsl:attribute>
898       </xsl:when>
899       <xsl:when test="(ancestor-or-self::marc:datafield/@tag=148 or ancestor-or-self::marc:datafield/@tag=150  or ancestor-or-self::marc:datafield/@tag=155) and $controlField008-11='a' ">
900         <xsl:attribute name="authority"><xsl:text>lcsh</xsl:text></xsl:attribute>
901       </xsl:when>
902       <xsl:when test="(ancestor-or-self::marc:datafield/@tag=148 or ancestor-or-self::marc:datafield/@tag=150  or ancestor-or-self::marc:datafield/@tag=155) and $controlField008-11='c' ">
903         <xsl:attribute name="authority"><xsl:text>mesh</xsl:text></xsl:attribute>
904       </xsl:when>
905       <xsl:when test="(ancestor-or-self::marc:datafield/@tag=148 or ancestor-or-self::marc:datafield/@tag=150  or ancestor-or-self::marc:datafield/@tag=155) and $controlField008-11='d' ">
906         <xsl:attribute name="authority"><xsl:text>nal</xsl:text></xsl:attribute>
907       </xsl:when>
908       <xsl:when test="(ancestor-or-self::marc:datafield/@tag=148 or ancestor-or-self::marc:datafield/@tag=150  or ancestor-or-self::marc:datafield/@tag=155) and $controlField008-11='k' ">
909         <xsl:attribute name="authority"><xsl:text>cash</xsl:text></xsl:attribute>
910       </xsl:when>
911       <xsl:when test="ancestor-or-self::marc:datafield/@tag=151 and $controlField008-11='a' and $controlField008-14='a'">
912         <xsl:attribute name="authority"><xsl:text>naf</xsl:text></xsl:attribute>
913       </xsl:when>
914       <xsl:when test="ancestor-or-self::marc:datafield/@tag=151 and $controlField008-11='a' and $controlField008-14='b'">
915         <xsl:attribute name="authority">lcsh</xsl:attribute>
916       </xsl:when>
917       <xsl:when test="ancestor-or-self::marc:datafield/@tag=151 and $controlField008-11='k' and $controlField008-14='a'">
918         <xsl:attribute name="authority">lacnaf</xsl:attribute>
919       </xsl:when>
920       <xsl:when test="ancestor-or-self::marc:datafield/@tag=151 and $controlField008-11='k' and $controlField008-14='b'">
921         <xsl:attribute name="authority">cash</xsl:attribute>
922       </xsl:when>
923       
924       <xsl:when test="(..//ancestor-or-self::marc:datafield/@tag=180 or ..//ancestor-or-self::marc:datafield/@tag=181 or ..//ancestor-or-self::marc:datafield/@tag=182 or ..//ancestor-or-self::marc:datafield/@tag=185) and $controlField008-11='a'">
925         <xsl:attribute name="authority">lcsh</xsl:attribute>
926       </xsl:when>
927       
928       <xsl:when test="ancestor-or-self::marc:datafield/@tag=700 and (@ind1='0' or @ind1='1') and @ind2='0'">   
929         <xsl:attribute name="authority">naf</xsl:attribute>
930       </xsl:when>
931       <xsl:when test="ancestor-or-self::marc:datafield/@tag=700 and (@ind1='0' or @ind1='1') and @ind2='5'">   
932         <xsl:attribute name="authority">lacnaf</xsl:attribute>
933       </xsl:when>
934       <xsl:when test="ancestor-or-self::marc:datafield/@tag=700 and @ind1='3' and @ind2='0'">   
935         <xsl:attribute name="authority">lcsh</xsl:attribute>
936       </xsl:when>
937       <xsl:when test="ancestor-or-self::marc:datafield/@tag=700 and @ind1='3' and @ind2='5'">   
938         <xsl:attribute name="authority">cash</xsl:attribute>
939       </xsl:when>
940       <xsl:when test="(700 &lt;= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag &lt;= 755 ) and @ind2='1'">   
941         <xsl:attribute name="authority">lcshcl</xsl:attribute>
942       </xsl:when>
943       <xsl:when test="(ancestor-or-self::marc:datafield/@tag=700 or ancestor-or-self::marc:datafield/@tag=710 or ancestor-or-self::marc:datafield/@tag=711 or ancestor-or-self::marc:datafield/@tag=730 or ancestor-or-self::marc:datafield/@tag=751)  and @ind2='2'">   
944         <xsl:attribute name="authority">nlmnaf</xsl:attribute>
945       </xsl:when>
946       <xsl:when test="(ancestor-or-self::marc:datafield/@tag=700 or ancestor-or-self::marc:datafield/@tag=710 or ancestor-or-self::marc:datafield/@tag=711 or ancestor-or-self::marc:datafield/@tag=730 or ancestor-or-self::marc:datafield/@tag=751)  and @ind2='3'">   
947         <xsl:attribute name="authority">nalnaf</xsl:attribute>
948       </xsl:when>   
949       <xsl:when test="(700 &lt;= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag &lt;= 755 ) and @ind2='6'">
950         <xsl:attribute name="authority">rvm</xsl:attribute>
951       </xsl:when>
952       <xsl:when test="(700 &lt;= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag &lt;= 755 ) and @ind2='7'">   
953         <xsl:attribute name="authority">
954           <xsl:value-of select="marc:subfield[@code='2']"/>
955         </xsl:attribute>
956       </xsl:when>
957       <xsl:when test="(ancestor-or-self::marc:datafield/@tag=710 or ancestor-or-self::marc:datafield/@tag=711 or ancestor-or-self::marc:datafield/@tag=730 or ancestor-or-self::marc:datafield/@tag=751)  and @ind2='5'">   
958         <xsl:attribute name="authority">lacnaf</xsl:attribute>
959       </xsl:when>
960       <xsl:when test="(ancestor-or-self::marc:datafield/@tag=710 or ancestor-or-self::marc:datafield/@tag=711 or ancestor-or-self::marc:datafield/@tag=730 or ancestor-or-self::marc:datafield/@tag=751)  and @ind2='0'">   
961         <xsl:attribute name="authority">naf</xsl:attribute>
962       </xsl:when>
963       <xsl:when test="(ancestor-or-self::marc:datafield/@tag=748 or ancestor-or-self::marc:datafield/@tag=750 or ancestor-or-self::marc:datafield/@tag=755)  and @ind2='0'">  
964         <xsl:attribute name="authority">lcsh</xsl:attribute>
965       </xsl:when>
966       <xsl:when test="(ancestor-or-self::marc:datafield/@tag=748 or ancestor-or-self::marc:datafield/@tag=750 or ancestor-or-self::marc:datafield/@tag=755)  and @ind2='2'">  
967         <xsl:attribute name="authority">mesh</xsl:attribute>
968       </xsl:when>
969       <xsl:when test="(ancestor-or-self::marc:datafield/@tag=748 or ancestor-or-self::marc:datafield/@tag=750 or ancestor-or-self::marc:datafield/@tag=755)  and @ind2='3'">      
970         <xsl:attribute name="authority">nal</xsl:attribute>
971       </xsl:when>
972       <xsl:when test="(ancestor-or-self::marc:datafield/@tag=748 or ancestor-or-self::marc:datafield/@tag=750 or ancestor-or-self::marc:datafield/@tag=755)  and @ind2='5'">      
973         <xsl:attribute name="authority">cash</xsl:attribute>
974       </xsl:when>
975     </xsl:choose>
976   </xsl:template>
977
978   <!--<xsl:template name="oldsetAuth">
979       <xsl:param name="ind2"/>
980       <xsl:if test="100 &lt;= @tag and @tag &lt; 200">
981       <xsl:attribute name="authority">
982       <xsl:value-of select="$auth"/>
983       </xsl:attribute>
984       </xsl:if>
985       <xsl:if test="(700 &lt;= @tag and @tag &lt; 800) or /marc:datafield[700 &lt;=@tag and @tag &lt; 800]">
986       <xsl:attribute name="authority">
987       <xsl:choose>
988       <xsl:when test="$ind2='0'">naf</xsl:when>                                 
989       <xsl:when test="$ind2='2'">nlm</xsl:when>
990       <xsl:when test="$ind2='3'">nal</xsl:when>
991       <xsl:when test="$ind2='5'">lac</xsl:when>
992       <xsl:when test="$ind2='6'">rvm</xsl:when>                                 
993       <xsl:when test="$ind2='7'"><xsl:value-of select="../marc:subfield[@code='2']"/></xsl:when>                                                                        
994       </xsl:choose>
995       </xsl:attribute>
996       </xsl:if>
997       </xsl:template>
998   -->
999   <!--<xsl:template name="oldsetAuth2">
1000       <xsl:param name="ind2"/>
1001       <xsl:if test="(100 &lt;= @tag and @tag &lt; 200) or ../marc:datafield[100 &lt;=@tag and @tag &lt; 200]">
1002       <xsl:attribute name="authority">
1003       <xsl:choose>
1004       <xsl:when test="$controlField008-11='a'">lcsh</xsl:when>
1005       <xsl:when test="$controlField008-11='b'">lcac</xsl:when>
1006       <xsl:when test="$controlField008-11='c'">mesh</xsl:when>
1007       <xsl:when test="$controlField008-11='d'">nal</xsl:when>
1008       <xsl:when test="$controlField008-11='k'">cash</xsl:when>
1009       <xsl:when test="$controlField008-11='r'">aat</xsl:when>
1010       <xsl:when test="$controlField008-11='s'">sears</xsl:when>
1011       <xsl:when test="$controlField008-11='v'">rvm</xsl:when>
1012       <xsl:when test="$controlField008-11='z'"><xsl:value-of select="../marc:datafield[@tag=040]/marc:subfield[@code='f']"/></xsl:when>                         
1013       </xsl:choose>
1014       </xsl:attribute>
1015       </xsl:if>
1016       <xsl:if test="(500 &lt;= @tag and @tag &lt; 800) or /marc:datafield[500 &lt;=@tag and @tag &lt; 800]">
1017       <xsl:attribute name="authority">
1018       <xsl:choose>
1019       <xsl:when test="$ind2='0'">lcsh</xsl:when>
1020       <xsl:when test="$ind2='1'">lcac</xsl:when>
1021       <xsl:when test="$ind2='2'">mesh</xsl:when>
1022       <xsl:when test="$ind2='3'">nal</xsl:when>
1023       <xsl:when test="$ind2='5'">cash</xsl:when>
1024       <xsl:when test="$ind2='6'">rvm</xsl:when>                                 
1025       <xsl:when test="$ind2='7'"><xsl:value-of select="../marc:subfield[@code='2']"/></xsl:when>                                                                        
1026       </xsl:choose>
1027       </xsl:attribute>
1028       </xsl:if>
1029       </xsl:template>-->
1030   <!--<xsl:template match="marc:subfield[@code='0']">
1031       <xsl:attribute name="xlink:href">
1032       <xsl:value-of select="."/>
1033       </xsl:attribute>
1034       </xsl:template>
1035   -->
1036   <xsl:template match="*"/>
1037   <!--<xsl:template match="*">
1038       <n><xsl:attribute name="tag"><xsl:value-of select="@tag"/></xsl:attribute>
1039       <xsl:attribute name="code"><xsl:value-of select="@code"/></xsl:attribute>
1040       <xsl:value-of select="name()"/>
1041       
1042       <v><xsl:value-of select="."/></v></n>
1043       </xsl:template>-->
1044 </xsl:stylesheet><!-- Stylus Studio meta-information - (c)1998-2003 Copyright Sonic Software Corporation. All rights reserved.
1045                       <metaInformation>
1046                       <scenarios ><scenario default="yes" name="Scenario1" userelativepaths="yes" externalpreview="no" url="..\..\documents\mads_short.xml" htmlbaseurl="" outputurl="" processortype="internal" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext=""/></scenarios><MapperInfo srcSchemaPath="" srcSchemaRoot="" srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>
1047                       </metaInformation>
1048                  -->