LP#1638299: MADS 2.1 stylesheet
[working/Evergreen.git] / Open-ILS / xsl / MARC21slim2MADS.xsl
1 <?xml version="1.0" encoding="UTF-8"?>\r
2 <xsl:stylesheet version="1.0" xmlns:mads="http://www.loc.gov/mads/v2"\r
3         xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:marc="http://www.loc.gov/MARC21/slim"\r
4         xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="marc">\r
5 \r
6         <xsl:include href="MARC21slimUtils.xsl"/>\r
7         <xsl:output method="xml" indent="yes" encoding="UTF-8"/>\r
8         <xsl:strip-space elements="*"/>\r
9 \r
10 <!--\r
11 2.14    Fixed bug in mads:geographic attributes syntax                                      ws   05/04/2016             \r
12 2.13    fixed repeating <geographic>                                                                                                            tmee 01/31/2014\r
13 2.12    added $2 authority for <classification>                                                                                         tmee 09/18/2012\r
14 2.11    added delimiters between <classification> subfields                                                                     tmee 09/18/2012\r
15 2.10    fixed type="other" and type="otherType" for mads:related                                                        tmee 09/16/2011\r
16 2.09    fixed professionTerm and genreTerm empty tag error                                                                      tmee 09/16/2011\r
17 2.08    fixed marc:subfield @code='i' matching error                                                                            tmee 09/16/2011\r
18 2.07    fixed 555 duplication error                                                                                                                     tmee 08/10/2011 \r
19 2.06    fixed topic subfield error                                                                                                                      tmee 08/10/2011 \r
20 2.05    fixed title subfield error                                                                                                                      tmee 06/20/2011 \r
21 2.04    fixed geographicSubdivision mapping for authority element                                                       tmee 06/16/2011\r
22 2.03    added classification for 053, 055, 060, 065, 070, 080, 082, 083, 086, 087                       tmee 06/03/2011         \r
23 2.02    added descriptionStandard for 008/10                                                                                            tmee 04/27/2011\r
24 2.01    added extensions for 046, 336, 370, 374, 375, 376                                                                       tmee 04/08/2011\r
25 2.00    redefined imported MODS elements in version 1.0 to MADS elements in version 2.0         tmee 02/08/2011\r
26 1.08    added 372 subfields $a $s $t for <fieldOfActivity>                                                                      tmee 06/24/2010\r
27 1.07    removed role/roleTerm 100, 110, 111, 400, 410, 411, 500, 510, 511, 700, 710, 711        tmee 06/24/2010\r
28 1.06    added strip-space                                                                                                                                       tmee 06/24/2010\r
29 1.05    added subfield $a for 130, 430, 530                                                                                                     tmee 06/21/2010\r
30 1.04    fixed 550 z omission                                                                                                                            ntra 08/11/2008\r
31 1.03    removed duplication of 550 $a text                                                                                                      tmee 11/01/2006\r
32 1.02    fixed namespace references between mads and mods                                                                        ntra 10/06/2006\r
33 1.01    revised                                                                                                                                                         rgue/jrad 11/29/05\r
34 1.00    adapted from MARC21Slim2MODS3.xsl                                                                                                       ntra 07/06/05\r
35 -->\r
36 \r
37         <!-- authority attribute defaults to 'naf' if not set using this authority parameter, for <authority> descriptors: name, titleInfo, geographic -->\r
38         <xsl:param name="authority"/>\r
39         <xsl:variable name="auth">\r
40                 <xsl:choose>\r
41                         <xsl:when test="$authority">\r
42                                 <xsl:value-of select="$authority"/>\r
43                         </xsl:when>\r
44                         <xsl:otherwise>naf</xsl:otherwise>\r
45                 </xsl:choose>\r
46         </xsl:variable>\r
47         <xsl:variable name="controlField008" select="marc:controlfield[@tag='008']"/>\r
48         <xsl:variable name="controlField008-06"\r
49                 select="substring(descendant-or-self::marc:controlfield[@tag=008],7,1)"/>\r
50         <xsl:variable name="controlField008-11"\r
51                 select="substring(descendant-or-self::marc:controlfield[@tag=008],12,1)"/>\r
52         <xsl:variable name="controlField008-14"\r
53                 select="substring(descendant-or-self::marc:controlfield[@tag=008],15,1)"/>\r
54         <xsl:template match="/">\r
55                 <xsl:choose>\r
56                         <xsl:when test="descendant-or-self::marc:collection">\r
57                                 <mads:madsCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
58                                         xsi:schemaLocation="http://www.loc.gov/mads/v2 http://www.loc.gov/standards/mads/v2/mads-2-0.xsd">\r
59                                         <xsl:for-each select="descendant-or-self::marc:collection/marc:record">\r
60                                                 <mads:mads version="2.0">\r
61                                                         <xsl:call-template name="marcRecord"/>\r
62                                                 </mads:mads>\r
63                                         </xsl:for-each>\r
64                                 </mads:madsCollection>\r
65                         </xsl:when>\r
66                         <xsl:otherwise>\r
67                                 <mads:mads version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
68                                         xsi:schemaLocation="http://www.loc.gov/mads/v2 http://www.loc.gov/standards/mads/mads-2-0.xsd">\r
69                                         <xsl:for-each select="descendant-or-self::marc:record">\r
70                                                 <xsl:call-template name="marcRecord"/>\r
71                                         </xsl:for-each>\r
72                                 </mads:mads>\r
73                         </xsl:otherwise>\r
74                 </xsl:choose>\r
75         </xsl:template>\r
76 \r
77         <xsl:template name="marcRecord">\r
78                 <mads:authority>\r
79                         <!-- 2.04 -->\r
80                         <xsl:choose>\r
81                                 <xsl:when test="$controlField008-06='d'">\r
82                                         <xsl:attribute name="geographicSubdivision">\r
83                                                 <xsl:text>direct</xsl:text>\r
84                                         </xsl:attribute>\r
85                                 </xsl:when>\r
86                                 <xsl:when test="$controlField008-06='i'">\r
87                                         <xsl:attribute name="geographicSubdivision">\r
88                                                 <xsl:text>indirect</xsl:text>\r
89                                         </xsl:attribute>\r
90                                 </xsl:when>\r
91                                 <xsl:when test="$controlField008-06='n'">\r
92                                         <xsl:attribute name="geographicSubdivision">\r
93                                                 <xsl:text>not applicable</xsl:text>\r
94                                         </xsl:attribute>\r
95                                 </xsl:when>\r
96                         </xsl:choose>\r
97                         \r
98                         <xsl:apply-templates select="marc:datafield[100 &lt;= @tag  and @tag &lt; 200]"/>               \r
99                 </mads:authority>\r
100 \r
101                 <!-- related -->\r
102                 <xsl:apply-templates\r
103                         select="marc:datafield[500 &lt;= @tag and @tag &lt;= 585]|marc:datafield[700 &lt;= @tag and @tag &lt;= 785]"/>\r
104 \r
105                 <!-- variant -->\r
106                 <xsl:apply-templates select="marc:datafield[400 &lt;= @tag and @tag &lt;= 485]"/>\r
107 \r
108                 <!-- notes -->\r
109                 <xsl:apply-templates select="marc:datafield[667 &lt;= @tag and @tag &lt;= 688]"/>\r
110 \r
111                 <!-- url -->\r
112                 <xsl:apply-templates select="marc:datafield[@tag=856]"/>\r
113                 <xsl:apply-templates select="marc:datafield[@tag=010]"/>\r
114                 <xsl:apply-templates select="marc:datafield[@tag=024]"/>\r
115                 <xsl:apply-templates select="marc:datafield[@tag=372]"/>\r
116                 \r
117                 <!-- classification -->\r
118                 <xsl:apply-templates select="marc:datafield[@tag=053]"/>\r
119                 <xsl:apply-templates select="marc:datafield[@tag=055]"/>\r
120                 <xsl:apply-templates select="marc:datafield[@tag=060]"/>\r
121                 <xsl:apply-templates select="marc:datafield[@tag=065]"/>\r
122                 <xsl:apply-templates select="marc:datafield[@tag=070]"/>\r
123                 <xsl:apply-templates select="marc:datafield[@tag=080]"/>\r
124                 <xsl:apply-templates select="marc:datafield[@tag=082]"/>\r
125                 <xsl:apply-templates select="marc:datafield[@tag=083]"/>\r
126                 <xsl:apply-templates select="marc:datafield[@tag=086]"/>\r
127                 <xsl:apply-templates select="marc:datafield[@tag=087]"/>\r
128 \r
129                 <!-- affiliation-->\r
130                 <xsl:for-each select="marc:datafield[@tag=373]">\r
131                         <mads:affiliation>\r
132                                 <mads:position>\r
133                                         <xsl:value-of select="marc:subfield[@code='a']"/>\r
134                                 </mads:position>\r
135                                 <mads:dateValid point="start">\r
136                                         <xsl:value-of select="marc:subfield[@code='s']"/>\r
137                                 </mads:dateValid>\r
138                                 <mads:dateValid point="end">\r
139                                         <xsl:value-of select="marc:subfield[@code='t']"/>\r
140                                 </mads:dateValid>\r
141                         </mads:affiliation>\r
142                 </xsl:for-each>\r
143                 <xsl:for-each select="marc:datafield[@tag=371]">\r
144                         <mads:affiliation>\r
145                                 <mads:address>\r
146                                         <mads:street>\r
147                                                 <xsl:value-of select="marc:subfield[@code='a']"/>\r
148                                         </mads:street>\r
149                                         <mads:city>\r
150                                                 <xsl:value-of select="marc:subfield[@code='b']"/>\r
151                                         </mads:city>\r
152                                         <mads:state>\r
153                                                 <xsl:value-of select="marc:subfield[@code='c']"/>\r
154                                         </mads:state>\r
155                                         <mads:country>\r
156                                                 <xsl:value-of select="marc:subfield[@code='d']"/>\r
157                                         </mads:country>\r
158                                         <mads:postcode>\r
159                                                 <xsl:value-of select="marc:subfield[@code='e']"/>\r
160                                         </mads:postcode>\r
161                                 </mads:address>\r
162                                 <mads:email>\r
163                                         <xsl:value-of select="marc:subfield[@code='m']"/>\r
164                                 </mads:email>\r
165                         </mads:affiliation>\r
166                 </xsl:for-each>\r
167 \r
168                 <!-- extension-->\r
169                 <xsl:for-each select="marc:datafield[@tag=336]">\r
170                         <mads:extension>\r
171                                 <mads:contentType>\r
172                                         <mads:contentType type="text">\r
173                                                 <xsl:value-of select="marc:subfield[@code='a']"/>\r
174                                         </mads:contentType>\r
175                                         <mads:contentType type="code">\r
176                                                 <xsl:value-of select="marc:subfield[@code='b']"/>\r
177                                         </mads:contentType>\r
178                                 </mads:contentType>\r
179                         </mads:extension>\r
180                 </xsl:for-each>\r
181 \r
182                 <xsl:for-each select="marc:datafield[@tag=374]">\r
183                         <mads:extension>\r
184                                 <mads:profession>\r
185                                         <xsl:choose>\r
186                                                 <xsl:when test="marc:subfield[@code='a']">\r
187                                                         <mads:professionTerm>\r
188                                                                 <xsl:value-of select="marc:subfield[@code='a']"/>\r
189                                                         </mads:professionTerm>\r
190                                                 </xsl:when>\r
191                                                 <xsl:when test="marc:subfield[@code='s']">\r
192                                                         <mads:dateValid point="start">\r
193                                                                 <xsl:value-of select="marc:subfield[@code='s']"/>\r
194                                                         </mads:dateValid>\r
195                                                 </xsl:when>\r
196                                                 <xsl:when test="marc:subfield[@code='t']">\r
197                                                         <mads:dateValid point="end">\r
198                                                                 <xsl:value-of select="marc:subfield[@code='t']"/>\r
199                                                         </mads:dateValid>\r
200                                                 </xsl:when>\r
201                                         </xsl:choose>\r
202                                 </mads:profession>\r
203                         </mads:extension>\r
204                 </xsl:for-each>\r
205                 \r
206                 <xsl:for-each select="marc:datafield[@tag=375]">\r
207                         <mads:extension>\r
208                                 <mads:gender>\r
209                                         <xsl:choose>\r
210                                                 <xsl:when test="marc:subfield[@code='a']">\r
211                                                         <mads:genderTerm>\r
212                                                                 <xsl:value-of select="marc:subfield[@code='a']"/>\r
213                                                         </mads:genderTerm>\r
214                                                 </xsl:when>\r
215                                                 <xsl:when test="marc:subfield[@code='s']">\r
216                                                         <mads:dateValid point="start">\r
217                                                                 <xsl:value-of select="marc:subfield[@code='s']"/>\r
218                                                         </mads:dateValid>\r
219                                                 </xsl:when>\r
220                                                 <xsl:when test="marc:subfield[@code='t']">\r
221                                                         <mads:dateValid point="end">\r
222                                                                 <xsl:value-of select="marc:subfield[@code='t']"/>\r
223                                                         </mads:dateValid>\r
224                                                 </xsl:when>\r
225                                         </xsl:choose>\r
226                                 </mads:gender>\r
227                         </mads:extension>\r
228                 </xsl:for-each>\r
229 \r
230                 <xsl:for-each select="marc:datafield[@tag=376]">\r
231                         <mads:extension>\r
232                                 <mads:familyInformation>\r
233                                         <mads:typeOfFamily>\r
234                                                 <xsl:value-of select="marc:subfield[@code='a']"/>\r
235                                         </mads:typeOfFamily>\r
236                                         <mads:nameOfProminentMember>\r
237                                                 <xsl:value-of select="marc:subfield[@code='b']"/>\r
238                                         </mads:nameOfProminentMember>\r
239                                         <mads:hereditaryTitle>\r
240                                                 <xsl:value-of select="marc:subfield[@code='c']"/>\r
241                                         </mads:hereditaryTitle>\r
242                                         <mads:dateValid point="start">\r
243                                                 <xsl:value-of select="marc:subfield[@code='s']"/>\r
244                                         </mads:dateValid>\r
245                                         <mads:dateValid point="end">\r
246                                                 <xsl:value-of select="marc:subfield[@code='t']"/>\r
247                                         </mads:dateValid>\r
248                                 </mads:familyInformation>\r
249                         </mads:extension>\r
250                 </xsl:for-each>\r
251 \r
252                 <mads:recordInfo>\r
253                         <mads:recordOrigin>Converted from MARCXML to MADS version 2.0 (Revision 2.13)</mads:recordOrigin>\r
254                         <!-- <xsl:apply-templates select="marc:datafield[@tag=024]"/> -->\r
255 \r
256                         <xsl:apply-templates select="marc:datafield[@tag=040]/marc:subfield[@code='a']"/>\r
257                         <xsl:apply-templates select="marc:controlfield[@tag=005]"/>\r
258                         <xsl:apply-templates select="marc:controlfield[@tag=001]"/>\r
259                         <xsl:apply-templates select="marc:datafield[@tag=040]/marc:subfield[@code='b']"/>\r
260                         <xsl:apply-templates select="marc:datafield[@tag=040]/marc:subfield[@code='e']"/>\r
261                         <xsl:for-each select="marc:controlfield[@tag=008]">\r
262                                 <xsl:if test="substring(.,11,1)='a'">\r
263                                         <mads:descriptionStandard>\r
264                                                 <xsl:text>earlier rules</xsl:text>\r
265                                         </mads:descriptionStandard>\r
266                                 </xsl:if>\r
267                                 <xsl:if test="substring(.,11,1)='b'">\r
268                                         <mads:descriptionStandard>\r
269                                                 <xsl:text>aacr1</xsl:text>\r
270                                         </mads:descriptionStandard>\r
271                                 </xsl:if>\r
272                                 <xsl:if test="substring(.,11,1)='c'">\r
273                                         <mads:descriptionStandard>\r
274                                                 <xsl:text>aacr2</xsl:text>\r
275                                         </mads:descriptionStandard>\r
276                                 </xsl:if>\r
277                                 <xsl:if test="substring(.,11,1)='d'">\r
278                                         <mads:descriptionStandard>\r
279                                                 <xsl:text>aacr2 compatible</xsl:text>\r
280                                         </mads:descriptionStandard>\r
281                                 </xsl:if>\r
282                                 <xsl:if test="substring(.,11,1)='z'">\r
283                                         <mads:descriptionStandard>\r
284                                                 <xsl:text>other rules</xsl:text>\r
285                                         </mads:descriptionStandard>\r
286                                 </xsl:if>\r
287                         </xsl:for-each>\r
288                 </mads:recordInfo>\r
289         </xsl:template>\r
290 \r
291         <!-- start of secondary templates -->\r
292 \r
293         <!-- ======== xlink ======== -->\r
294 \r
295         <!-- <xsl:template name="uri"> \r
296     <xsl:for-each select="marc:subfield[@code='0']">\r
297       <xsl:attribute name="xlink:href">\r
298         <xsl:value-of select="."/>\r
299       </xsl:attribute>\r
300     </xsl:for-each>\r
301      </xsl:template> \r
302    -->\r
303         <xsl:template match="marc:subfield[@code='i']">\r
304                 <xsl:attribute name="otherType">\r
305                         <xsl:value-of select="."/>\r
306                 </xsl:attribute>\r
307         </xsl:template>\r
308 \r
309         <!-- No role/roleTerm mapped in MADS 06/24/2010\r
310         <xsl:template name="role">\r
311                 <xsl:for-each select="marc:subfield[@code='e']">\r
312                         <mads:role>\r
313                                 <mads:roleTerm type="text">\r
314                                         <xsl:value-of select="."/>\r
315                                 </mads:roleTerm>\r
316                         </mads:role>\r
317                 </xsl:for-each>\r
318         </xsl:template>\r
319 -->\r
320 \r
321         <xsl:template name="part">\r
322                 <xsl:variable name="partNumber">\r
323                         <xsl:call-template name="specialSubfieldSelect">\r
324                                 <xsl:with-param name="axis">n</xsl:with-param>\r
325                                 <xsl:with-param name="anyCodes">n</xsl:with-param>\r
326                                 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>\r
327                         </xsl:call-template>\r
328                 </xsl:variable>\r
329                 <xsl:variable name="partName">\r
330                         <xsl:call-template name="specialSubfieldSelect">\r
331                                 <xsl:with-param name="axis">p</xsl:with-param>\r
332                                 <xsl:with-param name="anyCodes">p</xsl:with-param>\r
333                                 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>\r
334                         </xsl:call-template>\r
335                 </xsl:variable>\r
336                 <xsl:if test="string-length(normalize-space($partNumber))">\r
337                         <mads:partNumber>\r
338                                 <xsl:call-template name="chopPunctuation">\r
339                                         <xsl:with-param name="chopString" select="$partNumber"/>\r
340                                 </xsl:call-template>\r
341                         </mads:partNumber>\r
342                 </xsl:if>\r
343                 <xsl:if test="string-length(normalize-space($partName))">\r
344                         <mads:partName>\r
345                                 <xsl:call-template name="chopPunctuation">\r
346                                         <xsl:with-param name="chopString" select="$partName"/>\r
347                                 </xsl:call-template>\r
348                         </mads:partName>\r
349                 </xsl:if>\r
350         </xsl:template>\r
351 \r
352         <xsl:template name="nameABCDN">\r
353                 <xsl:for-each select="marc:subfield[@code='a']">\r
354                         <mads:namePart>\r
355                                 <xsl:call-template name="chopPunctuation">\r
356                                         <xsl:with-param name="chopString" select="."/>\r
357                                 </xsl:call-template>\r
358                         </mads:namePart>\r
359                 </xsl:for-each>\r
360                 <xsl:for-each select="marc:subfield[@code='b']">\r
361                         <mads:namePart>\r
362                                 <xsl:value-of select="."/>\r
363                         </mads:namePart>\r
364                 </xsl:for-each>\r
365                 <xsl:if\r
366                         test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">\r
367                         <mads:namePart>\r
368                                 <xsl:call-template name="subfieldSelect">\r
369                                         <xsl:with-param name="codes">cdn</xsl:with-param>\r
370                                 </xsl:call-template>\r
371                         </mads:namePart>\r
372                 </xsl:if>\r
373         </xsl:template>\r
374 \r
375         <xsl:template name="nameABCDQ">\r
376                 <mads:namePart>\r
377                         <xsl:call-template name="chopPunctuation">\r
378                                 <xsl:with-param name="chopString">\r
379                                         <xsl:call-template name="subfieldSelect">\r
380                                                 <xsl:with-param name="codes">aq</xsl:with-param>\r
381                                         </xsl:call-template>\r
382                                 </xsl:with-param>\r
383                         </xsl:call-template>\r
384                 </mads:namePart>\r
385                 <xsl:call-template name="termsOfAddress"/>\r
386                 <xsl:call-template name="nameDate"/>\r
387         </xsl:template>\r
388 \r
389         <xsl:template name="nameACDENQ">\r
390                 <mads:namePart>\r
391                         <xsl:call-template name="subfieldSelect">\r
392                                 <xsl:with-param name="codes">acdenq</xsl:with-param>\r
393                         </xsl:call-template>\r
394                 </mads:namePart>\r
395         </xsl:template>\r
396 \r
397         <xsl:template name="nameDate">\r
398                 <xsl:for-each select="marc:subfield[@code='d']">\r
399                         <mads:namePart type="date">\r
400                                 <xsl:call-template name="chopPunctuation">\r
401                                         <xsl:with-param name="chopString" select="."/>\r
402                                 </xsl:call-template>\r
403                         </mads:namePart>\r
404                 </xsl:for-each>\r
405         </xsl:template>\r
406 \r
407         <xsl:template name="specialSubfieldSelect">\r
408                 <xsl:param name="anyCodes"/>\r
409                 <xsl:param name="axis"/>\r
410                 <xsl:param name="beforeCodes"/>\r
411                 <xsl:param name="afterCodes"/>\r
412                 <xsl:variable name="str">\r
413                         <xsl:for-each select="marc:subfield">\r
414                                 <xsl:if\r
415                                         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])">\r
416                                         <xsl:value-of select="text()"/>\r
417                                         <xsl:text> </xsl:text>\r
418                                 </xsl:if>\r
419                         </xsl:for-each>\r
420                 </xsl:variable>\r
421                 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>\r
422         </xsl:template>\r
423 \r
424         <xsl:template name="termsOfAddress">\r
425                 <xsl:if test="marc:subfield[@code='b' or @code='c']">\r
426                         <mads:namePart type="termsOfAddress">\r
427                                 <xsl:call-template name="chopPunctuation">\r
428                                         <xsl:with-param name="chopString">\r
429                                                 <xsl:call-template name="subfieldSelect">\r
430                                                         <xsl:with-param name="codes">bc</xsl:with-param>\r
431                                                 </xsl:call-template>\r
432                                         </xsl:with-param>\r
433                                 </xsl:call-template>\r
434                         </mads:namePart>\r
435                 </xsl:if>\r
436         </xsl:template>\r
437 \r
438         <xsl:template name="displayLabel">\r
439                 <xsl:if test="marc:subfield[@code='z']">\r
440                         <xsl:attribute name="displayLabel">\r
441                                 <xsl:value-of select="marc:subfield[@code='z']"/>\r
442                         </xsl:attribute>\r
443                 </xsl:if>\r
444                 <xsl:if test="marc:subfield[@code='3']">\r
445                         <xsl:attribute name="displayLabel">\r
446                                 <xsl:value-of select="marc:subfield[@code='3']"/>\r
447                         </xsl:attribute>\r
448                 </xsl:if>\r
449         </xsl:template>\r
450 \r
451         <xsl:template name="isInvalid">\r
452                 <xsl:if test="@code='z'">\r
453                         <xsl:attribute name="invalid">yes</xsl:attribute>\r
454                 </xsl:if>\r
455         </xsl:template>\r
456 \r
457         <xsl:template name="sub2Attribute">\r
458                 <!-- 024 -->\r
459                 <xsl:if test="../marc:subfield[@code='2']">\r
460                         <xsl:attribute name="type">\r
461                                 <xsl:value-of select="../marc:subfield[@code='2']"/>\r
462                         </xsl:attribute>\r
463                 </xsl:if>\r
464         </xsl:template>\r
465 \r
466         <xsl:template match="marc:controlfield[@tag=001]">\r
467                 <mads:recordIdentifier>\r
468                         <xsl:if test="../marc:controlfield[@tag=003]">\r
469                                 <xsl:attribute name="source">\r
470                                         <xsl:value-of select="../marc:controlfield[@tag=003]"/>\r
471                                 </xsl:attribute>\r
472                         </xsl:if>\r
473                         <xsl:value-of select="."/>\r
474                 </mads:recordIdentifier>\r
475         </xsl:template>\r
476 \r
477         <xsl:template match="marc:controlfield[@tag=005]">\r
478                 <mads:recordChangeDate encoding="iso8601">\r
479                         <xsl:value-of select="."/>\r
480                 </mads:recordChangeDate>\r
481         </xsl:template>\r
482 \r
483         <xsl:template match="marc:controlfield[@tag=008]">\r
484                 <mads:recordCreationDate encoding="marc">\r
485                         <xsl:value-of select="substring(.,1,6)"/>\r
486                 </mads:recordCreationDate>\r
487         </xsl:template>\r
488 \r
489         <xsl:template match="marc:datafield[@tag=010]">\r
490                 <xsl:for-each select="marc:subfield">\r
491                         <mads:identifier type="lccn">\r
492                                 <xsl:call-template name="isInvalid"/>\r
493                                 <xsl:value-of select="."/>\r
494                         </mads:identifier>\r
495                 </xsl:for-each>\r
496         </xsl:template>\r
497 \r
498         <xsl:template match="marc:datafield[@tag=024]">\r
499                 <xsl:for-each select="marc:subfield[not(@code=2)]">\r
500                         <mads:identifier>\r
501                                 <xsl:call-template name="isInvalid"/>\r
502                                 <xsl:call-template name="sub2Attribute"/>\r
503                                 <xsl:value-of select="."/>\r
504                         </mads:identifier>\r
505                 </xsl:for-each>\r
506         </xsl:template>\r
507 \r
508         <!-- ========== 372 ========== -->\r
509         <xsl:template match="marc:datafield[@tag=372]">\r
510                 <mads:fieldOfActivity>\r
511                         <xsl:call-template name="subfieldSelect">\r
512                                 <xsl:with-param name="codes">a</xsl:with-param>\r
513                         </xsl:call-template>\r
514                         <xsl:text>-</xsl:text>\r
515                         <xsl:call-template name="subfieldSelect">\r
516                                 <xsl:with-param name="codes">st</xsl:with-param>\r
517                         </xsl:call-template>\r
518                 </mads:fieldOfActivity>\r
519         </xsl:template>\r
520 \r
521 \r
522         <!-- ========== 040 ========== -->\r
523         <xsl:template match="marc:datafield[@tag=040]/marc:subfield[@code='a']">\r
524                 <mads:recordContentSource authority="marcorg">\r
525                         <xsl:value-of select="."/>\r
526                 </mads:recordContentSource>\r
527         </xsl:template>\r
528 \r
529         <xsl:template match="marc:datafield[@tag=040]/marc:subfield[@code='b']">\r
530                 <mads:languageOfCataloging>\r
531                         <mads:languageTerm authority="iso639-2b" type="code">\r
532                                 <xsl:value-of select="."/>\r
533                         </mads:languageTerm>\r
534                 </mads:languageOfCataloging>\r
535         </xsl:template>\r
536 \r
537         <xsl:template match="marc:datafield[@tag=040]/marc:subfield[@code='e']">\r
538                 <mads:descriptionStandard>\r
539                         <xsl:value-of select="."/>\r
540                 </mads:descriptionStandard>\r
541         </xsl:template>\r
542         \r
543         <!-- ========== classification 2.03 ========== -->\r
544         \r
545         <xsl:template match="marc:datafield[@tag=053]">\r
546                 <mads:classification>\r
547                         <xsl:call-template name="subfieldSelect">\r
548                                 <xsl:with-param name="codes">abcdxyz</xsl:with-param>\r
549                                 <xsl:with-param name="delimeter">-</xsl:with-param>\r
550                         </xsl:call-template>\r
551                 </mads:classification>\r
552         </xsl:template>\r
553         \r
554         <xsl:template match="marc:datafield[@tag=055]">\r
555                 <mads:classification>\r
556                         <xsl:call-template name="subfieldSelect">\r
557                                 <xsl:with-param name="codes">abcdxyz</xsl:with-param>\r
558                                 <xsl:with-param name="delimeter">-</xsl:with-param>\r
559                         </xsl:call-template>\r
560                 </mads:classification>\r
561         </xsl:template>\r
562         \r
563         <xsl:template match="marc:datafield[@tag=060]">\r
564                 <mads:classification>\r
565                         <xsl:call-template name="subfieldSelect">\r
566                                 <xsl:with-param name="codes">abcdxyz</xsl:with-param>\r
567                                 <xsl:with-param name="delimeter">-</xsl:with-param>\r
568                         </xsl:call-template>\r
569                 </mads:classification>\r
570         </xsl:template>\r
571         <xsl:template match="marc:datafield[@tag=065]">\r
572                 <mads:classification>\r
573                         <xsl:attribute name="authority">\r
574                                 <xsl:value-of select="marc:subfield[@code='2']"/>\r
575                         </xsl:attribute>\r
576                         <xsl:call-template name="subfieldSelect">\r
577                                 <xsl:with-param name="codes">abcdxyz</xsl:with-param>\r
578                                 <xsl:with-param name="delimeter">-</xsl:with-param>\r
579                         </xsl:call-template>\r
580                 </mads:classification>\r
581         </xsl:template>\r
582         <xsl:template match="marc:datafield[@tag=070]">\r
583                 <mads:classification>\r
584                         <xsl:call-template name="subfieldSelect">\r
585                                 <xsl:with-param name="codes">abcdxyz5</xsl:with-param>\r
586                                 <xsl:with-param name="delimeter">-</xsl:with-param>\r
587                         </xsl:call-template>\r
588                 </mads:classification>\r
589         </xsl:template>\r
590         <xsl:template match="marc:datafield[@tag=080]">\r
591                 <mads:classification>\r
592                         <xsl:attribute name="authority">\r
593                                 <xsl:value-of select="marc:subfield[@code='2']"/>\r
594                         </xsl:attribute>\r
595                         <xsl:call-template name="subfieldSelect">\r
596                                 <xsl:with-param name="codes">abcdxyz5</xsl:with-param>\r
597                                 <xsl:with-param name="delimeter">-</xsl:with-param>\r
598                         </xsl:call-template>\r
599                 </mads:classification>\r
600         </xsl:template>\r
601         <xsl:template match="marc:datafield[@tag=082]">\r
602                 <mads:classification>\r
603                         <xsl:attribute name="authority">\r
604                                 <xsl:value-of select="marc:subfield[@code='2']"/>\r
605                         </xsl:attribute>\r
606                         <xsl:call-template name="subfieldSelect">\r
607                                 <xsl:with-param name="codes">abcdxyz5</xsl:with-param>\r
608                                 <xsl:with-param name="delimeter">-</xsl:with-param>\r
609                         </xsl:call-template>\r
610                 </mads:classification>\r
611         </xsl:template>\r
612         <xsl:template match="marc:datafield[@tag=083]">\r
613                 <mads:classification>\r
614                         <xsl:attribute name="authority">\r
615                                 <xsl:value-of select="marc:subfield[@code='2']"/>\r
616                         </xsl:attribute>\r
617                         <xsl:call-template name="subfieldSelect">\r
618                                 <xsl:with-param name="codes">abcdxyz5</xsl:with-param>\r
619                                 <xsl:with-param name="delimeter">-</xsl:with-param>\r
620                         </xsl:call-template>\r
621                 </mads:classification>\r
622         </xsl:template>\r
623         <xsl:template match="marc:datafield[@tag=086]">\r
624                 <mads:classification>\r
625                         <xsl:attribute name="authority">\r
626                                 <xsl:value-of select="marc:subfield[@code='2']"/>\r
627                         </xsl:attribute>\r
628                         <xsl:call-template name="subfieldSelect">\r
629                                 <xsl:with-param name="codes">abcdxyz5</xsl:with-param>\r
630                                 <xsl:with-param name="delimeter">-</xsl:with-param>\r
631                         </xsl:call-template>\r
632                 </mads:classification>\r
633         </xsl:template>\r
634         <xsl:template match="marc:datafield[@tag=087]">\r
635                 <mads:classification>\r
636                         <xsl:attribute name="authority">\r
637                                 <xsl:value-of select="marc:subfield[@code='2']"/>\r
638                         </xsl:attribute>\r
639                         <xsl:call-template name="subfieldSelect">\r
640                                 <xsl:with-param name="codes">abcdxyz5</xsl:with-param>\r
641                                 <xsl:with-param name="delimeter">-</xsl:with-param>\r
642                         </xsl:call-template>\r
643                 </mads:classification>\r
644         </xsl:template>\r
645         \r
646 \r
647         <!-- ========== names  ========== -->\r
648         <xsl:template match="marc:datafield[@tag=100]">\r
649                 <mads:name type="personal">\r
650                         <xsl:call-template name="setAuthority"/>\r
651                         <xsl:call-template name="nameABCDQ"/>\r
652                 </mads:name>\r
653                 <xsl:apply-templates select="*[marc:subfield[not(contains('abcdeq',@code))]]"/>\r
654                 <xsl:call-template name="title"/>\r
655                 <xsl:apply-templates select="marc:subfield[@code!='i']"/>\r
656         </xsl:template>\r
657 \r
658         <xsl:template match="marc:datafield[@tag=110]">\r
659                 <mads:name type="corporate">\r
660                         <xsl:call-template name="setAuthority"/>\r
661                         <xsl:call-template name="nameABCDN"/>\r
662                 </mads:name>\r
663                 <xsl:apply-templates select="marc:subfield[@code!='i']"/>\r
664         </xsl:template>\r
665 \r
666         <xsl:template match="marc:datafield[@tag=111]">\r
667                 <mads:name type="conference">\r
668                         <xsl:call-template name="setAuthority"/>\r
669                         <xsl:call-template name="nameACDENQ"/>\r
670                 </mads:name>\r
671                 <xsl:apply-templates select="marc:subfield[@code!='i']"/>\r
672         </xsl:template>\r
673 \r
674         <xsl:template match="marc:datafield[@tag=400]">\r
675                 <mads:variant>\r
676                         <xsl:call-template name="variantTypeAttribute"/>\r
677                         <mads:name type="personal">\r
678                                 <xsl:call-template name="nameABCDQ"/>\r
679                         </mads:name>\r
680                         <xsl:apply-templates select="marc:subfield[@code!='i']"/>\r
681                         <xsl:call-template name="title"/>\r
682                 </mads:variant>\r
683         </xsl:template>\r
684 \r
685         <xsl:template match="marc:datafield[@tag=410]">\r
686                 <mads:variant>\r
687                         <xsl:call-template name="variantTypeAttribute"/>\r
688                         <mads:name type="corporate">\r
689                                 <xsl:call-template name="nameABCDN"/>\r
690                         </mads:name>\r
691                         <xsl:apply-templates select="marc:subfield[@code!='i']"/>\r
692                 </mads:variant>\r
693         </xsl:template>\r
694 \r
695         <xsl:template match="marc:datafield[@tag=411]">\r
696                 <mads:variant>\r
697                         <xsl:call-template name="variantTypeAttribute"/>\r
698                         <mads:name type="conference">\r
699                                 <xsl:call-template name="nameACDENQ"/>\r
700                         </mads:name>\r
701                         <xsl:apply-templates select="marc:subfield[@code!='i']"/>\r
702                 </mads:variant>\r
703         </xsl:template>\r
704 \r
705         <xsl:template match="marc:datafield[@tag=500]|marc:datafield[@tag=700]">\r
706                 <mads:related>\r
707                         <xsl:call-template name="relatedTypeAttribute"/>\r
708                         <!-- <xsl:call-template name="uri"/> -->\r
709                         <mads:name type="personal">\r
710                                 <xsl:call-template name="setAuthority"/>\r
711                                 <xsl:call-template name="nameABCDQ"/>\r
712                         </mads:name>\r
713                         <xsl:call-template name="title"/>\r
714                         <xsl:apply-templates select="marc:subfield[@code!='i']"/>\r
715                 </mads:related>\r
716         </xsl:template>\r
717 \r
718         <xsl:template match="marc:datafield[@tag=510]|marc:datafield[@tag=710]">\r
719                 <mads:related>\r
720                         <xsl:call-template name="relatedTypeAttribute"/>\r
721                         <!-- <xsl:call-template name="uri"/> -->\r
722                         <mads:name type="corporate">\r
723                                 <xsl:call-template name="setAuthority"/>\r
724                                 <xsl:call-template name="nameABCDN"/>\r
725                         </mads:name>\r
726                         <xsl:apply-templates select="marc:subfield[@code!='i']"/>\r
727                 </mads:related>\r
728         </xsl:template>\r
729 \r
730         <xsl:template match="marc:datafield[@tag=511]|marc:datafield[@tag=711]">\r
731                 <mads:related>\r
732                         <xsl:call-template name="relatedTypeAttribute"/>\r
733                         <!-- <xsl:call-template name="uri"/> -->\r
734                         <mads:name type="conference">\r
735                                 <xsl:call-template name="setAuthority"/>\r
736                                 <xsl:call-template name="nameACDENQ"/>\r
737                         </mads:name>\r
738                         <xsl:apply-templates select="marc:subfield[@code!='i']"/>\r
739                 </mads:related>\r
740         </xsl:template>\r
741 \r
742         <!-- ========== titles  ========== -->\r
743         <xsl:template match="marc:datafield[@tag=130]">\r
744                 <xsl:call-template name="uniform-title"/>\r
745                 <xsl:apply-templates select="marc:subfield[@code!='i']"/>\r
746         </xsl:template>\r
747 \r
748         <xsl:template match="marc:datafield[@tag=430]">\r
749                 <mads:variant>\r
750                         <xsl:call-template name="variantTypeAttribute"/>\r
751                         <xsl:call-template name="uniform-title"/>\r
752                         <xsl:apply-templates select="marc:subfield[@code!='i']"/>\r
753                 </mads:variant>\r
754         </xsl:template>\r
755 \r
756         <xsl:template match="marc:datafield[@tag=530]|marc:datafield[@tag=730]">\r
757                 <mads:related>\r
758                         <xsl:call-template name="relatedTypeAttribute"/>\r
759                         <xsl:call-template name="uniform-title"/>\r
760                         <xsl:apply-templates select="marc:subfield[@code!='i']"/>\r
761                 </mads:related>\r
762         </xsl:template>\r
763 \r
764         <xsl:template name="title">\r
765                 <xsl:variable name="hasTitle">\r
766                         <xsl:for-each select="marc:subfield">\r
767                                 <xsl:if test="(contains('tfghklmors',@code) )">\r
768                                         <xsl:value-of select="@code"/>\r
769                                 </xsl:if>\r
770                         </xsl:for-each>\r
771                 </xsl:variable>\r
772                 <xsl:if test="string-length($hasTitle) &gt; 0 ">\r
773                         <mads:titleInfo>\r
774                                 <xsl:call-template name="setAuthority"/>\r
775                                 <mads:title>\r
776                                         <xsl:variable name="str">\r
777                                                 <xsl:for-each select="marc:subfield">\r
778                                                         <xsl:if test="(contains('atfghklmors',@code) )">\r
779                                                                 <xsl:value-of select="text()"/>\r
780                                                                 <xsl:text> </xsl:text>\r
781                                                         </xsl:if>\r
782                                                 </xsl:for-each>\r
783                                         </xsl:variable>\r
784                                         <xsl:call-template name="chopPunctuation">\r
785                                                 <xsl:with-param name="chopString">\r
786                                                         <xsl:value-of select="substring($str,1,string-length($str)-1)"/>\r
787                                                 </xsl:with-param>\r
788                                         </xsl:call-template>\r
789                                 </mads:title>\r
790                                 <xsl:call-template name="part"/>\r
791                                 <!-- <xsl:call-template name="uri"/> -->\r
792                         </mads:titleInfo>\r
793                 </xsl:if>\r
794         </xsl:template>\r
795 \r
796         <xsl:template name="uniform-title">\r
797                 <xsl:variable name="hasTitle">\r
798                         <xsl:for-each select="marc:subfield">\r
799                                 <xsl:if test="(contains('atfghklmors',@code) )">\r
800                                         <xsl:value-of select="@code"/>\r
801                                 </xsl:if>\r
802                         </xsl:for-each>\r
803                 </xsl:variable>\r
804                 <xsl:if test="string-length($hasTitle) &gt; 0 ">\r
805                         <mads:titleInfo>\r
806                                 <xsl:call-template name="setAuthority"/>\r
807                                 <mads:title>\r
808                                         <xsl:variable name="str">\r
809                                                 <xsl:for-each select="marc:subfield">\r
810                                                         <xsl:if test="(contains('adfghklmors',@code) )">\r
811                                                                 <xsl:value-of select="text()"/>\r
812                                                                 <xsl:text> </xsl:text>\r
813                                                         </xsl:if>\r
814                                                 </xsl:for-each>\r
815                                         </xsl:variable>\r
816                                         <xsl:call-template name="chopPunctuation">\r
817                                                 <xsl:with-param name="chopString">\r
818                                                         <xsl:value-of select="substring($str,1,string-length($str)-1)"/>\r
819                                                 </xsl:with-param>\r
820                                         </xsl:call-template>\r
821                                 </mads:title>\r
822                                 <xsl:call-template name="part"/>\r
823                                 <!-- <xsl:call-template name="uri"/> -->\r
824                         </mads:titleInfo>\r
825                 </xsl:if>\r
826         </xsl:template>\r
827 \r
828 \r
829         <!-- ========== topics  ========== -->\r
830         <xsl:template match="marc:subfield[@code='x']">\r
831                 <mads:topic>\r
832                         <xsl:call-template name="chopPunctuation">\r
833                                 <xsl:with-param name="chopString">\r
834                                         <xsl:value-of select="."/>\r
835                                 </xsl:with-param>\r
836                         </xsl:call-template>\r
837                 </mads:topic>\r
838         </xsl:template>\r
839         \r
840         <!-- 2.06 fix -->\r
841         <xsl:template\r
842                 match="marc:datafield[@tag=150][marc:subfield[@code='a' or @code='b']]|marc:datafield[@tag=180][marc:subfield[@code='x']]">\r
843                 <xsl:call-template name="topic"/>\r
844                 <xsl:apply-templates select="marc:subfield[@code!='i']"/>\r
845         </xsl:template>\r
846         <xsl:template\r
847                 match="marc:datafield[@tag=450][marc:subfield[@code='a' or @code='b']]|marc:datafield[@tag=480][marc:subfield[@code='x']]">\r
848                 <mads:variant>\r
849                         <xsl:call-template name="variantTypeAttribute"/>\r
850                         <xsl:call-template name="topic"/>\r
851                 </mads:variant>\r
852         </xsl:template>\r
853         <xsl:template\r
854                 match="marc:datafield[@tag=550 or @tag=750][marc:subfield[@code='a' or @code='b']]">\r
855                 <mads:related>\r
856                         <xsl:call-template name="relatedTypeAttribute"/>\r
857                         <!-- <xsl:call-template name="uri"/> -->\r
858                         <xsl:call-template name="topic"/>\r
859                         <xsl:apply-templates select="marc:subfield[@code='z']"/>\r
860                 </mads:related>\r
861         </xsl:template>\r
862         <xsl:template name="topic">\r
863                 <mads:topic>\r
864                         <xsl:call-template name="setAuthority"/>\r
865                         <!-- tmee2006 dedupe 550a\r
866                         <xsl:if test="@tag=550 or @tag=750">\r
867                                 <xsl:call-template name="subfieldSelect">\r
868                                         <xsl:with-param name="codes">ab</xsl:with-param>\r
869                                 </xsl:call-template>\r
870                         </xsl:if>       \r
871                         -->\r
872                         <xsl:choose>\r
873                                 <xsl:when test="@tag=180 or @tag=480 or @tag=580 or @tag=780">\r
874                                         <xsl:call-template name="chopPunctuation">\r
875                                                 <xsl:with-param name="chopString">\r
876                                                         <xsl:apply-templates select="marc:subfield[@code='x']"/>\r
877                                                 </xsl:with-param>\r
878                                         </xsl:call-template>\r
879                                 </xsl:when>\r
880                         </xsl:choose>\r
881                         <xsl:call-template name="chopPunctuation">\r
882                                 <xsl:with-param name="chopString">\r
883                                         <xsl:choose>\r
884                                                 <xsl:when test="@tag=180 or @tag=480 or @tag=580 or @tag=780">\r
885                                                         <xsl:apply-templates select="marc:subfield[@code='x']"/>\r
886                                                 </xsl:when>\r
887                                                 <xsl:otherwise>\r
888                                                         <xsl:call-template name="subfieldSelect">\r
889                                                                 <xsl:with-param name="codes">ab</xsl:with-param>\r
890                                                         </xsl:call-template>\r
891                                                 </xsl:otherwise>\r
892                                         </xsl:choose>\r
893                                 </xsl:with-param>\r
894                         </xsl:call-template>\r
895                 </mads:topic>\r
896         </xsl:template>\r
897 \r
898         <!-- ========= temporals  ========== -->\r
899         <xsl:template match="marc:subfield[@code='y']">\r
900                 <mads:temporal>\r
901                         <xsl:call-template name="chopPunctuation">\r
902                                 <xsl:with-param name="chopString">\r
903                                         <xsl:value-of select="."/>\r
904                                 </xsl:with-param>\r
905                         </xsl:call-template>\r
906                 </mads:temporal>\r
907         </xsl:template>\r
908         <xsl:template\r
909                 match="marc:datafield[@tag=148][marc:subfield[@code='a']]|marc:datafield[@tag=182 ][marc:subfield[@code='y']]">\r
910                 <xsl:call-template name="temporal"/>\r
911         </xsl:template>\r
912         <xsl:template\r
913                 match="marc:datafield[@tag=448][marc:subfield[@code='a']]|marc:datafield[@tag=482][marc:subfield[@code='y']]">\r
914                 <mads:variant>\r
915                         <xsl:call-template name="variantTypeAttribute"/>\r
916                         <xsl:call-template name="temporal"/>\r
917                 </mads:variant>\r
918         </xsl:template>\r
919         <xsl:template\r
920                 match="marc:datafield[@tag=548 or @tag=748][marc:subfield[@code='a']]|marc:datafield[@tag=582 or @tag=782][marc:subfield[@code='y']]">\r
921                 <mads:related>\r
922                         <xsl:call-template name="relatedTypeAttribute"/>\r
923                         <!-- <xsl:call-template name="uri"/> -->\r
924                         <xsl:call-template name="temporal"/>\r
925                 </mads:related>\r
926         </xsl:template>\r
927         <xsl:template name="temporal">\r
928                 <mads:temporal>\r
929                         <xsl:call-template name="setAuthority"/>\r
930                         <xsl:if test="@tag=548 or @tag=748">\r
931                                 <xsl:value-of select="marc:subfield[@code='a']"/>\r
932                         </xsl:if>\r
933                         <xsl:call-template name="chopPunctuation">\r
934                                 <xsl:with-param name="chopString">\r
935                                         <xsl:choose>\r
936                                                 <xsl:when test="@tag=182 or @tag=482 or @tag=582 or @tag=782">\r
937                                                         <xsl:apply-templates select="marc:subfield[@code='y']"/>\r
938                                                 </xsl:when>\r
939                                                 <xsl:otherwise>\r
940                                                         <xsl:value-of select="marc:subfield[@code='a']"/>\r
941                                                 </xsl:otherwise>\r
942                                         </xsl:choose>\r
943                                 </xsl:with-param>\r
944                         </xsl:call-template>\r
945                 </mads:temporal>\r
946                 <xsl:apply-templates select="marc:subfield[@code!='i']"/>\r
947         </xsl:template>\r
948 \r
949         <!-- ========== genre  ========== -->\r
950         <xsl:template match="marc:subfield[@code='v']">\r
951                 <mads:genre>\r
952                         <xsl:call-template name="chopPunctuation">\r
953                                 <xsl:with-param name="chopString">\r
954                                         <xsl:value-of select="."/>\r
955                                 </xsl:with-param>\r
956                         </xsl:call-template>\r
957                 </mads:genre>\r
958         </xsl:template>\r
959         <xsl:template\r
960                 match="marc:datafield[@tag=155][marc:subfield[@code='a']]|marc:datafield[@tag=185][marc:subfield[@code='v']]">\r
961                 <xsl:call-template name="genre"/>\r
962         </xsl:template>\r
963         <xsl:template\r
964                 match="marc:datafield[@tag=455][marc:subfield[@code='a']]|marc:datafield[@tag=485 ][marc:subfield[@code='v']]">\r
965                 <mads:variant>\r
966                         <xsl:call-template name="variantTypeAttribute"/>\r
967                         <xsl:call-template name="genre"/>\r
968                 </mads:variant>\r
969         </xsl:template>\r
970         <!--\r
971         <xsl:template match="marc:datafield[@tag=555]">\r
972                 <mads:related>\r
973                         <xsl:call-template name="relatedTypeAttribute"/>\r
974                         <xsl:call-template name="uri"/>\r
975                         <xsl:call-template name="genre"/>\r
976                 </mads:related>\r
977         </xsl:template>\r
978         -->\r
979         <xsl:template\r
980                 match="marc:datafield[@tag=555 or @tag=755][marc:subfield[@code='a']]|marc:datafield[@tag=585][marc:subfield[@code='v']]">\r
981                 <mads:related>\r
982                         <xsl:call-template name="relatedTypeAttribute"/>\r
983                         <xsl:call-template name="genre"/>\r
984                 </mads:related>\r
985         </xsl:template>\r
986         <xsl:template name="genre">\r
987                 <mads:genre>\r
988                         <xsl:if test="@tag=555">\r
989                                 <xsl:value-of select="marc:subfield[@code='a']"/>\r
990                         </xsl:if>\r
991                         <xsl:call-template name="setAuthority"/>\r
992                         <xsl:call-template name="chopPunctuation">\r
993                                 <xsl:with-param name="chopString">\r
994                                         <xsl:choose>\r
995                                                 <!-- 2.07 fix -->\r
996                                                 <xsl:when test="@tag='555'"/>\r
997                                                 <xsl:when test="@tag=185 or @tag=485 or @tag=585">\r
998                                                         <xsl:apply-templates select="marc:subfield[@code='v']"/>\r
999                                                 </xsl:when>\r
1000                                                 <xsl:otherwise>\r
1001                                                         <xsl:value-of select="marc:subfield[@code='a']"/>\r
1002                                                 </xsl:otherwise>\r
1003                                         </xsl:choose>\r
1004                                 </xsl:with-param>\r
1005                         </xsl:call-template>\r
1006                 </mads:genre>\r
1007                 <xsl:apply-templates/>\r
1008         </xsl:template>\r
1009 \r
1010         <!-- ========= geographic  ========== -->\r
1011         <xsl:template match="marc:subfield[@code='z']">\r
1012                 <mads:geographic>\r
1013                         <xsl:call-template name="chopPunctuation">\r
1014                                 <xsl:with-param name="chopString">\r
1015                                         <xsl:value-of select="."/>\r
1016                                 </xsl:with-param>\r
1017                         </xsl:call-template>\r
1018                 </mads:geographic>\r
1019         </xsl:template>\r
1020         <xsl:template name="geographic">\r
1021                 <mads:geographic>\r
1022                         <!-- 2.14 -->\r
1023                         <xsl:call-template name="setAuthority"/>\r
1024                         <!-- 2.13 -->\r
1025                         <xsl:if test="@tag=151 or @tag=551">\r
1026                                 <xsl:value-of select="marc:subfield[@code='a']"/>\r
1027                         </xsl:if>\r
1028                         <xsl:call-template name="chopPunctuation">\r
1029                                 <xsl:with-param name="chopString">\r
1030                                                 <xsl:if test="@tag=181 or @tag=481 or @tag=581">\r
1031                                                                 <xsl:apply-templates select="marc:subfield[@code='z']"/>\r
1032                                                 </xsl:if>\r
1033                                                 <!-- 2.13\r
1034                                                         <xsl:choose>\r
1035                                                 <xsl:when test="@tag=181 or @tag=481 or @tag=581">\r
1036                                                         <xsl:apply-templates select="marc:subfield[@code='z']"/>\r
1037                                                 </xsl:when>\r
1038                                         \r
1039                                                 <xsl:otherwise>\r
1040                                                         <xsl:value-of select="marc:subfield[@code='a']"/>\r
1041                                                 </xsl:otherwise>\r
1042                                                 </xsl:choose>\r
1043                                                 -->\r
1044                                 </xsl:with-param>\r
1045                         </xsl:call-template>\r
1046                 </mads:geographic>\r
1047                 <xsl:apply-templates select="marc:subfield[@code!='i']"/>\r
1048         </xsl:template>\r
1049         <xsl:template\r
1050                 match="marc:datafield[@tag=151][marc:subfield[@code='a']]|marc:datafield[@tag=181][marc:subfield[@code='z']]">\r
1051                 <xsl:call-template name="geographic"/>\r
1052         </xsl:template>\r
1053         <xsl:template\r
1054                 match="marc:datafield[@tag=451][marc:subfield[@code='a']]|marc:datafield[@tag=481][marc:subfield[@code='z']]">\r
1055                 <mads:variant>\r
1056                         <xsl:call-template name="variantTypeAttribute"/>\r
1057                         <xsl:call-template name="geographic"/>\r
1058                 </mads:variant>\r
1059         </xsl:template>\r
1060         <xsl:template\r
1061                 match="marc:datafield[@tag=551]|marc:datafield[@tag=581][marc:subfield[@code='z']]">\r
1062                 <mads:related>\r
1063                         <xsl:call-template name="relatedTypeAttribute"/>\r
1064                         <!-- <xsl:call-template name="uri"/> -->\r
1065                         <xsl:call-template name="geographic"/>\r
1066                 </mads:related>\r
1067         </xsl:template>\r
1068         <xsl:template match="marc:datafield[@tag=580]">\r
1069                 <mads:related>\r
1070                         <xsl:call-template name="relatedTypeAttribute"/>\r
1071                         <xsl:apply-templates select="marc:subfield[@code!='i']"/>\r
1072                 </mads:related>\r
1073         </xsl:template>\r
1074         <xsl:template\r
1075                 match="marc:datafield[@tag=751][marc:subfield[@code='z']]|marc:datafield[@tag=781][marc:subfield[@code='z']]">\r
1076                 <mads:related>\r
1077                         <xsl:call-template name="relatedTypeAttribute"/>\r
1078                         <xsl:call-template name="geographic"/>\r
1079                 </mads:related>\r
1080         </xsl:template>\r
1081         <xsl:template match="marc:datafield[@tag=755]">\r
1082                 <mads:related>\r
1083                         <xsl:call-template name="relatedTypeAttribute"/>\r
1084                         <xsl:call-template name="genre"/>\r
1085                         <xsl:call-template name="setAuthority"/>\r
1086                         <xsl:apply-templates select="marc:subfield[@code!='i']"/>\r
1087                 </mads:related>\r
1088         </xsl:template>\r
1089         <xsl:template match="marc:datafield[@tag=780]">\r
1090                 <mads:related>\r
1091                         <xsl:call-template name="relatedTypeAttribute"/>\r
1092                         <xsl:apply-templates select="marc:subfield[@code!='i']"/>\r
1093                 </mads:related>\r
1094         </xsl:template>\r
1095         <xsl:template match="marc:datafield[@tag=785]">\r
1096                 <mads:related>\r
1097                         <xsl:call-template name="relatedTypeAttribute"/>\r
1098                         <xsl:apply-templates select="marc:subfield[@code!='i']"/>\r
1099                 </mads:related>\r
1100         </xsl:template>\r
1101 \r
1102         <!-- ========== notes  ========== -->\r
1103         <xsl:template match="marc:datafield[667 &lt;= @tag and @tag &lt;= 688]">\r
1104                 <mads:note>\r
1105                         <xsl:choose>\r
1106                                 <xsl:when test="@tag=667">\r
1107                                         <xsl:attribute name="type">nonpublic</xsl:attribute>\r
1108                                 </xsl:when>\r
1109                                 <xsl:when test="@tag=670">\r
1110                                         <xsl:attribute name="type">source</xsl:attribute>\r
1111                                 </xsl:when>\r
1112                                 <xsl:when test="@tag=675">\r
1113                                         <xsl:attribute name="type">notFound</xsl:attribute>\r
1114                                 </xsl:when>\r
1115                                 <xsl:when test="@tag=678">\r
1116                                         <xsl:attribute name="type">history</xsl:attribute>\r
1117                                 </xsl:when>\r
1118                                 <xsl:when test="@tag=681">\r
1119                                         <xsl:attribute name="type">subject example</xsl:attribute>\r
1120                                 </xsl:when>\r
1121                                 <xsl:when test="@tag=682">\r
1122                                         <xsl:attribute name="type">deleted heading information</xsl:attribute>\r
1123                                 </xsl:when>\r
1124                                 <xsl:when test="@tag=688">\r
1125                                         <xsl:attribute name="type">application history</xsl:attribute>\r
1126                                 </xsl:when>\r
1127                         </xsl:choose>\r
1128                         <xsl:call-template name="chopPunctuation">\r
1129                                 <xsl:with-param name="chopString">\r
1130                                         <xsl:choose>\r
1131                                                 <xsl:when test="@tag=667 or @tag=675">\r
1132                                                         <xsl:value-of select="marc:subfield[@code='a']"/>\r
1133                                                 </xsl:when>\r
1134                                                 <xsl:when test="@tag=670 or @tag=678">\r
1135                                                         <xsl:call-template name="subfieldSelect">\r
1136                                                                 <xsl:with-param name="codes">ab</xsl:with-param>\r
1137                                                         </xsl:call-template>\r
1138                                                 </xsl:when>\r
1139                                                 <xsl:when test="680 &lt;= @tag and @tag &lt;=688">\r
1140                                                         <xsl:call-template name="subfieldSelect">\r
1141                                                                 <xsl:with-param name="codes">ai</xsl:with-param>\r
1142                                                         </xsl:call-template>\r
1143                                                 </xsl:when>\r
1144                                         </xsl:choose>\r
1145                                 </xsl:with-param>\r
1146                         </xsl:call-template>\r
1147                 </mads:note>\r
1148         </xsl:template>\r
1149 \r
1150         <!-- ========== url  ========== -->\r
1151         <xsl:template match="marc:datafield[@tag=856][marc:subfield[@code='u']]">\r
1152                 <mads:url>\r
1153                         <xsl:if test="marc:subfield[@code='z' or @code='3']">\r
1154                                 <xsl:attribute name="displayLabel">\r
1155                                         <xsl:call-template name="subfieldSelect">\r
1156                                                 <xsl:with-param name="codes">z3</xsl:with-param>\r
1157                                         </xsl:call-template>\r
1158                                 </xsl:attribute>\r
1159                         </xsl:if>\r
1160                         <xsl:value-of select="marc:subfield[@code='u']"/>\r
1161                 </mads:url>\r
1162         </xsl:template>\r
1163 \r
1164         <xsl:template name="relatedTypeAttribute">\r
1165                 <xsl:choose>\r
1166                         <xsl:when\r
1167                                 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">\r
1168                                 <xsl:if test="substring(marc:subfield[@code='w'],1,1)='a'">\r
1169                                         <xsl:attribute name="type">earlier</xsl:attribute>\r
1170                                 </xsl:if>\r
1171                                 <xsl:if test="substring(marc:subfield[@code='w'],1,1)='b'">\r
1172                                         <xsl:attribute name="type">later</xsl:attribute>\r
1173                                 </xsl:if>\r
1174                                 <xsl:if test="substring(marc:subfield[@code='w'],1,1)='t'">\r
1175                                         <xsl:attribute name="type">parentOrg</xsl:attribute>\r
1176                                 </xsl:if>\r
1177                                 <xsl:if test="substring(marc:subfield[@code='w'],1,1)='g'">\r
1178                                         <xsl:attribute name="type">broader</xsl:attribute>\r
1179                                 </xsl:if>\r
1180                                 <xsl:if test="substring(marc:subfield[@code='w'],1,1)='h'">\r
1181                                         <xsl:attribute name="type">narrower</xsl:attribute>\r
1182                                 </xsl:if>\r
1183                                 <xsl:if test="substring(marc:subfield[@code='w'],1,1)='r'">\r
1184                                         <xsl:attribute name="type">other</xsl:attribute>\r
1185                                 </xsl:if>\r
1186                                 <xsl:if test="contains('fin|', substring(marc:subfield[@code='w'],1,1))">\r
1187                                         <xsl:attribute name="type">other</xsl:attribute>\r
1188                                 </xsl:if>\r
1189                         </xsl:when>\r
1190                         <xsl:when test="@tag=530 or @tag=730">\r
1191                                 <xsl:attribute name="type">other</xsl:attribute>\r
1192                         </xsl:when>\r
1193                         <xsl:otherwise>\r
1194                                 <!-- 7xx -->\r
1195                                 <xsl:attribute name="type">equivalent</xsl:attribute>\r
1196                         </xsl:otherwise>\r
1197                 </xsl:choose>\r
1198                 <xsl:apply-templates select="marc:subfield[@code='i']"/>\r
1199         </xsl:template>\r
1200         \r
1201 \r
1202 \r
1203         <xsl:template name="variantTypeAttribute">\r
1204                 <xsl:choose>\r
1205                         <xsl:when\r
1206                                 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">\r
1207                                 <xsl:if test="substring(marc:subfield[@code='w'],1,1)='d'">\r
1208                                         <xsl:attribute name="type">acronym</xsl:attribute>\r
1209                                 </xsl:if>\r
1210                                 <xsl:if test="substring(marc:subfield[@code='w'],1,1)='n'">\r
1211                                         <xsl:attribute name="type">other</xsl:attribute>\r
1212                                 </xsl:if>\r
1213                                 <xsl:if test="contains('fit', substring(marc:subfield[@code='w'],1,1))">\r
1214                                         <xsl:attribute name="type">other</xsl:attribute>\r
1215                                 </xsl:if>\r
1216                         </xsl:when>\r
1217                         <xsl:otherwise>\r
1218                                 <!-- 430  -->\r
1219                                 <xsl:attribute name="type">other</xsl:attribute>\r
1220                         </xsl:otherwise>\r
1221                 </xsl:choose>\r
1222                 <xsl:apply-templates select="marc:subfield[@code='i']"/>\r
1223         </xsl:template>\r
1224 \r
1225         <xsl:template name="setAuthority">\r
1226                 <xsl:choose>\r
1227                         <!-- can be called from the datafield or subfield level, so "..//@tag" means\r
1228                         the tag can be at the subfield's parent level or at the datafields own level -->\r
1229 \r
1230                         <xsl:when\r
1231                                 test="ancestor-or-self::marc:datafield/@tag=100 and (@ind1=0 or @ind1=1) and $controlField008-11='a' and $controlField008-14='a'">\r
1232                                 <xsl:attribute name="authority">\r
1233                                         <xsl:text>naf</xsl:text>\r
1234                                 </xsl:attribute>\r
1235                         </xsl:when>\r
1236                         <xsl:when\r
1237                                 test="ancestor-or-self::marc:datafield/@tag=100 and (@ind1=0 or @ind1=1) and $controlField008-11='a' and $controlField008-14='b'">\r
1238                                 <xsl:attribute name="authority">\r
1239                                         <xsl:text>lcsh</xsl:text>\r
1240                                 </xsl:attribute>\r
1241                         </xsl:when>\r
1242                         <xsl:when\r
1243                                 test="ancestor-or-self::marc:datafield/@tag=100 and (@ind1=0 or @ind1=1) and $controlField008-11='k'">\r
1244                                 <xsl:attribute name="authority">\r
1245                                         <xsl:text>lacnaf</xsl:text>\r
1246                                 </xsl:attribute>\r
1247                         </xsl:when>\r
1248                         <xsl:when\r
1249                                 test="ancestor-or-self::marc:datafield/@tag=100 and @ind1=3 and $controlField008-11='a' and $controlField008-14='b'">\r
1250                                 <xsl:attribute name="authority">\r
1251                                         <xsl:text>lcsh</xsl:text>\r
1252                                 </xsl:attribute>\r
1253                         </xsl:when>\r
1254                         <xsl:when\r
1255                                 test="ancestor-or-self::marc:datafield/@tag=100 and @ind1=3 and $controlField008-11='k' and $controlField008-14='b'">\r
1256                                 <xsl:attribute name="authority">cash</xsl:attribute>\r
1257                         </xsl:when>\r
1258                         <xsl:when\r
1259                                 test="ancestor-or-self::marc:datafield/@tag=110 and $controlField008-11='a' and $controlField008-14='a'">\r
1260                                 <xsl:attribute name="authority">naf</xsl:attribute>\r
1261                         </xsl:when>\r
1262                         <xsl:when\r
1263                                 test="ancestor-or-self::marc:datafield/@tag=110 and $controlField008-11='a' and $controlField008-14='b'">\r
1264                                 <xsl:attribute name="authority">lcsh</xsl:attribute>\r
1265                         </xsl:when>\r
1266                         <xsl:when\r
1267                                 test="ancestor-or-self::marc:datafield/@tag=110 and $controlField008-11='k' and $controlField008-14='a'">\r
1268                                 <xsl:attribute name="authority">\r
1269                                         <xsl:text>lacnaf</xsl:text>\r
1270                                 </xsl:attribute>\r
1271                         </xsl:when>\r
1272                         <xsl:when\r
1273                                 test="ancestor-or-self::marc:datafield/@tag=110 and $controlField008-11='k' and $controlField008-14='b'">\r
1274                                 <xsl:attribute name="authority">\r
1275                                         <xsl:text>cash</xsl:text>\r
1276                                 </xsl:attribute>\r
1277                         </xsl:when>\r
1278                         <xsl:when\r
1279                                 test="100 &lt;= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag &lt;= 155 and $controlField008-11='b'">\r
1280                                 <xsl:attribute name="authority">\r
1281                                         <xsl:text>lcshcl</xsl:text>\r
1282                                 </xsl:attribute>\r
1283                         </xsl:when>\r
1284                         <xsl:when\r
1285                                 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'">\r
1286                                 <xsl:attribute name="authority">\r
1287                                         <xsl:text>nlmnaf</xsl:text>\r
1288                                 </xsl:attribute>\r
1289                         </xsl:when>\r
1290                         <xsl:when\r
1291                                 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'">\r
1292                                 <xsl:attribute name="authority">\r
1293                                         <xsl:text>nalnaf</xsl:text>\r
1294                                 </xsl:attribute>\r
1295                         </xsl:when>\r
1296                         <xsl:when\r
1297                                 test="100 &lt;= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag &lt;= 155 and $controlField008-11='r'">\r
1298                                 <xsl:attribute name="authority">\r
1299                                         <xsl:text>aat</xsl:text>\r
1300                                 </xsl:attribute>\r
1301                         </xsl:when>\r
1302                         <xsl:when\r
1303                                 test="100 &lt;= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag &lt;= 155 and $controlField008-11='s'">\r
1304                                 <xsl:attribute name="authority">sears</xsl:attribute>\r
1305                         </xsl:when>\r
1306                         <xsl:when\r
1307                                 test="100 &lt;= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag &lt;= 155 and $controlField008-11='v'">\r
1308                                 <xsl:attribute name="authority">rvm</xsl:attribute>\r
1309                         </xsl:when>\r
1310                         <xsl:when\r
1311                                 test="100 &lt;= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag &lt;= 155 and $controlField008-11='z'">\r
1312                                 <xsl:attribute name="authority">\r
1313                                         <xsl:value-of\r
1314                                                 select="../marc:datafield[ancestor-or-self::marc:datafield/@tag=040]/marc:subfield[@code='f']"\r
1315                                         />\r
1316                                 </xsl:attribute>\r
1317                         </xsl:when>\r
1318                         <xsl:when\r
1319                                 test="(ancestor-or-self::marc:datafield/@tag=111 or ancestor-or-self::marc:datafield/@tag=130) and $controlField008-11='a' and $controlField008-14='a'">\r
1320                                 <xsl:attribute name="authority">\r
1321                                         <xsl:text>naf</xsl:text>\r
1322                                 </xsl:attribute>\r
1323                         </xsl:when>\r
1324                         <xsl:when\r
1325                                 test="(ancestor-or-self::marc:datafield/@tag=111 or ancestor-or-self::marc:datafield/@tag=130) and $controlField008-11='a' and $controlField008-14='b'">\r
1326                                 <xsl:attribute name="authority">\r
1327                                         <xsl:text>lcsh</xsl:text>\r
1328                                 </xsl:attribute>\r
1329                         </xsl:when>\r
1330                         <xsl:when\r
1331                                 test="(ancestor-or-self::marc:datafield/@tag=111 or ancestor-or-self::marc:datafield/@tag=130) and $controlField008-11='k' ">\r
1332                                 <xsl:attribute name="authority">\r
1333                                         <xsl:text>lacnaf</xsl:text>\r
1334                                 </xsl:attribute>\r
1335                         </xsl:when>\r
1336                         <xsl:when\r
1337                                 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' ">\r
1338                                 <xsl:attribute name="authority">\r
1339                                         <xsl:text>lcsh</xsl:text>\r
1340                                 </xsl:attribute>\r
1341                         </xsl:when>\r
1342                         <xsl:when\r
1343                                 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' ">\r
1344                                 <xsl:attribute name="authority">\r
1345                                         <xsl:text>lcsh</xsl:text>\r
1346                                 </xsl:attribute>\r
1347                         </xsl:when>\r
1348                         <xsl:when\r
1349                                 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' ">\r
1350                                 <xsl:attribute name="authority">\r
1351                                         <xsl:text>mesh</xsl:text>\r
1352                                 </xsl:attribute>\r
1353                         </xsl:when>\r
1354                         <xsl:when\r
1355                                 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' ">\r
1356                                 <xsl:attribute name="authority">\r
1357                                         <xsl:text>nal</xsl:text>\r
1358                                 </xsl:attribute>\r
1359                         </xsl:when>\r
1360                         <xsl:when\r
1361                                 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' ">\r
1362                                 <xsl:attribute name="authority">\r
1363                                         <xsl:text>cash</xsl:text>\r
1364                                 </xsl:attribute>\r
1365                         </xsl:when>\r
1366                         <xsl:when\r
1367                                 test="ancestor-or-self::marc:datafield/@tag=151 and $controlField008-11='a' and $controlField008-14='a'">\r
1368                                 <xsl:attribute name="authority">\r
1369                                         <xsl:text>naf</xsl:text>\r
1370                                 </xsl:attribute>\r
1371                         </xsl:when>\r
1372                         <xsl:when\r
1373                                 test="ancestor-or-self::marc:datafield/@tag=151 and $controlField008-11='a' and $controlField008-14='b'">\r
1374                                 <xsl:attribute name="authority">lcsh</xsl:attribute>\r
1375                         </xsl:when>\r
1376                         <xsl:when\r
1377                                 test="ancestor-or-self::marc:datafield/@tag=151 and $controlField008-11='k' and $controlField008-14='a'">\r
1378                                 <xsl:attribute name="authority">lacnaf</xsl:attribute>\r
1379                         </xsl:when>\r
1380                         <xsl:when\r
1381                                 test="ancestor-or-self::marc:datafield/@tag=151 and $controlField008-11='k' and $controlField008-14='b'">\r
1382                                 <xsl:attribute name="authority">cash</xsl:attribute>\r
1383                         </xsl:when>\r
1384                         <xsl:when\r
1385                                 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'">\r
1386                                 <xsl:attribute name="authority">lcsh</xsl:attribute>\r
1387                         </xsl:when>\r
1388                         <xsl:when\r
1389                                 test="ancestor-or-self::marc:datafield/@tag=700 and (@ind1='0' or @ind1='1') and @ind2='0'">\r
1390                                 <xsl:attribute name="authority">naf</xsl:attribute>\r
1391                         </xsl:when>\r
1392                         <xsl:when\r
1393                                 test="ancestor-or-self::marc:datafield/@tag=700 and (@ind1='0' or @ind1='1') and @ind2='5'">\r
1394                                 <xsl:attribute name="authority">lacnaf</xsl:attribute>\r
1395                         </xsl:when>\r
1396                         <xsl:when test="ancestor-or-self::marc:datafield/@tag=700 and @ind1='3' and @ind2='0'">\r
1397                                 <xsl:attribute name="authority">lcsh</xsl:attribute>\r
1398                         </xsl:when>\r
1399                         <xsl:when test="ancestor-or-self::marc:datafield/@tag=700 and @ind1='3' and @ind2='5'">\r
1400                                 <xsl:attribute name="authority">cash</xsl:attribute>\r
1401                         </xsl:when>\r
1402                         <xsl:when\r
1403                                 test="(700 &lt;= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag &lt;= 755 ) and @ind2='1'">\r
1404                                 <xsl:attribute name="authority">lcshcl</xsl:attribute>\r
1405                         </xsl:when>\r
1406                         <xsl:when\r
1407                                 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'">\r
1408                                 <xsl:attribute name="authority">nlmnaf</xsl:attribute>\r
1409                         </xsl:when>\r
1410                         <xsl:when\r
1411                                 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'">\r
1412                                 <xsl:attribute name="authority">nalnaf</xsl:attribute>\r
1413                         </xsl:when>\r
1414                         <xsl:when\r
1415                                 test="(700 &lt;= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag &lt;= 755 ) and @ind2='6'">\r
1416                                 <xsl:attribute name="authority">rvm</xsl:attribute>\r
1417                         </xsl:when>\r
1418                         <xsl:when\r
1419                                 test="(700 &lt;= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag &lt;= 755 ) and @ind2='7'">\r
1420                                 <xsl:attribute name="authority">\r
1421                                         <xsl:value-of select="marc:subfield[@code='2']"/>\r
1422                                 </xsl:attribute>\r
1423                         </xsl:when>\r
1424                         <xsl:when\r
1425                                 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'">\r
1426                                 <xsl:attribute name="authority">lacnaf</xsl:attribute>\r
1427                         </xsl:when>\r
1428                         <xsl:when\r
1429                                 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'">\r
1430                                 <xsl:attribute name="authority">naf</xsl:attribute>\r
1431                         </xsl:when>\r
1432                         <xsl:when\r
1433                                 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'">\r
1434                                 <xsl:attribute name="authority">lcsh</xsl:attribute>\r
1435                         </xsl:when>\r
1436                         <xsl:when\r
1437                                 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'">\r
1438                                 <xsl:attribute name="authority">mesh</xsl:attribute>\r
1439                         </xsl:when>\r
1440                         <xsl:when\r
1441                                 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'">\r
1442                                 <xsl:attribute name="authority">nal</xsl:attribute>\r
1443                         </xsl:when>\r
1444                         <xsl:when\r
1445                                 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'">\r
1446                                 <xsl:attribute name="authority">cash</xsl:attribute>\r
1447                         </xsl:when>\r
1448                 </xsl:choose>\r
1449         </xsl:template>\r
1450         <xsl:template match="*"/>\r
1451 </xsl:stylesheet>\r