1 --Upgrade Script for 3.7.2 to 3.7.3
2 \set eg_version '''3.7.3'''
4 INSERT INTO config.upgrade_log (version, applied_to) VALUES ('3.7.3', :eg_version);
6 SELECT evergreen.upgrade_deps_block_check('1306', :eg_version);
8 -- We don't pass this function arrays with nulls, so we save 5% not testing for that
9 CREATE OR REPLACE FUNCTION evergreen.text_array_merge_unique (
11 ) RETURNS TEXT[] AS $F$
13 SELECT * FROM UNNEST($1) x
15 SELECT * FROM UNNEST($2) y
19 CREATE OR REPLACE FUNCTION search.symspell_build_raw_entry (
22 no_limit BOOL DEFAULT FALSE,
23 prefix_length INT DEFAULT 6,
25 ) RETURNS SETOF search.symspell_dictionary AS $F$
30 entry search.symspell_dictionary%ROWTYPE;
34 IF NOT no_limit AND CHARACTER_LENGTH(raw_input) > prefix_length THEN
35 key := SUBSTRING(key FROM 1 FOR prefix_length);
36 key_list := ARRAY[raw_input, key];
38 key_list := ARRAY[key];
41 FOREACH del_key IN ARRAY key_list LOOP
43 CONTINUE WHEN del_key IS NULL OR CHARACTER_LENGTH(del_key) = 0;
45 entry.prefix_key := del_key;
47 entry.keyword_count := 0;
48 entry.title_count := 0;
49 entry.author_count := 0;
50 entry.subject_count := 0;
51 entry.series_count := 0;
52 entry.identifier_count := 0;
54 entry.keyword_suggestions := '{}';
55 entry.title_suggestions := '{}';
56 entry.author_suggestions := '{}';
57 entry.subject_suggestions := '{}';
58 entry.series_suggestions := '{}';
59 entry.identifier_suggestions := '{}';
61 IF source_class = 'keyword' THEN entry.keyword_suggestions := ARRAY[raw_input]; END IF;
62 IF source_class = 'title' THEN entry.title_suggestions := ARRAY[raw_input]; END IF;
63 IF source_class = 'author' THEN entry.author_suggestions := ARRAY[raw_input]; END IF;
64 IF source_class = 'subject' THEN entry.subject_suggestions := ARRAY[raw_input]; END IF;
65 IF source_class = 'series' THEN entry.series_suggestions := ARRAY[raw_input]; END IF;
66 IF source_class = 'identifier' THEN entry.identifier_suggestions := ARRAY[raw_input]; END IF;
67 IF source_class = 'keyword' THEN entry.keyword_suggestions := ARRAY[raw_input]; END IF;
69 IF del_key = raw_input THEN
70 IF source_class = 'keyword' THEN entry.keyword_count := 1; END IF;
71 IF source_class = 'title' THEN entry.title_count := 1; END IF;
72 IF source_class = 'author' THEN entry.author_count := 1; END IF;
73 IF source_class = 'subject' THEN entry.subject_count := 1; END IF;
74 IF source_class = 'series' THEN entry.series_count := 1; END IF;
75 IF source_class = 'identifier' THEN entry.identifier_count := 1; END IF;
81 FOR del_key IN SELECT x FROM UNNEST(search.symspell_generate_edits(key, 1, maxED)) x LOOP
84 CONTINUE WHEN del_key IS NULL OR CHARACTER_LENGTH(del_key) = 0;
85 -- skip suggestions that are already too long for the prefix key
86 CONTINUE WHEN CHARACTER_LENGTH(del_key) <= (prefix_length - maxED) AND CHARACTER_LENGTH(raw_input) > prefix_length;
88 entry.keyword_suggestions := '{}';
89 entry.title_suggestions := '{}';
90 entry.author_suggestions := '{}';
91 entry.subject_suggestions := '{}';
92 entry.series_suggestions := '{}';
93 entry.identifier_suggestions := '{}';
95 IF source_class = 'keyword' THEN entry.keyword_count := 0; END IF;
96 IF source_class = 'title' THEN entry.title_count := 0; END IF;
97 IF source_class = 'author' THEN entry.author_count := 0; END IF;
98 IF source_class = 'subject' THEN entry.subject_count := 0; END IF;
99 IF source_class = 'series' THEN entry.series_count := 0; END IF;
100 IF source_class = 'identifier' THEN entry.identifier_count := 0; END IF;
102 entry.prefix_key := del_key;
104 IF source_class = 'keyword' THEN entry.keyword_suggestions := ARRAY[raw_input]; END IF;
105 IF source_class = 'title' THEN entry.title_suggestions := ARRAY[raw_input]; END IF;
106 IF source_class = 'author' THEN entry.author_suggestions := ARRAY[raw_input]; END IF;
107 IF source_class = 'subject' THEN entry.subject_suggestions := ARRAY[raw_input]; END IF;
108 IF source_class = 'series' THEN entry.series_suggestions := ARRAY[raw_input]; END IF;
109 IF source_class = 'identifier' THEN entry.identifier_suggestions := ARRAY[raw_input]; END IF;
110 IF source_class = 'keyword' THEN entry.keyword_suggestions := ARRAY[raw_input]; END IF;
116 $F$ LANGUAGE PLPGSQL STRICT IMMUTABLE;
118 CREATE OR REPLACE FUNCTION search.symspell_build_entries (
121 old_input TEXT DEFAULT NULL,
122 include_phrases BOOL DEFAULT FALSE
123 ) RETURNS SETOF search.symspell_dictionary AS $F$
130 entry search.symspell_dictionary;
132 IF full_input IS NOT NULL THEN
133 SELECT value::INT INTO prefix_length FROM config.internal_flag WHERE name = 'symspell.prefix_length' AND enabled;
134 prefix_length := COALESCE(prefix_length, 6);
136 SELECT value::INT INTO maxED FROM config.internal_flag WHERE name = 'symspell.max_edit_distance' AND enabled;
137 maxED := COALESCE(maxED, 3);
139 input := evergreen.lowercase(full_input);
140 word_list := ARRAY_AGG(x) FROM search.symspell_parse_words_distinct(input) x;
141 IF word_list IS NULL THEN
145 IF CARDINALITY(word_list) > 1 AND include_phrases THEN
146 RETURN QUERY SELECT * FROM search.symspell_build_raw_entry(input, source_class, TRUE, prefix_length, maxED);
149 FOREACH word IN ARRAY word_list LOOP
150 -- Skip words that have runs of 5 or more digits (I'm looking at you, ISxNs)
151 CONTINUE WHEN CHARACTER_LENGTH(word) > 4 AND word ~ '\d{5,}';
152 RETURN QUERY SELECT * FROM search.symspell_build_raw_entry(word, source_class, FALSE, prefix_length, maxED);
156 IF old_input IS NOT NULL THEN
157 input := evergreen.lowercase(old_input);
159 FOR word IN SELECT x FROM search.symspell_parse_words_distinct(input) x LOOP
160 -- similarly skip words that have 5 or more digits here to
161 -- avoid adding erroneous prefix deletion entries to the dictionary
162 CONTINUE WHEN CHARACTER_LENGTH(word) > 4 AND word ~ '\d{5,}';
163 entry.prefix_key := word;
165 entry.keyword_count := 0;
166 entry.title_count := 0;
167 entry.author_count := 0;
168 entry.subject_count := 0;
169 entry.series_count := 0;
170 entry.identifier_count := 0;
172 entry.keyword_suggestions := '{}';
173 entry.title_suggestions := '{}';
174 entry.author_suggestions := '{}';
175 entry.subject_suggestions := '{}';
176 entry.series_suggestions := '{}';
177 entry.identifier_suggestions := '{}';
179 IF source_class = 'keyword' THEN entry.keyword_count := -1; END IF;
180 IF source_class = 'title' THEN entry.title_count := -1; END IF;
181 IF source_class = 'author' THEN entry.author_count := -1; END IF;
182 IF source_class = 'subject' THEN entry.subject_count := -1; END IF;
183 IF source_class = 'series' THEN entry.series_count := -1; END IF;
184 IF source_class = 'identifier' THEN entry.identifier_count := -1; END IF;
190 $F$ LANGUAGE PLPGSQL;
192 CREATE OR REPLACE FUNCTION search.symspell_build_and_merge_entries (
195 old_input TEXT DEFAULT NULL,
196 include_phrases BOOL DEFAULT FALSE
197 ) RETURNS SETOF search.symspell_dictionary AS $F$
200 conflict_entry RECORD;
203 IF full_input = old_input THEN -- neither NULL, and are the same
207 FOR new_entry IN EXECUTE $q$
211 FROM (SELECT prefix_key,
212 ARRAY_AGG(DISTINCT $q$ || source_class || $q$_suggestions[1]) s,
213 SUM($q$ || source_class || $q$_count) count
214 FROM search.symspell_build_entries($1, $2, $3, $4)
216 $q$ USING full_input, source_class, old_input, include_phrases
220 $q$ || source_class || $q$_suggestions suggestions,
221 $q$ || source_class || $q$_count count
222 FROM search.symspell_dictionary
223 WHERE prefix_key = $1 $q$
225 USING new_entry.prefix_key;
227 IF new_entry.count <> 0 THEN -- Real word, and count changed
228 IF conflict_entry.prefix_key IS NOT NULL THEN -- we'll be updating
229 IF conflict_entry.count > 0 THEN -- it's a real word
230 RETURN QUERY EXECUTE $q$
231 UPDATE search.symspell_dictionary
232 SET $q$ || source_class || $q$_count = $2
233 WHERE prefix_key = $1
235 USING new_entry.prefix_key, GREATEST(0, new_entry.count + conflict_entry.count);
236 ELSE -- it was a prefix key or delete-emptied word before
237 IF conflict_entry.suggestions @> new_entry.suggestions THEN -- already have all suggestions here...
238 RETURN QUERY EXECUTE $q$
239 UPDATE search.symspell_dictionary
240 SET $q$ || source_class || $q$_count = $2
241 WHERE prefix_key = $1
243 USING new_entry.prefix_key, GREATEST(0, new_entry.count);
244 ELSE -- new suggestion!
245 RETURN QUERY EXECUTE $q$
246 UPDATE search.symspell_dictionary
247 SET $q$ || source_class || $q$_count = $2,
248 $q$ || source_class || $q$_suggestions = $3
249 WHERE prefix_key = $1
251 USING new_entry.prefix_key, GREATEST(0, new_entry.count), evergreen.text_array_merge_unique(conflict_entry.suggestions,new_entry.suggestions);
255 -- We keep the on-conflict clause just in case...
256 RETURN QUERY EXECUTE $q$
257 INSERT INTO search.symspell_dictionary AS d (
258 $q$ || source_class || $q$_count,
260 $q$ || source_class || $q$_suggestions
261 ) VALUES ( $1, $2, $3 ) ON CONFLICT (prefix_key) DO
262 UPDATE SET $q$ || source_class || $q$_count = d.$q$ || source_class || $q$_count + EXCLUDED.$q$ || source_class || $q$_count,
263 $q$ || source_class || $q$_suggestions = evergreen.text_array_merge_unique(d.$q$ || source_class || $q$_suggestions, EXCLUDED.$q$ || source_class || $q$_suggestions)
265 USING new_entry.count, new_entry.prefix_key, new_entry.suggestions;
267 ELSE -- key only, or no change
268 IF conflict_entry.prefix_key IS NOT NULL THEN -- we'll be updating
269 IF NOT conflict_entry.suggestions @> new_entry.suggestions THEN -- There are new suggestions
270 RETURN QUERY EXECUTE $q$
271 UPDATE search.symspell_dictionary
272 SET $q$ || source_class || $q$_suggestions = $2
273 WHERE prefix_key = $1
275 USING new_entry.prefix_key, evergreen.text_array_merge_unique(conflict_entry.suggestions,new_entry.suggestions);
278 RETURN QUERY EXECUTE $q$
279 INSERT INTO search.symspell_dictionary AS d (
280 $q$ || source_class || $q$_count,
282 $q$ || source_class || $q$_suggestions
283 ) VALUES ( $1, $2, $3 ) ON CONFLICT (prefix_key) DO -- key exists, suggestions may be added due to this entry
284 UPDATE SET $q$ || source_class || $q$_suggestions = evergreen.text_array_merge_unique(d.$q$ || source_class || $q$_suggestions, EXCLUDED.$q$ || source_class || $q$_suggestions)
286 USING new_entry.count, new_entry.prefix_key, new_entry.suggestions;
291 $F$ LANGUAGE PLPGSQL;
295 \qecho 'The following should be run at the end of the upgrade before any'
296 \qecho 'reingest occurs. Because new triggers are installed already,'
297 \qecho 'updates to indexed strings will cause zero-count dictionary entries'
298 \qecho 'to be recorded which will require updating every row again (or'
299 \qecho 'starting from scratch) so best to do this before other batch'
300 \qecho 'changes. A later reingest that does not significantly change'
301 \qecho 'indexed strings will /not/ cause table bloat here, and will be'
302 \qecho 'as fast as normal. A copy of the SQL in a ready-to-use, non-escaped'
303 \qecho 'form is available inside a comment at the end of this upgrade sub-'
304 \qecho 'script so you do not need to copy this comment from the psql ouptut.'
310 \qecho 'select value from metabib.title_field_entry where source in (select id from biblio.record_entry where not deleted);'
312 \qecho 'select value from metabib.author_field_entry where source in (select id from biblio.record_entry where not deleted);'
314 \qecho 'select value from metabib.subject_field_entry where source in (select id from biblio.record_entry where not deleted);'
316 \qecho 'select value from metabib.series_field_entry where source in (select id from biblio.record_entry where not deleted);'
317 \qecho '\\o identifier'
318 \qecho 'select value from metabib.identifier_field_entry where source in (select id from biblio.record_entry where not deleted);'
320 \qecho 'select value from metabib.keyword_field_entry where source in (select id from biblio.record_entry where not deleted);'
326 \qecho '// Then, at the command line:'
328 \qecho '$ ~/EG-src-path/Open-ILS/src/support-scripts/symspell-sideload.pl title > title.sql'
329 \qecho '$ ~/EG-src-path/Open-ILS/src/support-scripts/symspell-sideload.pl author > author.sql'
330 \qecho '$ ~/EG-src-path/Open-ILS/src/support-scripts/symspell-sideload.pl subject > subject.sql'
331 \qecho '$ ~/EG-src-path/Open-ILS/src/support-scripts/symspell-sideload.pl series > series.sql'
332 \qecho '$ ~/EG-src-path/Open-ILS/src/support-scripts/symspell-sideload.pl identifier > identifier.sql'
333 \qecho '$ ~/EG-src-path/Open-ILS/src/support-scripts/symspell-sideload.pl keyword > keyword.sql'
335 \qecho '// And, back in psql'
337 \qecho 'ALTER TABLE search.symspell_dictionary SET UNLOGGED;'
338 \qecho 'TRUNCATE search.symspell_dictionary;'
340 \qecho '\\i identifier.sql'
341 \qecho '\\i author.sql'
342 \qecho '\\i title.sql'
343 \qecho '\\i subject.sql'
344 \qecho '\\i series.sql'
345 \qecho '\\i keyword.sql'
347 \qecho 'CLUSTER search.symspell_dictionary USING symspell_dictionary_pkey;'
348 \qecho 'REINDEX TABLE search.symspell_dictionary;'
349 \qecho 'ALTER TABLE search.symspell_dictionary SET LOGGED;'
350 \qecho 'VACUUM ANALYZE search.symspell_dictionary;'
352 \qecho 'DROP TABLE search.symspell_dictionary_partial_title;'
353 \qecho 'DROP TABLE search.symspell_dictionary_partial_author;'
354 \qecho 'DROP TABLE search.symspell_dictionary_partial_subject;'
355 \qecho 'DROP TABLE search.symspell_dictionary_partial_series;'
356 \qecho 'DROP TABLE search.symspell_dictionary_partial_identifier;'
357 \qecho 'DROP TABLE search.symspell_dictionary_partial_keyword;'
365 select value from metabib.title_field_entry where source in (select id from biblio.record_entry where not deleted);
368 select value from metabib.author_field_entry where source in (select id from biblio.record_entry where not deleted);
371 select value from metabib.subject_field_entry where source in (select id from biblio.record_entry where not deleted);
374 select value from metabib.series_field_entry where source in (select id from biblio.record_entry where not deleted);
377 select value from metabib.identifier_field_entry where source in (select id from biblio.record_entry where not deleted);
380 select value from metabib.keyword_field_entry where source in (select id from biblio.record_entry where not deleted);
386 // Then, at the command line:
388 $ ~/EG-src-path/Open-ILS/src/support-scripts/symspell-sideload.pl title > title.sql
389 $ ~/EG-src-path/Open-ILS/src/support-scripts/symspell-sideload.pl author > author.sql
390 $ ~/EG-src-path/Open-ILS/src/support-scripts/symspell-sideload.pl subject > subject.sql
391 $ ~/EG-src-path/Open-ILS/src/support-scripts/symspell-sideload.pl series > series.sql
392 $ ~/EG-src-path/Open-ILS/src/support-scripts/symspell-sideload.pl identifier > identifier.sql
393 $ ~/EG-src-path/Open-ILS/src/support-scripts/symspell-sideload.pl keyword > keyword.sql
395 // To the extent your hardware allows, the above commands can be run in
396 // in parallel, in different shells. Each will use a full CPU, and RAM
397 // may be a limiting resource, so keep an eye on that with `top`.
402 ALTER TABLE search.symspell_dictionary SET UNLOGGED;
403 TRUNCATE search.symspell_dictionary;
412 CLUSTER search.symspell_dictionary USING symspell_dictionary_pkey;
413 REINDEX TABLE search.symspell_dictionary;
414 ALTER TABLE search.symspell_dictionary SET LOGGED;
415 VACUUM ANALYZE search.symspell_dictionary;
417 DROP TABLE search.symspell_dictionary_partial_title;
418 DROP TABLE search.symspell_dictionary_partial_author;
419 DROP TABLE search.symspell_dictionary_partial_subject;
420 DROP TABLE search.symspell_dictionary_partial_series;
421 DROP TABLE search.symspell_dictionary_partial_identifier;
422 DROP TABLE search.symspell_dictionary_partial_keyword;
427 SELECT evergreen.upgrade_deps_block_check('1309', :eg_version);
429 ALTER TABLE asset.course_module_term
430 DROP CONSTRAINT course_module_term_name_key;
432 ALTER TABLE asset.course_module_term
433 ADD CONSTRAINT cmt_once_per_owning_lib UNIQUE (owning_lib, name);
436 SELECT evergreen.upgrade_deps_block_check('1311', :eg_version);
438 CREATE OR REPLACE FUNCTION biblio.extract_located_uris( bib_id BIGINT, marcxml TEXT, editor_id INT ) RETURNS VOID AS $func$
445 uri_owner_list TEXT[];
454 current_uri_map_list INT[];
455 current_map_owner_list INT[];
459 uris := oils_xpath('//*[@tag="856" and (@ind1="4" or @ind1="1") and (@ind2="0" or @ind2="1")]',marcxml);
460 IF ARRAY_UPPER(uris,1) > 0 THEN
461 FOR i IN 1 .. ARRAY_UPPER(uris, 1) LOOP
462 -- First we pull info out of the 856
465 uri_href := (oils_xpath('//*[@code="u"]/text()',uri_xml))[1];
466 uri_label := (oils_xpath('//*[@code="y"]/text()|//*[@code="3"]/text()',uri_xml))[1];
467 uri_use := (oils_xpath('//*[@code="z"]/text()|//*[@code="2"]/text()|//*[@code="n"]/text()',uri_xml))[1];
469 IF uri_label IS NULL THEN
470 uri_label := uri_href;
472 CONTINUE WHEN uri_href IS NULL;
474 -- Get the distinct list of libraries wanting to use
476 DISTINCT REGEXP_REPLACE(
478 $re$^.*?\((\w+)\).*$$re$,
481 ) INTO uri_owner_list
484 '//*[@code="9"]/text()|//*[@code="w"]/text()|//*[@code="n"]/text()',
489 IF ARRAY_UPPER(uri_owner_list,1) > 0 THEN
491 -- look for a matching uri
492 IF uri_use IS NULL THEN
493 SELECT id INTO uri_id
495 WHERE label = uri_label AND href = uri_href AND use_restriction IS NULL AND active
497 IF NOT FOUND THEN -- create one
498 INSERT INTO asset.uri (label, href, use_restriction) VALUES (uri_label, uri_href, uri_use);
499 SELECT id INTO uri_id
501 WHERE label = uri_label AND href = uri_href AND use_restriction IS NULL AND active;
504 SELECT id INTO uri_id
506 WHERE label = uri_label AND href = uri_href AND use_restriction = uri_use AND active
508 IF NOT FOUND THEN -- create one
509 INSERT INTO asset.uri (label, href, use_restriction) VALUES (uri_label, uri_href, uri_use);
510 SELECT id INTO uri_id
512 WHERE label = uri_label AND href = uri_href AND use_restriction = uri_use AND active;
516 FOR j IN 1 .. ARRAY_UPPER(uri_owner_list, 1) LOOP
517 uri_owner := uri_owner_list[j];
519 SELECT id INTO uri_owner_id FROM actor.org_unit WHERE shortname = BTRIM(REPLACE(uri_owner,chr(160),''));
520 CONTINUE WHEN NOT FOUND;
522 -- we need a call number to link through
523 SELECT id INTO uri_cn_id FROM asset.call_number WHERE owning_lib = uri_owner_id AND record = bib_id AND label = '##URI##' AND NOT deleted;
525 INSERT INTO asset.call_number (owning_lib, record, create_date, edit_date, creator, editor, label)
526 VALUES (uri_owner_id, bib_id, 'now', 'now', editor_id, editor_id, '##URI##');
527 SELECT id INTO uri_cn_id FROM asset.call_number WHERE owning_lib = uri_owner_id AND record = bib_id AND label = '##URI##' AND NOT deleted;
530 -- now, link them if they're not already
531 SELECT id INTO uri_map_id FROM asset.uri_call_number_map WHERE call_number = uri_cn_id AND uri = uri_id;
533 INSERT INTO asset.uri_call_number_map (call_number, uri) VALUES (uri_cn_id, uri_id);
534 SELECT id INTO uri_map_id FROM asset.uri_call_number_map WHERE call_number = uri_cn_id AND uri = uri_id;
537 current_uri_map_list := current_uri_map_list || uri_map_id;
538 current_map_owner_list := current_map_owner_list || uri_cn_id;
547 -- Clear any orphaned URIs, URI mappings and call
548 -- numbers for this bib that weren't mapped above.
551 FROM asset.uri_call_number_map m
552 LEFT JOIN asset.call_number cn ON (cn.id = m.call_number)
553 WHERE cn.record = bib_id
554 AND cn.label = '##URI##'
555 AND (NOT (m.id = ANY (current_uri_map_list))
556 OR current_uri_map_list is NULL)
558 SELECT uri INTO current_uri FROM asset.uri_call_number_map WHERE id = current_map;
559 DELETE FROM asset.uri_call_number_map WHERE id = current_map;
561 SELECT COUNT(*) INTO uri_map_count FROM asset.uri_call_number_map WHERE uri = current_uri;
562 IF uri_map_count = 0 THEN
563 DELETE FROM asset.uri WHERE id = current_uri;
567 UPDATE asset.call_number
568 SET deleted = TRUE, edit_date = now(), editor = editor_id
571 FROM asset.call_number
572 WHERE record = bib_id
573 AND label = '##URI##'
575 AND (NOT (id = ANY (current_map_owner_list))
576 OR current_map_owner_list is NULL)
581 $func$ LANGUAGE PLPGSQL;
583 -- Remove existing orphaned URIs from the database.
584 DELETE FROM asset.uri
589 LEFT JOIN asset.uri_call_number_map
590 ON uri_call_number_map.uri = uri.id
591 LEFT JOIN serial.item
593 WHERE uri_call_number_map IS NULL
599 SELECT evergreen.upgrade_deps_block_check('1325', :eg_version);
601 UPDATE config.xml_transform SET xslt=$XSLT$<?xml version="1.0" encoding="UTF-8"?>
602 <xsl:stylesheet version="1.0" xmlns:mads="http://www.loc.gov/mads/v2"
603 xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:marc="http://www.loc.gov/MARC21/slim"
604 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="marc">
605 <xsl:output method="xml" indent="yes" encoding="UTF-8"/>
606 <xsl:strip-space elements="*"/>
608 <xsl:variable name="ascii">
609 <xsl:text> !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~</xsl:text>
612 <xsl:variable name="latin1">
613 <xsl:text> ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ</xsl:text>
615 <!-- Characters that usually don't need to be escaped -->
616 <xsl:variable name="safe">
617 <xsl:text>!'()*-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~</xsl:text>
620 <xsl:variable name="hex">0123456789ABCDEF</xsl:variable>
623 <xsl:template name="datafield">
624 <xsl:param name="tag"/>
625 <xsl:param name="ind1">
626 <xsl:text> </xsl:text>
628 <xsl:param name="ind2">
629 <xsl:text> </xsl:text>
631 <xsl:param name="subfields"/>
632 <xsl:element name="marc:datafield">
633 <xsl:attribute name="tag">
634 <xsl:value-of select="$tag"/>
636 <xsl:attribute name="ind1">
637 <xsl:value-of select="$ind1"/>
639 <xsl:attribute name="ind2">
640 <xsl:value-of select="$ind2"/>
642 <xsl:copy-of select="$subfields"/>
646 <xsl:template name="subfieldSelect">
647 <xsl:param name="codes">abcdefghijklmnopqrstuvwxyz</xsl:param>
648 <xsl:param name="delimeter">
649 <xsl:text> </xsl:text>
651 <xsl:variable name="str">
652 <xsl:for-each select="marc:subfield">
653 <xsl:if test="contains($codes, @code)">
654 <xsl:value-of select="text()"/>
655 <xsl:value-of select="$delimeter"/>
659 <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
662 <xsl:template name="buildSpaces">
663 <xsl:param name="spaces"/>
664 <xsl:param name="char">
665 <xsl:text> </xsl:text>
667 <xsl:if test="$spaces>0">
668 <xsl:value-of select="$char"/>
669 <xsl:call-template name="buildSpaces">
670 <xsl:with-param name="spaces" select="$spaces - 1"/>
671 <xsl:with-param name="char" select="$char"/>
676 <xsl:template name="chopPunctuation">
677 <xsl:param name="chopString"/>
678 <xsl:param name="punctuation">
679 <xsl:text>.:,;/ </xsl:text>
681 <xsl:variable name="length" select="string-length($chopString)"/>
683 <xsl:when test="$length=0"/>
684 <xsl:when test="contains($punctuation, substring($chopString,$length,1))">
685 <xsl:call-template name="chopPunctuation">
686 <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
687 <xsl:with-param name="punctuation" select="$punctuation"/>
690 <xsl:when test="not($chopString)"/>
692 <xsl:value-of select="$chopString"/>
697 <xsl:template name="chopPunctuationFront">
698 <xsl:param name="chopString"/>
699 <xsl:variable name="length" select="string-length($chopString)"/>
701 <xsl:when test="$length=0"/>
702 <xsl:when test="contains('.:,;/[ ', substring($chopString,1,1))">
703 <xsl:call-template name="chopPunctuationFront">
704 <xsl:with-param name="chopString" select="substring($chopString,2,$length - 1)"
708 <xsl:when test="not($chopString)"/>
710 <xsl:value-of select="$chopString"/>
715 <xsl:template name="chopPunctuationBack">
716 <xsl:param name="chopString"/>
717 <xsl:param name="punctuation">
718 <xsl:text>.:,;/] </xsl:text>
720 <xsl:variable name="length" select="string-length($chopString)"/>
722 <xsl:when test="$length=0"/>
723 <xsl:when test="contains($punctuation, substring($chopString,$length,1))">
724 <xsl:call-template name="chopPunctuation">
725 <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
726 <xsl:with-param name="punctuation" select="$punctuation"/>
729 <xsl:when test="not($chopString)"/>
731 <xsl:value-of select="$chopString"/>
736 <!-- nate added 12/14/2007 for lccn.loc.gov: url encode ampersand, etc. -->
737 <xsl:template name="url-encode">
739 <xsl:param name="str"/>
742 <xsl:variable name="first-char" select="substring($str,1,1)"/>
744 <xsl:when test="contains($safe,$first-char)">
745 <xsl:value-of select="$first-char"/>
748 <xsl:variable name="codepoint">
750 <xsl:when test="contains($ascii,$first-char)">
752 select="string-length(substring-before($ascii,$first-char)) + 32"
755 <xsl:when test="contains($latin1,$first-char)">
757 select="string-length(substring-before($latin1,$first-char)) + 160"/>
761 <xsl:message terminate="no">Warning: string contains a character
762 that is out of range! Substituting "?".</xsl:message>
763 <xsl:text>63</xsl:text>
767 <xsl:variable name="hex-digit1"
768 select="substring($hex,floor($codepoint div 16) + 1,1)"/>
769 <xsl:variable name="hex-digit2" select="substring($hex,$codepoint mod 16 + 1,1)"/>
770 <!-- <xsl:value-of select="concat('%',$hex-digit2)"/> -->
771 <xsl:value-of select="concat('%',$hex-digit1,$hex-digit2)"/>
774 <xsl:if test="string-length($str) > 1">
775 <xsl:call-template name="url-encode">
776 <xsl:with-param name="str" select="substring($str,2)"/>
784 2.15 reversed genre and setAuthority template order under relatedTypeAttribute tmee 11/13/2018
785 2.14 Fixed bug in mads:geographic attributes syntax ws 05/04/2016
786 2.13 fixed repeating <geographic> tmee 01/31/2014
787 2.12 added $2 authority for <classification> tmee 09/18/2012
788 2.11 added delimiters between <classification> subfields tmee 09/18/2012
789 2.10 fixed type="other" and type="otherType" for mads:related tmee 09/16/2011
790 2.09 fixed professionTerm and genreTerm empty tag error tmee 09/16/2011
791 2.08 fixed marc:subfield @code='i' matching error tmee 09/16/2011
792 2.07 fixed 555 duplication error tmee 08/10/2011
793 2.06 fixed topic subfield error tmee 08/10/2011
794 2.05 fixed title subfield error tmee 06/20/2011
795 2.04 fixed geographicSubdivision mapping for authority element tmee 06/16/2011
796 2.03 added classification for 053, 055, 060, 065, 070, 080, 082, 083, 086, 087 tmee 06/03/2011
797 2.02 added descriptionStandard for 008/10 tmee 04/27/2011
798 2.01 added extensions for 046, 336, 370, 374, 375, 376 tmee 04/08/2011
799 2.00 redefined imported MODS elements in version 1.0 to MADS elements in version 2.0 tmee 02/08/2011
800 1.08 added 372 subfields $a $s $t for <fieldOfActivity> tmee 06/24/2010
801 1.07 removed role/roleTerm 100, 110, 111, 400, 410, 411, 500, 510, 511, 700, 710, 711 tmee 06/24/2010
802 1.06 added strip-space tmee 06/24/2010
803 1.05 added subfield $a for 130, 430, 530 tmee 06/21/2010
804 1.04 fixed 550 z omission ntra 08/11/2008
805 1.03 removed duplication of 550 $a text tmee 11/01/2006
806 1.02 fixed namespace references between mads and mods ntra 10/06/2006
807 1.01 revised rgue/jrad 11/29/05
808 1.00 adapted from MARC21Slim2MODS3.xsl ntra 07/06/05
811 <!-- authority attribute defaults to 'naf' if not set using this authority parameter, for <authority> descriptors: name, titleInfo, geographic -->
812 <xsl:param name="authority"/>
813 <xsl:variable name="auth">
815 <xsl:when test="$authority">
816 <xsl:value-of select="$authority"/>
818 <xsl:otherwise>naf</xsl:otherwise>
821 <xsl:variable name="controlField008" select="marc:controlfield[@tag='008']"/>
822 <xsl:variable name="controlField008-06"
823 select="substring(descendant-or-self::marc:controlfield[@tag=008],7,1)"/>
824 <xsl:variable name="controlField008-11"
825 select="substring(descendant-or-self::marc:controlfield[@tag=008],12,1)"/>
826 <xsl:variable name="controlField008-14"
827 select="substring(descendant-or-self::marc:controlfield[@tag=008],15,1)"/>
828 <xsl:template match="/">
830 <xsl:when test="descendant-or-self::marc:collection">
831 <mads:madsCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
832 xsi:schemaLocation="http://www.loc.gov/mads/v2 http://www.loc.gov/standards/mads/v2/mads-2-0.xsd">
833 <xsl:for-each select="descendant-or-self::marc:collection/marc:record">
834 <mads:mads version="2.0">
835 <xsl:call-template name="marcRecord"/>
838 </mads:madsCollection>
841 <mads:mads version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
842 xsi:schemaLocation="http://www.loc.gov/mads/v2 http://www.loc.gov/standards/mads/mads-2-0.xsd">
843 <xsl:for-each select="descendant-or-self::marc:record">
844 <xsl:call-template name="marcRecord"/>
851 <xsl:template name="marcRecord">
855 <xsl:when test="$controlField008-06='d'">
856 <xsl:attribute name="geographicSubdivision">
857 <xsl:text>direct</xsl:text>
860 <xsl:when test="$controlField008-06='i'">
861 <xsl:attribute name="geographicSubdivision">
862 <xsl:text>indirect</xsl:text>
865 <xsl:when test="$controlField008-06='n'">
866 <xsl:attribute name="geographicSubdivision">
867 <xsl:text>not applicable</xsl:text>
872 <xsl:apply-templates select="marc:datafield[100 <= @tag and @tag < 200]"/>
877 select="marc:datafield[500 <= @tag and @tag <= 585]|marc:datafield[700 <= @tag and @tag <= 785]"/>
880 <xsl:apply-templates select="marc:datafield[400 <= @tag and @tag <= 485]"/>
883 <xsl:apply-templates select="marc:datafield[667 <= @tag and @tag <= 688]"/>
886 <xsl:apply-templates select="marc:datafield[@tag=856]"/>
887 <xsl:apply-templates select="marc:datafield[@tag=010]"/>
888 <xsl:apply-templates select="marc:datafield[@tag=024]"/>
889 <xsl:apply-templates select="marc:datafield[@tag=372]"/>
891 <!-- classification -->
892 <xsl:apply-templates select="marc:datafield[@tag=053]"/>
893 <xsl:apply-templates select="marc:datafield[@tag=055]"/>
894 <xsl:apply-templates select="marc:datafield[@tag=060]"/>
895 <xsl:apply-templates select="marc:datafield[@tag=065]"/>
896 <xsl:apply-templates select="marc:datafield[@tag=070]"/>
897 <xsl:apply-templates select="marc:datafield[@tag=080]"/>
898 <xsl:apply-templates select="marc:datafield[@tag=082]"/>
899 <xsl:apply-templates select="marc:datafield[@tag=083]"/>
900 <xsl:apply-templates select="marc:datafield[@tag=086]"/>
901 <xsl:apply-templates select="marc:datafield[@tag=087]"/>
904 <xsl:for-each select="marc:datafield[@tag=373]">
907 <xsl:value-of select="marc:subfield[@code='a']"/>
909 <mads:dateValid point="start">
910 <xsl:value-of select="marc:subfield[@code='s']"/>
912 <mads:dateValid point="end">
913 <xsl:value-of select="marc:subfield[@code='t']"/>
917 <xsl:for-each select="marc:datafield[@tag=371]">
921 <xsl:value-of select="marc:subfield[@code='a']"/>
924 <xsl:value-of select="marc:subfield[@code='b']"/>
927 <xsl:value-of select="marc:subfield[@code='c']"/>
930 <xsl:value-of select="marc:subfield[@code='d']"/>
933 <xsl:value-of select="marc:subfield[@code='e']"/>
937 <xsl:value-of select="marc:subfield[@code='m']"/>
943 <xsl:for-each select="marc:datafield[@tag=336]">
946 <mads:contentType type="text">
947 <xsl:value-of select="marc:subfield[@code='a']"/>
949 <mads:contentType type="code">
950 <xsl:value-of select="marc:subfield[@code='b']"/>
956 <xsl:for-each select="marc:datafield[@tag=374]">
960 <xsl:when test="marc:subfield[@code='a']">
961 <mads:professionTerm>
962 <xsl:value-of select="marc:subfield[@code='a']"/>
963 </mads:professionTerm>
965 <xsl:when test="marc:subfield[@code='s']">
966 <mads:dateValid point="start">
967 <xsl:value-of select="marc:subfield[@code='s']"/>
970 <xsl:when test="marc:subfield[@code='t']">
971 <mads:dateValid point="end">
972 <xsl:value-of select="marc:subfield[@code='t']"/>
980 <xsl:for-each select="marc:datafield[@tag=375]">
984 <xsl:when test="marc:subfield[@code='a']">
986 <xsl:value-of select="marc:subfield[@code='a']"/>
989 <xsl:when test="marc:subfield[@code='s']">
990 <mads:dateValid point="start">
991 <xsl:value-of select="marc:subfield[@code='s']"/>
994 <xsl:when test="marc:subfield[@code='t']">
995 <mads:dateValid point="end">
996 <xsl:value-of select="marc:subfield[@code='t']"/>
1004 <xsl:for-each select="marc:datafield[@tag=376]">
1006 <mads:familyInformation>
1008 <xsl:value-of select="marc:subfield[@code='a']"/>
1009 </mads:typeOfFamily>
1010 <mads:nameOfProminentMember>
1011 <xsl:value-of select="marc:subfield[@code='b']"/>
1012 </mads:nameOfProminentMember>
1013 <mads:hereditaryTitle>
1014 <xsl:value-of select="marc:subfield[@code='c']"/>
1015 </mads:hereditaryTitle>
1016 <mads:dateValid point="start">
1017 <xsl:value-of select="marc:subfield[@code='s']"/>
1019 <mads:dateValid point="end">
1020 <xsl:value-of select="marc:subfield[@code='t']"/>
1022 </mads:familyInformation>
1027 <mads:recordOrigin>Converted from MARCXML to MADS version 2.0 (Revision 2.13)</mads:recordOrigin>
1028 <!-- <xsl:apply-templates select="marc:datafield[@tag=024]"/> -->
1030 <xsl:apply-templates select="marc:datafield[@tag=040]/marc:subfield[@code='a']"/>
1031 <xsl:apply-templates select="marc:controlfield[@tag=005]"/>
1032 <xsl:apply-templates select="marc:controlfield[@tag=001]"/>
1033 <xsl:apply-templates select="marc:datafield[@tag=040]/marc:subfield[@code='b']"/>
1034 <xsl:apply-templates select="marc:datafield[@tag=040]/marc:subfield[@code='e']"/>
1035 <xsl:for-each select="marc:controlfield[@tag=008]">
1036 <xsl:if test="substring(.,11,1)='a'">
1037 <mads:descriptionStandard>
1038 <xsl:text>earlier rules</xsl:text>
1039 </mads:descriptionStandard>
1041 <xsl:if test="substring(.,11,1)='b'">
1042 <mads:descriptionStandard>
1043 <xsl:text>aacr1</xsl:text>
1044 </mads:descriptionStandard>
1046 <xsl:if test="substring(.,11,1)='c'">
1047 <mads:descriptionStandard>
1048 <xsl:text>aacr2</xsl:text>
1049 </mads:descriptionStandard>
1051 <xsl:if test="substring(.,11,1)='d'">
1052 <mads:descriptionStandard>
1053 <xsl:text>aacr2 compatible</xsl:text>
1054 </mads:descriptionStandard>
1056 <xsl:if test="substring(.,11,1)='z'">
1057 <mads:descriptionStandard>
1058 <xsl:text>other rules</xsl:text>
1059 </mads:descriptionStandard>
1065 <!-- start of secondary templates -->
1067 <!-- ======== xlink ======== -->
1069 <!-- <xsl:template name="uri">
1070 <xsl:for-each select="marc:subfield[@code='0']">
1071 <xsl:attribute name="xlink:href">
1072 <xsl:value-of select="."/>
1077 <xsl:template match="marc:subfield[@code='i']">
1078 <xsl:attribute name="otherType">
1079 <xsl:value-of select="."/>
1083 <!-- No role/roleTerm mapped in MADS 06/24/2010
1084 <xsl:template name="role">
1085 <xsl:for-each select="marc:subfield[@code='e']">
1087 <mads:roleTerm type="text">
1088 <xsl:value-of select="."/>
1095 <xsl:template name="part">
1096 <xsl:variable name="partNumber">
1097 <xsl:call-template name="specialSubfieldSelect">
1098 <xsl:with-param name="axis">n</xsl:with-param>
1099 <xsl:with-param name="anyCodes">n</xsl:with-param>
1100 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
1101 </xsl:call-template>
1103 <xsl:variable name="partName">
1104 <xsl:call-template name="specialSubfieldSelect">
1105 <xsl:with-param name="axis">p</xsl:with-param>
1106 <xsl:with-param name="anyCodes">p</xsl:with-param>
1107 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
1108 </xsl:call-template>
1110 <xsl:if test="string-length(normalize-space($partNumber))">
1112 <xsl:call-template name="chopPunctuation">
1113 <xsl:with-param name="chopString" select="$partNumber"/>
1114 </xsl:call-template>
1117 <xsl:if test="string-length(normalize-space($partName))">
1119 <xsl:call-template name="chopPunctuation">
1120 <xsl:with-param name="chopString" select="$partName"/>
1121 </xsl:call-template>
1126 <xsl:template name="nameABCDN">
1127 <xsl:for-each select="marc:subfield[@code='a']">
1129 <xsl:call-template name="chopPunctuation">
1130 <xsl:with-param name="chopString" select="."/>
1131 </xsl:call-template>
1134 <xsl:for-each select="marc:subfield[@code='b']">
1136 <xsl:value-of select="."/>
1140 test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">
1142 <xsl:call-template name="subfieldSelect">
1143 <xsl:with-param name="codes">cdn</xsl:with-param>
1144 </xsl:call-template>
1149 <xsl:template name="nameABCDQ">
1151 <xsl:call-template name="chopPunctuation">
1152 <xsl:with-param name="chopString">
1153 <xsl:call-template name="subfieldSelect">
1154 <xsl:with-param name="codes">aq</xsl:with-param>
1155 </xsl:call-template>
1157 </xsl:call-template>
1159 <xsl:call-template name="termsOfAddress"/>
1160 <xsl:call-template name="nameDate"/>
1163 <xsl:template name="nameACDENQ">
1165 <xsl:call-template name="subfieldSelect">
1166 <xsl:with-param name="codes">acdenq</xsl:with-param>
1167 </xsl:call-template>
1171 <xsl:template name="nameDate">
1172 <xsl:for-each select="marc:subfield[@code='d']">
1173 <mads:namePart type="date">
1174 <xsl:call-template name="chopPunctuation">
1175 <xsl:with-param name="chopString" select="."/>
1176 </xsl:call-template>
1181 <xsl:template name="specialSubfieldSelect">
1182 <xsl:param name="anyCodes"/>
1183 <xsl:param name="axis"/>
1184 <xsl:param name="beforeCodes"/>
1185 <xsl:param name="afterCodes"/>
1186 <xsl:variable name="str">
1187 <xsl:for-each select="marc:subfield">
1189 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])">
1190 <xsl:value-of select="text()"/>
1191 <xsl:text> </xsl:text>
1195 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
1198 <xsl:template name="termsOfAddress">
1199 <xsl:if test="marc:subfield[@code='b' or @code='c']">
1200 <mads:namePart type="termsOfAddress">
1201 <xsl:call-template name="chopPunctuation">
1202 <xsl:with-param name="chopString">
1203 <xsl:call-template name="subfieldSelect">
1204 <xsl:with-param name="codes">bc</xsl:with-param>
1205 </xsl:call-template>
1207 </xsl:call-template>
1212 <xsl:template name="displayLabel">
1213 <xsl:if test="marc:subfield[@code='z']">
1214 <xsl:attribute name="displayLabel">
1215 <xsl:value-of select="marc:subfield[@code='z']"/>
1218 <xsl:if test="marc:subfield[@code='3']">
1219 <xsl:attribute name="displayLabel">
1220 <xsl:value-of select="marc:subfield[@code='3']"/>
1225 <xsl:template name="isInvalid">
1226 <xsl:if test="@code='z'">
1227 <xsl:attribute name="invalid">yes</xsl:attribute>
1231 <xsl:template name="sub2Attribute">
1233 <xsl:if test="../marc:subfield[@code='2']">
1234 <xsl:attribute name="type">
1235 <xsl:value-of select="../marc:subfield[@code='2']"/>
1240 <xsl:template match="marc:controlfield[@tag=001]">
1241 <mads:recordIdentifier>
1242 <xsl:if test="../marc:controlfield[@tag=003]">
1243 <xsl:attribute name="source">
1244 <xsl:value-of select="../marc:controlfield[@tag=003]"/>
1247 <xsl:value-of select="."/>
1248 </mads:recordIdentifier>
1251 <xsl:template match="marc:controlfield[@tag=005]">
1252 <mads:recordChangeDate encoding="iso8601">
1253 <xsl:value-of select="."/>
1254 </mads:recordChangeDate>
1257 <xsl:template match="marc:controlfield[@tag=008]">
1258 <mads:recordCreationDate encoding="marc">
1259 <xsl:value-of select="substring(.,1,6)"/>
1260 </mads:recordCreationDate>
1263 <xsl:template match="marc:datafield[@tag=010]">
1264 <xsl:for-each select="marc:subfield">
1265 <mads:identifier type="lccn">
1266 <xsl:call-template name="isInvalid"/>
1267 <xsl:value-of select="."/>
1272 <xsl:template match="marc:datafield[@tag=024]">
1273 <xsl:for-each select="marc:subfield[not(@code=2)]">
1275 <xsl:call-template name="isInvalid"/>
1276 <xsl:call-template name="sub2Attribute"/>
1277 <xsl:value-of select="."/>
1282 <!-- ========== 372 ========== -->
1283 <xsl:template match="marc:datafield[@tag=372]">
1284 <mads:fieldOfActivity>
1285 <xsl:call-template name="subfieldSelect">
1286 <xsl:with-param name="codes">a</xsl:with-param>
1287 </xsl:call-template>
1288 <xsl:text>-</xsl:text>
1289 <xsl:call-template name="subfieldSelect">
1290 <xsl:with-param name="codes">st</xsl:with-param>
1291 </xsl:call-template>
1292 </mads:fieldOfActivity>
1296 <!-- ========== 040 ========== -->
1297 <xsl:template match="marc:datafield[@tag=040]/marc:subfield[@code='a']">
1298 <mads:recordContentSource authority="marcorg">
1299 <xsl:value-of select="."/>
1300 </mads:recordContentSource>
1303 <xsl:template match="marc:datafield[@tag=040]/marc:subfield[@code='b']">
1304 <mads:languageOfCataloging>
1305 <mads:languageTerm authority="iso639-2b" type="code">
1306 <xsl:value-of select="."/>
1307 </mads:languageTerm>
1308 </mads:languageOfCataloging>
1311 <xsl:template match="marc:datafield[@tag=040]/marc:subfield[@code='e']">
1312 <mads:descriptionStandard>
1313 <xsl:value-of select="."/>
1314 </mads:descriptionStandard>
1317 <!-- ========== classification 2.03 ========== -->
1319 <xsl:template match="marc:datafield[@tag=053]">
1320 <mads:classification>
1321 <xsl:call-template name="subfieldSelect">
1322 <xsl:with-param name="codes">abcdxyz</xsl:with-param>
1323 <xsl:with-param name="delimeter">-</xsl:with-param>
1324 </xsl:call-template>
1325 </mads:classification>
1328 <xsl:template match="marc:datafield[@tag=055]">
1329 <mads:classification>
1330 <xsl:call-template name="subfieldSelect">
1331 <xsl:with-param name="codes">abcdxyz</xsl:with-param>
1332 <xsl:with-param name="delimeter">-</xsl:with-param>
1333 </xsl:call-template>
1334 </mads:classification>
1337 <xsl:template match="marc:datafield[@tag=060]">
1338 <mads:classification>
1339 <xsl:call-template name="subfieldSelect">
1340 <xsl:with-param name="codes">abcdxyz</xsl:with-param>
1341 <xsl:with-param name="delimeter">-</xsl:with-param>
1342 </xsl:call-template>
1343 </mads:classification>
1345 <xsl:template match="marc:datafield[@tag=065]">
1346 <mads:classification>
1347 <xsl:attribute name="authority">
1348 <xsl:value-of select="marc:subfield[@code='2']"/>
1350 <xsl:call-template name="subfieldSelect">
1351 <xsl:with-param name="codes">abcdxyz</xsl:with-param>
1352 <xsl:with-param name="delimeter">-</xsl:with-param>
1353 </xsl:call-template>
1354 </mads:classification>
1356 <xsl:template match="marc:datafield[@tag=070]">
1357 <mads:classification>
1358 <xsl:call-template name="subfieldSelect">
1359 <xsl:with-param name="codes">abcdxyz5</xsl:with-param>
1360 <xsl:with-param name="delimeter">-</xsl:with-param>
1361 </xsl:call-template>
1362 </mads:classification>
1364 <xsl:template match="marc:datafield[@tag=080]">
1365 <mads:classification>
1366 <xsl:attribute name="authority">
1367 <xsl:value-of select="marc:subfield[@code='2']"/>
1369 <xsl:call-template name="subfieldSelect">
1370 <xsl:with-param name="codes">abcdxyz5</xsl:with-param>
1371 <xsl:with-param name="delimeter">-</xsl:with-param>
1372 </xsl:call-template>
1373 </mads:classification>
1375 <xsl:template match="marc:datafield[@tag=082]">
1376 <mads:classification>
1377 <xsl:attribute name="authority">
1378 <xsl:value-of select="marc:subfield[@code='2']"/>
1380 <xsl:call-template name="subfieldSelect">
1381 <xsl:with-param name="codes">abcdxyz5</xsl:with-param>
1382 <xsl:with-param name="delimeter">-</xsl:with-param>
1383 </xsl:call-template>
1384 </mads:classification>
1386 <xsl:template match="marc:datafield[@tag=083]">
1387 <mads:classification>
1388 <xsl:attribute name="authority">
1389 <xsl:value-of select="marc:subfield[@code='2']"/>
1391 <xsl:call-template name="subfieldSelect">
1392 <xsl:with-param name="codes">abcdxyz5</xsl:with-param>
1393 <xsl:with-param name="delimeter">-</xsl:with-param>
1394 </xsl:call-template>
1395 </mads:classification>
1397 <xsl:template match="marc:datafield[@tag=086]">
1398 <mads:classification>
1399 <xsl:attribute name="authority">
1400 <xsl:value-of select="marc:subfield[@code='2']"/>
1402 <xsl:call-template name="subfieldSelect">
1403 <xsl:with-param name="codes">abcdxyz5</xsl:with-param>
1404 <xsl:with-param name="delimeter">-</xsl:with-param>
1405 </xsl:call-template>
1406 </mads:classification>
1408 <xsl:template match="marc:datafield[@tag=087]">
1409 <mads:classification>
1410 <xsl:attribute name="authority">
1411 <xsl:value-of select="marc:subfield[@code='2']"/>
1413 <xsl:call-template name="subfieldSelect">
1414 <xsl:with-param name="codes">abcdxyz5</xsl:with-param>
1415 <xsl:with-param name="delimeter">-</xsl:with-param>
1416 </xsl:call-template>
1417 </mads:classification>
1421 <!-- ========== names ========== -->
1422 <xsl:template match="marc:datafield[@tag=100]">
1423 <mads:name type="personal">
1424 <xsl:call-template name="setAuthority"/>
1425 <xsl:call-template name="nameABCDQ"/>
1427 <xsl:apply-templates select="*[marc:subfield[not(contains('abcdeq',@code))]]"/>
1428 <xsl:call-template name="title"/>
1429 <xsl:apply-templates select="marc:subfield[@code!='i']"/>
1432 <xsl:template match="marc:datafield[@tag=110]">
1433 <mads:name type="corporate">
1434 <xsl:call-template name="setAuthority"/>
1435 <xsl:call-template name="nameABCDN"/>
1437 <xsl:apply-templates select="marc:subfield[@code!='i']"/>
1440 <xsl:template match="marc:datafield[@tag=111]">
1441 <mads:name type="conference">
1442 <xsl:call-template name="setAuthority"/>
1443 <xsl:call-template name="nameACDENQ"/>
1445 <xsl:apply-templates select="marc:subfield[@code!='i']"/>
1448 <xsl:template match="marc:datafield[@tag=400]">
1450 <xsl:call-template name="variantTypeAttribute"/>
1451 <mads:name type="personal">
1452 <xsl:call-template name="nameABCDQ"/>
1454 <xsl:apply-templates select="marc:subfield[@code!='i']"/>
1455 <xsl:call-template name="title"/>
1459 <xsl:template match="marc:datafield[@tag=410]">
1461 <xsl:call-template name="variantTypeAttribute"/>
1462 <mads:name type="corporate">
1463 <xsl:call-template name="nameABCDN"/>
1465 <xsl:apply-templates select="marc:subfield[@code!='i']"/>
1469 <xsl:template match="marc:datafield[@tag=411]">
1471 <xsl:call-template name="variantTypeAttribute"/>
1472 <mads:name type="conference">
1473 <xsl:call-template name="nameACDENQ"/>
1475 <xsl:apply-templates select="marc:subfield[@code!='i']"/>
1479 <xsl:template match="marc:datafield[@tag=500]|marc:datafield[@tag=700]">
1481 <xsl:call-template name="relatedTypeAttribute"/>
1482 <!-- <xsl:call-template name="uri"/> -->
1483 <mads:name type="personal">
1484 <xsl:call-template name="setAuthority"/>
1485 <xsl:call-template name="nameABCDQ"/>
1487 <xsl:call-template name="title"/>
1488 <xsl:apply-templates select="marc:subfield[@code!='i']"/>
1492 <xsl:template match="marc:datafield[@tag=510]|marc:datafield[@tag=710]">
1494 <xsl:call-template name="relatedTypeAttribute"/>
1495 <!-- <xsl:call-template name="uri"/> -->
1496 <mads:name type="corporate">
1497 <xsl:call-template name="setAuthority"/>
1498 <xsl:call-template name="nameABCDN"/>
1500 <xsl:apply-templates select="marc:subfield[@code!='i']"/>
1504 <xsl:template match="marc:datafield[@tag=511]|marc:datafield[@tag=711]">
1506 <xsl:call-template name="relatedTypeAttribute"/>
1507 <!-- <xsl:call-template name="uri"/> -->
1508 <mads:name type="conference">
1509 <xsl:call-template name="setAuthority"/>
1510 <xsl:call-template name="nameACDENQ"/>
1512 <xsl:apply-templates select="marc:subfield[@code!='i']"/>
1516 <!-- ========== titles ========== -->
1517 <xsl:template match="marc:datafield[@tag=130]">
1518 <xsl:call-template name="uniform-title"/>
1519 <xsl:apply-templates select="marc:subfield[@code!='i']"/>
1522 <xsl:template match="marc:datafield[@tag=430]">
1524 <xsl:call-template name="variantTypeAttribute"/>
1525 <xsl:call-template name="uniform-title"/>
1526 <xsl:apply-templates select="marc:subfield[@code!='i']"/>
1530 <xsl:template match="marc:datafield[@tag=530]|marc:datafield[@tag=730]">
1532 <xsl:call-template name="relatedTypeAttribute"/>
1533 <xsl:call-template name="uniform-title"/>
1534 <xsl:apply-templates select="marc:subfield[@code!='i']"/>
1538 <xsl:template name="title">
1539 <xsl:variable name="hasTitle">
1540 <xsl:for-each select="marc:subfield">
1541 <xsl:if test="(contains('tfghklmors',@code) )">
1542 <xsl:value-of select="@code"/>
1546 <xsl:if test="string-length($hasTitle) > 0 ">
1548 <xsl:call-template name="setAuthority"/>
1550 <xsl:variable name="str">
1551 <xsl:for-each select="marc:subfield">
1552 <xsl:if test="(contains('atfghklmors',@code) )">
1553 <xsl:value-of select="text()"/>
1554 <xsl:text> </xsl:text>
1558 <xsl:call-template name="chopPunctuation">
1559 <xsl:with-param name="chopString">
1560 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
1562 </xsl:call-template>
1564 <xsl:call-template name="part"/>
1565 <!-- <xsl:call-template name="uri"/> -->
1570 <xsl:template name="uniform-title">
1571 <xsl:variable name="hasTitle">
1572 <xsl:for-each select="marc:subfield">
1573 <xsl:if test="(contains('atfghklmors',@code) )">
1574 <xsl:value-of select="@code"/>
1578 <xsl:if test="string-length($hasTitle) > 0 ">
1580 <xsl:call-template name="setAuthority"/>
1582 <xsl:variable name="str">
1583 <xsl:for-each select="marc:subfield">
1584 <xsl:if test="(contains('adfghklmors',@code) )">
1585 <xsl:value-of select="text()"/>
1586 <xsl:text> </xsl:text>
1590 <xsl:call-template name="chopPunctuation">
1591 <xsl:with-param name="chopString">
1592 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
1594 </xsl:call-template>
1596 <xsl:call-template name="part"/>
1597 <!-- <xsl:call-template name="uri"/> -->
1603 <!-- ========== topics ========== -->
1604 <xsl:template match="marc:subfield[@code='x']">
1606 <xsl:call-template name="chopPunctuation">
1607 <xsl:with-param name="chopString">
1608 <xsl:value-of select="."/>
1610 </xsl:call-template>
1616 match="marc:datafield[@tag=150][marc:subfield[@code='a' or @code='b']]|marc:datafield[@tag=180][marc:subfield[@code='x']]">
1617 <xsl:call-template name="topic"/>
1618 <xsl:apply-templates select="marc:subfield[@code!='i']"/>
1621 match="marc:datafield[@tag=450][marc:subfield[@code='a' or @code='b']]|marc:datafield[@tag=480][marc:subfield[@code='x']]">
1623 <xsl:call-template name="variantTypeAttribute"/>
1624 <xsl:call-template name="topic"/>
1628 match="marc:datafield[@tag=550 or @tag=750][marc:subfield[@code='a' or @code='b']]">
1630 <xsl:call-template name="relatedTypeAttribute"/>
1631 <!-- <xsl:call-template name="uri"/> -->
1632 <xsl:call-template name="topic"/>
1633 <xsl:apply-templates select="marc:subfield[@code='z']"/>
1636 <xsl:template name="topic">
1638 <xsl:call-template name="setAuthority"/>
1639 <!-- tmee2006 dedupe 550a
1640 <xsl:if test="@tag=550 or @tag=750">
1641 <xsl:call-template name="subfieldSelect">
1642 <xsl:with-param name="codes">ab</xsl:with-param>
1643 </xsl:call-template>
1647 <xsl:when test="@tag=180 or @tag=480 or @tag=580 or @tag=780">
1648 <xsl:call-template name="chopPunctuation">
1649 <xsl:with-param name="chopString">
1650 <xsl:apply-templates select="marc:subfield[@code='x']"/>
1652 </xsl:call-template>
1655 <xsl:call-template name="chopPunctuation">
1656 <xsl:with-param name="chopString">
1658 <xsl:when test="@tag=180 or @tag=480 or @tag=580 or @tag=780">
1659 <xsl:apply-templates select="marc:subfield[@code='x']"/>
1662 <xsl:call-template name="subfieldSelect">
1663 <xsl:with-param name="codes">ab</xsl:with-param>
1664 </xsl:call-template>
1668 </xsl:call-template>
1672 <!-- ========= temporals ========== -->
1673 <xsl:template match="marc:subfield[@code='y']">
1675 <xsl:call-template name="chopPunctuation">
1676 <xsl:with-param name="chopString">
1677 <xsl:value-of select="."/>
1679 </xsl:call-template>
1683 match="marc:datafield[@tag=148][marc:subfield[@code='a']]|marc:datafield[@tag=182 ][marc:subfield[@code='y']]">
1684 <xsl:call-template name="temporal"/>
1687 match="marc:datafield[@tag=448][marc:subfield[@code='a']]|marc:datafield[@tag=482][marc:subfield[@code='y']]">
1689 <xsl:call-template name="variantTypeAttribute"/>
1690 <xsl:call-template name="temporal"/>
1694 match="marc:datafield[@tag=548 or @tag=748][marc:subfield[@code='a']]|marc:datafield[@tag=582 or @tag=782][marc:subfield[@code='y']]">
1696 <xsl:call-template name="relatedTypeAttribute"/>
1697 <!-- <xsl:call-template name="uri"/> -->
1698 <xsl:call-template name="temporal"/>
1701 <xsl:template name="temporal">
1703 <xsl:call-template name="setAuthority"/>
1704 <xsl:if test="@tag=548 or @tag=748">
1705 <xsl:value-of select="marc:subfield[@code='a']"/>
1707 <xsl:call-template name="chopPunctuation">
1708 <xsl:with-param name="chopString">
1710 <xsl:when test="@tag=182 or @tag=482 or @tag=582 or @tag=782">
1711 <xsl:apply-templates select="marc:subfield[@code='y']"/>
1714 <xsl:value-of select="marc:subfield[@code='a']"/>
1718 </xsl:call-template>
1720 <xsl:apply-templates select="marc:subfield[@code!='i']"/>
1723 <!-- ========== genre ========== -->
1724 <xsl:template match="marc:subfield[@code='v']">
1726 <xsl:call-template name="chopPunctuation">
1727 <xsl:with-param name="chopString">
1728 <xsl:value-of select="."/>
1730 </xsl:call-template>
1734 match="marc:datafield[@tag=155][marc:subfield[@code='a']]|marc:datafield[@tag=185][marc:subfield[@code='v']]">
1735 <xsl:call-template name="genre"/>
1738 match="marc:datafield[@tag=455][marc:subfield[@code='a']]|marc:datafield[@tag=485 ][marc:subfield[@code='v']]">
1740 <xsl:call-template name="variantTypeAttribute"/>
1741 <xsl:call-template name="genre"/>
1745 <xsl:template match="marc:datafield[@tag=555]">
1747 <xsl:call-template name="relatedTypeAttribute"/>
1748 <xsl:call-template name="uri"/>
1749 <xsl:call-template name="genre"/>
1754 match="marc:datafield[@tag=555 or @tag=755][marc:subfield[@code='a']]|marc:datafield[@tag=585][marc:subfield[@code='v']]">
1756 <xsl:call-template name="relatedTypeAttribute"/>
1757 <xsl:call-template name="genre"/>
1760 <xsl:template name="genre">
1762 <xsl:if test="@tag=555">
1763 <xsl:value-of select="marc:subfield[@code='a']"/>
1765 <xsl:call-template name="setAuthority"/>
1766 <xsl:call-template name="chopPunctuation">
1767 <xsl:with-param name="chopString">
1770 <xsl:when test="@tag='555'"/>
1771 <xsl:when test="@tag=185 or @tag=485 or @tag=585">
1772 <xsl:apply-templates select="marc:subfield[@code='v']"/>
1775 <xsl:value-of select="marc:subfield[@code='a']"/>
1779 </xsl:call-template>
1781 <xsl:apply-templates/>
1784 <!-- ========= geographic ========== -->
1785 <xsl:template match="marc:subfield[@code='z']">
1787 <xsl:call-template name="chopPunctuation">
1788 <xsl:with-param name="chopString">
1789 <xsl:value-of select="."/>
1791 </xsl:call-template>
1794 <xsl:template name="geographic">
1797 <xsl:call-template name="setAuthority"/>
1799 <xsl:if test="@tag=151 or @tag=551">
1800 <xsl:value-of select="marc:subfield[@code='a']"/>
1802 <xsl:call-template name="chopPunctuation">
1803 <xsl:with-param name="chopString">
1804 <xsl:if test="@tag=181 or @tag=481 or @tag=581">
1805 <xsl:apply-templates select="marc:subfield[@code='z']"/>
1809 <xsl:when test="@tag=181 or @tag=481 or @tag=581">
1810 <xsl:apply-templates select="marc:subfield[@code='z']"/>
1814 <xsl:value-of select="marc:subfield[@code='a']"/>
1819 </xsl:call-template>
1821 <xsl:apply-templates select="marc:subfield[@code!='i']"/>
1824 match="marc:datafield[@tag=151][marc:subfield[@code='a']]|marc:datafield[@tag=181][marc:subfield[@code='z']]">
1825 <xsl:call-template name="geographic"/>
1828 match="marc:datafield[@tag=451][marc:subfield[@code='a']]|marc:datafield[@tag=481][marc:subfield[@code='z']]">
1830 <xsl:call-template name="variantTypeAttribute"/>
1831 <xsl:call-template name="geographic"/>
1835 match="marc:datafield[@tag=551]|marc:datafield[@tag=581][marc:subfield[@code='z']]">
1837 <xsl:call-template name="relatedTypeAttribute"/>
1838 <!-- <xsl:call-template name="uri"/> -->
1839 <xsl:call-template name="geographic"/>
1842 <xsl:template match="marc:datafield[@tag=580]">
1844 <xsl:call-template name="relatedTypeAttribute"/>
1845 <xsl:apply-templates select="marc:subfield[@code!='i']"/>
1849 match="marc:datafield[@tag=751][marc:subfield[@code='z']]|marc:datafield[@tag=781][marc:subfield[@code='z']]">
1851 <xsl:call-template name="relatedTypeAttribute"/>
1852 <xsl:call-template name="geographic"/>
1855 <xsl:template match="marc:datafield[@tag=755]">
1857 <xsl:call-template name="relatedTypeAttribute"/>
1858 <xsl:call-template name="setAuthority"/>
1859 <xsl:call-template name="genre"/>
1860 <xsl:apply-templates select="marc:subfield[@code!='i']"/>
1863 <xsl:template match="marc:datafield[@tag=780]">
1865 <xsl:call-template name="relatedTypeAttribute"/>
1866 <xsl:apply-templates select="marc:subfield[@code!='i']"/>
1869 <xsl:template match="marc:datafield[@tag=785]">
1871 <xsl:call-template name="relatedTypeAttribute"/>
1872 <xsl:apply-templates select="marc:subfield[@code!='i']"/>
1876 <!-- ========== notes ========== -->
1877 <xsl:template match="marc:datafield[667 <= @tag and @tag <= 688]">
1880 <xsl:when test="@tag=667">
1881 <xsl:attribute name="type">nonpublic</xsl:attribute>
1883 <xsl:when test="@tag=670">
1884 <xsl:attribute name="type">source</xsl:attribute>
1886 <xsl:when test="@tag=675">
1887 <xsl:attribute name="type">notFound</xsl:attribute>
1889 <xsl:when test="@tag=678">
1890 <xsl:attribute name="type">history</xsl:attribute>
1892 <xsl:when test="@tag=681">
1893 <xsl:attribute name="type">subject example</xsl:attribute>
1895 <xsl:when test="@tag=682">
1896 <xsl:attribute name="type">deleted heading information</xsl:attribute>
1898 <xsl:when test="@tag=688">
1899 <xsl:attribute name="type">application history</xsl:attribute>
1902 <xsl:call-template name="chopPunctuation">
1903 <xsl:with-param name="chopString">
1905 <xsl:when test="@tag=667 or @tag=675">
1906 <xsl:value-of select="marc:subfield[@code='a']"/>
1908 <xsl:when test="@tag=670 or @tag=678">
1909 <xsl:call-template name="subfieldSelect">
1910 <xsl:with-param name="codes">ab</xsl:with-param>
1911 </xsl:call-template>
1913 <xsl:when test="680 <= @tag and @tag <=688">
1914 <xsl:call-template name="subfieldSelect">
1915 <xsl:with-param name="codes">ai</xsl:with-param>
1916 </xsl:call-template>
1920 </xsl:call-template>
1924 <!-- ========== url ========== -->
1925 <xsl:template match="marc:datafield[@tag=856][marc:subfield[@code='u']]">
1927 <xsl:if test="marc:subfield[@code='z' or @code='3']">
1928 <xsl:attribute name="displayLabel">
1929 <xsl:call-template name="subfieldSelect">
1930 <xsl:with-param name="codes">z3</xsl:with-param>
1931 </xsl:call-template>
1934 <xsl:value-of select="marc:subfield[@code='u']"/>
1938 <xsl:template name="relatedTypeAttribute">
1941 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">
1942 <xsl:if test="substring(marc:subfield[@code='w'],1,1)='a'">
1943 <xsl:attribute name="type">earlier</xsl:attribute>
1945 <xsl:if test="substring(marc:subfield[@code='w'],1,1)='b'">
1946 <xsl:attribute name="type">later</xsl:attribute>
1948 <xsl:if test="substring(marc:subfield[@code='w'],1,1)='t'">
1949 <xsl:attribute name="type">parentOrg</xsl:attribute>
1951 <xsl:if test="substring(marc:subfield[@code='w'],1,1)='g'">
1952 <xsl:attribute name="type">broader</xsl:attribute>
1954 <xsl:if test="substring(marc:subfield[@code='w'],1,1)='h'">
1955 <xsl:attribute name="type">narrower</xsl:attribute>
1957 <xsl:if test="substring(marc:subfield[@code='w'],1,1)='r'">
1958 <xsl:attribute name="type">other</xsl:attribute>
1960 <xsl:if test="contains('fin|', substring(marc:subfield[@code='w'],1,1))">
1961 <xsl:attribute name="type">other</xsl:attribute>
1964 <xsl:when test="@tag=530 or @tag=730">
1965 <xsl:attribute name="type">other</xsl:attribute>
1969 <xsl:attribute name="type">equivalent</xsl:attribute>
1972 <xsl:apply-templates select="marc:subfield[@code='i']"/>
1977 <xsl:template name="variantTypeAttribute">
1980 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">
1981 <xsl:if test="substring(marc:subfield[@code='w'],1,1)='d'">
1982 <xsl:attribute name="type">acronym</xsl:attribute>
1984 <xsl:if test="substring(marc:subfield[@code='w'],1,1)='n'">
1985 <xsl:attribute name="type">other</xsl:attribute>
1987 <xsl:if test="contains('fit', substring(marc:subfield[@code='w'],1,1))">
1988 <xsl:attribute name="type">other</xsl:attribute>
1993 <xsl:attribute name="type">other</xsl:attribute>
1996 <xsl:apply-templates select="marc:subfield[@code='i']"/>
1999 <xsl:template name="setAuthority">
2001 <!-- can be called from the datafield or subfield level, so "..//@tag" means
2002 the tag can be at the subfield's parent level or at the datafields own level -->
2005 test="ancestor-or-self::marc:datafield/@tag=100 and (@ind1=0 or @ind1=1) and $controlField008-11='a' and $controlField008-14='a'">
2006 <xsl:attribute name="authority">
2007 <xsl:text>naf</xsl:text>
2011 test="ancestor-or-self::marc:datafield/@tag=100 and (@ind1=0 or @ind1=1) and $controlField008-11='a' and $controlField008-14='b'">
2012 <xsl:attribute name="authority">
2013 <xsl:text>lcsh</xsl:text>
2017 test="ancestor-or-self::marc:datafield/@tag=100 and (@ind1=0 or @ind1=1) and $controlField008-11='k'">
2018 <xsl:attribute name="authority">
2019 <xsl:text>lacnaf</xsl:text>
2023 test="ancestor-or-self::marc:datafield/@tag=100 and @ind1=3 and $controlField008-11='a' and $controlField008-14='b'">
2024 <xsl:attribute name="authority">
2025 <xsl:text>lcsh</xsl:text>
2029 test="ancestor-or-self::marc:datafield/@tag=100 and @ind1=3 and $controlField008-11='k' and $controlField008-14='b'">
2030 <xsl:attribute name="authority">cash</xsl:attribute>
2033 test="ancestor-or-self::marc:datafield/@tag=110 and $controlField008-11='a' and $controlField008-14='a'">
2034 <xsl:attribute name="authority">naf</xsl:attribute>
2037 test="ancestor-or-self::marc:datafield/@tag=110 and $controlField008-11='a' and $controlField008-14='b'">
2038 <xsl:attribute name="authority">lcsh</xsl:attribute>
2041 test="ancestor-or-self::marc:datafield/@tag=110 and $controlField008-11='k' and $controlField008-14='a'">
2042 <xsl:attribute name="authority">
2043 <xsl:text>lacnaf</xsl:text>
2047 test="ancestor-or-self::marc:datafield/@tag=110 and $controlField008-11='k' and $controlField008-14='b'">
2048 <xsl:attribute name="authority">
2049 <xsl:text>cash</xsl:text>
2053 test="100 <= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag <= 155 and $controlField008-11='b'">
2054 <xsl:attribute name="authority">
2055 <xsl:text>lcshcl</xsl:text>
2059 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'">
2060 <xsl:attribute name="authority">
2061 <xsl:text>nlmnaf</xsl:text>
2065 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'">
2066 <xsl:attribute name="authority">
2067 <xsl:text>nalnaf</xsl:text>
2071 test="100 <= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag <= 155 and $controlField008-11='r'">
2072 <xsl:attribute name="authority">
2073 <xsl:text>aat</xsl:text>
2077 test="100 <= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag <= 155 and $controlField008-11='s'">
2078 <xsl:attribute name="authority">sears</xsl:attribute>
2081 test="100 <= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag <= 155 and $controlField008-11='v'">
2082 <xsl:attribute name="authority">rvm</xsl:attribute>
2085 test="100 <= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag <= 155 and $controlField008-11='z'">
2086 <xsl:attribute name="authority">
2088 select="../marc:datafield[ancestor-or-self::marc:datafield/@tag=040]/marc:subfield[@code='f']"
2093 test="(ancestor-or-self::marc:datafield/@tag=111 or ancestor-or-self::marc:datafield/@tag=130) and $controlField008-11='a' and $controlField008-14='a'">
2094 <xsl:attribute name="authority">
2095 <xsl:text>naf</xsl:text>
2099 test="(ancestor-or-self::marc:datafield/@tag=111 or ancestor-or-self::marc:datafield/@tag=130) and $controlField008-11='a' and $controlField008-14='b'">
2100 <xsl:attribute name="authority">
2101 <xsl:text>lcsh</xsl:text>
2105 test="(ancestor-or-self::marc:datafield/@tag=111 or ancestor-or-self::marc:datafield/@tag=130) and $controlField008-11='k' ">
2106 <xsl:attribute name="authority">
2107 <xsl:text>lacnaf</xsl:text>
2111 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' ">
2112 <xsl:attribute name="authority">
2113 <xsl:text>lcsh</xsl:text>
2117 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' ">
2118 <xsl:attribute name="authority">
2119 <xsl:text>lcsh</xsl:text>
2123 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' ">
2124 <xsl:attribute name="authority">
2125 <xsl:text>mesh</xsl:text>
2129 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' ">
2130 <xsl:attribute name="authority">
2131 <xsl:text>nal</xsl:text>
2135 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' ">
2136 <xsl:attribute name="authority">
2137 <xsl:text>cash</xsl:text>
2141 test="ancestor-or-self::marc:datafield/@tag=151 and $controlField008-11='a' and $controlField008-14='a'">
2142 <xsl:attribute name="authority">
2143 <xsl:text>naf</xsl:text>
2147 test="ancestor-or-self::marc:datafield/@tag=151 and $controlField008-11='a' and $controlField008-14='b'">
2148 <xsl:attribute name="authority">lcsh</xsl:attribute>
2151 test="ancestor-or-self::marc:datafield/@tag=151 and $controlField008-11='k' and $controlField008-14='a'">
2152 <xsl:attribute name="authority">lacnaf</xsl:attribute>
2155 test="ancestor-or-self::marc:datafield/@tag=151 and $controlField008-11='k' and $controlField008-14='b'">
2156 <xsl:attribute name="authority">cash</xsl:attribute>
2159 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'">
2160 <xsl:attribute name="authority">lcsh</xsl:attribute>
2163 test="ancestor-or-self::marc:datafield/@tag=700 and (@ind1='0' or @ind1='1') and @ind2='0'">
2164 <xsl:attribute name="authority">naf</xsl:attribute>
2167 test="ancestor-or-self::marc:datafield/@tag=700 and (@ind1='0' or @ind1='1') and @ind2='5'">
2168 <xsl:attribute name="authority">lacnaf</xsl:attribute>
2170 <xsl:when test="ancestor-or-self::marc:datafield/@tag=700 and @ind1='3' and @ind2='0'">
2171 <xsl:attribute name="authority">lcsh</xsl:attribute>
2173 <xsl:when test="ancestor-or-self::marc:datafield/@tag=700 and @ind1='3' and @ind2='5'">
2174 <xsl:attribute name="authority">cash</xsl:attribute>
2177 test="(700 <= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag <= 755 ) and @ind2='1'">
2178 <xsl:attribute name="authority">lcshcl</xsl:attribute>
2181 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'">
2182 <xsl:attribute name="authority">nlmnaf</xsl:attribute>
2185 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'">
2186 <xsl:attribute name="authority">nalnaf</xsl:attribute>
2189 test="(700 <= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag <= 755 ) and @ind2='6'">
2190 <xsl:attribute name="authority">rvm</xsl:attribute>
2193 test="(700 <= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag <= 755 ) and @ind2='7'">
2194 <xsl:attribute name="authority">
2195 <xsl:value-of select="marc:subfield[@code='2']"/>
2199 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'">
2200 <xsl:attribute name="authority">lacnaf</xsl:attribute>
2203 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'">
2204 <xsl:attribute name="authority">naf</xsl:attribute>
2207 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'">
2208 <xsl:attribute name="authority">lcsh</xsl:attribute>
2211 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'">
2212 <xsl:attribute name="authority">mesh</xsl:attribute>
2215 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'">
2216 <xsl:attribute name="authority">nal</xsl:attribute>
2219 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'">
2220 <xsl:attribute name="authority">cash</xsl:attribute>
2224 <xsl:template match="*"/>
2225 </xsl:stylesheet>$XSLT$ WHERE name = 'mads21';
2229 -- Update auditor tables to catch changes to source tables.
2230 -- Can be removed/skipped if there were no schema changes.
2231 SELECT auditor.update_auditors();