View | Details | Raw Unified | Return to bug 8203
Collapse All | Expand All

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

Return to bug 8203