1 --Upgrade Script for 3.0.6 to 3.1.0
2 \set eg_version '''3.1.0'''
4 INSERT INTO config.upgrade_log (version, applied_to) VALUES ('3.1.0', :eg_version);
6 SELECT evergreen.upgrade_deps_block_check('1089', :eg_version);
8 -- Add the circ.holds.max_duplicate_holds org. unit setting type.
9 INSERT into config.org_unit_setting_type
10 ( name, grp, label, description, datatype, fm_class )
12 ( 'circ.holds.max_duplicate_holds', 'holds',
14 'circ.holds.max_duplicate_holds',
15 'Maximum number of duplicate holds allowed.',
18 'circ.holds.max_duplicate_holds',
19 'Maximum number of duplicate title or metarecord holds allowed per patron.',
20 'coust', 'description'),
25 SELECT evergreen.upgrade_deps_block_check('1090', :eg_version);
27 ALTER TABLE biblio.record_entry
28 ADD COLUMN merge_date TIMESTAMP WITH TIME ZONE,
29 ADD COLUMN merged_to BIGINT REFERENCES biblio.record_entry(id);
31 CREATE OR REPLACE FUNCTION asset.merge_record_assets( target_record BIGINT, source_record BIGINT ) RETURNS INT AS $func$
33 moved_objects INT := 0;
34 source_cn asset.call_number%ROWTYPE;
35 target_cn asset.call_number%ROWTYPE;
36 metarec metabib.metarecord%ROWTYPE;
37 hold action.hold_request%ROWTYPE;
38 ser_rec serial.record_entry%ROWTYPE;
39 ser_sub serial.subscription%ROWTYPE;
40 acq_lineitem acq.lineitem%ROWTYPE;
41 acq_request acq.user_request%ROWTYPE;
42 booking booking.resource_type%ROWTYPE;
43 source_part biblio.monograph_part%ROWTYPE;
44 target_part biblio.monograph_part%ROWTYPE;
45 multi_home biblio.peer_bib_copy_map%ROWTYPE;
52 -- move any 856 entries on records that have at least one MARC-mapped URI entry
53 SELECT INTO uri_count COUNT(*)
54 FROM asset.uri_call_number_map m
55 JOIN asset.call_number cn ON (m.call_number = cn.id)
56 WHERE cn.record = source_record;
60 -- This returns more nodes than you might expect:
61 -- 7 instead of 1 for an 856 with $u $y $9
62 SELECT COUNT(*) INTO counter
63 FROM oils_xpath_table(
66 'biblio.record_entry',
68 'id=' || source_record
71 FOR i IN 1 .. counter LOOP
72 SELECT '<datafield xmlns="http://www.loc.gov/MARC21/slim"' ||
74 ' ind1="' || FIRST(ind1) || '"' ||
75 ' ind2="' || FIRST(ind2) || '">' ||
77 '<subfield code="' || subfield || '">' ||
80 regexp_replace(data,'&','&','g'),
84 ) || '</subfield>', ''
85 ) || '</datafield>' INTO uri_datafield
86 FROM oils_xpath_table(
89 'biblio.record_entry',
90 '//*[@tag="856"][position()=' || i || ']/@ind1|' ||
91 '//*[@tag="856"][position()=' || i || ']/@ind2|' ||
92 '//*[@tag="856"][position()=' || i || ']/*/@code|' ||
93 '//*[@tag="856"][position()=' || i || ']/*[@code]',
94 'id=' || source_record
95 ) as t(id int,ind1 text, ind2 text,subfield text,data text);
97 -- As most of the results will be NULL, protect against NULLifying
98 -- the valid content that we do generate
99 uri_text := uri_text || COALESCE(uri_datafield, '');
102 IF uri_text <> '' THEN
103 UPDATE biblio.record_entry
104 SET marc = regexp_replace(marc,'(</[^>]*record>)', uri_text || E'\\1')
105 WHERE id = target_record;
110 -- Find and move metarecords to the target record
111 SELECT INTO metarec *
112 FROM metabib.metarecord
113 WHERE master_record = source_record;
116 UPDATE metabib.metarecord
117 SET master_record = target_record,
119 WHERE id = metarec.id;
121 moved_objects := moved_objects + 1;
124 -- Find call numbers attached to the source ...
125 FOR source_cn IN SELECT * FROM asset.call_number WHERE record = source_record LOOP
127 SELECT INTO target_cn *
128 FROM asset.call_number
129 WHERE label = source_cn.label
130 AND prefix = source_cn.prefix
131 AND suffix = source_cn.suffix
132 AND owning_lib = source_cn.owning_lib
133 AND record = target_record
136 -- ... and if there's a conflicting one on the target ...
139 -- ... move the copies to that, and ...
141 SET call_number = target_cn.id
142 WHERE call_number = source_cn.id;
144 -- ... move V holds to the move-target call number
145 FOR hold IN SELECT * FROM action.hold_request WHERE target = source_cn.id AND hold_type = 'V' LOOP
147 UPDATE action.hold_request
148 SET target = target_cn.id
151 moved_objects := moved_objects + 1;
154 UPDATE asset.call_number SET deleted = TRUE WHERE id = source_cn.id;
158 -- ... just move the call number to the target record
159 UPDATE asset.call_number
160 SET record = target_record
161 WHERE id = source_cn.id;
164 moved_objects := moved_objects + 1;
167 -- Find T holds targeting the source record ...
168 FOR hold IN SELECT * FROM action.hold_request WHERE target = source_record AND hold_type = 'T' LOOP
170 -- ... and move them to the target record
171 UPDATE action.hold_request
172 SET target = target_record
175 moved_objects := moved_objects + 1;
178 -- Find serial records targeting the source record ...
179 FOR ser_rec IN SELECT * FROM serial.record_entry WHERE record = source_record LOOP
180 -- ... and move them to the target record
181 UPDATE serial.record_entry
182 SET record = target_record
183 WHERE id = ser_rec.id;
185 moved_objects := moved_objects + 1;
188 -- Find serial subscriptions targeting the source record ...
189 FOR ser_sub IN SELECT * FROM serial.subscription WHERE record_entry = source_record LOOP
190 -- ... and move them to the target record
191 UPDATE serial.subscription
192 SET record_entry = target_record
193 WHERE id = ser_sub.id;
195 moved_objects := moved_objects + 1;
198 -- Find booking resource types targeting the source record ...
199 FOR booking IN SELECT * FROM booking.resource_type WHERE record = source_record LOOP
200 -- ... and move them to the target record
201 UPDATE booking.resource_type
202 SET record = target_record
203 WHERE id = booking.id;
205 moved_objects := moved_objects + 1;
208 -- Find acq lineitems targeting the source record ...
209 FOR acq_lineitem IN SELECT * FROM acq.lineitem WHERE eg_bib_id = source_record LOOP
210 -- ... and move them to the target record
212 SET eg_bib_id = target_record
213 WHERE id = acq_lineitem.id;
215 moved_objects := moved_objects + 1;
218 -- Find acq user purchase requests targeting the source record ...
219 FOR acq_request IN SELECT * FROM acq.user_request WHERE eg_bib = source_record LOOP
220 -- ... and move them to the target record
221 UPDATE acq.user_request
222 SET eg_bib = target_record
223 WHERE id = acq_request.id;
225 moved_objects := moved_objects + 1;
228 -- Find parts attached to the source ...
229 FOR source_part IN SELECT * FROM biblio.monograph_part WHERE record = source_record LOOP
231 SELECT INTO target_part *
232 FROM biblio.monograph_part
233 WHERE label = source_part.label
234 AND record = target_record;
236 -- ... and if there's a conflicting one on the target ...
239 -- ... move the copy-part maps to that, and ...
240 UPDATE asset.copy_part_map
241 SET part = target_part.id
242 WHERE part = source_part.id;
244 -- ... move P holds to the move-target part
245 FOR hold IN SELECT * FROM action.hold_request WHERE target = source_part.id AND hold_type = 'P' LOOP
247 UPDATE action.hold_request
248 SET target = target_part.id
251 moved_objects := moved_objects + 1;
256 -- ... just move the part to the target record
257 UPDATE biblio.monograph_part
258 SET record = target_record
259 WHERE id = source_part.id;
262 moved_objects := moved_objects + 1;
265 -- Find multi_home items attached to the source ...
266 FOR multi_home IN SELECT * FROM biblio.peer_bib_copy_map WHERE peer_record = source_record LOOP
267 -- ... and move them to the target record
268 UPDATE biblio.peer_bib_copy_map
269 SET peer_record = target_record
270 WHERE id = multi_home.id;
272 moved_objects := moved_objects + 1;
275 -- And delete mappings where the item's home bib was merged with the peer bib
276 DELETE FROM biblio.peer_bib_copy_map WHERE peer_record = (
277 SELECT (SELECT record FROM asset.call_number WHERE id = call_number)
278 FROM asset.copy WHERE id = target_copy
281 -- Apply merge tracking
282 UPDATE biblio.record_entry
283 SET merge_date = NOW() WHERE id = target_record;
285 UPDATE biblio.record_entry
286 SET merge_date = NOW(), merged_to = target_record
287 WHERE id = source_record;
289 -- Finally, "delete" the source record
290 DELETE FROM biblio.record_entry WHERE id = source_record;
292 -- That's all, folks!
293 RETURN moved_objects;
295 $func$ LANGUAGE plpgsql;
299 SELECT evergreen.upgrade_deps_block_check('1091', :eg_version);
301 ALTER TABLE acq.funding_source DROP CONSTRAINT funding_source_code_key;
302 ALTER TABLE acq.funding_source ALTER COLUMN code SET NOT NULL;
303 ALTER TABLE acq.funding_source ADD CONSTRAINT funding_source_code_once_per_owner UNIQUE (code,owner);
306 SELECT evergreen.upgrade_deps_block_check('1092', :eg_version);
308 CREATE OR REPLACE FUNCTION metabib.reingest_record_attributes (rid BIGINT, pattr_list TEXT[] DEFAULT NULL, prmarc TEXT DEFAULT NULL, rdeleted BOOL DEFAULT TRUE) RETURNS VOID AS $func$
310 transformed_xml TEXT;
311 rmarc TEXT := prmarc;
315 xfrm config.xml_transform%ROWTYPE;
316 attr_vector INT[] := '{}'::INT[];
317 attr_vector_tmp INT[];
318 attr_list TEXT[] := pattr_list;
320 norm_attr_value TEXT[];
323 attr_def config.record_attr_definition%ROWTYPE;
324 ccvm_row config.coded_value_map%ROWTYPE;
328 IF attr_list IS NULL OR rdeleted THEN -- need to do the full dance on INSERT or undelete
329 SELECT ARRAY_AGG(name) INTO attr_list FROM config.record_attr_definition
332 fixed_field IS NOT NULL OR
334 phys_char_sf IS NOT NULL OR
341 IF rmarc IS NULL THEN
342 SELECT marc INTO rmarc FROM biblio.record_entry WHERE id = rid;
345 FOR attr_def IN SELECT * FROM config.record_attr_definition WHERE NOT composite AND name = ANY( attr_list ) ORDER BY format LOOP
347 jump_past := FALSE; -- This gets set when we are non-multi and have found something
348 attr_value := '{}'::TEXT[];
349 norm_attr_value := '{}'::TEXT[];
350 attr_vector_tmp := '{}'::INT[];
352 SELECT * INTO ccvm_row FROM config.coded_value_map c WHERE c.ctype = attr_def.name LIMIT 1;
354 IF attr_def.tag IS NOT NULL THEN -- tag (and optional subfield list) selection
355 SELECT ARRAY_AGG(value) INTO attr_value
356 FROM (SELECT * FROM metabib.full_rec ORDER BY tag, subfield) AS x
358 AND tag LIKE attr_def.tag
360 WHEN attr_def.sf_list IS NOT NULL
361 THEN POSITION(subfield IN attr_def.sf_list) > 0
367 IF NOT attr_def.multi THEN
368 attr_value := ARRAY[ARRAY_TO_STRING(attr_value, COALESCE(attr_def.joiner,' '))];
373 IF NOT jump_past AND attr_def.fixed_field IS NOT NULL THEN -- a named fixed field, see config.marc21_ff_pos_map.fixed_field
374 attr_value := attr_value || vandelay.marc21_extract_fixed_field_list(rmarc, attr_def.fixed_field);
376 IF NOT attr_def.multi THEN
377 attr_value := ARRAY[attr_value[1]];
382 IF NOT jump_past AND attr_def.xpath IS NOT NULL THEN -- and xpath expression
384 SELECT INTO xfrm * FROM config.xml_transform WHERE name = attr_def.format;
386 -- See if we can skip the XSLT ... it's expensive
387 IF prev_xfrm IS NULL OR prev_xfrm <> xfrm.name THEN
388 -- Can't skip the transform
389 IF xfrm.xslt <> '---' THEN
390 transformed_xml := oils_xslt_process(rmarc,xfrm.xslt);
392 transformed_xml := rmarc;
395 prev_xfrm := xfrm.name;
398 IF xfrm.name IS NULL THEN
399 -- just grab the marcxml (empty) transform
400 SELECT INTO xfrm * FROM config.xml_transform WHERE xslt = '---' LIMIT 1;
401 prev_xfrm := xfrm.name;
404 FOR tmp_xml IN SELECT UNNEST(oils_xpath(attr_def.xpath, transformed_xml, ARRAY[ARRAY[xfrm.prefix, xfrm.namespace_uri]])) LOOP
405 tmp_val := oils_xpath_string(
408 COALESCE(attr_def.joiner,' '),
409 ARRAY[ARRAY[xfrm.prefix, xfrm.namespace_uri]]
411 IF tmp_val IS NOT NULL AND BTRIM(tmp_val) <> '' THEN
412 attr_value := attr_value || tmp_val;
413 EXIT WHEN NOT attr_def.multi;
418 IF NOT jump_past AND attr_def.phys_char_sf IS NOT NULL THEN -- a named Physical Characteristic, see config.marc21_physical_characteristic_*_map
419 SELECT ARRAY_AGG(m.value) INTO tmp_array
420 FROM vandelay.marc21_physical_characteristics(rmarc) v
421 LEFT JOIN config.marc21_physical_characteristic_value_map m ON (m.id = v.value)
422 WHERE v.subfield = attr_def.phys_char_sf AND (m.value IS NOT NULL AND BTRIM(m.value) <> '')
423 AND ( ccvm_row.id IS NULL OR ( ccvm_row.id IS NOT NULL AND v.id IS NOT NULL) );
425 attr_value := attr_value || tmp_array;
427 IF NOT attr_def.multi THEN
428 attr_value := ARRAY[attr_value[1]];
433 -- apply index normalizers to attr_value
434 FOR tmp_val IN SELECT value FROM UNNEST(attr_value) x(value) LOOP
436 SELECT n.func AS func,
437 n.param_count AS param_count,
439 FROM config.index_normalizer n
440 JOIN config.record_attr_index_norm_map m ON (m.norm = n.id)
441 WHERE attr = attr_def.name
443 EXECUTE 'SELECT ' || normalizer.func || '(' ||
444 COALESCE( quote_literal( tmp_val ), 'NULL' ) ||
446 WHEN normalizer.param_count > 0
447 THEN ',' || REPLACE(REPLACE(BTRIM(normalizer.params,'[]'),E'\'',E'\\\''),E'"',E'\'')
453 IF tmp_val IS NOT NULL AND tmp_val <> '' THEN
454 -- note that a string that contains only blanks
455 -- is a valid value for some attributes
456 norm_attr_value := norm_attr_value || tmp_val;
460 IF attr_def.filter THEN
461 -- Create unknown uncontrolled values and find the IDs of the values
462 IF ccvm_row.id IS NULL THEN
463 FOR tmp_val IN SELECT value FROM UNNEST(norm_attr_value) x(value) LOOP
464 IF tmp_val IS NOT NULL AND BTRIM(tmp_val) <> '' THEN
465 BEGIN -- use subtransaction to isolate unique constraint violations
466 INSERT INTO metabib.uncontrolled_record_attr_value ( attr, value ) VALUES ( attr_def.name, tmp_val );
467 EXCEPTION WHEN unique_violation THEN END;
471 SELECT ARRAY_AGG(id) INTO attr_vector_tmp FROM metabib.uncontrolled_record_attr_value WHERE attr = attr_def.name AND value = ANY( norm_attr_value );
473 SELECT ARRAY_AGG(id) INTO attr_vector_tmp FROM config.coded_value_map WHERE ctype = attr_def.name AND code = ANY( norm_attr_value );
476 -- Add the new value to the vector
477 attr_vector := attr_vector || attr_vector_tmp;
480 IF attr_def.sorter THEN
481 DELETE FROM metabib.record_sorter WHERE source = rid AND attr = attr_def.name;
482 IF norm_attr_value[1] IS NOT NULL THEN
483 INSERT INTO metabib.record_sorter (source, attr, value) VALUES (rid, attr_def.name, norm_attr_value[1]);
489 /* We may need to rewrite the vlist to contain
490 the intersection of new values for requested
491 attrs and old values for ignored attrs. To
492 do this, we take the old attr vlist and
493 subtract any values that are valid for the
494 requested attrs, and then add back the new
495 set of attr values. */
497 IF ARRAY_LENGTH(pattr_list, 1) > 0 THEN
498 SELECT vlist INTO attr_vector_tmp FROM metabib.record_attr_vector_list WHERE source = rid;
499 SELECT attr_vector_tmp - ARRAY_AGG(id::INT) INTO attr_vector_tmp FROM metabib.full_attr_id_map WHERE attr = ANY (pattr_list);
500 attr_vector := attr_vector || attr_vector_tmp;
503 -- On to composite attributes, now that the record attrs have been pulled. Processed in name order, so later composite
504 -- attributes can depend on earlier ones.
505 PERFORM metabib.compile_composite_attr_cache_init();
506 FOR attr_def IN SELECT * FROM config.record_attr_definition WHERE composite AND name = ANY( attr_list ) ORDER BY name LOOP
508 FOR ccvm_row IN SELECT * FROM config.coded_value_map c WHERE c.ctype = attr_def.name ORDER BY value LOOP
510 tmp_val := metabib.compile_composite_attr( ccvm_row.id );
511 CONTINUE WHEN tmp_val IS NULL OR tmp_val = ''; -- nothing to do
513 IF attr_def.filter THEN
514 IF attr_vector @@ tmp_val::query_int THEN
515 attr_vector = attr_vector + intset(ccvm_row.id);
516 EXIT WHEN NOT attr_def.multi;
520 IF attr_def.sorter THEN
521 IF attr_vector @@ tmp_val THEN
522 DELETE FROM metabib.record_sorter WHERE source = rid AND attr = attr_def.name;
523 INSERT INTO metabib.record_sorter (source, attr, value) VALUES (rid, attr_def.name, ccvm_row.code);
531 IF ARRAY_LENGTH(attr_vector, 1) > 0 THEN
532 IF rdeleted THEN -- initial insert OR revivication
533 DELETE FROM metabib.record_attr_vector_list WHERE source = rid;
534 INSERT INTO metabib.record_attr_vector_list (source, vlist) VALUES (rid, attr_vector);
536 UPDATE metabib.record_attr_vector_list SET vlist = attr_vector WHERE source = rid;
542 $func$ LANGUAGE PLPGSQL;
546 SELECT evergreen.upgrade_deps_block_check('1093', :eg_version);
548 UPDATE config.record_attr_definition SET tag = '041', sf_list = 'abdefgm' where name = 'item_lang';
552 SELECT evergreen.upgrade_deps_block_check('1094', :eg_version);
554 SELECT metabib.reingest_record_attributes (record, '{item_lang}'::TEXT[])
555 FROM (SELECT DISTINCT record
556 FROM metabib.real_full_rec
558 AND subfield IN ('a','b','d','e','f','g','m')
563 SELECT evergreen.upgrade_deps_block_check('1095', :eg_version);
565 CREATE OR REPLACE FUNCTION asset.copy_state (cid BIGINT) RETURNS TEXT AS $$
568 the_copy asset.copy%ROWTYPE;
571 SELECT * INTO the_copy FROM asset.copy WHERE id = cid;
572 IF NOT FOUND THEN RETURN NULL; END IF;
574 IF the_copy.status = 3 THEN -- Lost
576 ELSIF the_copy.status = 4 THEN -- Missing
578 ELSIF the_copy.status = 14 THEN -- Damaged
580 ELSIF the_copy.status = 17 THEN -- Lost and paid
581 RETURN 'LOST_AND_PAID';
584 SELECT stop_fines INTO last_circ_stop
585 FROM action.circulation
586 WHERE target_copy = cid
587 ORDER BY xact_start DESC LIMIT 1;
590 IF last_circ_stop IN (
591 'CLAIMSNEVERCHECKEDOUT',
595 RETURN last_circ_stop;
603 CREATE TYPE config.copy_alert_type_state AS ENUM (
611 'CLAIMSNEVERCHECKEDOUT'
614 CREATE TYPE config.copy_alert_type_event AS ENUM (
619 CREATE TABLE config.copy_alert_type (
620 id serial primary key, -- reserve 1-100 for system
621 scope_org int not null references actor.org_unit (id) on delete cascade,
622 active bool not null default true,
623 name text not null unique,
624 state config.copy_alert_type_state,
625 event config.copy_alert_type_event,
627 invert_location bool not null default false,
632 SELECT SETVAL('config.copy_alert_type_id_seq'::TEXT, 100);
634 CREATE OR REPLACE FUNCTION evergreen.asset_copy_alert_copy_inh_fkey() RETURNS TRIGGER AS $f$
636 PERFORM 1 FROM asset.copy WHERE id = NEW.copy;
638 RAISE foreign_key_violation USING MESSAGE = FORMAT(
639 $$Referenced asset.copy id not found, copy:%s$$, NEW.copy
644 $f$ LANGUAGE PLPGSQL VOLATILE COST 50;
646 CREATE TABLE actor.copy_alert_suppress (
647 id serial primary key,
648 org int not null references actor.org_unit (id) on delete cascade,
649 alert_type int not null references config.copy_alert_type (id) on delete cascade
652 CREATE TABLE asset.copy_alert (
653 id bigserial primary key,
654 alert_type int not null references config.copy_alert_type (id) on delete cascade,
655 copy bigint not null,
656 temp bool not null default false,
657 create_time timestamptz not null default now(),
658 create_staff bigint not null references actor.usr (id) on delete set null,
660 ack_time timestamptz,
661 ack_staff bigint references actor.usr (id) on delete set null
664 CREATE CONSTRAINT TRIGGER inherit_asset_copy_alert_copy_fkey
665 AFTER UPDATE OR INSERT ON asset.copy_alert
666 DEFERRABLE FOR EACH ROW EXECUTE PROCEDURE evergreen.asset_copy_alert_copy_inh_fkey();
668 CREATE VIEW asset.active_copy_alert AS
670 FROM asset.copy_alert
671 WHERE ack_time IS NULL;
675 SELECT evergreen.upgrade_deps_block_check('1096', :eg_version);
677 -- staff-usable alert types with no location awareness
678 INSERT INTO config.copy_alert_type (id, scope_org, active, name, state, event, in_renew)
679 VALUES (1, 1, TRUE, 'Normal checkout', 'NORMAL', 'CHECKOUT', FALSE);
680 INSERT INTO config.copy_alert_type (id, scope_org, active, name, state, event, in_renew)
681 VALUES (2, 1, TRUE, 'Normal checkin', 'NORMAL', 'CHECKIN', FALSE);
682 INSERT INTO config.copy_alert_type (id, scope_org, active, name, state, event, in_renew)
683 VALUES (3, 1, FALSE, 'Normal renewal', 'NORMAL', 'CHECKIN', TRUE);
685 -- copy alerts upon checkin or renewal of exceptional copy statuses are not active by
686 -- default; they're meant to be turned once a site is ready to fully
687 -- commit to using the webstaff client for circulation
688 INSERT INTO config.copy_alert_type (id, scope_org, active, name, state, event)
689 VALUES (4, 1, FALSE, 'Checkin of lost copy', 'LOST', 'CHECKIN');
690 INSERT INTO config.copy_alert_type (id, scope_org, active, name, state, event)
691 VALUES (5, 1, FALSE, 'Checkin of missing copy', 'MISSING', 'CHECKIN');
692 INSERT INTO config.copy_alert_type (id, scope_org, active, name, state, event)
693 VALUES (6, 1, FALSE, 'Checkin of lost-and-paid copy', 'LOST_AND_PAID', 'CHECKIN');
694 INSERT INTO config.copy_alert_type (id, scope_org, active, name, state, event)
695 VALUES (7, 1, FALSE, 'Checkin of damaged copy', 'DAMAGED', 'CHECKIN');
696 INSERT INTO config.copy_alert_type (id, scope_org, active, name, state, event)
697 VALUES (8, 1, FALSE, 'Checkin of claims-returned copy', 'CLAIMSRETURNED', 'CHECKIN');
698 INSERT INTO config.copy_alert_type (id, scope_org, active, name, state, event)
699 VALUES (9, 1, FALSE, 'Checkin of long overdue copy', 'LONGOVERDUE', 'CHECKIN');
700 INSERT INTO config.copy_alert_type (id, scope_org, active, name, state, event)
701 VALUES (10, 1, FALSE, 'Checkin of claims-never-checked-out copy', 'CLAIMSNEVERCHECKEDOUT', 'CHECKIN');
703 -- copy alerts upon checkout of exceptional copy statuses are not active by
704 -- default; they're meant to be turned once a site is ready to fully
705 -- commit to using the webstaff client for circulation
706 INSERT INTO config.copy_alert_type (id, scope_org, active, name, state, event)
707 VALUES (11, 1, FALSE, 'Checkout of lost copy', 'LOST', 'CHECKOUT');
708 INSERT INTO config.copy_alert_type (id, scope_org, active, name, state, event)
709 VALUES (12, 1, FALSE, 'Checkout of missing copy', 'MISSING', 'CHECKOUT');
710 INSERT INTO config.copy_alert_type (id, scope_org, active, name, state, event)
711 VALUES (13, 1, FALSE, 'Checkout of lost-and-paid copy', 'LOST_AND_PAID', 'CHECKOUT');
712 INSERT INTO config.copy_alert_type (id, scope_org, active, name, state, event)
713 VALUES (14, 1, FALSE, 'Checkout of damaged copy', 'DAMAGED', 'CHECKOUT');
714 INSERT INTO config.copy_alert_type (id, scope_org, active, name, state, event)
715 VALUES (15, 1, FALSE, 'Checkout of claims-returned copy', 'CLAIMSRETURNED', 'CHECKOUT');
716 INSERT INTO config.copy_alert_type (id, scope_org, active, name, state, event)
717 VALUES (16, 1, FALSE, 'Checkout of long overdue copy', 'LONGOVERDUE', 'CHECKOUT');
718 INSERT INTO config.copy_alert_type (id, scope_org, active, name, state, event)
719 VALUES (17, 1, FALSE, 'Checkout of claims-never-checked-out copy', 'CLAIMSNEVERCHECKEDOUT', 'CHECKOUT');
721 -- staff-usable alert types based on location
722 INSERT INTO config.copy_alert_type (id, scope_org, active, name, state, event, in_renew, at_circ)
723 VALUES (18, 1, FALSE, 'Normal checkout at circ lib', 'NORMAL', 'CHECKOUT', FALSE, TRUE);
724 INSERT INTO config.copy_alert_type (id, scope_org, active, name, state, event, in_renew, at_circ)
725 VALUES (19, 1, FALSE, 'Normal checkin at circ lib', 'NORMAL', 'CHECKIN', FALSE, TRUE);
726 INSERT INTO config.copy_alert_type (id, scope_org, active, name, state, event, in_renew, at_circ)
727 VALUES (20, 1, FALSE, 'Normal renewal at circ lib', 'NORMAL', 'CHECKIN', TRUE, TRUE);
729 INSERT INTO config.copy_alert_type (id, scope_org, active, name, state, event, in_renew, at_owning)
730 VALUES (21, 1, FALSE, 'Normal checkout at owning lib', 'NORMAL', 'CHECKOUT', FALSE, TRUE);
731 INSERT INTO config.copy_alert_type (id, scope_org, active, name, state, event, in_renew, at_owning)
732 VALUES (22, 1, FALSE, 'Normal checkin at owning lib', 'NORMAL', 'CHECKIN', FALSE, TRUE);
733 INSERT INTO config.copy_alert_type (id, scope_org, active, name, state, event, in_renew, at_owning)
734 VALUES (23, 1, FALSE, 'Normal renewal at owning lib', 'NORMAL', 'CHECKIN', TRUE, TRUE);
737 SELECT evergreen.upgrade_deps_block_check('1097', :eg_version);
739 INSERT INTO config.org_unit_setting_type
740 (name, grp, label, description, datatype)
742 ('circ.copy_alerts.forgive_fines_on_lost_checkin',
744 oils_i18n_gettext('circ.copy_alerts.forgive_fines_on_lost_checkin',
745 'Forgive fines when checking out a lost item and copy alert is suppressed?',
747 oils_i18n_gettext('circ.copy_alerts.forgive_fines_on_lost_checkin',
748 'Controls whether fines are automatically forgiven when checking out an '||
749 'item that has been marked as lost, and the corresponding copy alert has been '||
751 'coust', 'description'),
754 INSERT INTO config.org_unit_setting_type
755 (name, grp, label, description, datatype)
757 ('circ.copy_alerts.forgive_fines_on_long_overdue_checkin',
759 oils_i18n_gettext('circ.copy_alerts.forgive_fines_on_long_overdue_checkin',
760 'Forgive fines when checking out a long-overdue item and copy alert is suppressed?',
762 oils_i18n_gettext('circ.copy_alerts.forgive_fines_on_lost_checkin',
763 'Controls whether fines are automatically forgiven when checking out an '||
764 'item that has been marked as lost, and the corresponding copy alert has been '||
766 'coust', 'description'),
770 SELECT evergreen.upgrade_deps_block_check('1098', :eg_version);
772 \qecho Copying copy alert messages to normal checkout copy alerts...
773 INSERT INTO asset.copy_alert (alert_type, copy, note, create_staff)
774 SELECT 1, id, alert_message, 1
776 WHERE alert_message IS NOT NULL
777 AND alert_message <> '';
779 \qecho Copying copy alert messages to normal checkin copy alerts...
780 INSERT INTO asset.copy_alert (alert_type, copy, note, create_staff)
781 SELECT 2, id, alert_message, 1
783 WHERE alert_message IS NOT NULL
784 AND alert_message <> '';
786 \qecho Clearing legacy copy alert field; this may take a while
787 UPDATE asset.copy SET alert_message = NULL
788 WHERE alert_message IS NOT NULL;
791 SELECT evergreen.upgrade_deps_block_check('1099', :eg_version);
793 \qecho Making the following copy alert types active by default; if you
794 \qecho are not using the web staff client yet, you may want to disable
796 \qecho - Checkin of lost, missing, lost-and-paid, damaged, claims returned,
797 \qecho long overdue, and claims never checked out items.
798 \qecho - Checkout of lost, missing, lost-and-paid, damaged, claims returned,
799 \qecho long overdue, and claims never checked out items.
801 UPDATE config.copy_alert_type
803 WHERE id IN (4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
806 SELECT evergreen.upgrade_deps_block_check('1100', :eg_version);
808 -- NEW config.metabib_field entries
810 UPDATE config.metabib_field SET display_xpath = facet_xpath, display_field = TRUE WHERE id = 33;
812 INSERT INTO config.metabib_field (id, field_class, name,
813 label, xpath, display_field, search_field, browse_field)
815 38, 'identifier', 'edition',
816 oils_i18n_gettext(38, 'Edition', 'cmf', 'label'),
817 $$//mods33:mods/mods33:originInfo//mods33:edition[1]$$,
821 INSERT INTO config.metabib_field (id, field_class, name,
822 label, xpath, display_field, search_field, browse_field)
824 39, 'keyword', 'physical_description',
825 oils_i18n_gettext(39, 'Physical Descrption', 'cmf', 'label'),
826 $$(//mods33:mods/mods33:physicalDescription/mods33:form|//mods33:mods/mods33:physicalDescription/mods33:extent|//mods33:mods/mods33:physicalDescription/mods33:reformattingQuality|//mods33:mods/mods33:physicalDescription/mods33:internetMediaType|//mods33:mods/mods33:physicalDescription/mods33:digitalOrigin)$$,
830 INSERT INTO config.metabib_field (id, field_class, name,
831 label, xpath, display_field, search_field, browse_field)
833 40, 'identifier', 'publisher',
834 oils_i18n_gettext(40, 'Publisher', 'cmf', 'label'),
835 $$//mods33:mods/mods33:originInfo//mods33:publisher[1]$$,
839 INSERT INTO config.metabib_field (id, field_class, name,
840 label, xpath, display_field, search_field, browse_field)
842 41, 'keyword', 'abstract',
843 oils_i18n_gettext(41, 'Abstract', 'cmf', 'label'),
844 $$//mods33:mods/mods33:abstract$$,
848 INSERT INTO config.metabib_field (id, field_class, name,
849 label, xpath, display_field, search_field, browse_field)
851 42, 'keyword', 'toc',
852 oils_i18n_gettext(42, 'Table of Contents', 'cmf', 'label'),
853 $$//mods33:tableOfContents$$,
857 INSERT INTO config.metabib_field (id, field_class, name,
858 label, xpath, display_field, search_field, browse_field)
860 43, 'identifier', 'type_of_resource',
861 oils_i18n_gettext(43, 'Type of Resource', 'cmf', 'label'),
862 $$//mods33:mods/mods33:typeOfResource$$,
866 INSERT INTO config.metabib_field (id, field_class, name,
867 label, xpath, display_field, search_field, browse_field)
869 44, 'identifier', 'pubdate',
870 oils_i18n_gettext(44, 'Publication Date', 'cmf', 'label'),
871 $$//mods33:mods/mods33:originInfo//mods33:dateIssued[@encoding="marc"]|//mods33:mods/mods33:originInfo//mods33:dateIssued[1]$$,
875 INSERT INTO config.metabib_field (id, field_class, name,
876 label, xpath, display_field, search_field, browse_field)
878 46, 'keyword', 'bibliography',
879 oils_i18n_gettext(46, 'Bibliography', 'cmf', 'label'),
880 $$//mods33:note[@type='bibliography']$$,
883 47, 'keyword', 'thesis',
884 oils_i18n_gettext(47, 'Thesis', 'cmf', 'label'),
885 $$//mods33:note[@type='thesis']$$,
888 48, 'keyword', 'production_credits',
889 oils_i18n_gettext(48, 'Creation/Production Credits', 'cmf', 'label'),
890 $$//mods33:note[@type='creation/production credits']$$,
893 49, 'keyword', 'performers',
894 oils_i18n_gettext(49, 'Performers', 'cmf', 'label'),
895 $$//mods33:note[@type='performers']$$,
898 50, 'keyword', 'general_note',
899 oils_i18n_gettext(50, 'General Note', 'cmf', 'label'),
900 $$//mods33:note[not(@type)]$$,
905 INSERT INTO config.metabib_field (id, field_class, name, format,
906 label, xpath, display_xpath, display_field, search_field, browse_field)
908 51, 'author', 'first_author', 'mods32',
909 oils_i18n_gettext(51, 'Author', 'cmf', 'label'),
910 $$//mods32:mods/mods32:name[mods32:role/mods32:roleTerm[text()='creator']][1]$$,
911 $$//*[local-name()='namePart']$$,
915 INSERT INTO config.metabib_field (id, field_class, name, format,
916 label, xpath, display_xpath, display_field, search_field, browse_field)
918 52, 'identifier', 'origin_info', 'marcxml',
919 oils_i18n_gettext(52, 'Origin Info', 'cmf', 'label'),
921 $$//*[local-name()='subfield' and contains('abc',@code)]$$,
926 -- Modify existing config.metabib_field entries
928 UPDATE config.metabib_field SET display_field = TRUE WHERE id IN (
930 11, -- subject_geographic
932 13, -- subject_temporal
939 -- Map display field names to config.metabib_field entries
941 INSERT INTO config.display_field_map (name, field, multi) VALUES
942 ('series_title', 1, TRUE),
943 ('subject_geographic', 11, TRUE),
944 ('subject_name', 12, TRUE),
945 ('subject_temporal', 13, TRUE),
946 ('subject_topic', 14, TRUE),
950 ('edition', 38, FALSE),
951 ('physical_description',39, TRUE),
953 ('bibliography', 46, TRUE),
954 ('thesis', 47, TRUE),
955 ('performers', 49, TRUE),
956 ('production_credits', 48, TRUE),
957 ('general_note', 50, TRUE),
958 ('publisher', 52, FALSE),
959 ('abstract', 41, FALSE),
961 ('type_of_resource', 43, FALSE),
962 ('pubdate', 44, FALSE)
965 UPDATE config.display_field_map SET field = 51 WHERE name = 'author';
967 -- Add a column to wide-display-entry per well-known field
969 DROP VIEW IF EXISTS metabib.wide_display_entry;
970 CREATE VIEW metabib.wide_display_entry AS
973 COALESCE(mcde_title.value, 'null')::TEXT AS title,
974 COALESCE(mcde_author.value, 'null')::TEXT AS author,
975 COALESCE(mcde_subject_geographic.value, 'null')::TEXT AS subject_geographic,
976 COALESCE(mcde_subject_name.value, 'null')::TEXT AS subject_name,
977 COALESCE(mcde_subject_temporal.value, 'null')::TEXT AS subject_temporal,
978 COALESCE(mcde_subject_topic.value, 'null')::TEXT AS subject_topic,
979 COALESCE(mcde_creators.value, 'null')::TEXT AS creators,
980 COALESCE(mcde_isbn.value, 'null')::TEXT AS isbn,
981 COALESCE(mcde_issn.value, 'null')::TEXT AS issn,
982 COALESCE(mcde_upc.value, 'null')::TEXT AS upc,
983 COALESCE(mcde_tcn.value, 'null')::TEXT AS tcn,
984 COALESCE(mcde_edition.value, 'null')::TEXT AS edition,
985 COALESCE(mcde_physical_description.value, 'null')::TEXT AS physical_description,
986 COALESCE(mcde_publisher.value, 'null')::TEXT AS publisher,
987 COALESCE(mcde_series_title.value, 'null')::TEXT AS series_title,
988 COALESCE(mcde_abstract.value, 'null')::TEXT AS abstract,
989 COALESCE(mcde_toc.value, 'null')::TEXT AS toc,
990 COALESCE(mcde_pubdate.value, 'null')::TEXT AS pubdate,
991 COALESCE(mcde_type_of_resource.value, 'null')::TEXT AS type_of_resource
992 FROM biblio.record_entry bre
993 LEFT JOIN metabib.compressed_display_entry mcde_title
994 ON (bre.id = mcde_title.source AND mcde_title.name = 'title')
995 LEFT JOIN metabib.compressed_display_entry mcde_author
996 ON (bre.id = mcde_author.source AND mcde_author.name = 'author')
997 LEFT JOIN metabib.compressed_display_entry mcde_subject
998 ON (bre.id = mcde_subject.source AND mcde_subject.name = 'subject')
999 LEFT JOIN metabib.compressed_display_entry mcde_subject_geographic
1000 ON (bre.id = mcde_subject_geographic.source
1001 AND mcde_subject_geographic.name = 'subject_geographic')
1002 LEFT JOIN metabib.compressed_display_entry mcde_subject_name
1003 ON (bre.id = mcde_subject_name.source
1004 AND mcde_subject_name.name = 'subject_name')
1005 LEFT JOIN metabib.compressed_display_entry mcde_subject_temporal
1006 ON (bre.id = mcde_subject_temporal.source
1007 AND mcde_subject_temporal.name = 'subject_temporal')
1008 LEFT JOIN metabib.compressed_display_entry mcde_subject_topic
1009 ON (bre.id = mcde_subject_topic.source
1010 AND mcde_subject_topic.name = 'subject_topic')
1011 LEFT JOIN metabib.compressed_display_entry mcde_creators
1012 ON (bre.id = mcde_creators.source AND mcde_creators.name = 'creators')
1013 LEFT JOIN metabib.compressed_display_entry mcde_isbn
1014 ON (bre.id = mcde_isbn.source AND mcde_isbn.name = 'isbn')
1015 LEFT JOIN metabib.compressed_display_entry mcde_issn
1016 ON (bre.id = mcde_issn.source AND mcde_issn.name = 'issn')
1017 LEFT JOIN metabib.compressed_display_entry mcde_upc
1018 ON (bre.id = mcde_upc.source AND mcde_upc.name = 'upc')
1019 LEFT JOIN metabib.compressed_display_entry mcde_tcn
1020 ON (bre.id = mcde_tcn.source AND mcde_tcn.name = 'tcn')
1021 LEFT JOIN metabib.compressed_display_entry mcde_edition
1022 ON (bre.id = mcde_edition.source AND mcde_edition.name = 'edition')
1023 LEFT JOIN metabib.compressed_display_entry mcde_physical_description
1024 ON (bre.id = mcde_physical_description.source
1025 AND mcde_physical_description.name = 'physical_description')
1026 LEFT JOIN metabib.compressed_display_entry mcde_publisher
1027 ON (bre.id = mcde_publisher.source AND mcde_publisher.name = 'publisher')
1028 LEFT JOIN metabib.compressed_display_entry mcde_series_title
1029 ON (bre.id = mcde_series_title.source AND mcde_series_title.name = 'series_title')
1030 LEFT JOIN metabib.compressed_display_entry mcde_abstract
1031 ON (bre.id = mcde_abstract.source AND mcde_abstract.name = 'abstract')
1032 LEFT JOIN metabib.compressed_display_entry mcde_toc
1033 ON (bre.id = mcde_toc.source AND mcde_toc.name = 'toc')
1034 LEFT JOIN metabib.compressed_display_entry mcde_pubdate
1035 ON (bre.id = mcde_pubdate.source AND mcde_pubdate.name = 'pubdate')
1036 LEFT JOIN metabib.compressed_display_entry mcde_type_of_resource
1037 ON (bre.id = mcde_type_of_resource.source
1038 AND mcde_type_of_resource.name = 'type_of_resource')
1041 CREATE OR REPLACE VIEW reporter.old_super_simple_record AS
1047 evergreen.oils_json_to_text(d.title) AS title,
1048 evergreen.oils_json_to_text(d.author) AS author,
1049 evergreen.oils_json_to_text(d.publisher) AS publisher,
1050 evergreen.oils_json_to_text(d.pubdate) AS pubdate,
1051 CASE WHEN d.isbn = 'null'
1053 ELSE (SELECT ARRAY(SELECT json_array_elements_text(d.isbn::JSON)))
1055 CASE WHEN d.issn = 'null'
1057 ELSE (SELECT ARRAY(SELECT json_array_elements_text(d.issn::JSON)))
1059 FROM biblio.record_entry r
1060 JOIN metabib.wide_display_entry d ON (r.id = d.source);
1064 SELECT evergreen.upgrade_deps_block_check('1101', :eg_version);
1066 ALTER TABLE config.metabib_field ALTER COLUMN xpath DROP NOT NULL;
1068 CREATE TABLE config.metabib_field_virtual_map (
1069 id SERIAL PRIMARY KEY,
1070 real INT NOT NULL REFERENCES config.metabib_field (id),
1071 virtual INT NOT NULL REFERENCES config.metabib_field (id),
1072 weight INT NOT NULL DEFAULT 1
1074 COMMENT ON TABLE config.metabib_field_virtual_map IS $$
1075 Maps between real (physically extracted) index definitions
1076 and virtual (target sync, no required extraction of its own)
1079 The virtual side may not extract any data of its own, but
1080 will collect data from all of the real fields. This reduces
1081 extraction (ingest) overhead by eliminating duplcated extraction,
1082 and allows for searching across novel combinations of fields, such
1083 as names used as either subjects or authors. By preserving this
1084 mapping rather than defining duplicate extractions, information
1085 about the originating, "real" index definitions can be used
1086 in interesting ways, such as highlighting in search results.
1089 CREATE OR REPLACE VIEW metabib.combined_all_field_entry AS
1090 SELECT * FROM metabib.combined_title_field_entry
1092 SELECT * FROM metabib.combined_author_field_entry
1094 SELECT * FROM metabib.combined_subject_field_entry
1096 SELECT * FROM metabib.combined_keyword_field_entry
1098 SELECT * FROM metabib.combined_identifier_field_entry
1100 SELECT * FROM metabib.combined_series_field_entry;
1103 CREATE OR REPLACE FUNCTION biblio.extract_metabib_field_entry (
1105 default_joiner TEXT,
1108 ) RETURNS SETOF metabib.field_entry_template AS $func$
1110 bib biblio.record_entry%ROWTYPE;
1111 idx config.metabib_field%ROWTYPE;
1112 xfrm config.xml_transform%ROWTYPE;
1114 transformed_xml TEXT;
1116 xml_node_list TEXT[];
1123 joiner TEXT := default_joiner; -- XXX will index defs supply a joiner?
1124 authority_text TEXT;
1125 authority_link BIGINT;
1126 output_row metabib.field_entry_template%ROWTYPE;
1130 -- Start out with no field-use bools set
1131 output_row.browse_field = FALSE;
1132 output_row.facet_field = FALSE;
1133 output_row.display_field = FALSE;
1134 output_row.search_field = FALSE;
1137 SELECT INTO bib * FROM biblio.record_entry WHERE id = rid;
1139 -- Loop over the indexing entries
1140 FOR idx IN SELECT * FROM config.metabib_field WHERE id = ANY (only_fields) ORDER BY format LOOP
1141 CONTINUE WHEN idx.xpath IS NULL OR idx.xpath = ''; -- pure virtual field
1143 process_idx := FALSE;
1144 IF idx.display_field AND 'display' = ANY (field_types) THEN process_idx = TRUE; END IF;
1145 IF idx.browse_field AND 'browse' = ANY (field_types) THEN process_idx = TRUE; END IF;
1146 IF idx.search_field AND 'search' = ANY (field_types) THEN process_idx = TRUE; END IF;
1147 IF idx.facet_field AND 'facet' = ANY (field_types) THEN process_idx = TRUE; END IF;
1148 CONTINUE WHEN process_idx = FALSE; -- disabled for all types
1150 joiner := COALESCE(idx.joiner, default_joiner);
1152 SELECT INTO xfrm * from config.xml_transform WHERE name = idx.format;
1154 -- See if we can skip the XSLT ... it's expensive
1155 IF prev_xfrm IS NULL OR prev_xfrm <> xfrm.name THEN
1156 -- Can't skip the transform
1157 IF xfrm.xslt <> '---' THEN
1158 transformed_xml := oils_xslt_process(bib.marc,xfrm.xslt);
1160 transformed_xml := bib.marc;
1163 prev_xfrm := xfrm.name;
1166 xml_node_list := oils_xpath( idx.xpath, transformed_xml, ARRAY[ARRAY[xfrm.prefix, xfrm.namespace_uri]] );
1169 FOR xml_node IN SELECT x FROM unnest(xml_node_list) AS x LOOP
1170 CONTINUE WHEN xml_node !~ E'^\\s*<';
1172 -- XXX much of this should be moved into oils_xpath_string...
1173 curr_text := ARRAY_TO_STRING(evergreen.array_remove_item_by_value(evergreen.array_remove_item_by_value(
1174 oils_xpath( '//text()', -- get the content of all the nodes within the main selected node
1175 REGEXP_REPLACE( xml_node, E'\\s+', ' ', 'g' ) -- Translate adjacent whitespace to a single space
1176 ), ' '), ''), -- throw away morally empty (bankrupt?) strings
1180 CONTINUE WHEN curr_text IS NULL OR curr_text = '';
1182 IF raw_text IS NOT NULL THEN
1183 raw_text := raw_text || joiner;
1186 raw_text := COALESCE(raw_text,'') || curr_text;
1188 -- autosuggest/metabib.browse_entry
1189 IF idx.browse_field THEN
1191 IF idx.browse_xpath IS NOT NULL AND idx.browse_xpath <> '' THEN
1192 browse_text := oils_xpath_string( idx.browse_xpath, xml_node, joiner, ARRAY[ARRAY[xfrm.prefix, xfrm.namespace_uri]] );
1194 browse_text := curr_text;
1197 IF idx.browse_sort_xpath IS NOT NULL AND
1198 idx.browse_sort_xpath <> '' THEN
1200 sort_value := oils_xpath_string(
1201 idx.browse_sort_xpath, xml_node, joiner,
1202 ARRAY[ARRAY[xfrm.prefix, xfrm.namespace_uri]]
1205 sort_value := browse_text;
1208 output_row.field_class = idx.field_class;
1209 output_row.field = idx.id;
1210 output_row.source = rid;
1211 output_row.value = BTRIM(REGEXP_REPLACE(browse_text, E'\\s+', ' ', 'g'));
1212 output_row.sort_value :=
1213 public.naco_normalize(sort_value);
1215 output_row.authority := NULL;
1217 IF idx.authority_xpath IS NOT NULL AND idx.authority_xpath <> '' THEN
1218 authority_text := oils_xpath_string(
1219 idx.authority_xpath, xml_node, joiner,
1221 ARRAY[xfrm.prefix, xfrm.namespace_uri],
1222 ARRAY['xlink','http://www.w3.org/1999/xlink']
1226 IF authority_text ~ '^\d+$' THEN
1227 authority_link := authority_text::BIGINT;
1228 PERFORM * FROM authority.record_entry WHERE id = authority_link;
1230 output_row.authority := authority_link;
1236 output_row.browse_field = TRUE;
1237 -- Returning browse rows with search_field = true for search+browse
1238 -- configs allows us to retain granularity of being able to search
1239 -- browse fields with "starts with" type operators (for example, for
1240 -- titles of songs in music albums)
1241 IF idx.search_field THEN
1242 output_row.search_field = TRUE;
1244 RETURN NEXT output_row;
1245 output_row.browse_field = FALSE;
1246 output_row.search_field = FALSE;
1247 output_row.sort_value := NULL;
1250 -- insert raw node text for faceting
1251 IF idx.facet_field THEN
1253 IF idx.facet_xpath IS NOT NULL AND idx.facet_xpath <> '' THEN
1254 facet_text := oils_xpath_string( idx.facet_xpath, xml_node, joiner, ARRAY[ARRAY[xfrm.prefix, xfrm.namespace_uri]] );
1256 facet_text := curr_text;
1259 output_row.field_class = idx.field_class;
1260 output_row.field = -1 * idx.id;
1261 output_row.source = rid;
1262 output_row.value = BTRIM(REGEXP_REPLACE(facet_text, E'\\s+', ' ', 'g'));
1264 output_row.facet_field = TRUE;
1265 RETURN NEXT output_row;
1266 output_row.facet_field = FALSE;
1269 -- insert raw node text for display
1270 IF idx.display_field THEN
1272 IF idx.display_xpath IS NOT NULL AND idx.display_xpath <> '' THEN
1273 display_text := oils_xpath_string( idx.display_xpath, xml_node, joiner, ARRAY[ARRAY[xfrm.prefix, xfrm.namespace_uri]] );
1275 display_text := curr_text;
1278 output_row.field_class = idx.field_class;
1279 output_row.field = -1 * idx.id;
1280 output_row.source = rid;
1281 output_row.value = BTRIM(REGEXP_REPLACE(display_text, E'\\s+', ' ', 'g'));
1283 output_row.display_field = TRUE;
1284 RETURN NEXT output_row;
1285 output_row.display_field = FALSE;
1290 CONTINUE WHEN raw_text IS NULL OR raw_text = '';
1292 -- insert combined node text for searching
1293 IF idx.search_field THEN
1294 output_row.field_class = idx.field_class;
1295 output_row.field = idx.id;
1296 output_row.source = rid;
1297 output_row.value = BTRIM(REGEXP_REPLACE(raw_text, E'\\s+', ' ', 'g'));
1299 output_row.search_field = TRUE;
1300 RETURN NEXT output_row;
1301 output_row.search_field = FALSE;
1307 $func$ LANGUAGE PLPGSQL;
1309 CREATE OR REPLACE FUNCTION metabib.update_combined_index_vectors(bib_id BIGINT) RETURNS VOID AS $func$
1316 DELETE FROM metabib.combined_keyword_field_entry WHERE record = bib_id;
1317 INSERT INTO metabib.combined_keyword_field_entry(record, metabib_field, index_vector)
1318 SELECT bib_id, field, strip(COALESCE(string_agg(index_vector::TEXT,' '),'')::tsvector)
1319 FROM metabib.keyword_field_entry WHERE source = bib_id GROUP BY field;
1320 INSERT INTO metabib.combined_keyword_field_entry(record, metabib_field, index_vector)
1321 SELECT bib_id, NULL, strip(COALESCE(string_agg(index_vector::TEXT,' '),'')::tsvector)
1322 FROM metabib.keyword_field_entry WHERE source = bib_id;
1324 DELETE FROM metabib.combined_title_field_entry WHERE record = bib_id;
1325 INSERT INTO metabib.combined_title_field_entry(record, metabib_field, index_vector)
1326 SELECT bib_id, field, strip(COALESCE(string_agg(index_vector::TEXT,' '),'')::tsvector)
1327 FROM metabib.title_field_entry WHERE source = bib_id GROUP BY field;
1328 INSERT INTO metabib.combined_title_field_entry(record, metabib_field, index_vector)
1329 SELECT bib_id, NULL, strip(COALESCE(string_agg(index_vector::TEXT,' '),'')::tsvector)
1330 FROM metabib.title_field_entry WHERE source = bib_id;
1332 DELETE FROM metabib.combined_author_field_entry WHERE record = bib_id;
1333 INSERT INTO metabib.combined_author_field_entry(record, metabib_field, index_vector)
1334 SELECT bib_id, field, strip(COALESCE(string_agg(index_vector::TEXT,' '),'')::tsvector)
1335 FROM metabib.author_field_entry WHERE source = bib_id GROUP BY field;
1336 INSERT INTO metabib.combined_author_field_entry(record, metabib_field, index_vector)
1337 SELECT bib_id, NULL, strip(COALESCE(string_agg(index_vector::TEXT,' '),'')::tsvector)
1338 FROM metabib.author_field_entry WHERE source = bib_id;
1340 DELETE FROM metabib.combined_subject_field_entry WHERE record = bib_id;
1341 INSERT INTO metabib.combined_subject_field_entry(record, metabib_field, index_vector)
1342 SELECT bib_id, field, strip(COALESCE(string_agg(index_vector::TEXT,' '),'')::tsvector)
1343 FROM metabib.subject_field_entry WHERE source = bib_id GROUP BY field;
1344 INSERT INTO metabib.combined_subject_field_entry(record, metabib_field, index_vector)
1345 SELECT bib_id, NULL, strip(COALESCE(string_agg(index_vector::TEXT,' '),'')::tsvector)
1346 FROM metabib.subject_field_entry WHERE source = bib_id;
1348 DELETE FROM metabib.combined_series_field_entry WHERE record = bib_id;
1349 INSERT INTO metabib.combined_series_field_entry(record, metabib_field, index_vector)
1350 SELECT bib_id, field, strip(COALESCE(string_agg(index_vector::TEXT,' '),'')::tsvector)
1351 FROM metabib.series_field_entry WHERE source = bib_id GROUP BY field;
1352 INSERT INTO metabib.combined_series_field_entry(record, metabib_field, index_vector)
1353 SELECT bib_id, NULL, strip(COALESCE(string_agg(index_vector::TEXT,' '),'')::tsvector)
1354 FROM metabib.series_field_entry WHERE source = bib_id;
1356 DELETE FROM metabib.combined_identifier_field_entry WHERE record = bib_id;
1357 INSERT INTO metabib.combined_identifier_field_entry(record, metabib_field, index_vector)
1358 SELECT bib_id, field, strip(COALESCE(string_agg(index_vector::TEXT,' '),'')::tsvector)
1359 FROM metabib.identifier_field_entry WHERE source = bib_id GROUP BY field;
1360 INSERT INTO metabib.combined_identifier_field_entry(record, metabib_field, index_vector)
1361 SELECT bib_id, NULL, strip(COALESCE(string_agg(index_vector::TEXT,' '),'')::tsvector)
1362 FROM metabib.identifier_field_entry WHERE source = bib_id;
1364 -- For each virtual def, gather the data from the combined real field
1365 -- entries and append it to the virtual combined entry.
1366 FOR vfield, rfields IN SELECT virtual, ARRAY_AGG(real) FROM config.metabib_field_virtual_map GROUP BY virtual LOOP
1367 SELECT field_class INTO vclass
1368 FROM config.metabib_field
1371 SELECT string_agg(index_vector::TEXT,' ')::tsvector INTO rdata
1372 FROM metabib.combined_all_field_entry
1373 WHERE record = bib_id
1374 AND metabib_field = ANY (rfields);
1376 BEGIN -- I cannot wait for INSERT ON CONFLICT ... 9.5, though
1378 INSERT INTO metabib.combined_$$ || vclass || $$_field_entry
1379 (record, metabib_field, index_vector) VALUES ($1, $2, $3)
1380 $$ USING bib_id, vfield, rdata;
1381 EXCEPTION WHEN unique_violation THEN
1383 UPDATE metabib.combined_$$ || vclass || $$_field_entry
1384 SET index_vector = index_vector || $3
1386 AND metabib_field = $2
1387 $$ USING bib_id, vfield, rdata;
1389 -- ignore and move on
1393 $func$ LANGUAGE PLPGSQL;
1395 CREATE OR REPLACE VIEW search.best_tsconfig AS
1397 COALESCE(f.ts_config, c.ts_config, 'simple') AS ts_config
1398 FROM config.metabib_field m
1399 LEFT JOIN config.metabib_class_ts_map c ON (c.field_class = m.field_class AND c.index_weight = 'C')
1400 LEFT JOIN config.metabib_field_ts_map f ON (f.metabib_field = m.id AND f.index_weight = 'C');
1402 CREATE TYPE search.highlight_result AS ( id BIGINT, source BIGINT, field INT, value TEXT, highlight TEXT );
1404 CREATE OR REPLACE FUNCTION search.highlight_display_fields_impl(
1407 field_list INT[] DEFAULT '{}'::INT[],
1408 css_class TEXT DEFAULT 'oils_SH',
1409 hl_all BOOL DEFAULT TRUE,
1410 minwords INT DEFAULT 5,
1411 maxwords INT DEFAULT 25,
1412 shortwords INT DEFAULT 0,
1413 maxfrags INT DEFAULT 0,
1414 delimiter TEXT DEFAULT ' ... '
1415 ) RETURNS SETOF search.highlight_result AS $f$
1418 v_css_class TEXT := css_class;
1419 v_delimiter TEXT := delimiter;
1420 v_field_list INT[] := field_list;
1423 IF v_delimiter LIKE $$%'%$$ OR v_delimiter LIKE '%"%' THEN --"
1424 v_delimiter := ' ... ';
1428 opts := opts || 'MinWords=' || minwords;
1429 opts := opts || ', MaxWords=' || maxwords;
1430 opts := opts || ', ShortWords=' || shortwords;
1431 opts := opts || ', MaxFragments=' || maxfrags;
1432 opts := opts || ', FragmentDelimiter="' || delimiter || '"';
1434 opts := opts || 'HighlightAll=TRUE';
1437 IF v_css_class LIKE $$%'%$$ OR v_css_class LIKE '%"%' THEN -- "
1438 v_css_class := 'oils_SH';
1441 opts := opts || $$, StopSel=</b>, StartSel="<b class='$$ || v_css_class; -- "
1443 IF v_field_list = '{}'::INT[] THEN
1444 SELECT ARRAY_AGG(id) INTO v_field_list FROM config.metabib_field WHERE display_field;
1453 ts_config::REGCONFIG,
1454 evergreen.escape_for_html(de.value),
1455 $$ || quote_literal(tsq) || $$,
1456 $1 || ' ' || mf.field_class || ' ' || mf.name || $xx$'>"$xx$ -- "'
1458 FROM metabib.display_entry de
1459 JOIN config.metabib_field mf ON (mf.id = de.field)
1460 JOIN search.best_tsconfig t ON (t.id = de.field)
1461 WHERE de.source = $2
1462 AND field = ANY ($3)
1465 RETURN QUERY EXECUTE hl_query USING opts, rid, v_field_list;
1467 $f$ LANGUAGE PLPGSQL;
1469 CREATE OR REPLACE FUNCTION evergreen.escape_for_html (TEXT) RETURNS TEXT AS $$
1470 SELECT regexp_replace(
1486 $$ LANGUAGE SQL IMMUTABLE LEAKPROOF STRICT COST 10;
1488 CREATE OR REPLACE FUNCTION search.highlight_display_fields(
1490 tsq_map TEXT, -- { '(a | b) & c' => '1,2,3,4', ...}
1491 css_class TEXT DEFAULT 'oils_SH',
1492 hl_all BOOL DEFAULT TRUE,
1493 minwords INT DEFAULT 5,
1494 maxwords INT DEFAULT 25,
1495 shortwords INT DEFAULT 0,
1496 maxfrags INT DEFAULT 0,
1497 delimiter TEXT DEFAULT ' ... '
1498 ) RETURNS SETOF search.highlight_result AS $f$
1507 IF (tsq_map ILIKE 'hstore%') THEN
1508 EXECUTE 'SELECT ' || tsq_map INTO tsq_hstore;
1510 tsq_hstore := tsq_map::HSTORE;
1513 FOR tsq, fields IN SELECT key, value FROM each(tsq_hstore::HSTORE) LOOP
1514 SELECT ARRAY_AGG(unnest::INT) INTO afields
1515 FROM unnest(regexp_split_to_array(fields,','));
1516 seen := seen || afields;
1519 SELECT * FROM search.highlight_display_fields_impl(
1520 rid, tsq, afields, css_class, hl_all,minwords,
1521 maxwords, shortwords, maxfrags, delimiter
1531 FROM metabib.display_entry
1533 AND NOT (field = ANY (seen));
1535 $f$ LANGUAGE PLPGSQL ROWS 10;
1537 CREATE OR REPLACE FUNCTION metabib.remap_metarecord_for_bib(
1540 bib_is_deleted boolean DEFAULT false,
1541 retain_deleted boolean DEFAULT false
1542 ) RETURNS bigint AS $function$
1544 new_mapping BOOL := TRUE;
1547 tmp_mr metabib.metarecord%ROWTYPE;
1548 deleted_mrs BIGINT[];
1551 -- We need to make sure we're not a deleted master record of an MR
1552 IF bib_is_deleted THEN
1553 IF NOT retain_deleted THEN -- Go away for any MR that we're master of, unless retained
1554 DELETE FROM metabib.metarecord_source_map WHERE source = bib_id;
1557 FOR old_mr IN SELECT id FROM metabib.metarecord WHERE master_record = bib_id LOOP
1559 -- Now, are there any more sources on this MR?
1560 SELECT COUNT(*) INTO source_count FROM metabib.metarecord_source_map WHERE metarecord = old_mr;
1562 IF source_count = 0 AND NOT retain_deleted THEN -- No other records
1563 deleted_mrs := ARRAY_APPEND(deleted_mrs, old_mr); -- Just in case...
1564 DELETE FROM metabib.metarecord WHERE id = old_mr;
1566 ELSE -- indeed there are. Update it with a null cache and recalcualated master record
1567 UPDATE metabib.metarecord
1569 master_record = ( SELECT id FROM biblio.record_entry WHERE fingerprint = fp AND NOT deleted ORDER BY quality DESC LIMIT 1)
1574 ELSE -- insert or update
1576 FOR tmp_mr IN SELECT m.* FROM metabib.metarecord m JOIN metabib.metarecord_source_map s ON (s.metarecord = m.id) WHERE s.source = bib_id LOOP
1578 -- Find the first fingerprint-matching
1579 IF old_mr IS NULL AND fp = tmp_mr.fingerprint THEN
1580 old_mr := tmp_mr.id;
1581 new_mapping := FALSE;
1583 ELSE -- Our fingerprint changed ... maybe remove the old MR
1584 DELETE FROM metabib.metarecord_source_map WHERE metarecord = tmp_mr.id AND source = bib_id; -- remove the old source mapping
1585 SELECT COUNT(*) INTO source_count FROM metabib.metarecord_source_map WHERE metarecord = tmp_mr.id;
1586 IF source_count = 0 THEN -- No other records
1587 deleted_mrs := ARRAY_APPEND(deleted_mrs, tmp_mr.id);
1588 DELETE FROM metabib.metarecord WHERE id = tmp_mr.id;
1594 -- we found no suitable, preexisting MR based on old source maps
1595 IF old_mr IS NULL THEN
1596 SELECT id INTO old_mr FROM metabib.metarecord WHERE fingerprint = fp; -- is there one for our current fingerprint?
1598 IF old_mr IS NULL THEN -- nope, create one and grab its id
1599 INSERT INTO metabib.metarecord ( fingerprint, master_record ) VALUES ( fp, bib_id );
1600 SELECT id INTO old_mr FROM metabib.metarecord WHERE fingerprint = fp;
1602 ELSE -- indeed there is. update it with a null cache and recalcualated master record
1603 UPDATE metabib.metarecord
1605 master_record = ( SELECT id FROM biblio.record_entry WHERE fingerprint = fp AND NOT deleted ORDER BY quality DESC LIMIT 1)
1609 ELSE -- there was one we already attached to, update its mods cache and master_record
1610 UPDATE metabib.metarecord
1612 master_record = ( SELECT id FROM biblio.record_entry WHERE fingerprint = fp AND NOT deleted ORDER BY quality DESC LIMIT 1)
1617 INSERT INTO metabib.metarecord_source_map (metarecord, source) VALUES (old_mr, bib_id); -- new source mapping
1622 IF ARRAY_UPPER(deleted_mrs,1) > 0 THEN
1623 UPDATE action.hold_request SET target = old_mr WHERE target IN ( SELECT unnest(deleted_mrs) ) AND hold_type = 'M'; -- if we had to delete any MRs above, make sure their holds are moved
1629 $function$ LANGUAGE plpgsql;
1631 CREATE OR REPLACE FUNCTION evergreen.marc_to (marc text, xfrm text) RETURNS TEXT AS $$
1632 SELECT evergreen.xml_pretty_print(xslt_process($1,xslt)::XML)::TEXT FROM config.xml_transform WHERE name = $2;
1637 SELECT evergreen.upgrade_deps_block_check('1102', :eg_version);
1639 update config.xml_transform set xslt = $XXXX$<?xml version="1.0" encoding="UTF-8"?>
1640 <xsl:stylesheet xmlns="http://www.loc.gov/mods/v3" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xlink marc" version="1.0">
1641 <xsl:output encoding="UTF-8" indent="yes" method="xml"/>
1643 Revision 1.14 - Fixed template isValid and fields 010, 020, 022, 024, 028, and 037 to output additional identifier elements
1644 with corresponding @type and @invalid eq 'yes' when subfields z or y (in the case of 022) exist in the MARCXML ::: 2007/01/04 17:35:20 cred
1646 Revision 1.13 - Changed order of output under cartographics to reflect schema 2006/11/28 tmee
1648 Revision 1.12 - Updated to reflect MODS 3.2 Mapping 2006/10/11 tmee
1650 Revision 1.11 - The attribute objectPart moved from <languageTerm> to <language>
1653 Revision 1.10 MODS 3.1 revisions to language and classification elements
1654 (plus ability to find marc:collection embedded in wrapper elements such as SRU zs: wrappers)
1657 Revision 1.9 subfield $y was added to field 242 2004/09/02 10:57 jrad
1659 Revision 1.8 Subject chopPunctuation expanded and attribute fixes 2004/08/12 jrad
1661 Revision 1.7 2004/03/25 08:29 jrad
1663 Revision 1.6 various validation fixes 2004/02/20 ntra
1665 Revision 1.5 2003/10/02 16:18:58 ntra
1666 MODS2 to MODS3 updates, language unstacking and
1667 de-duping, chopPunctuation expanded
1669 Revision 1.3 2003/04/03 00:07:19 ntra
1670 Revision 1.3 Additional Changes not related to MODS Version 2.0 by ntra
1672 Revision 1.2 2003/03/24 19:37:42 ckeith
1676 <xsl:template match="/">
1678 <xsl:when test="//marc:collection">
1679 <modsCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-2.xsd">
1680 <xsl:for-each select="//marc:collection/marc:record">
1681 <mods version="3.2">
1682 <xsl:call-template name="marcRecord"/>
1688 <mods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.2" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-2.xsd">
1689 <xsl:for-each select="//marc:record">
1690 <xsl:call-template name="marcRecord"/>
1696 <xsl:template name="marcRecord">
1697 <xsl:variable name="leader" select="marc:leader"/>
1698 <xsl:variable name="leader6" select="substring($leader,7,1)"/>
1699 <xsl:variable name="leader7" select="substring($leader,8,1)"/>
1700 <xsl:variable name="controlField008" select="marc:controlfield[@tag='008']"/>
1701 <xsl:variable name="typeOf008">
1703 <xsl:when test="$leader6='a'">
1705 <xsl:when test="$leader7='a' or $leader7='c' or $leader7='d' or $leader7='m'">BK</xsl:when>
1706 <xsl:when test="$leader7='b' or $leader7='i' or $leader7='s'">SE</xsl:when>
1709 <xsl:when test="$leader6='t'">BK</xsl:when>
1710 <xsl:when test="$leader6='p'">MM</xsl:when>
1711 <xsl:when test="$leader6='m'">CF</xsl:when>
1712 <xsl:when test="$leader6='e' or $leader6='f'">MP</xsl:when>
1713 <xsl:when test="$leader6='g' or $leader6='k' or $leader6='o' or $leader6='r'">VM</xsl:when>
1714 <xsl:when test="$leader6='c' or $leader6='d' or $leader6='i' or $leader6='j'">MU</xsl:when>
1717 <xsl:for-each select="marc:datafield[@tag='245']">
1719 <xsl:variable name="title">
1721 <xsl:when test="marc:subfield[@code='b']">
1722 <xsl:call-template name="specialSubfieldSelect">
1723 <xsl:with-param name="axis">b</xsl:with-param>
1724 <xsl:with-param name="beforeCodes">afgk</xsl:with-param>
1725 </xsl:call-template>
1728 <xsl:call-template name="subfieldSelect">
1729 <xsl:with-param name="codes">abfgk</xsl:with-param>
1730 </xsl:call-template>
1734 <xsl:variable name="titleChop">
1735 <xsl:call-template name="chopPunctuation">
1736 <xsl:with-param name="chopString">
1737 <xsl:value-of select="$title"/>
1739 <xsl:with-param name="punctuation">
1740 <xsl:text>,;/ </xsl:text>
1742 </xsl:call-template>
1745 <xsl:when test="@ind2>0">
1747 <xsl:value-of select="substring($titleChop,1,@ind2)"/>
1750 <xsl:value-of select="substring($titleChop,@ind2+1)"/>
1755 <xsl:value-of select="$titleChop"/>
1759 <xsl:if test="marc:subfield[@code='b']">
1761 <xsl:call-template name="chopPunctuation">
1762 <xsl:with-param name="chopString">
1763 <xsl:call-template name="specialSubfieldSelect">
1764 <xsl:with-param name="axis">b</xsl:with-param>
1765 <xsl:with-param name="anyCodes">b</xsl:with-param>
1766 <xsl:with-param name="afterCodes">afgk</xsl:with-param>
1767 </xsl:call-template>
1769 </xsl:call-template>
1772 <xsl:call-template name="part"></xsl:call-template>
1774 <!-- A form of title that ignores non-filing characters; useful
1775 for not converting "L'Oreal" into "L' Oreal" at index time -->
1778 <xsl:call-template name="chopPunctuation">
1779 <xsl:with-param name="chopString">
1780 <xsl:call-template name="subfieldSelect">
1781 <xsl:with-param name="codes">abfgk</xsl:with-param>
1782 </xsl:call-template>
1784 </xsl:call-template>
1786 <xsl:call-template name="part"></xsl:call-template>
1788 <!-- hybrid of titleInfo and titleNonfiling which will give us a preformatted string (for punctuation)
1789 but also keep the nonSort stuff in a separate field (for sorting) -->
1791 <xsl:variable name="titleBrowseChop">
1792 <xsl:call-template name="chopPunctuation">
1793 <xsl:with-param name="chopString">
1794 <xsl:call-template name="subfieldSelect">
1795 <xsl:with-param name="codes">abfgk</xsl:with-param>
1796 </xsl:call-template>
1798 </xsl:call-template>
1801 <xsl:when test="@ind2>0">
1803 <xsl:value-of select="substring($titleBrowseChop,1,@ind2)"/>
1806 <xsl:value-of select="substring($titleBrowseChop,@ind2+1)"/>
1811 <xsl:value-of select="$titleBrowseChop"/>
1815 <xsl:call-template name="part"></xsl:call-template>
1818 <xsl:for-each select="marc:datafield[@tag='210']">
1819 <titleInfo type="abbreviated">
1821 <xsl:call-template name="chopPunctuation">
1822 <xsl:with-param name="chopString">
1823 <xsl:call-template name="subfieldSelect">
1824 <xsl:with-param name="codes">a</xsl:with-param>
1825 </xsl:call-template>
1827 </xsl:call-template>
1829 <xsl:call-template name="subtitle"/>
1832 <xsl:for-each select="marc:datafield[@tag='242']">
1833 <xsl:variable name="titleChop">
1834 <xsl:call-template name="chopPunctuation">
1835 <xsl:with-param name="chopString">
1836 <xsl:call-template name="subfieldSelect">
1837 <!-- 1/04 removed $h, b -->
1838 <xsl:with-param name="codes">a</xsl:with-param>
1839 </xsl:call-template>
1841 </xsl:call-template>
1843 <titleInfo type="translated">
1844 <!--09/01/04 Added subfield $y-->
1845 <xsl:for-each select="marc:subfield[@code='y']">
1846 <xsl:attribute name="lang">
1847 <xsl:value-of select="text()"/>
1851 <xsl:value-of select="$titleChop" />
1854 <xsl:call-template name="subtitle"/>
1855 <xsl:call-template name="part"/>
1857 <titleInfo type="translated-nfi">
1858 <xsl:for-each select="marc:subfield[@code='y']">
1859 <xsl:attribute name="lang">
1860 <xsl:value-of select="text()"/>
1864 <xsl:when test="@ind2>0">
1866 <xsl:value-of select="substring($titleChop,1,@ind2)"/>
1869 <xsl:value-of select="substring($titleChop,@ind2+1)"/>
1874 <xsl:value-of select="$titleChop" />
1878 <xsl:call-template name="subtitle"/>
1879 <xsl:call-template name="part"/>
1882 <xsl:for-each select="marc:datafield[@tag='246']">
1883 <titleInfo type="alternative">
1884 <xsl:for-each select="marc:subfield[@code='i']">
1885 <xsl:attribute name="displayLabel">
1886 <xsl:value-of select="text()"/>
1890 <xsl:call-template name="chopPunctuation">
1891 <xsl:with-param name="chopString">
1892 <xsl:call-template name="subfieldSelect">
1893 <!-- 1/04 removed $h, $b -->
1894 <xsl:with-param name="codes">af</xsl:with-param>
1895 </xsl:call-template>
1897 </xsl:call-template>
1899 <xsl:call-template name="subtitle"/>
1900 <xsl:call-template name="part"/>
1903 <xsl:for-each select="marc:datafield[@tag='130']|marc:datafield[@tag='240']|marc:datafield[@tag='730'][@ind2!='2']">
1904 <xsl:variable name="nfi">
1906 <xsl:when test="@tag='240'">
1907 <xsl:value-of select="@ind2"/>
1910 <xsl:value-of select="@ind1"/>
1914 <xsl:variable name="titleChop">
1915 <xsl:call-template name="uri" />
1916 <xsl:variable name="str">
1917 <xsl:for-each select="marc:subfield">
1918 <xsl:if test="(contains('adfklmor',@code) and (not(../marc:subfield[@code='n' or @code='p']) or (following-sibling::marc:subfield[@code='n' or @code='p'])))">
1919 <xsl:value-of select="text()"/>
1920 <xsl:text> </xsl:text>
1924 <xsl:call-template name="chopPunctuation">
1925 <xsl:with-param name="chopString">
1926 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
1928 </xsl:call-template>
1930 <titleInfo type="uniform">
1932 <xsl:value-of select="$titleChop"/>
1934 <xsl:call-template name="part"/>
1936 <titleInfo type="uniform-nfi">
1938 <xsl:when test="$nfi>0">
1940 <xsl:value-of select="substring($titleChop,1,$nfi)"/>
1943 <xsl:value-of select="substring($titleChop,$nfi+1)"/>
1948 <xsl:value-of select="$titleChop"/>
1952 <xsl:call-template name="part"/>
1955 <xsl:for-each select="marc:datafield[@tag='740'][@ind2!='2']">
1956 <xsl:variable name="titleChop">
1957 <xsl:call-template name="chopPunctuation">
1958 <xsl:with-param name="chopString">
1959 <xsl:call-template name="subfieldSelect">
1960 <xsl:with-param name="codes">ah</xsl:with-param>
1961 </xsl:call-template>
1963 </xsl:call-template>
1965 <titleInfo type="alternative">
1967 <xsl:value-of select="$titleChop" />
1969 <xsl:call-template name="part"/>
1971 <titleInfo type="alternative-nfi">
1973 <xsl:when test="@ind1>0">
1975 <xsl:value-of select="substring($titleChop,1,@ind1)"/>
1978 <xsl:value-of select="substring($titleChop,@ind1+1)"/>
1983 <xsl:value-of select="$titleChop" />
1987 <xsl:call-template name="part"/>
1990 <xsl:for-each select="marc:datafield[@tag='100']">
1991 <name type="personal">
1992 <xsl:call-template name="uri" />
1993 <xsl:call-template name="nameABCDQ"/>
1994 <xsl:call-template name="affiliation"/>
1996 <roleTerm authority="marcrelator" type="text">creator</roleTerm>
1998 <xsl:call-template name="role"/>
2001 <xsl:for-each select="marc:datafield[@tag='110']">
2002 <name type="corporate">
2003 <xsl:call-template name="uri" />
2004 <xsl:call-template name="nameABCDN"/>
2006 <roleTerm authority="marcrelator" type="text">creator</roleTerm>
2008 <xsl:call-template name="role"/>
2011 <xsl:for-each select="marc:datafield[@tag='111']">
2012 <name type="conference">
2013 <xsl:call-template name="uri" />
2014 <xsl:call-template name="nameACDEQ"/>
2016 <roleTerm authority="marcrelator" type="text">creator</roleTerm>
2018 <xsl:call-template name="role"/>
2021 <xsl:for-each select="marc:datafield[@tag='700'][not(marc:subfield[@code='t'])]">
2022 <name type="personal">
2023 <xsl:call-template name="uri" />
2024 <xsl:call-template name="nameABCDQ"/>
2025 <xsl:call-template name="affiliation"/>
2026 <xsl:call-template name="role"/>
2029 <xsl:for-each select="marc:datafield[@tag='710'][not(marc:subfield[@code='t'])]">
2030 <name type="corporate">
2031 <xsl:call-template name="uri" />
2032 <xsl:call-template name="nameABCDN"/>
2033 <xsl:call-template name="role"/>
2036 <xsl:for-each select="marc:datafield[@tag='711'][not(marc:subfield[@code='t'])]">
2037 <name type="conference">
2038 <xsl:call-template name="uri" />
2039 <xsl:call-template name="nameACDEQ"/>
2040 <xsl:call-template name="role"/>
2043 <xsl:for-each select="marc:datafield[@tag='720'][not(marc:subfield[@code='t'])]">
2045 <xsl:if test="@ind1=1">
2046 <xsl:attribute name="type">
2047 <xsl:text>personal</xsl:text>
2051 <xsl:value-of select="marc:subfield[@code='a']"/>
2053 <xsl:call-template name="role"/>
2057 <xsl:if test="$leader7='c'">
2058 <xsl:attribute name="collection">yes</xsl:attribute>
2060 <xsl:if test="$leader6='d' or $leader6='f' or $leader6='p' or $leader6='t'">
2061 <xsl:attribute name="manuscript">yes</xsl:attribute>
2064 <xsl:when test="$leader6='a' or $leader6='t'">text</xsl:when>
2065 <xsl:when test="$leader6='e' or $leader6='f'">cartographic</xsl:when>
2066 <xsl:when test="$leader6='c' or $leader6='d'">notated music</xsl:when>
2067 <xsl:when test="$leader6='i'">sound recording-nonmusical</xsl:when>
2068 <xsl:when test="$leader6='j'">sound recording-musical</xsl:when>
2069 <xsl:when test="$leader6='k'">still image</xsl:when>
2070 <xsl:when test="$leader6='g'">moving image</xsl:when>
2071 <xsl:when test="$leader6='r'">three dimensional object</xsl:when>
2072 <xsl:when test="$leader6='m'">software, multimedia</xsl:when>
2073 <xsl:when test="$leader6='p'">mixed material</xsl:when>
2076 <xsl:if test="substring($controlField008,26,1)='d'">
2077 <genre authority="marc">globe</genre>
2079 <xsl:if test="marc:controlfield[@tag='007'][substring(text(),1,1)='a'][substring(text(),2,1)='r']">
2080 <genre authority="marc">remote sensing image</genre>
2082 <xsl:if test="$typeOf008='MP'">
2083 <xsl:variable name="controlField008-25" select="substring($controlField008,26,1)"></xsl:variable>
2085 <xsl:when test="$controlField008-25='a' or $controlField008-25='b' or $controlField008-25='c' or marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='j']">
2086 <genre authority="marc">map</genre>
2088 <xsl:when test="$controlField008-25='e' or marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='d']">
2089 <genre authority="marc">atlas</genre>
2093 <xsl:if test="$typeOf008='SE'">
2094 <xsl:variable name="controlField008-21" select="substring($controlField008,22,1)"></xsl:variable>
2096 <xsl:when test="$controlField008-21='d'">
2097 <genre authority="marc">database</genre>
2099 <xsl:when test="$controlField008-21='l'">
2100 <genre authority="marc">loose-leaf</genre>
2102 <xsl:when test="$controlField008-21='m'">
2103 <genre authority="marc">series</genre>
2105 <xsl:when test="$controlField008-21='n'">
2106 <genre authority="marc">newspaper</genre>
2108 <xsl:when test="$controlField008-21='p'">
2109 <genre authority="marc">periodical</genre>
2111 <xsl:when test="$controlField008-21='w'">
2112 <genre authority="marc">web site</genre>
2116 <xsl:if test="$typeOf008='BK' or $typeOf008='SE'">
2117 <xsl:variable name="controlField008-24" select="substring($controlField008,25,4)"></xsl:variable>
2119 <xsl:when test="contains($controlField008-24,'a')">
2120 <genre authority="marc">abstract or summary</genre>
2122 <xsl:when test="contains($controlField008-24,'b')">
2123 <genre authority="marc">bibliography</genre>
2125 <xsl:when test="contains($controlField008-24,'c')">
2126 <genre authority="marc">catalog</genre>
2128 <xsl:when test="contains($controlField008-24,'d')">
2129 <genre authority="marc">dictionary</genre>
2131 <xsl:when test="contains($controlField008-24,'e')">
2132 <genre authority="marc">encyclopedia</genre>
2134 <xsl:when test="contains($controlField008-24,'f')">
2135 <genre authority="marc">handbook</genre>
2137 <xsl:when test="contains($controlField008-24,'g')">
2138 <genre authority="marc">legal article</genre>
2140 <xsl:when test="contains($controlField008-24,'i')">
2141 <genre authority="marc">index</genre>
2143 <xsl:when test="contains($controlField008-24,'k')">
2144 <genre authority="marc">discography</genre>
2146 <xsl:when test="contains($controlField008-24,'l')">
2147 <genre authority="marc">legislation</genre>
2149 <xsl:when test="contains($controlField008-24,'m')">
2150 <genre authority="marc">theses</genre>
2152 <xsl:when test="contains($controlField008-24,'n')">
2153 <genre authority="marc">survey of literature</genre>
2155 <xsl:when test="contains($controlField008-24,'o')">
2156 <genre authority="marc">review</genre>
2158 <xsl:when test="contains($controlField008-24,'p')">
2159 <genre authority="marc">programmed text</genre>
2161 <xsl:when test="contains($controlField008-24,'q')">
2162 <genre authority="marc">filmography</genre>
2164 <xsl:when test="contains($controlField008-24,'r')">
2165 <genre authority="marc">directory</genre>
2167 <xsl:when test="contains($controlField008-24,'s')">
2168 <genre authority="marc">statistics</genre>
2170 <xsl:when test="contains($controlField008-24,'t')">
2171 <genre authority="marc">technical report</genre>
2173 <xsl:when test="contains($controlField008-24,'v')">
2174 <genre authority="marc">legal case and case notes</genre>
2176 <xsl:when test="contains($controlField008-24,'w')">
2177 <genre authority="marc">law report or digest</genre>
2179 <xsl:when test="contains($controlField008-24,'z')">
2180 <genre authority="marc">treaty</genre>
2183 <xsl:variable name="controlField008-29" select="substring($controlField008,30,1)"></xsl:variable>
2185 <xsl:when test="$controlField008-29='1'">
2186 <genre authority="marc">conference publication</genre>
2190 <xsl:if test="$typeOf008='CF'">
2191 <xsl:variable name="controlField008-26" select="substring($controlField008,27,1)"></xsl:variable>
2193 <xsl:when test="$controlField008-26='a'">
2194 <genre authority="marc">numeric data</genre>
2196 <xsl:when test="$controlField008-26='e'">
2197 <genre authority="marc">database</genre>
2199 <xsl:when test="$controlField008-26='f'">
2200 <genre authority="marc">font</genre>
2202 <xsl:when test="$controlField008-26='g'">
2203 <genre authority="marc">game</genre>
2207 <xsl:if test="$typeOf008='BK'">
2208 <xsl:if test="substring($controlField008,25,1)='j'">
2209 <genre authority="marc">patent</genre>
2211 <xsl:if test="substring($controlField008,31,1)='1'">
2212 <genre authority="marc">festschrift</genre>
2214 <xsl:variable name="controlField008-34" select="substring($controlField008,35,1)"></xsl:variable>
2215 <xsl:if test="$controlField008-34='a' or $controlField008-34='b' or $controlField008-34='c' or $controlField008-34='d'">
2216 <genre authority="marc">biography</genre>
2218 <xsl:variable name="controlField008-33" select="substring($controlField008,34,1)"></xsl:variable>
2220 <xsl:when test="$controlField008-33='e'">
2221 <genre authority="marc">essay</genre>
2223 <xsl:when test="$controlField008-33='d'">
2224 <genre authority="marc">drama</genre>
2226 <xsl:when test="$controlField008-33='c'">
2227 <genre authority="marc">comic strip</genre>
2229 <xsl:when test="$controlField008-33='l'">
2230 <genre authority="marc">fiction</genre>
2232 <xsl:when test="$controlField008-33='h'">
2233 <genre authority="marc">humor, satire</genre>
2235 <xsl:when test="$controlField008-33='i'">
2236 <genre authority="marc">letter</genre>
2238 <xsl:when test="$controlField008-33='f'">
2239 <genre authority="marc">novel</genre>
2241 <xsl:when test="$controlField008-33='j'">
2242 <genre authority="marc">short story</genre>
2244 <xsl:when test="$controlField008-33='s'">
2245 <genre authority="marc">speech</genre>
2249 <xsl:if test="$typeOf008='MU'">
2250 <xsl:variable name="controlField008-30-31" select="substring($controlField008,31,2)"></xsl:variable>
2251 <xsl:if test="contains($controlField008-30-31,'b')">
2252 <genre authority="marc">biography</genre>
2254 <xsl:if test="contains($controlField008-30-31,'c')">
2255 <genre authority="marc">conference publication</genre>
2257 <xsl:if test="contains($controlField008-30-31,'d')">
2258 <genre authority="marc">drama</genre>
2260 <xsl:if test="contains($controlField008-30-31,'e')">
2261 <genre authority="marc">essay</genre>
2263 <xsl:if test="contains($controlField008-30-31,'f')">
2264 <genre authority="marc">fiction</genre>
2266 <xsl:if test="contains($controlField008-30-31,'o')">
2267 <genre authority="marc">folktale</genre>
2269 <xsl:if test="contains($controlField008-30-31,'h')">
2270 <genre authority="marc">history</genre>
2272 <xsl:if test="contains($controlField008-30-31,'k')">
2273 <genre authority="marc">humor, satire</genre>
2275 <xsl:if test="contains($controlField008-30-31,'m')">
2276 <genre authority="marc">memoir</genre>
2278 <xsl:if test="contains($controlField008-30-31,'p')">
2279 <genre authority="marc">poetry</genre>
2281 <xsl:if test="contains($controlField008-30-31,'r')">
2282 <genre authority="marc">rehearsal</genre>
2284 <xsl:if test="contains($controlField008-30-31,'g')">
2285 <genre authority="marc">reporting</genre>
2287 <xsl:if test="contains($controlField008-30-31,'s')">
2288 <genre authority="marc">sound</genre>
2290 <xsl:if test="contains($controlField008-30-31,'l')">
2291 <genre authority="marc">speech</genre>
2294 <xsl:if test="$typeOf008='VM'">
2295 <xsl:variable name="controlField008-33" select="substring($controlField008,34,1)"></xsl:variable>
2297 <xsl:when test="$controlField008-33='a'">
2298 <genre authority="marc">art original</genre>
2300 <xsl:when test="$controlField008-33='b'">
2301 <genre authority="marc">kit</genre>
2303 <xsl:when test="$controlField008-33='c'">
2304 <genre authority="marc">art reproduction</genre>
2306 <xsl:when test="$controlField008-33='d'">
2307 <genre authority="marc">diorama</genre>
2309 <xsl:when test="$controlField008-33='f'">
2310 <genre authority="marc">filmstrip</genre>
2312 <xsl:when test="$controlField008-33='g'">
2313 <genre authority="marc">legal article</genre>
2315 <xsl:when test="$controlField008-33='i'">
2316 <genre authority="marc">picture</genre>
2318 <xsl:when test="$controlField008-33='k'">
2319 <genre authority="marc">graphic</genre>
2321 <xsl:when test="$controlField008-33='l'">
2322 <genre authority="marc">technical drawing</genre>
2324 <xsl:when test="$controlField008-33='m'">
2325 <genre authority="marc">motion picture</genre>
2327 <xsl:when test="$controlField008-33='n'">
2328 <genre authority="marc">chart</genre>
2330 <xsl:when test="$controlField008-33='o'">
2331 <genre authority="marc">flash card</genre>
2333 <xsl:when test="$controlField008-33='p'">
2334 <genre authority="marc">microscope slide</genre>
2336 <xsl:when test="$controlField008-33='q' or marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='q']">
2337 <genre authority="marc">model</genre>
2339 <xsl:when test="$controlField008-33='r'">
2340 <genre authority="marc">realia</genre>
2342 <xsl:when test="$controlField008-33='s'">
2343 <genre authority="marc">slide</genre>
2345 <xsl:when test="$controlField008-33='t'">
2346 <genre authority="marc">transparency</genre>
2348 <xsl:when test="$controlField008-33='v'">
2349 <genre authority="marc">videorecording</genre>
2351 <xsl:when test="$controlField008-33='w'">
2352 <genre authority="marc">toy</genre>
2356 <xsl:for-each select="marc:datafield[@tag=655]">
2357 <genre authority="marc">
2358 <xsl:attribute name="authority">
2359 <xsl:value-of select="marc:subfield[@code='2']"/>
2361 <xsl:call-template name="subfieldSelect">
2362 <xsl:with-param name="codes">abvxyz</xsl:with-param>
2363 <xsl:with-param name="delimeter">-</xsl:with-param>
2364 </xsl:call-template>
2368 <xsl:variable name="MARCpublicationCode" select="normalize-space(substring($controlField008,16,3))"></xsl:variable>
2369 <xsl:if test="translate($MARCpublicationCode,'|','')">
2372 <xsl:attribute name="type">code</xsl:attribute>
2373 <xsl:attribute name="authority">marccountry</xsl:attribute>
2374 <xsl:value-of select="$MARCpublicationCode"/>
2378 <xsl:for-each select="marc:datafield[@tag=044]/marc:subfield[@code='c']">
2381 <xsl:attribute name="type">code</xsl:attribute>
2382 <xsl:attribute name="authority">iso3166</xsl:attribute>
2383 <xsl:value-of select="."/>
2387 <xsl:for-each select="marc:datafield[@tag=260]/marc:subfield[@code='a']">
2390 <xsl:attribute name="type">text</xsl:attribute>
2391 <xsl:call-template name="chopPunctuationFront">
2392 <xsl:with-param name="chopString">
2393 <xsl:call-template name="chopPunctuation">
2394 <xsl:with-param name="chopString" select="."/>
2395 </xsl:call-template>
2397 </xsl:call-template>
2401 <xsl:for-each select="marc:datafield[@tag=046]/marc:subfield[@code='m']">
2402 <dateValid point="start">
2403 <xsl:value-of select="."/>
2406 <xsl:for-each select="marc:datafield[@tag=046]/marc:subfield[@code='n']">
2407 <dateValid point="end">
2408 <xsl:value-of select="."/>
2411 <xsl:for-each select="marc:datafield[@tag=046]/marc:subfield[@code='j']">
2413 <xsl:value-of select="."/>
2416 <xsl:for-each select="marc:datafield[@tag=260]/marc:subfield[@code='b' or @code='c' or @code='g']">
2418 <xsl:when test="@code='b'">
2420 <xsl:call-template name="chopPunctuation">
2421 <xsl:with-param name="chopString" select="."/>
2422 <xsl:with-param name="punctuation">
2423 <xsl:text>:,;/ </xsl:text>
2425 </xsl:call-template>
2428 <xsl:when test="@code='c'">
2430 <xsl:call-template name="chopPunctuation">
2431 <xsl:with-param name="chopString" select="."/>
2432 </xsl:call-template>
2435 <xsl:when test="@code='g'">
2437 <xsl:value-of select="."/>
2442 <xsl:variable name="dataField260c">
2443 <xsl:call-template name="chopPunctuation">
2444 <xsl:with-param name="chopString" select="marc:datafield[@tag=260]/marc:subfield[@code='c']"></xsl:with-param>
2445 </xsl:call-template>
2447 <xsl:variable name="controlField008-7-10" select="normalize-space(substring($controlField008, 8, 4))"></xsl:variable>
2448 <xsl:variable name="controlField008-11-14" select="normalize-space(substring($controlField008, 12, 4))"></xsl:variable>
2449 <xsl:variable name="controlField008-6" select="normalize-space(substring($controlField008, 7, 1))"></xsl:variable>
2450 <xsl:if test="$controlField008-6='e' or $controlField008-6='p' or $controlField008-6='r' or $controlField008-6='t' or $controlField008-6='s'">
2451 <xsl:if test="$controlField008-7-10 and ($controlField008-7-10 != $dataField260c)">
2452 <dateIssued encoding="marc">
2453 <xsl:value-of select="$controlField008-7-10"/>
2457 <xsl:if test="$controlField008-6='c' or $controlField008-6='d' or $controlField008-6='i' or $controlField008-6='k' or $controlField008-6='m' or $controlField008-6='q' or $controlField008-6='u'">
2458 <xsl:if test="$controlField008-7-10">
2459 <dateIssued encoding="marc" point="start">
2460 <xsl:value-of select="$controlField008-7-10"/>
2464 <xsl:if test="$controlField008-6='c' or $controlField008-6='d' or $controlField008-6='i' or $controlField008-6='k' or $controlField008-6='m' or $controlField008-6='q' or $controlField008-6='u'">
2465 <xsl:if test="$controlField008-11-14">
2466 <dateIssued encoding="marc" point="end">
2467 <xsl:value-of select="$controlField008-11-14"/>
2471 <xsl:if test="$controlField008-6='q'">
2472 <xsl:if test="$controlField008-7-10">
2473 <dateIssued encoding="marc" point="start" qualifier="questionable">
2474 <xsl:value-of select="$controlField008-7-10"/>
2478 <xsl:if test="$controlField008-6='q'">
2479 <xsl:if test="$controlField008-11-14">
2480 <dateIssued encoding="marc" point="end" qualifier="questionable">
2481 <xsl:value-of select="$controlField008-11-14"/>
2485 <xsl:if test="$controlField008-6='t'">
2486 <xsl:if test="$controlField008-11-14">
2487 <copyrightDate encoding="marc">
2488 <xsl:value-of select="$controlField008-11-14"/>
2492 <xsl:for-each select="marc:datafield[@tag=033][@ind1=0 or @ind1=1]/marc:subfield[@code='a']">
2493 <dateCaptured encoding="iso8601">
2494 <xsl:value-of select="."/>
2497 <xsl:for-each select="marc:datafield[@tag=033][@ind1=2]/marc:subfield[@code='a'][1]">
2498 <dateCaptured encoding="iso8601" point="start">
2499 <xsl:value-of select="."/>
2502 <xsl:for-each select="marc:datafield[@tag=033][@ind1=2]/marc:subfield[@code='a'][2]">
2503 <dateCaptured encoding="iso8601" point="end">
2504 <xsl:value-of select="."/>
2507 <xsl:for-each select="marc:datafield[@tag=250]/marc:subfield[@code='a']">
2509 <xsl:value-of select="."/>
2512 <xsl:for-each select="marc:leader">
2515 <xsl:when test="$leader7='a' or $leader7='c' or $leader7='d' or $leader7='m'">monographic</xsl:when>
2516 <xsl:when test="$leader7='b' or $leader7='i' or $leader7='s'">continuing</xsl:when>
2520 <xsl:for-each select="marc:datafield[@tag=310]|marc:datafield[@tag=321]">
2522 <xsl:call-template name="subfieldSelect">
2523 <xsl:with-param name="codes">ab</xsl:with-param>
2524 </xsl:call-template>
2528 <xsl:variable name="controlField008-35-37" select="normalize-space(translate(substring($controlField008,36,3),'|#',''))"></xsl:variable>
2529 <xsl:if test="$controlField008-35-37">
2531 <languageTerm authority="iso639-2b" type="code">
2532 <xsl:value-of select="substring($controlField008,36,3)"/>
2536 <xsl:for-each select="marc:datafield[@tag=041]">
2537 <xsl:for-each select="marc:subfield[@code='a' or @code='b' or @code='d' or @code='e' or @code='f' or @code='g' or @code='h']">
2538 <xsl:variable name="langCodes" select="."/>
2540 <xsl:when test="../marc:subfield[@code='2']='rfc3066'">
2541 <!-- not stacked but could be repeated -->
2542 <xsl:call-template name="rfcLanguages">
2543 <xsl:with-param name="nodeNum">
2544 <xsl:value-of select="1"/>
2546 <xsl:with-param name="usedLanguages">
2547 <xsl:text></xsl:text>
2549 <xsl:with-param name="controlField008-35-37">
2550 <xsl:value-of select="$controlField008-35-37"></xsl:value-of>
2552 </xsl:call-template>
2556 <xsl:variable name="allLanguages">
2557 <xsl:copy-of select="$langCodes"></xsl:copy-of>
2559 <xsl:variable name="currentLanguage">
2560 <xsl:value-of select="substring($allLanguages,1,3)"></xsl:value-of>
2562 <xsl:call-template name="isoLanguage">
2563 <xsl:with-param name="currentLanguage">
2564 <xsl:value-of select="substring($allLanguages,1,3)"></xsl:value-of>
2566 <xsl:with-param name="remainingLanguages">
2567 <xsl:value-of select="substring($allLanguages,4,string-length($allLanguages)-3)"></xsl:value-of>
2569 <xsl:with-param name="usedLanguages">
2570 <xsl:if test="$controlField008-35-37">
2571 <xsl:value-of select="$controlField008-35-37"></xsl:value-of>
2574 </xsl:call-template>
2579 <xsl:variable name="physicalDescription">
2580 <!--3.2 change tmee 007/11 -->
2581 <xsl:if test="$typeOf008='CF' and marc:controlfield[@tag=007][substring(.,12,1)='a']">
2582 <digitalOrigin>reformatted digital</digitalOrigin>
2584 <xsl:if test="$typeOf008='CF' and marc:controlfield[@tag=007][substring(.,12,1)='b']">
2585 <digitalOrigin>digitized microfilm</digitalOrigin>
2587 <xsl:if test="$typeOf008='CF' and marc:controlfield[@tag=007][substring(.,12,1)='d']">
2588 <digitalOrigin>digitized other analog</digitalOrigin>
2590 <xsl:variable name="controlField008-23" select="substring($controlField008,24,1)"></xsl:variable>
2591 <xsl:variable name="controlField008-29" select="substring($controlField008,30,1)"></xsl:variable>
2592 <xsl:variable name="check008-23">
2593 <xsl:if test="$typeOf008='BK' or $typeOf008='MU' or $typeOf008='SE' or $typeOf008='MM'">
2594 <xsl:value-of select="true()"></xsl:value-of>
2597 <xsl:variable name="check008-29">
2598 <xsl:if test="$typeOf008='MP' or $typeOf008='VM'">
2599 <xsl:value-of select="true()"></xsl:value-of>
2603 <xsl:when test="($check008-23 and $controlField008-23='f') or ($check008-29 and $controlField008-29='f')">
2604 <form authority="marcform">braille</form>
2606 <xsl:when test="($controlField008-23=' ' and ($leader6='c' or $leader6='d')) or (($typeOf008='BK' or $typeOf008='SE') and ($controlField008-23=' ' or $controlField008='r'))">
2607 <form authority="marcform">print</form>
2609 <xsl:when test="$leader6 = 'm' or ($check008-23 and $controlField008-23='s') or ($check008-29 and $controlField008-29='s')">
2610 <form authority="marcform">electronic</form>
2612 <xsl:when test="($check008-23 and $controlField008-23='b') or ($check008-29 and $controlField008-29='b')">
2613 <form authority="marcform">microfiche</form>
2615 <xsl:when test="($check008-23 and $controlField008-23='a') or ($check008-29 and $controlField008-29='a')">
2616 <form authority="marcform">microfilm</form>
2620 <xsl:if test="marc:datafield[@tag=130]/marc:subfield[@code='h']">
2621 <form authority="gmd">
2622 <xsl:call-template name="chopBrackets">
2623 <xsl:with-param name="chopString">
2624 <xsl:value-of select="marc:datafield[@tag=130]/marc:subfield[@code='h']"></xsl:value-of>
2626 </xsl:call-template>
2629 <xsl:if test="marc:datafield[@tag=240]/marc:subfield[@code='h']">
2630 <form authority="gmd">
2631 <xsl:call-template name="chopBrackets">
2632 <xsl:with-param name="chopString">
2633 <xsl:value-of select="marc:datafield[@tag=240]/marc:subfield[@code='h']"></xsl:value-of>
2635 </xsl:call-template>
2638 <xsl:if test="marc:datafield[@tag=242]/marc:subfield[@code='h']">
2639 <form authority="gmd">
2640 <xsl:call-template name="chopBrackets">
2641 <xsl:with-param name="chopString">
2642 <xsl:value-of select="marc:datafield[@tag=242]/marc:subfield[@code='h']"></xsl:value-of>
2644 </xsl:call-template>
2647 <xsl:if test="marc:datafield[@tag=245]/marc:subfield[@code='h']">
2648 <form authority="gmd">
2649 <xsl:call-template name="chopBrackets">
2650 <xsl:with-param name="chopString">
2651 <xsl:value-of select="marc:datafield[@tag=245]/marc:subfield[@code='h']"></xsl:value-of>
2653 </xsl:call-template>
2656 <xsl:if test="marc:datafield[@tag=246]/marc:subfield[@code='h']">
2657 <form authority="gmd">
2658 <xsl:call-template name="chopBrackets">
2659 <xsl:with-param name="chopString">
2660 <xsl:value-of select="marc:datafield[@tag=246]/marc:subfield[@code='h']"></xsl:value-of>
2662 </xsl:call-template>
2665 <xsl:if test="marc:datafield[@tag=730]/marc:subfield[@code='h']">
2666 <form authority="gmd">
2667 <xsl:call-template name="chopBrackets">
2668 <xsl:with-param name="chopString">
2669 <xsl:value-of select="marc:datafield[@tag=730]/marc:subfield[@code='h']"></xsl:value-of>
2671 </xsl:call-template>
2674 <xsl:for-each select="marc:datafield[@tag=256]/marc:subfield[@code='a']">
2676 <xsl:value-of select="."></xsl:value-of>
2679 <xsl:for-each select="marc:controlfield[@tag=007][substring(text(),1,1)='c']">
2681 <xsl:when test="substring(text(),14,1)='a'">
2682 <reformattingQuality>access</reformattingQuality>
2684 <xsl:when test="substring(text(),14,1)='p'">
2685 <reformattingQuality>preservation</reformattingQuality>
2687 <xsl:when test="substring(text(),14,1)='r'">
2688 <reformattingQuality>replacement</reformattingQuality>
2692 <!--3.2 change tmee 007/01 -->
2693 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='b']">
2694 <form authority="smd">chip cartridge</form>
2696 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='c']">
2697 <form authority="smd">computer optical disc cartridge</form>
2699 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='j']">
2700 <form authority="smd">magnetic disc</form>
2702 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='m']">
2703 <form authority="smd">magneto-optical disc</form>
2705 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='o']">
2706 <form authority="smd">optical disc</form>
2708 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='r']">
2709 <form authority="smd">remote</form>
2711 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='a']">
2712 <form authority="smd">tape cartridge</form>
2714 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='f']">
2715 <form authority="smd">tape cassette</form>
2717 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='h']">
2718 <form authority="smd">tape reel</form>
2721 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='d'][substring(text(),2,1)='a']">
2722 <form authority="smd">celestial globe</form>
2724 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='d'][substring(text(),2,1)='e']">
2725 <form authority="smd">earth moon globe</form>
2727 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='d'][substring(text(),2,1)='b']">
2728 <form authority="smd">planetary or lunar globe</form>
2730 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='d'][substring(text(),2,1)='c']">
2731 <form authority="smd">terrestrial globe</form>
2734 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='o'][substring(text(),2,1)='o']">
2735 <form authority="smd">kit</form>
2738 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='d']">
2739 <form authority="smd">atlas</form>
2741 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='g']">
2742 <form authority="smd">diagram</form>
2744 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='j']">
2745 <form authority="smd">map</form>
2747 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='q']">
2748 <form authority="smd">model</form>
2750 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='k']">
2751 <form authority="smd">profile</form>
2753 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='r']">
2754 <form authority="smd">remote-sensing image</form>
2756 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='s']">
2757 <form authority="smd">section</form>
2759 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='y']">
2760 <form authority="smd">view</form>
2763 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='a']">
2764 <form authority="smd">aperture card</form>
2766 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='e']">
2767 <form authority="smd">microfiche</form>
2769 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='f']">
2770 <form authority="smd">microfiche cassette</form>
2772 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='b']">
2773 <form authority="smd">microfilm cartridge</form>
2775 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='c']">
2776 <form authority="smd">microfilm cassette</form>
2778 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='d']">
2779 <form authority="smd">microfilm reel</form>
2781 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='g']">
2782 <form authority="smd">microopaque</form>
2785 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='m'][substring(text(),2,1)='c']">
2786 <form authority="smd">film cartridge</form>
2788 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='m'][substring(text(),2,1)='f']">
2789 <form authority="smd">film cassette</form>
2791 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='m'][substring(text(),2,1)='r']">
2792 <form authority="smd">film reel</form>
2795 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='n']">
2796 <form authority="smd">chart</form>
2798 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='c']">
2799 <form authority="smd">collage</form>
2801 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='d']">
2802 <form authority="smd">drawing</form>
2804 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='o']">
2805 <form authority="smd">flash card</form>
2807 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='e']">
2808 <form authority="smd">painting</form>
2810 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='f']">
2811 <form authority="smd">photomechanical print</form>
2813 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='g']">
2814 <form authority="smd">photonegative</form>
2816 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='h']">
2817 <form authority="smd">photoprint</form>
2819 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='i']">
2820 <form authority="smd">picture</form>
2822 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='j']">
2823 <form authority="smd">print</form>
2825 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='l']">
2826 <form authority="smd">technical drawing</form>
2829 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='q'][substring(text(),2,1)='q']">
2830 <form authority="smd">notated music</form>
2833 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='d']">
2834 <form authority="smd">filmslip</form>
2836 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='c']">
2837 <form authority="smd">filmstrip cartridge</form>
2839 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='o']">
2840 <form authority="smd">filmstrip roll</form>
2842 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='f']">
2843 <form authority="smd">other filmstrip type</form>
2845 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='s']">
2846 <form authority="smd">slide</form>
2848 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='t']">
2849 <form authority="smd">transparency</form>
2851 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='r'][substring(text(),2,1)='r']">
2852 <form authority="smd">remote-sensing image</form>
2854 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='e']">
2855 <form authority="smd">cylinder</form>
2857 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='q']">
2858 <form authority="smd">roll</form>
2860 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='g']">
2861 <form authority="smd">sound cartridge</form>
2863 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='s']">
2864 <form authority="smd">sound cassette</form>
2866 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='d']">
2867 <form authority="smd">sound disc</form>
2869 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='t']">
2870 <form authority="smd">sound-tape reel</form>
2872 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='i']">
2873 <form authority="smd">sound-track film</form>
2875 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='w']">
2876 <form authority="smd">wire recording</form>
2879 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='f'][substring(text(),2,1)='c']">
2880 <form authority="smd">braille</form>
2882 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='f'][substring(text(),2,1)='b']">
2883 <form authority="smd">combination</form>
2885 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='f'][substring(text(),2,1)='a']">
2886 <form authority="smd">moon</form>
2888 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='f'][substring(text(),2,1)='d']">
2889 <form authority="smd">tactile, with no writing system</form>
2892 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='t'][substring(text(),2,1)='c']">
2893 <form authority="smd">braille</form>
2895 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='t'][substring(text(),2,1)='b']">
2896 <form authority="smd">large print</form>
2898 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='t'][substring(text(),2,1)='a']">
2899 <form authority="smd">regular print</form>
2901 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='t'][substring(text(),2,1)='d']">
2902 <form authority="smd">text in looseleaf binder</form>
2905 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='v'][substring(text(),2,1)='c']">
2906 <form authority="smd">videocartridge</form>
2908 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='v'][substring(text(),2,1)='f']">
2909 <form authority="smd">videocassette</form>
2911 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='v'][substring(text(),2,1)='d']">
2912 <form authority="smd">videodisc</form>
2914 <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='v'][substring(text(),2,1)='r']">
2915 <form authority="smd">videoreel</form>
2918 <xsl:for-each select="marc:datafield[@tag=856]/marc:subfield[@code='q'][string-length(.)>1]">
2920 <xsl:value-of select="."></xsl:value-of>
2921 </internetMediaType>
2923 <xsl:for-each select="marc:datafield[@tag=300]">
2925 <xsl:call-template name="subfieldSelect">
2926 <xsl:with-param name="codes">abce</xsl:with-param>
2927 </xsl:call-template>
2931 <xsl:if test="string-length(normalize-space($physicalDescription))">
2932 <physicalDescription>
2933 <xsl:copy-of select="$physicalDescription"></xsl:copy-of>
2934 </physicalDescription>
2936 <xsl:for-each select="marc:datafield[@tag=520]">
2938 <xsl:call-template name="uri"></xsl:call-template>
2939 <xsl:call-template name="subfieldSelect">
2940 <xsl:with-param name="codes">ab</xsl:with-param>
2941 </xsl:call-template>
2944 <xsl:for-each select="marc:datafield[@tag=505]">
2946 <xsl:call-template name="uri"></xsl:call-template>
2947 <xsl:call-template name="subfieldSelect">
2948 <xsl:with-param name="codes">agrt</xsl:with-param>
2949 </xsl:call-template>
2952 <xsl:for-each select="marc:datafield[@tag=521]">
2954 <xsl:call-template name="subfieldSelect">
2955 <xsl:with-param name="codes">ab</xsl:with-param>
2956 </xsl:call-template>
2959 <xsl:if test="$typeOf008='BK' or $typeOf008='CF' or $typeOf008='MU' or $typeOf008='VM'">
2960 <xsl:variable name="controlField008-22" select="substring($controlField008,23,1)"></xsl:variable>
2963 <xsl:when test="$controlField008-22='d'">
2964 <targetAudience authority="marctarget">adolescent</targetAudience>
2966 <xsl:when test="$controlField008-22='e'">
2967 <targetAudience authority="marctarget">adult</targetAudience>
2969 <xsl:when test="$controlField008-22='g'">
2970 <targetAudience authority="marctarget">general</targetAudience>
2972 <xsl:when test="$controlField008-22='b' or $controlField008-22='c' or $controlField008-22='j'">
2973 <targetAudience authority="marctarget">juvenile</targetAudience>
2975 <xsl:when test="$controlField008-22='a'">
2976 <targetAudience authority="marctarget">preschool</targetAudience>
2978 <xsl:when test="$controlField008-22='f'">
2979 <targetAudience authority="marctarget">specialized</targetAudience>
2983 <xsl:for-each select="marc:datafield[@tag=245]/marc:subfield[@code='c']">
2984 <note type="statement of responsibility">
2985 <xsl:value-of select="."></xsl:value-of>
2988 <xsl:for-each select="marc:datafield[@tag=500]">
2990 <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
2991 <xsl:call-template name="uri"></xsl:call-template>
2995 <!--3.2 change tmee additional note fields-->
2997 <xsl:for-each select="marc:datafield[@tag=502]">
2998 <note type="thesis">
2999 <xsl:call-template name="uri"/>
3000 <xsl:variable name="str">
3001 <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
3002 <xsl:value-of select="."/>
3003 <xsl:text> </xsl:text>
3006 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
3010 <xsl:for-each select="marc:datafield[@tag=504]">
3011 <note type="bibliography">
3012 <xsl:call-template name="uri"/>
3013 <xsl:variable name="str">
3014 <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
3015 <xsl:value-of select="."/>
3016 <xsl:text> </xsl:text>
3019 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
3023 <xsl:for-each select="marc:datafield[@tag=508]">
3024 <note type="creation/production credits">
3025 <xsl:call-template name="uri"/>
3026 <xsl:variable name="str">
3027 <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
3028 <xsl:value-of select="."/>
3029 <xsl:text> </xsl:text>
3032 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
3036 <xsl:for-each select="marc:datafield[@tag=506]">
3037 <note type="restrictions">
3038 <xsl:call-template name="uri"></xsl:call-template>
3039 <xsl:variable name="str">
3040 <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
3041 <xsl:value-of select="."></xsl:value-of>
3042 <xsl:text> </xsl:text>
3045 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
3049 <xsl:for-each select="marc:datafield[@tag=510]">
3050 <note type="citation/reference">
3051 <xsl:call-template name="uri"></xsl:call-template>
3052 <xsl:variable name="str">
3053 <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
3054 <xsl:value-of select="."></xsl:value-of>
3055 <xsl:text> </xsl:text>
3058 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
3063 <xsl:for-each select="marc:datafield[@tag=511]">
3064 <note type="performers">
3065 <xsl:call-template name="uri"></xsl:call-template>
3066 <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
3069 <xsl:for-each select="marc:datafield[@tag=518]">
3071 <xsl:call-template name="uri"></xsl:call-template>
3072 <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
3076 <xsl:for-each select="marc:datafield[@tag=530]">
3077 <note type="additional physical form">
3078 <xsl:call-template name="uri"></xsl:call-template>
3079 <xsl:variable name="str">
3080 <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
3081 <xsl:value-of select="."></xsl:value-of>
3082 <xsl:text> </xsl:text>
3085 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
3089 <xsl:for-each select="marc:datafield[@tag=533]">
3090 <note type="reproduction">
3091 <xsl:call-template name="uri"></xsl:call-template>
3092 <xsl:variable name="str">
3093 <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
3094 <xsl:value-of select="."></xsl:value-of>
3095 <xsl:text> </xsl:text>
3098 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
3102 <xsl:for-each select="marc:datafield[@tag=534]">
3103 <note type="original version">
3104 <xsl:call-template name="uri"></xsl:call-template>
3105 <xsl:variable name="str">
3106 <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
3107 <xsl:value-of select="."></xsl:value-of>
3108 <xsl:text> </xsl:text>
3111 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
3115 <xsl:for-each select="marc:datafield[@tag=538]">
3116 <note type="system details">
3117 <xsl:call-template name="uri"></xsl:call-template>
3118 <xsl:variable name="str">
3119 <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
3120 <xsl:value-of select="."></xsl:value-of>
3121 <xsl:text> </xsl:text>
3124 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
3128 <xsl:for-each select="marc:datafield[@tag=583]">
3129 <note type="action">
3130 <xsl:call-template name="uri"></xsl:call-template>
3131 <xsl:variable name="str">
3132 <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
3133 <xsl:value-of select="."></xsl:value-of>
3134 <xsl:text> </xsl:text>
3137 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
3145 <xsl:for-each select="marc:datafield[@tag=501 or @tag=507 or @tag=513 or @tag=514 or @tag=515 or @tag=516 or @tag=522 or @tag=524 or @tag=525 or @tag=526 or @tag=535 or @tag=536 or @tag=540 or @tag=541 or @tag=544 or @tag=545 or @tag=546 or @tag=547 or @tag=550 or @tag=552 or @tag=555 or @tag=556 or @tag=561 or @tag=562 or @tag=565 or @tag=567 or @tag=580 or @tag=581 or @tag=584 or @tag=585 or @tag=586]">
3147 <xsl:call-template name="uri"></xsl:call-template>
3148 <xsl:variable name="str">
3149 <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
3150 <xsl:value-of select="."></xsl:value-of>
3151 <xsl:text> </xsl:text>
3154 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
3157 <xsl:for-each select="marc:datafield[@tag=034][marc:subfield[@code='d' or @code='e' or @code='f' or @code='g']]">
3161 <xsl:call-template name="subfieldSelect">
3162 <xsl:with-param name="codes">defg</xsl:with-param>
3163 </xsl:call-template>
3168 <xsl:for-each select="marc:datafield[@tag=043]">
3170 <xsl:for-each select="marc:subfield[@code='a' or @code='b' or @code='c']">
3172 <xsl:attribute name="authority">
3173 <xsl:if test="@code='a'">
3174 <xsl:text>marcgac</xsl:text>
3176 <xsl:if test="@code='b'">
3177 <xsl:value-of select="following-sibling::marc:subfield[@code=2]"></xsl:value-of>
3179 <xsl:if test="@code='c'">
3180 <xsl:text>iso3166</xsl:text>
3183 <xsl:value-of select="self::marc:subfield"></xsl:value-of>
3188 <!-- tmee 2006/11/27 -->
3189 <xsl:for-each select="marc:datafield[@tag=255]">
3191 <xsl:for-each select="marc:subfield[@code='a' or @code='b' or @code='c']">
3193 <xsl:if test="@code='a'">
3195 <xsl:value-of select="."></xsl:value-of>
3198 <xsl:if test="@code='b'">
3200 <xsl:value-of select="."></xsl:value-of>
3203 <xsl:if test="@code='c'">
3205 <xsl:value-of select="."></xsl:value-of>
3213 <xsl:apply-templates select="marc:datafield[653 >= @tag and @tag >= 600]"></xsl:apply-templates>
3214 <xsl:apply-templates select="marc:datafield[@tag=656]"></xsl:apply-templates>
3215 <xsl:for-each select="marc:datafield[@tag=752]">
3217 <hierarchicalGeographic>
3218 <xsl:for-each select="marc:subfield[@code='a']">
3220 <xsl:call-template name="chopPunctuation">
3221 <xsl:with-param name="chopString" select="."></xsl:with-param>
3222 </xsl:call-template>
3225 <xsl:for-each select="marc:subfield[@code='b']">
3227 <xsl:call-template name="chopPunctuation">
3228 <xsl:with-param name="chopString" select="."></xsl:with-param>
3229 </xsl:call-template>
3232 <xsl:for-each select="marc:subfield[@code='c']">
3234 <xsl:call-template name="chopPunctuation">
3235 <xsl:with-param name="chopString" select="."></xsl:with-param>
3236 </xsl:call-template>
3239 <xsl:for-each select="marc:subfield[@code='d']">
3241 <xsl:call-template name="chopPunctuation">
3242 <xsl:with-param name="chopString" select="."></xsl:with-param>
3243 </xsl:call-template>
3246 </hierarchicalGeographic>
3249 <xsl:for-each select="marc:datafield[@tag=045][marc:subfield[@code='b']]">
3252 <xsl:when test="@ind1=2">
3253 <temporal encoding="iso8601" point="start">
3254 <xsl:call-template name="chopPunctuation">
3255 <xsl:with-param name="chopString">
3256 <xsl:value-of select="marc:subfield[@code='b'][1]"></xsl:value-of>
3258 </xsl:call-template>
3260 <temporal encoding="iso8601" point="end">
3261 <xsl:call-template name="chopPunctuation">
3262 <xsl:with-param name="chopString">
3263 <xsl:value-of select="marc:subfield[@code='b'][2]"></xsl:value-of>
3265 </xsl:call-template>
3269 <xsl:for-each select="marc:subfield[@code='b']">
3270 <temporal encoding="iso8601">
3271 <xsl:call-template name="chopPunctuation">
3272 <xsl:with-param name="chopString" select="."></xsl:with-param>
3273 </xsl:call-template>
3280 <xsl:for-each select="marc:datafield[@tag=050]">
3281 <xsl:for-each select="marc:subfield[@code='b']">
3282 <classification authority="lcc">
3283 <xsl:if test="../marc:subfield[@code='3']">
3284 <xsl:attribute name="displayLabel">
3285 <xsl:value-of select="../marc:subfield[@code='3']"></xsl:value-of>
3288 <xsl:value-of select="preceding-sibling::marc:subfield[@code='a'][1]"></xsl:value-of>
3289 <xsl:text> </xsl:text>
3290 <xsl:value-of select="text()"></xsl:value-of>
3293 <xsl:for-each select="marc:subfield[@code='a'][not(following-sibling::marc:subfield[@code='b'])]">
3294 <classification authority="lcc">
3295 <xsl:if test="../marc:subfield[@code='3']">
3296 <xsl:attribute name="displayLabel">
3297 <xsl:value-of select="../marc:subfield[@code='3']"></xsl:value-of>
3300 <xsl:value-of select="text()"></xsl:value-of>
3304 <xsl:for-each select="marc:datafield[@tag=082]">
3305 <classification authority="ddc">
3306 <xsl:if test="marc:subfield[@code='2']">
3307 <xsl:attribute name="edition">
3308 <xsl:value-of select="marc:subfield[@code='2']"></xsl:value-of>
3311 <xsl:call-template name="subfieldSelect">
3312 <xsl:with-param name="codes">ab</xsl:with-param>
3313 </xsl:call-template>
3316 <xsl:for-each select="marc:datafield[@tag=080]">
3317 <classification authority="udc">
3318 <xsl:call-template name="subfieldSelect">
3319 <xsl:with-param name="codes">abx</xsl:with-param>
3320 </xsl:call-template>
3323 <xsl:for-each select="marc:datafield[@tag=060]">
3324 <classification authority="nlm">
3325 <xsl:call-template name="subfieldSelect">
3326 <xsl:with-param name="codes">ab</xsl:with-param>
3327 </xsl:call-template>
3330 <xsl:for-each select="marc:datafield[@tag=086][@ind1=0]">
3331 <classification authority="sudocs">
3332 <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
3335 <xsl:for-each select="marc:datafield[@tag=086][@ind1=1]">
3336 <classification authority="candoc">
3337 <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
3340 <xsl:for-each select="marc:datafield[@tag=086]">
3342 <xsl:attribute name="authority">
3343 <xsl:value-of select="marc:subfield[@code='2']"></xsl:value-of>
3345 <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
3348 <xsl:for-each select="marc:datafield[@tag=084]">
3350 <xsl:attribute name="authority">
3351 <xsl:value-of select="marc:subfield[@code='2']"></xsl:value-of>
3353 <xsl:call-template name="subfieldSelect">
3354 <xsl:with-param name="codes">ab</xsl:with-param>
3355 </xsl:call-template>
3358 <xsl:for-each select="marc:datafield[@tag=440]">
3359 <relatedItem type="series">
3360 <xsl:variable name="titleChop">
3361 <xsl:call-template name="chopPunctuation">
3362 <xsl:with-param name="chopString">
3363 <xsl:call-template name="subfieldSelect">
3364 <xsl:with-param name="codes">av</xsl:with-param>
3365 </xsl:call-template>
3367 </xsl:call-template>
3371 <xsl:value-of select="$titleChop" />
3373 <xsl:call-template name="part"></xsl:call-template>
3375 <titleInfo type="nfi">
3377 <xsl:when test="@ind2>0">
3379 <xsl:value-of select="substring($titleChop,1,@ind2)"/>
3382 <xsl:value-of select="substring($titleChop,@ind2+1)"/>
3384 <xsl:call-template name="part"/>
3388 <xsl:value-of select="$titleChop" />
3392 <xsl:call-template name="part"></xsl:call-template>
3396 <xsl:for-each select="marc:datafield[@tag=490][@ind1=0]">
3397 <relatedItem type="series">
3400 <xsl:call-template name="chopPunctuation">
3401 <xsl:with-param name="chopString">
3402 <xsl:call-template name="subfieldSelect">
3403 <xsl:with-param name="codes">av</xsl:with-param>
3404 </xsl:call-template>
3406 </xsl:call-template>
3408 <xsl:call-template name="part"></xsl:call-template>
3412 <xsl:for-each select="marc:datafield[@tag=510]">
3413 <relatedItem type="isReferencedBy">
3415 <xsl:call-template name="subfieldSelect">
3416 <xsl:with-param name="codes">abcx3</xsl:with-param>
3417 </xsl:call-template>
3421 <xsl:for-each select="marc:datafield[@tag=534]">
3422 <relatedItem type="original">
3423 <xsl:call-template name="relatedTitle"></xsl:call-template>
3424 <xsl:call-template name="relatedName"></xsl:call-template>
3425 <xsl:if test="marc:subfield[@code='b' or @code='c']">
3427 <xsl:for-each select="marc:subfield[@code='c']">
3429 <xsl:value-of select="."></xsl:value-of>
3432 <xsl:for-each select="marc:subfield[@code='b']">
3434 <xsl:value-of select="."></xsl:value-of>
3439 <xsl:call-template name="relatedIdentifierISSN"></xsl:call-template>
3440 <xsl:for-each select="marc:subfield[@code='z']">
3441 <identifier type="isbn">
3442 <xsl:value-of select="."></xsl:value-of>
3445 <xsl:call-template name="relatedNote"></xsl:call-template>
3448 <xsl:for-each select="marc:datafield[@tag=700][marc:subfield[@code='t']]">
3450 <xsl:call-template name="constituentOrRelatedType"></xsl:call-template>
3453 <xsl:call-template name="chopPunctuation">
3454 <xsl:with-param name="chopString">
3455 <xsl:call-template name="specialSubfieldSelect">
3456 <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
3457 <xsl:with-param name="axis">t</xsl:with-param>
3458 <xsl:with-param name="afterCodes">g</xsl:with-param>
3459 </xsl:call-template>
3461 </xsl:call-template>
3463 <xsl:call-template name="part"></xsl:call-template>
3465 <name type="personal">
3467 <xsl:call-template name="specialSubfieldSelect">
3468 <xsl:with-param name="anyCodes">aq</xsl:with-param>
3469 <xsl:with-param name="axis">t</xsl:with-param>
3470 <xsl:with-param name="beforeCodes">g</xsl:with-param>
3471 </xsl:call-template>
3473 <xsl:call-template name="termsOfAddress"></xsl:call-template>
3474 <xsl:call-template name="nameDate"></xsl:call-template>
3475 <xsl:call-template name="role"></xsl:call-template>
3477 <xsl:call-template name="relatedForm"></xsl:call-template>
3478 <xsl:call-template name="relatedIdentifierISSN"></xsl:call-template>
3481 <xsl:for-each select="marc:datafield[@tag=710][marc:subfield[@code='t']]">
3483 <xsl:call-template name="constituentOrRelatedType"></xsl:call-template>
3486 <xsl:call-template name="chopPunctuation">
3487 <xsl:with-param name="chopString">
3488 <xsl:call-template name="specialSubfieldSelect">
3489 <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
3490 <xsl:with-param name="axis">t</xsl:with-param>
3491 <xsl:with-param name="afterCodes">dg</xsl:with-param>
3492 </xsl:call-template>
3494 </xsl:call-template>
3496 <xsl:call-template name="relatedPartNumName"></xsl:call-template>
3498 <name type="corporate">
3499 <xsl:for-each select="marc:subfield[@code='a']">
3501 <xsl:value-of select="."></xsl:value-of>
3504 <xsl:for-each select="marc:subfield[@code='b']">
3506 <xsl:value-of select="."></xsl:value-of>
3509 <xsl:variable name="tempNamePart">
3510 <xsl:call-template name="specialSubfieldSelect">
3511 <xsl:with-param name="anyCodes">c</xsl:with-param>
3512 <xsl:with-param name="axis">t</xsl:with-param>
3513 <xsl:with-param name="beforeCodes">dgn</xsl:with-param>
3514 </xsl:call-template>
3516 <xsl:if test="normalize-space($tempNamePart)">
3518 <xsl:value-of select="$tempNamePart"></xsl:value-of>
3521 <xsl:call-template name="role"></xsl:call-template>
3523 <xsl:call-template name="relatedForm"></xsl:call-template>
3524 <xsl:call-template name="relatedIdentifierISSN"></xsl:call-template>
3527 <xsl:for-each select="marc:datafield[@tag=711][marc:subfield[@code='t']]">
3529 <xsl:call-template name="constituentOrRelatedType"></xsl:call-template>
3532 <xsl:call-template name="chopPunctuation">
3533 <xsl:with-param name="chopString">
3534 <xsl:call-template name="specialSubfieldSelect">
3535 <xsl:with-param name="anyCodes">tfklsv</xsl:with-param>
3536 <xsl:with-param name="axis">t</xsl:with-param>
3537 <xsl:with-param name="afterCodes">g</xsl:with-param>
3538 </xsl:call-template>
3540 </xsl:call-template>
3542 <xsl:call-template name="relatedPartNumName"></xsl:call-template>
3544 <name type="conference">
3546 <xsl:call-template name="specialSubfieldSelect">
3547 <xsl:with-param name="anyCodes">aqdc</xsl:with-param>
3548 <xsl:with-param name="axis">t</xsl:with-param>
3549 <xsl:with-param name="beforeCodes">gn</xsl:with-param>
3550 </xsl:call-template>
3553 <xsl:call-template name="relatedForm"></xsl:call-template>
3554 <xsl:call-template name="relatedIdentifierISSN"></xsl:call-template>
3557 <xsl:for-each select="marc:datafield[@tag=730][@ind2=2]">
3559 <xsl:call-template name="constituentOrRelatedType"></xsl:call-template>
3562 <xsl:call-template name="chopPunctuation">
3563 <xsl:with-param name="chopString">
3564 <xsl:call-template name="subfieldSelect">
3565 <xsl:with-param name="codes">adfgklmorsv</xsl:with-param>
3566 </xsl:call-template>
3568 </xsl:call-template>
3570 <xsl:call-template name="part"></xsl:call-template>
3572 <xsl:call-template name="relatedForm"></xsl:call-template>
3573 <xsl:call-template name="relatedIdentifierISSN"></xsl:call-template>
3576 <xsl:for-each select="marc:datafield[@tag=740][@ind2=2]">
3578 <xsl:call-template name="constituentOrRelatedType"></xsl:call-template>
3579 <xsl:variable name="titleChop">
3580 <xsl:call-template name="chopPunctuation">
3581 <xsl:with-param name="chopString">
3582 <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
3584 </xsl:call-template>
3588 <xsl:value-of select="$titleChop" />
3590 <xsl:call-template name="part"></xsl:call-template>
3592 <titleInfo type="nfi">
3594 <xsl:when test="@ind1>0">
3596 <xsl:value-of select="substring($titleChop,1,@ind1)"/>
3599 <xsl:value-of select="substring($titleChop,@ind1+1)"/>
3604 <xsl:value-of select="$titleChop" />
3608 <xsl:call-template name="part"></xsl:call-template>
3610 <xsl:call-template name="relatedForm"></xsl:call-template>
3613 <xsl:for-each select="marc:datafield[@tag=760]|marc:datafield[@tag=762]">
3614 <relatedItem type="series">
3615 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
3618 <xsl:for-each select="marc:datafield[@tag=765]|marc:datafield[@tag=767]|marc:datafield[@tag=777]|marc:datafield[@tag=787]">
3620 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
3623 <xsl:for-each select="marc:datafield[@tag=775]">
3624 <relatedItem type="otherVersion">
3625 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
3628 <xsl:for-each select="marc:datafield[@tag=770]|marc:datafield[@tag=774]">
3629 <relatedItem type="constituent">
3630 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
3633 <xsl:for-each select="marc:datafield[@tag=772]|marc:datafield[@tag=773]">
3634 <relatedItem type="host">
3635 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
3638 <xsl:for-each select="marc:datafield[@tag=776]">
3639 <relatedItem type="otherFormat">
3640 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
3643 <xsl:for-each select="marc:datafield[@tag=780]">
3644 <relatedItem type="preceding">
3645 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
3648 <xsl:for-each select="marc:datafield[@tag=785]">
3649 <relatedItem type="succeeding">
3650 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
3653 <xsl:for-each select="marc:datafield[@tag=786]">
3654 <relatedItem type="original">
3655 <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
3658 <xsl:for-each select="marc:datafield[@tag=800]">
3659 <relatedItem type="series">
3662 <xsl:call-template name="chopPunctuation">
3663 <xsl:with-param name="chopString">
3664 <xsl:call-template name="specialSubfieldSelect">
3665 <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
3666 <xsl:with-param name="axis">t</xsl:with-param>
3667 <xsl:with-param name="afterCodes">g</xsl:with-param>
3668 </xsl:call-template>
3670 </xsl:call-template>
3672 <xsl:call-template name="part"></xsl:call-template>
3674 <name type="personal">
3676 <xsl:call-template name="chopPunctuation">
3677 <xsl:with-param name="chopString">
3678 <xsl:call-template name="specialSubfieldSelect">
3679 <xsl:with-param name="anyCodes">aq</xsl:with-param>
3680 <xsl:with-param name="axis">t</xsl:with-param>
3681 <xsl:with-param name="beforeCodes">g</xsl:with-param>
3682 </xsl:call-template>
3684 </xsl:call-template>
3686 <xsl:call-template name="termsOfAddress"></xsl:call-template>
3687 <xsl:call-template name="nameDate"></xsl:call-template>
3688 <xsl:call-template name="role"></xsl:call-template>
3690 <xsl:call-template name="relatedForm"></xsl:call-template>
3693 <xsl:for-each select="marc:datafield[@tag=810]">
3694 <relatedItem type="series">
3697 <xsl:call-template name="chopPunctuation">
3698 <xsl:with-param name="chopString">
3699 <xsl:call-template name="specialSubfieldSelect">
3700 <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
3701 <xsl:with-param name="axis">t</xsl:with-param>
3702 <xsl:with-param name="afterCodes">dg</xsl:with-param>
3703 </xsl:call-template>
3705 </xsl:call-template>
3707 <xsl:call-template name="relatedPartNumName"></xsl:call-template>
3709 <name type="corporate">
3710 <xsl:for-each select="marc:subfield[@code='a']">
3712 <xsl:value-of select="."></xsl:value-of>
3715 <xsl:for-each select="marc:subfield[@code='b']">
3717 <xsl:value-of select="."></xsl:value-of>
3721 <xsl:call-template name="specialSubfieldSelect">
3722 <xsl:with-param name="anyCodes">c</xsl:with-param>
3723 <xsl:with-param name="axis">t</xsl:with-param>
3724 <xsl:with-param name="beforeCodes">dgn</xsl:with-param>
3725 </xsl:call-template>
3727 <xsl:call-template name="role"></xsl:call-template>
3729 <xsl:call-template name="relatedForm"></xsl:call-template>
3732 <xsl:for-each select="marc:datafield[@tag=811]">
3733 <relatedItem type="series">
3736 <xsl:call-template name="chopPunctuation">
3737 <xsl:with-param name="chopString">
3738 <xsl:call-template name="specialSubfieldSelect">
3739 <xsl:with-param name="anyCodes">tfklsv</xsl:with-param>
3740 <xsl:with-param name="axis">t</xsl:with-param>
3741 <xsl:with-param name="afterCodes">g</xsl:with-param>
3742 </xsl:call-template>
3744 </xsl:call-template>
3746 <xsl:call-template name="relatedPartNumName"/>
3748 <name type="conference">
3750 <xsl:call-template name="specialSubfieldSelect">
3751 <xsl:with-param name="anyCodes">aqdc</xsl:with-param>
3752 <xsl:with-param name="axis">t</xsl:with-param>
3753 <xsl:with-param name="beforeCodes">gn</xsl:with-param>
3754 </xsl:call-template>
3756 <xsl:call-template name="role"/>
3758 <xsl:call-template name="relatedForm"/>
3761 <xsl:for-each select="marc:datafield[@tag='830']">
3762 <relatedItem type="series">
3763 <xsl:variable name="titleChop">
3764 <xsl:call-template name="chopPunctuation">
3765 <xsl:with-param name="chopString">
3766 <xsl:call-template name="subfieldSelect">
3767 <xsl:with-param name="codes">adfgklmorsv</xsl:with-param>
3768 </xsl:call-template>
3770 </xsl:call-template>
3774 <xsl:value-of select="$titleChop" />
3776 <xsl:call-template name="part"/>
3778 <titleInfo type="nfi">
3780 <xsl:when test="@ind2>0">
3782 <xsl:value-of select="substring($titleChop,1,@ind2)"/>
3785 <xsl:value-of select="substring($titleChop,@ind2+1)"/>
3790 <xsl:value-of select="$titleChop" />
3794 <xsl:call-template name="part"/>
3796 <xsl:call-template name="relatedForm"/>
3799 <xsl:for-each select="marc:datafield[@tag='856'][@ind2='2']/marc:subfield[@code='q']">
3802 <xsl:value-of select="."/>
3803 </internetMediaType>
3806 <xsl:for-each select="marc:datafield[@tag='020']">
3807 <xsl:call-template name="isInvalid">
3808 <xsl:with-param name="type">isbn</xsl:with-param>
3809 </xsl:call-template>
3810 <xsl:if test="marc:subfield[@code='a']">
3811 <identifier type="isbn">
3812 <xsl:value-of select="marc:subfield[@code='a']"/>
3816 <xsl:for-each select="marc:datafield[@tag='024'][@ind1='0']">
3817 <xsl:call-template name="isInvalid">
3818 <xsl:with-param name="type">isrc</xsl:with-param>
3819 </xsl:call-template>
3820 <xsl:if test="marc:subfield[@code='a']">
3821 <identifier type="isrc">
3822 <xsl:value-of select="marc:subfield[@code='a']"/>
3826 <xsl:for-each select="marc:datafield[@tag='024'][@ind1='2']">
3827 <xsl:call-template name="isInvalid">
3828 <xsl:with-param name="type">ismn</xsl:with-param>
3829 </xsl:call-template>
3830 <xsl:if test="marc:subfield[@code='a']">
3831 <identifier type="ismn">
3832 <xsl:value-of select="marc:subfield[@code='a']"/>
3836 <xsl:for-each select="marc:datafield[@tag='024'][@ind1='4']">
3837 <xsl:call-template name="isInvalid">
3838 <xsl:with-param name="type">sici</xsl:with-param>
3839 </xsl:call-template>
3840 <identifier type="sici">
3841 <xsl:call-template name="subfieldSelect">
3842 <xsl:with-param name="codes">ab</xsl:with-param>
3843 </xsl:call-template>
3846 <xsl:for-each select="marc:datafield[@tag='022']">
3847 <xsl:call-template name="isInvalid">
3848 <xsl:with-param name="type">issn</xsl:with-param>
3849 </xsl:call-template>
3850 <identifier type="issn">
3851 <xsl:value-of select="marc:subfield[@code='a']"/>
3854 <xsl:for-each select="marc:datafield[@tag='010']">
3855 <xsl:call-template name="isInvalid">
3856 <xsl:with-param name="type">lccn</xsl:with-param>
3857 </xsl:call-template>
3858 <identifier type="lccn">
3859 <xsl:value-of select="normalize-space(marc:subfield[@code='a'])"/>
3862 <xsl:for-each select="marc:datafield[@tag='028']">
3864 <xsl:attribute name="type">
3866 <xsl:when test="@ind1='0'">issue number</xsl:when>
3867 <xsl:when test="@ind1='1'">matrix number</xsl:when>
3868 <xsl:when test="@ind1='2'">music plate</xsl:when>
3869 <xsl:when test="@ind1='3'">music publisher</xsl:when>
3870 <xsl:when test="@ind1='4'">videorecording identifier</xsl:when>
3873 <!--<xsl:call-template name="isInvalid"/>--> <!-- no $z in 028 -->
3874 <xsl:call-template name="subfieldSelect">
3875 <xsl:with-param name="codes">
3877 <xsl:when test="@ind1='0'">ba</xsl:when>
3878 <xsl:otherwise>ab</xsl:otherwise>
3881 </xsl:call-template>
3884 <xsl:for-each select="marc:datafield[@tag='037']">
3885 <identifier type="stock number">
3886 <!--<xsl:call-template name="isInvalid"/>--> <!-- no $z in 037 -->
3887 <xsl:call-template name="subfieldSelect">
3888 <xsl:with-param name="codes">ab</xsl:with-param>
3889 </xsl:call-template>
3892 <xsl:for-each select="marc:datafield[@tag='856'][marc:subfield[@code='u']]">
3894 <xsl:attribute name="type">
3896 <xsl:when test="starts-with(marc:subfield[@code='u'],'urn:doi') or starts-with(marc:subfield[@code='u'],'doi')">doi</xsl:when>
3897 <xsl:when test="starts-with(marc:subfield[@code='u'],'urn:hdl') or starts-with(marc:subfield[@code='u'],'hdl') or starts-with(marc:subfield[@code='u'],'http://hdl.loc.gov')">hdl</xsl:when>
3898 <xsl:otherwise>uri</xsl:otherwise>
3902 <xsl:when test="starts-with(marc:subfield[@code='u'],'urn:hdl') or starts-with(marc:subfield[@code='u'],'hdl') or starts-with(marc:subfield[@code='u'],'http://hdl.loc.gov') ">
3903 <xsl:value-of select="concat('hdl:',substring-after(marc:subfield[@code='u'],'http://hdl.loc.gov/'))"></xsl:value-of>
3906 <xsl:value-of select="marc:subfield[@code='u']"></xsl:value-of>
3910 <xsl:if test="starts-with(marc:subfield[@code='u'],'urn:hdl') or starts-with(marc:subfield[@code='u'],'hdl')">
3911 <identifier type="hdl">
3912 <xsl:if test="marc:subfield[@code='y' or @code='3' or @code='z']">
3913 <xsl:attribute name="displayLabel">
3914 <xsl:call-template name="subfieldSelect">
3915 <xsl:with-param name="codes">y3z</xsl:with-param>
3916 </xsl:call-template>
3919 <xsl:value-of select="concat('hdl:',substring-after(marc:subfield[@code='u'],'http://hdl.loc.gov/'))"></xsl:value-of>
3923 <xsl:for-each select="marc:datafield[@tag=024][@ind1=1]">
3924 <identifier type="upc">
3925 <xsl:call-template name="isInvalid"/>
3926 <xsl:value-of select="marc:subfield[@code='a']"/>
3929 <!-- 1/04 fix added $y -->
3930 <xsl:for-each select="marc:datafield[@tag=856][marc:subfield[@code='u']]">
3933 <xsl:if test="marc:subfield[@code='y' or @code='3']">
3934 <xsl:attribute name="displayLabel">
3935 <xsl:call-template name="subfieldSelect">
3936 <xsl:with-param name="codes">y3</xsl:with-param>
3937 </xsl:call-template>
3940 <xsl:if test="marc:subfield[@code='z' ]">
3941 <xsl:attribute name="note">
3942 <xsl:call-template name="subfieldSelect">
3943 <xsl:with-param name="codes">z</xsl:with-param>
3944 </xsl:call-template>
3947 <xsl:value-of select="marc:subfield[@code='u']"></xsl:value-of>
3953 <!-- 3.2 change tmee 856z -->
3956 <xsl:for-each select="marc:datafield[@tag=852]">
3959 <xsl:call-template name="displayLabel"></xsl:call-template>
3960 <xsl:call-template name="subfieldSelect">
3961 <xsl:with-param name="codes">abje</xsl:with-param>
3962 </xsl:call-template>
3966 <xsl:for-each select="marc:datafield[@tag=506]">
3967 <accessCondition type="restrictionOnAccess">
3968 <xsl:call-template name="subfieldSelect">
3969 <xsl:with-param name="codes">abcd35</xsl:with-param>
3970 </xsl:call-template>
3973 <xsl:for-each select="marc:datafield[@tag=540]">
3974 <accessCondition type="useAndReproduction">
3975 <xsl:call-template name="subfieldSelect">
3976 <xsl:with-param name="codes">abcde35</xsl:with-param>
3977 </xsl:call-template>
3981 <xsl:for-each select="marc:datafield[@tag=040]">
3982 <recordContentSource authority="marcorg">
3983 <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
3984 </recordContentSource>
3986 <xsl:for-each select="marc:controlfield[@tag=008]">
3987 <recordCreationDate encoding="marc">
3988 <xsl:value-of select="substring(.,1,6)"></xsl:value-of>
3989 </recordCreationDate>
3991 <xsl:for-each select="marc:controlfield[@tag=005]">
3992 <recordChangeDate encoding="iso8601">
3993 <xsl:value-of select="."></xsl:value-of>
3996 <xsl:for-each select="marc:controlfield[@tag=001]">
3998 <xsl:if test="../marc:controlfield[@tag=003]">
3999 <xsl:attribute name="source">
4000 <xsl:value-of select="../marc:controlfield[@tag=003]"></xsl:value-of>
4003 <xsl:value-of select="."></xsl:value-of>
4006 <xsl:for-each select="marc:datafield[@tag=040]/marc:subfield[@code='b']">
4007 <languageOfCataloging>
4008 <languageTerm authority="iso639-2b" type="code">
4009 <xsl:value-of select="."></xsl:value-of>
4011 </languageOfCataloging>
4015 <xsl:template name="displayForm">
4016 <xsl:for-each select="marc:subfield[@code='c']">
4018 <xsl:value-of select="."></xsl:value-of>
4022 <xsl:template name="affiliation">
4023 <xsl:for-each select="marc:subfield[@code='u']">
4025 <xsl:value-of select="."></xsl:value-of>
4029 <xsl:template name="uri">
4030 <xsl:for-each select="marc:subfield[@code='u']">
4031 <xsl:attribute name="xlink:href">
4032 <xsl:value-of select="."></xsl:value-of>
4035 <xsl:for-each select="marc:subfield[@code='0']">
4037 <xsl:when test="contains(text(), ')')">
4038 <xsl:attribute name="xlink:href">
4039 <xsl:value-of select="substring-after(text(), ')')"></xsl:value-of>
4043 <xsl:attribute name="xlink:href">
4044 <xsl:value-of select="."></xsl:value-of>
4050 <xsl:template name="role">
4051 <xsl:for-each select="marc:subfield[@code='e']">
4053 <roleTerm type="text">
4054 <xsl:value-of select="."></xsl:value-of>
4058 <xsl:for-each select="marc:subfield[@code='4']">
4060 <roleTerm authority="marcrelator" type="code">
4061 <xsl:value-of select="."></xsl:value-of>
4066 <xsl:template name="part">
4067 <xsl:variable name="partNumber">
4068 <xsl:call-template name="specialSubfieldSelect">
4069 <xsl:with-param name="axis">n</xsl:with-param>
4070 <xsl:with-param name="anyCodes">n</xsl:with-param>
4071 <xsl:with-param name="afterCodes">fgkdlmor</xsl:with-param>
4072 </xsl:call-template>
4074 <xsl:variable name="partName">
4075 <xsl:call-template name="specialSubfieldSelect">
4076 <xsl:with-param name="axis">p</xsl:with-param>
4077 <xsl:with-param name="anyCodes">p</xsl:with-param>
4078 <xsl:with-param name="afterCodes">fgkdlmor</xsl:with-param>
4079 </xsl:call-template>
4081 <xsl:if test="string-length(normalize-space($partNumber))">
4083 <xsl:call-template name="chopPunctuation">
4084 <xsl:with-param name="chopString" select="$partNumber"></xsl:with-param>
4085 </xsl:call-template>
4088 <xsl:if test="string-length(normalize-space($partName))">
4090 <xsl:call-template name="chopPunctuation">
4091 <xsl:with-param name="chopString" select="$partName"></xsl:with-param>
4092 </xsl:call-template>
4096 <xsl:template name="relatedPart">
4097 <xsl:if test="@tag=773">
4098 <xsl:for-each select="marc:subfield[@code='g']">
4101 <xsl:value-of select="."></xsl:value-of>
4105 <xsl:for-each select="marc:subfield[@code='q']">
4107 <xsl:call-template name="parsePart"></xsl:call-template>
4112 <xsl:template name="relatedPartNumName">
4113 <xsl:variable name="partNumber">
4114 <xsl:call-template name="specialSubfieldSelect">
4115 <xsl:with-param name="axis">g</xsl:with-param>
4116 <xsl:with-param name="anyCodes">g</xsl:with-param>
4117 <xsl:with-param name="afterCodes">pst</xsl:with-param>
4118 </xsl:call-template>
4120 <xsl:variable name="partName">
4121 <xsl:call-template name="specialSubfieldSelect">
4122 <xsl:with-param name="axis">p</xsl:with-param>
4123 <xsl:with-param name="anyCodes">p</xsl:with-param>
4124 <xsl:with-param name="afterCodes">fgkdlmor</xsl:with-param>
4125 </xsl:call-template>
4127 <xsl:if test="string-length(normalize-space($partNumber))">
4129 <xsl:value-of select="$partNumber"></xsl:value-of>
4132 <xsl:if test="string-length(normalize-space($partName))">
4134 <xsl:value-of select="$partName"></xsl:value-of>
4138 <xsl:template name="relatedName">
4139 <xsl:for-each select="marc:subfield[@code='a']">
4142 <xsl:value-of select="."></xsl:value-of>
4147 <xsl:template name="relatedForm">
4148 <xsl:for-each select="marc:subfield[@code='h']">
4149 <physicalDescription>
4151 <xsl:value-of select="."></xsl:value-of>
4153 </physicalDescription>
4156 <xsl:template name="relatedExtent">
4157 <xsl:for-each select="marc:subfield[@code='h']">
4158 <physicalDescription>
4160 <xsl:value-of select="."></xsl:value-of>
4162 </physicalDescription>
4165 <xsl:template name="relatedNote">
4166 <xsl:for-each select="marc:subfield[@code='n']">
4168 <xsl:value-of select="."></xsl:value-of>
4172 <xsl:template name="relatedSubject">
4173 <xsl:for-each select="marc:subfield[@code='j']">
4175 <temporal encoding="iso8601">
4176 <xsl:call-template name="chopPunctuation">
4177 <xsl:with-param name="chopString" select="."></xsl:with-param>
4178 </xsl:call-template>
4183 <xsl:template name="relatedIdentifierISSN">
4184 <xsl:for-each select="marc:subfield[@code='x']">
4185 <identifier type="issn">
4186 <xsl:value-of select="."></xsl:value-of>
4190 <xsl:template name="relatedIdentifierLocal">
4191 <xsl:for-each select="marc:subfield[@code='w']">
4192 <identifier type="local">
4193 <xsl:value-of select="."></xsl:value-of>
4197 <xsl:template name="relatedIdentifier">
4198 <xsl:for-each select="marc:subfield[@code='o']">
4200 <xsl:value-of select="."></xsl:value-of>
4204 <xsl:template name="relatedItem76X-78X">
4205 <xsl:call-template name="displayLabel"></xsl:call-template>
4206 <xsl:call-template name="relatedTitle76X-78X"></xsl:call-template>
4207 <xsl:call-template name="relatedName"></xsl:call-template>
4208 <xsl:call-template name="relatedOriginInfo"></xsl:call-template>
4209 <xsl:call-template name="relatedLanguage"></xsl:call-template>
4210 <xsl:call-template name="relatedExtent"></xsl:call-template>
4211 <xsl:call-template name="relatedNote"></xsl:call-template>
4212 <xsl:call-template name="relatedSubject"></xsl:call-template>
4213 <xsl:call-template name="relatedIdentifier"></xsl:call-template>
4214 <xsl:call-template name="relatedIdentifierISSN"></xsl:call-template>
4215 <xsl:call-template name="relatedIdentifierLocal"></xsl:call-template>
4216 <xsl:call-template name="relatedPart"></xsl:call-template>
4218 <xsl:template name="subjectGeographicZ">
4220 <xsl:call-template name="chopPunctuation">
4221 <xsl:with-param name="chopString" select="."></xsl:with-param>
4222 </xsl:call-template>
4225 <xsl:template name="subjectTemporalY">
4227 <xsl:call-template name="chopPunctuation">
4228 <xsl:with-param name="chopString" select="."></xsl:with-param>
4229 </xsl:call-template>
4232 <xsl:template name="subjectTopic">
4234 <xsl:call-template name="chopPunctuation">
4235 <xsl:with-param name="chopString" select="."></xsl:with-param>
4236 </xsl:call-template>
4239 <!-- 3.2 change tmee 6xx $v genre -->
4240 <xsl:template name="subjectGenre">
4242 <xsl:call-template name="chopPunctuation">
4243 <xsl:with-param name="chopString" select="."></xsl:with-param>
4244 </xsl:call-template>
4248 <xsl:template name="nameABCDN">
4249 <xsl:for-each select="marc:subfield[@code='a']">
4251 <xsl:call-template name="chopPunctuation">
4252 <xsl:with-param name="chopString" select="."></xsl:with-param>
4253 </xsl:call-template>
4256 <xsl:for-each select="marc:subfield[@code='b']">
4258 <xsl:value-of select="."></xsl:value-of>
4261 <xsl:if test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">
4263 <xsl:call-template name="subfieldSelect">
4264 <xsl:with-param name="codes">cdn</xsl:with-param>
4265 </xsl:call-template>
4269 <xsl:template name="nameABCDQ">
4271 <xsl:call-template name="chopPunctuation">
4272 <xsl:with-param name="chopString">
4273 <xsl:call-template name="subfieldSelect">
4274 <xsl:with-param name="codes">aq</xsl:with-param>
4275 </xsl:call-template>
4277 <xsl:with-param name="punctuation">
4278 <xsl:text>:,;/ </xsl:text>
4280 </xsl:call-template>
4282 <xsl:call-template name="termsOfAddress"></xsl:call-template>
4283 <xsl:call-template name="nameDate"></xsl:call-template>
4285 <xsl:template name="nameACDEQ">
4287 <xsl:call-template name="subfieldSelect">
4288 <xsl:with-param name="codes">acdeq</xsl:with-param>
4289 </xsl:call-template>
4292 <xsl:template name="constituentOrRelatedType">
4293 <xsl:if test="@ind2=2">
4294 <xsl:attribute name="type">constituent</xsl:attribute>
4297 <xsl:template name="relatedTitle">
4298 <xsl:for-each select="marc:subfield[@code='t']">
4301 <xsl:call-template name="chopPunctuation">
4302 <xsl:with-param name="chopString">
4303 <xsl:value-of select="."></xsl:value-of>
4305 </xsl:call-template>
4310 <xsl:template name="relatedTitle76X-78X">
4311 <xsl:for-each select="marc:subfield[@code='t']">
4314 <xsl:call-template name="chopPunctuation">
4315 <xsl:with-param name="chopString">
4316 <xsl:value-of select="."></xsl:value-of>
4318 </xsl:call-template>
4320 <xsl:if test="marc:datafield[@tag!=773]and marc:subfield[@code='g']">
4321 <xsl:call-template name="relatedPartNumName"></xsl:call-template>
4325 <xsl:for-each select="marc:subfield[@code='p']">
4326 <titleInfo type="abbreviated">
4328 <xsl:call-template name="chopPunctuation">
4329 <xsl:with-param name="chopString">
4330 <xsl:value-of select="."></xsl:value-of>
4332 </xsl:call-template>
4334 <xsl:if test="marc:datafield[@tag!=773]and marc:subfield[@code='g']">
4335 <xsl:call-template name="relatedPartNumName"></xsl:call-template>
4339 <xsl:for-each select="marc:subfield[@code='s']">
4340 <titleInfo type="uniform">
4342 <xsl:call-template name="chopPunctuation">
4343 <xsl:with-param name="chopString">
4344 <xsl:value-of select="."></xsl:value-of>
4346 </xsl:call-template>
4348 <xsl:if test="marc:datafield[@tag!=773]and marc:subfield[@code='g']">
4349 <xsl:call-template name="relatedPartNumName"></xsl:call-template>
4354 <xsl:template name="relatedOriginInfo">
4355 <xsl:if test="marc:subfield[@code='b' or @code='d'] or marc:subfield[@code='f']">
4357 <xsl:if test="@tag=775">
4358 <xsl:for-each select="marc:subfield[@code='f']">
4361 <xsl:attribute name="type">code</xsl:attribute>
4362 <xsl:attribute name="authority">marcgac</xsl:attribute>
4363 <xsl:value-of select="."></xsl:value-of>
4368 <xsl:for-each select="marc:subfield[@code='d']">
4370 <xsl:value-of select="."></xsl:value-of>
4373 <xsl:for-each select="marc:subfield[@code='b']">
4375 <xsl:value-of select="."></xsl:value-of>
4381 <xsl:template name="relatedLanguage">
4382 <xsl:for-each select="marc:subfield[@code='e']">
4383 <xsl:call-template name="getLanguage">
4384 <xsl:with-param name="langString">
4385 <xsl:value-of select="."></xsl:value-of>
4387 </xsl:call-template>
4390 <xsl:template name="nameDate">
4391 <xsl:for-each select="marc:subfield[@code='d']">
4392 <namePart type="date">
4393 <xsl:call-template name="chopPunctuation">
4394 <xsl:with-param name="chopString" select="."></xsl:with-param>
4395 </xsl:call-template>
4399 <xsl:template name="subjectAuthority">
4400 <xsl:if test="@ind2!=4">
4401 <xsl:if test="@ind2!=' '">
4402 <xsl:if test="@ind2!=8">
4403 <xsl:if test="@ind2!=9">
4404 <xsl:attribute name="authority">
4406 <xsl:when test="@ind2=0">lcsh</xsl:when>
4407 <xsl:when test="@ind2=1">lcshac</xsl:when>
4408 <xsl:when test="@ind2=2">mesh</xsl:when>
4410 <xsl:when test="@ind2=3">nal</xsl:when>
4411 <xsl:when test="@ind2=5">csh</xsl:when>
4412 <xsl:when test="@ind2=6">rvm</xsl:when>
4413 <xsl:when test="@ind2=7">
4414 <xsl:value-of select="marc:subfield[@code='2']"></xsl:value-of>
4423 <xsl:template name="subjectAnyOrder">
4424 <xsl:for-each select="marc:subfield[@code='v' or @code='x' or @code='y' or @code='z']">
4426 <xsl:when test="@code='v'">
4427 <xsl:call-template name="subjectGenre"></xsl:call-template>
4429 <xsl:when test="@code='x'">
4430 <xsl:call-template name="subjectTopic"></xsl:call-template>
4432 <xsl:when test="@code='y'">
4433 <xsl:call-template name="subjectTemporalY"></xsl:call-template>
4435 <xsl:when test="@code='z'">
4436 <xsl:call-template name="subjectGeographicZ"></xsl:call-template>
4441 <xsl:template name="specialSubfieldSelect">
4442 <xsl:param name="anyCodes"></xsl:param>
4443 <xsl:param name="axis"></xsl:param>
4444 <xsl:param name="beforeCodes"></xsl:param>
4445 <xsl:param name="afterCodes"></xsl:param>
4446 <xsl:variable name="str">
4447 <xsl:for-each select="marc:subfield">
4448 <xsl:if test="contains($anyCodes, @code) or (contains($beforeCodes,@code) and following-sibling::marc:subfield[@code=$axis]) or (contains($afterCodes,@code) and preceding-sibling::marc:subfield[@code=$axis])">
4449 <xsl:value-of select="text()"></xsl:value-of>
4450 <xsl:text> </xsl:text>
4454 <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
4457 <!-- 3.2 change tmee 6xx $v genre -->
4458 <xsl:template match="marc:datafield[@tag=600]">
4460 <xsl:call-template name="subjectAuthority"></xsl:call-template>
4461 <name type="personal">
4462 <xsl:call-template name="uri" />
4464 <xsl:call-template name="chopPunctuation">
4465 <xsl:with-param name="chopString">
4466 <xsl:call-template name="subfieldSelect">
4467 <xsl:with-param name="codes">aq</xsl:with-param>
4468 </xsl:call-template>
4470 </xsl:call-template>
4472 <xsl:call-template name="termsOfAddress"></xsl:call-template>
4473 <xsl:call-template name="nameDate"></xsl:call-template>
4474 <xsl:call-template name="affiliation"></xsl:call-template>
4475 <xsl:call-template name="role"></xsl:call-template>
4477 <xsl:call-template name="subjectAnyOrder"></xsl:call-template>
4480 <xsl:template match="marc:datafield[@tag=610]">
4482 <xsl:call-template name="subjectAuthority"></xsl:call-template>
4483 <name type="corporate">
4484 <xsl:call-template name="uri" />
4485 <xsl:for-each select="marc:subfield[@code='a']">
4487 <xsl:value-of select="."></xsl:value-of>
4490 <xsl:for-each select="marc:subfield[@code='b']">
4492 <xsl:value-of select="."></xsl:value-of>
4495 <xsl:if test="marc:subfield[@code='c' or @code='d' or @code='n' or @code='p']">
4497 <xsl:call-template name="subfieldSelect">
4498 <xsl:with-param name="codes">cdnp</xsl:with-param>
4499 </xsl:call-template>
4502 <xsl:call-template name="role"></xsl:call-template>
4504 <xsl:call-template name="subjectAnyOrder"></xsl:call-template>
4507 <xsl:template match="marc:datafield[@tag=611]">
4509 <xsl:call-template name="subjectAuthority"></xsl:call-template>
4510 <name type="conference">
4511 <xsl:call-template name="uri" />
4513 <xsl:call-template name="subfieldSelect">
4514 <xsl:with-param name="codes">abcdeqnp</xsl:with-param>
4515 </xsl:call-template>
4517 <xsl:for-each select="marc:subfield[@code='4']">
4519 <roleTerm authority="marcrelator" type="code">
4520 <xsl:value-of select="."></xsl:value-of>
4525 <xsl:call-template name="subjectAnyOrder"></xsl:call-template>
4528 <xsl:template match="marc:datafield[@tag=630]">
4530 <xsl:call-template name="subjectAuthority"></xsl:call-template>
4531 <xsl:variable name="titleChop">
4532 <xsl:call-template name="chopPunctuation">
4533 <xsl:with-param name="chopString">
4534 <xsl:call-template name="subfieldSelect">
4535 <xsl:with-param name="codes">adfhklor</xsl:with-param>
4536 </xsl:call-template>
4538 </xsl:call-template>
4542 <xsl:value-of select="$titleChop" />
4544 <xsl:call-template name="part"></xsl:call-template>
4546 <titleInfo type="nfi">
4548 <xsl:when test="@ind1>0">
4550 <xsl:value-of select="substring($titleChop,1,@ind1)"/>
4553 <xsl:value-of select="substring($titleChop,@ind1+1)"/>
4555 <xsl:call-template name="part"/>
4559 <xsl:value-of select="$titleChop" />
4563 <xsl:call-template name="part"></xsl:call-template>
4565 <xsl:call-template name="subjectAnyOrder"></xsl:call-template>
4568 <xsl:template match="marc:datafield[@tag=650]">
4570 <xsl:call-template name="subjectAuthority"></xsl:call-template>
4572 <xsl:call-template name="uri" />
4573 <xsl:call-template name="chopPunctuation">
4574 <xsl:with-param name="chopString">
4575 <xsl:call-template name="subfieldSelect">
4576 <xsl:with-param name="codes">abcd</xsl:with-param>
4577 </xsl:call-template>
4579 </xsl:call-template>
4581 <xsl:call-template name="subjectAnyOrder"></xsl:call-template>
4584 <xsl:template match="marc:datafield[@tag=651]">
4586 <xsl:call-template name="subjectAuthority"></xsl:call-template>
4587 <xsl:for-each select="marc:subfield[@code='a']">
4589 <xsl:call-template name="uri" />
4590 <xsl:call-template name="chopPunctuation">
4591 <xsl:with-param name="chopString" select="."></xsl:with-param>
4592 </xsl:call-template>
4595 <xsl:call-template name="subjectAnyOrder"></xsl:call-template>
4598 <xsl:template match="marc:datafield[@tag=653]">
4600 <xsl:for-each select="marc:subfield[@code='a']">
4602 <xsl:call-template name="uri" />
4603 <xsl:value-of select="."></xsl:value-of>
4608 <xsl:template match="marc:datafield[@tag=656]">
4610 <xsl:if test="marc:subfield[@code=2]">
4611 <xsl:attribute name="authority">
4612 <xsl:value-of select="marc:subfield[@code=2]"></xsl:value-of>
4616 <xsl:call-template name="uri" />
4617 <xsl:call-template name="chopPunctuation">
4618 <xsl:with-param name="chopString">
4619 <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
4621 </xsl:call-template>
4625 <xsl:template name="termsOfAddress">
4626 <xsl:if test="marc:subfield[@code='b' or @code='c']">
4627 <namePart type="termsOfAddress">
4628 <xsl:call-template name="chopPunctuation">
4629 <xsl:with-param name="chopString">
4630 <xsl:call-template name="subfieldSelect">
4631 <xsl:with-param name="codes">bc</xsl:with-param>
4632 </xsl:call-template>
4634 </xsl:call-template>
4638 <xsl:template name="displayLabel">
4639 <xsl:if test="marc:subfield[@code='i']">
4640 <xsl:attribute name="displayLabel">
4641 <xsl:value-of select="marc:subfield[@code='i']"></xsl:value-of>
4644 <xsl:if test="marc:subfield[@code='3']">
4645 <xsl:attribute name="displayLabel">
4646 <xsl:value-of select="marc:subfield[@code='3']"></xsl:value-of>
4650 <xsl:template name="isInvalid">
4651 <xsl:param name="type"/>
4652 <xsl:if test="marc:subfield[@code='z'] or marc:subfield[@code='y']">
4654 <xsl:attribute name="type">
4655 <xsl:value-of select="$type"/>
4657 <xsl:attribute name="invalid">
4658 <xsl:text>yes</xsl:text>
4660 <xsl:if test="marc:subfield[@code='z']">
4661 <xsl:value-of select="marc:subfield[@code='z']"/>
4663 <xsl:if test="marc:subfield[@code='y']">
4664 <xsl:value-of select="marc:subfield[@code='y']"/>
4669 <xsl:template name="subtitle">
4670 <xsl:if test="marc:subfield[@code='b']">
4672 <xsl:call-template name="chopPunctuation">
4673 <xsl:with-param name="chopString">
4674 <xsl:value-of select="marc:subfield[@code='b']"/>
4675 <!--<xsl:call-template name="subfieldSelect">
4676 <xsl:with-param name="codes">b</xsl:with-param>
4677 </xsl:call-template>-->
4679 </xsl:call-template>
4683 <xsl:template name="script">
4684 <xsl:param name="scriptCode"></xsl:param>
4685 <xsl:attribute name="script">
4687 <xsl:when test="$scriptCode='(3'">Arabic</xsl:when>
4688 <xsl:when test="$scriptCode='(B'">Latin</xsl:when>
4689 <xsl:when test="$scriptCode='$1'">Chinese, Japanese, Korean</xsl:when>
4690 <xsl:when test="$scriptCode='(N'">Cyrillic</xsl:when>
4691 <xsl:when test="$scriptCode='(2'">Hebrew</xsl:when>
4692 <xsl:when test="$scriptCode='(S'">Greek</xsl:when>
4696 <xsl:template name="parsePart">
4697 <!-- assumes 773$q= 1:2:3<4
4698 with up to 3 levels and one optional start page
4700 <xsl:variable name="level1">
4702 <xsl:when test="contains(text(),':')">
4704 <xsl:value-of select="substring-before(text(),':')"></xsl:value-of>
4706 <xsl:when test="not(contains(text(),':'))">
4708 <xsl:if test="contains(text(),'<')">
4710 <xsl:value-of select="substring-before(text(),'<')"></xsl:value-of>
4712 <xsl:if test="not(contains(text(),'<'))">
4714 <xsl:value-of select="text()"></xsl:value-of>
4719 <xsl:variable name="sici2">
4721 <xsl:when test="starts-with(substring-after(text(),$level1),':')">
4722 <xsl:value-of select="substring(substring-after(text(),$level1),2)"></xsl:value-of>
4725 <xsl:value-of select="substring-after(text(),$level1)"></xsl:value-of>
4729 <xsl:variable name="level2">
4731 <xsl:when test="contains($sici2,':')">
4733 <xsl:value-of select="substring-before($sici2,':')"></xsl:value-of>
4735 <xsl:when test="contains($sici2,'<')">
4737 <xsl:value-of select="substring-before($sici2,'<')"></xsl:value-of>
4740 <xsl:value-of select="$sici2"></xsl:value-of>
4745 <xsl:variable name="sici3">
4747 <xsl:when test="starts-with(substring-after($sici2,$level2),':')">
4748 <xsl:value-of select="substring(substring-after($sici2,$level2),2)"></xsl:value-of>
4751 <xsl:value-of select="substring-after($sici2,$level2)"></xsl:value-of>
4755 <xsl:variable name="level3">
4757 <xsl:when test="contains($sici3,'<')">
4759 <xsl:value-of select="substring-before($sici3,'<')"></xsl:value-of>
4762 <xsl:value-of select="$sici3"></xsl:value-of>
4767 <xsl:variable name="page">
4768 <xsl:if test="contains(text(),'<')">
4769 <xsl:value-of select="substring-after(text(),'<')"></xsl:value-of>
4772 <xsl:if test="$level1">
4775 <xsl:value-of select="$level1"></xsl:value-of>
4779 <xsl:if test="$level2">
4782 <xsl:value-of select="$level2"></xsl:value-of>
4786 <xsl:if test="$level3">
4789 <xsl:value-of select="$level3"></xsl:value-of>
4793 <xsl:if test="$page">
4794 <extent unit="page">
4796 <xsl:value-of select="$page"></xsl:value-of>
4801 <xsl:template name="getLanguage">
4802 <xsl:param name="langString"></xsl:param>
4803 <xsl:param name="controlField008-35-37"></xsl:param>
4804 <xsl:variable name="length" select="string-length($langString)"></xsl:variable>
4806 <xsl:when test="$length=0"></xsl:when>
4807 <xsl:when test="$controlField008-35-37=substring($langString,1,3)">
4808 <xsl:call-template name="getLanguage">
4809 <xsl:with-param name="langString" select="substring($langString,4,$length)"></xsl:with-param>
4810 <xsl:with-param name="controlField008-35-37" select="$controlField008-35-37"></xsl:with-param>
4811 </xsl:call-template>
4815 <languageTerm authority="iso639-2b" type="code">
4816 <xsl:value-of select="substring($langString,1,3)"></xsl:value-of>
4819 <xsl:call-template name="getLanguage">
4820 <xsl:with-param name="langString" select="substring($langString,4,$length)"></xsl:with-param>
4821 <xsl:with-param name="controlField008-35-37" select="$controlField008-35-37"></xsl:with-param>
4822 </xsl:call-template>
4826 <xsl:template name="isoLanguage">
4827 <xsl:param name="currentLanguage"></xsl:param>
4828 <xsl:param name="usedLanguages"></xsl:param>
4829 <xsl:param name="remainingLanguages"></xsl:param>
4831 <xsl:when test="string-length($currentLanguage)=0"></xsl:when>
4832 <xsl:when test="not(contains($usedLanguages, $currentLanguage))">
4834 <xsl:if test="@code!='a'">
4835 <xsl:attribute name="objectPart">
4837 <xsl:when test="@code='b'">summary or subtitle</xsl:when>
4838 <xsl:when test="@code='d'">sung or spoken text</xsl:when>
4839 <xsl:when test="@code='e'">libretto</xsl:when>
4840 <xsl:when test="@code='f'">table of contents</xsl:when>
4841 <xsl:when test="@code='g'">accompanying material</xsl:when>
4842 <xsl:when test="@code='h'">translation</xsl:when>
4846 <languageTerm authority="iso639-2b" type="code">
4847 <xsl:value-of select="$currentLanguage"></xsl:value-of>
4850 <xsl:call-template name="isoLanguage">
4851 <xsl:with-param name="currentLanguage">
4852 <xsl:value-of select="substring($remainingLanguages,1,3)"></xsl:value-of>
4854 <xsl:with-param name="usedLanguages">
4855 <xsl:value-of select="concat($usedLanguages,$currentLanguage)"></xsl:value-of>
4857 <xsl:with-param name="remainingLanguages">
4858 <xsl:value-of select="substring($remainingLanguages,4,string-length($remainingLanguages))"></xsl:value-of>
4860 </xsl:call-template>
4863 <xsl:call-template name="isoLanguage">
4864 <xsl:with-param name="currentLanguage">
4865 <xsl:value-of select="substring($remainingLanguages,1,3)"></xsl:value-of>
4867 <xsl:with-param name="usedLanguages">
4868 <xsl:value-of select="concat($usedLanguages,$currentLanguage)"></xsl:value-of>
4870 <xsl:with-param name="remainingLanguages">
4871 <xsl:value-of select="substring($remainingLanguages,4,string-length($remainingLanguages))"></xsl:value-of>
4873 </xsl:call-template>
4877 <xsl:template name="chopBrackets">
4878 <xsl:param name="chopString"></xsl:param>
4879 <xsl:variable name="string">
4880 <xsl:call-template name="chopPunctuation">
4881 <xsl:with-param name="chopString" select="$chopString"></xsl:with-param>
4882 </xsl:call-template>
4884 <xsl:if test="substring($string, 1,1)='['">
4885 <xsl:value-of select="substring($string,2, string-length($string)-2)"></xsl:value-of>
4887 <xsl:if test="substring($string, 1,1)!='['">
4888 <xsl:value-of select="$string"></xsl:value-of>
4891 <xsl:template name="rfcLanguages">
4892 <xsl:param name="nodeNum"></xsl:param>
4893 <xsl:param name="usedLanguages"></xsl:param>
4894 <xsl:param name="controlField008-35-37"></xsl:param>
4895 <xsl:variable name="currentLanguage" select="."></xsl:variable>
4897 <xsl:when test="not($currentLanguage)"></xsl:when>
4898 <xsl:when test="$currentLanguage!=$controlField008-35-37 and $currentLanguage!='rfc3066'">
4899 <xsl:if test="not(contains($usedLanguages,$currentLanguage))">
4901 <xsl:if test="@code!='a'">
4902 <xsl:attribute name="objectPart">
4904 <xsl:when test="@code='b'">summary or subtitle</xsl:when>
4905 <xsl:when test="@code='d'">sung or spoken text</xsl:when>
4906 <xsl:when test="@code='e'">libretto</xsl:when>
4907 <xsl:when test="@code='f'">table of contents</xsl:when>
4908 <xsl:when test="@code='g'">accompanying material</xsl:when>
4909 <xsl:when test="@code='h'">translation</xsl:when>
4913 <languageTerm authority="rfc3066" type="code">
4914 <xsl:value-of select="$currentLanguage"/>
4923 <xsl:template name="datafield">
4924 <xsl:param name="tag"/>
4925 <xsl:param name="ind1"><xsl:text> </xsl:text></xsl:param>
4926 <xsl:param name="ind2"><xsl:text> </xsl:text></xsl:param>
4927 <xsl:param name="subfields"/>
4928 <xsl:element name="marc:datafield">
4929 <xsl:attribute name="tag">
4930 <xsl:value-of select="$tag"/>
4932 <xsl:attribute name="ind1">
4933 <xsl:value-of select="$ind1"/>
4935 <xsl:attribute name="ind2">
4936 <xsl:value-of select="$ind2"/>
4938 <xsl:copy-of select="$subfields"/>
4942 <xsl:template name="subfieldSelect">
4943 <xsl:param name="codes"/>
4944 <xsl:param name="delimeter"><xsl:text> </xsl:text></xsl:param>
4945 <xsl:variable name="str">
4946 <xsl:for-each select="marc:subfield">
4947 <xsl:if test="contains($codes, @code)">
4948 <xsl:value-of select="text()"/><xsl:value-of select="$delimeter"/>
4952 <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
4955 <xsl:template name="buildSpaces">
4956 <xsl:param name="spaces"/>
4957 <xsl:param name="char"><xsl:text> </xsl:text></xsl:param>
4958 <xsl:if test="$spaces>0">
4959 <xsl:value-of select="$char"/>
4960 <xsl:call-template name="buildSpaces">
4961 <xsl:with-param name="spaces" select="$spaces - 1"/>
4962 <xsl:with-param name="char" select="$char"/>
4963 </xsl:call-template>
4967 <xsl:template name="chopPunctuation">
4968 <xsl:param name="chopString"/>
4969 <xsl:param name="punctuation"><xsl:text>.:,;/ </xsl:text></xsl:param>
4970 <xsl:variable name="length" select="string-length($chopString)"/>
4972 <xsl:when test="$length=0"/>
4973 <xsl:when test="contains($punctuation, substring($chopString,$length,1))">
4974 <xsl:call-template name="chopPunctuation">
4975 <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
4976 <xsl:with-param name="punctuation" select="$punctuation"/>
4977 </xsl:call-template>
4979 <xsl:when test="not($chopString)"/>
4980 <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>
4984 <xsl:template name="chopPunctuationFront">
4985 <xsl:param name="chopString"/>
4986 <xsl:variable name="length" select="string-length($chopString)"/>
4988 <xsl:when test="$length=0"/>
4989 <xsl:when test="contains('.:,;/[ ', substring($chopString,1,1))">
4990 <xsl:call-template name="chopPunctuationFront">
4991 <xsl:with-param name="chopString" select="substring($chopString,2,$length - 1)"/>
4992 </xsl:call-template>
4994 <xsl:when test="not($chopString)"/>
4995 <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>
4998 </xsl:stylesheet>$XXXX$ where name = $$mods32$$;
5000 update config.xml_transform set xslt = $XXXX$<xsl:stylesheet xmlns="http://www.loc.gov/mods/v3" xmlns:marc="http://www.loc.gov/MARC21/slim"
5001 xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5002 exclude-result-prefixes="xlink marc" version="1.0">
5003 <xsl:output encoding="UTF-8" indent="yes" method="xml"/>
5005 <xsl:variable name="ascii">
5006 <xsl:text> !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~</xsl:text>
5009 <xsl:variable name="latin1">
5010 <xsl:text> ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ</xsl:text>
5012 <!-- Characters that usually don't need to be escaped -->
5013 <xsl:variable name="safe">
5014 <xsl:text>!'()*-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~</xsl:text>
5017 <xsl:variable name="hex">0123456789ABCDEF</xsl:variable>
5019 <!-- Evergreen specific: revert Revision 1.23, so we can have those authority xlink attributes back. -->
5021 <!--MARC21slim2MODS3-3.xsl
5022 Revision 1.27 - Mapped 648 to <subject> 2009/03/13 tmee
5023 Revision 1.26 - Added subfield $s mapping for 130/240/730 2008/10/16 tmee
5024 Revision 1.25 - Mapped 040e to <descriptiveStandard> and Leader/18 to <descriptive standard>aacr2 2008/09/18 tmee
5025 Revision 1.24 - Mapped 852 subfields $h, $i, $j, $k, $l, $m, $t to <shelfLocation> and 852 subfield $u to <physicalLocation> with @xlink 2008/09/17 tmee
5026 Revision 1.23 - Commented out xlink/uri for subfield 0 for 130/240/730, 100/700, 110/710, 111/711 as these are currently unactionable 2008/09/17 tmee
5027 Revision 1.22 - Mapped 022 subfield $l to type "issn-l" subfield $m to output identifier element with corresponding @type and @invalid eq 'yes'2008/09/17 tmee
5028 Revision 1.21 - Mapped 856 ind2=1 or ind2=2 to <relatedItem><location><url> 2008/07/03 tmee
5029 Revision 1.20 - Added genre w/@auth="contents of 2" and type= "musical composition" 2008/07/01 tmee
5030 Revision 1.19 - Added genre offprint for 008/24+ BK code 2 2008/07/01 tmee
5031 Revision 1.18 - Added xlink/uri for subfield 0 for 130/240/730, 100/700, 110/710, 111/711 2008/06/26 tmee
5032 Revision 1.17 - Added mapping of 662 2008/05/14 tmee
5033 Revision 1.16 - Changed @authority from "marc" to "marcgt" for 007 and 008 codes mapped to a term in <genre> 2007/07/10 tmee
5034 Revision 1.15 - For field 630, moved call to part template outside title element 2007/07/10 tmee
5035 Revision 1.14 - Fixed template isValid and fields 010, 020, 022, 024, 028, and 037 to output additional identifier elements with corresponding @type and @invalid eq 'yes' when subfields z or y (in the case of 022) exist in the MARCXML ::: 2007/01/04 17:35:20 cred
5036 Revision 1.13 - Changed order of output under cartographics to reflect schema 2006/11/28 tmee
5037 Revision 1.12 - Updated to reflect MODS 3.2 Mapping 2006/10/11 tmee
5038 Revision 1.11 - The attribute objectPart moved from <languageTerm> to <language> 2006/04/08 jrad
5039 Revision 1.10 - MODS 3.1 revisions to language and classification elements (plus ability to find marc:collection embedded in wrapper elements such as SRU zs: wrappers) 2006/02/06 ggar
5040 Revision 1.9 - Subfield $y was added to field 242 2004/09/02 10:57 jrad
5041 Revision 1.8 - Subject chopPunctuation expanded and attribute fixes 2004/08/12 jrad
5042 Revision 1.7 - 2004/03/25 08:29 jrad
5043 Revision 1.6 - Various validation fixes 2004/02/20 ntra
5044 Revision 1.5 - MODS2 to MODS3 updates, language unstacking and de-duping, chopPunctuation expanded 2003/10/02 16:18:58 ntra
5045 Revision 1.3 - Additional Changes not related to MODS Version 2.0 by ntra
5046 Revision 1.2 - Added Log Comment 2003/03/24 19:37:42 ckeith
5048 <xsl:template match="/">
5050 <xsl:when test="//marc:collection">
5051 <modsCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5052 xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-2.xsd">
5053 <xsl:for-each select="//marc:collection/marc:record">
5054 <mods version="3.3">
5055 <xsl:call-template name="marcRecord"/>
5061 <mods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.3"
5062 xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-2.xsd">
5063 <xsl:for-each select="//marc:record">
5064 <xsl:call-template name="marcRecord"/>
5070 <xsl:template name="marcRecord">
5071 <xsl:variable name="leader" select="marc:leader"/>
5072 <xsl:variable name="leader6" select="substring($leader,7,1)"/>
5073 <xsl:variable name="leader7" select="substring($leader,8,1)"/>
5074 <xsl:variable name="controlField008" select="marc:controlfield[@tag='008']"/>
5075 <xsl:variable name="typeOf008">
5077 <xsl:when test="$leader6='a'">
5080 test="$leader7='a' or $leader7='c' or $leader7='d' or $leader7='m'">BK</xsl:when>
5081 <xsl:when test="$leader7='b' or $leader7='i' or $leader7='s'">SE</xsl:when>
5084 <xsl:when test="$leader6='t'">BK</xsl:when>
5085 <xsl:when test="$leader6='p'">MM</xsl:when>
5086 <xsl:when test="$leader6='m'">CF</xsl:when>
5087 <xsl:when test="$leader6='e' or $leader6='f'">MP</xsl:when>
5088 <xsl:when test="$leader6='g' or $leader6='k' or $leader6='o' or $leader6='r'">VM</xsl:when>
5089 <xsl:when test="$leader6='c' or $leader6='d' or $leader6='i' or $leader6='j'"
5093 <xsl:for-each select="marc:datafield[@tag='245']">
5095 <xsl:variable name="title">
5097 <xsl:when test="marc:subfield[@code='b']">
5098 <xsl:call-template name="specialSubfieldSelect">
5099 <xsl:with-param name="axis">b</xsl:with-param>
5100 <xsl:with-param name="beforeCodes">afgk</xsl:with-param>
5101 </xsl:call-template>
5104 <xsl:call-template name="subfieldSelect">
5105 <xsl:with-param name="codes">abfgk</xsl:with-param>
5106 </xsl:call-template>
5110 <xsl:variable name="titleChop">
5111 <xsl:call-template name="chopPunctuation">
5112 <xsl:with-param name="chopString">
5113 <xsl:value-of select="$title"/>
5115 <xsl:with-param name="punctuation">
5116 <xsl:text>,;/ </xsl:text>
5118 </xsl:call-template>
5121 <xsl:when test="@ind2>0">
5123 <xsl:value-of select="substring($titleChop,1,@ind2)"/>
5126 <xsl:value-of select="substring($titleChop,@ind2+1)"/>
5131 <xsl:value-of select="$titleChop"/>
5135 <xsl:if test="marc:subfield[@code='b']">
5137 <xsl:call-template name="chopPunctuation">
5138 <xsl:with-param name="chopString">
5139 <xsl:call-template name="specialSubfieldSelect">
5140 <xsl:with-param name="axis">b</xsl:with-param>
5141 <xsl:with-param name="anyCodes">b</xsl:with-param>
5142 <xsl:with-param name="afterCodes">afgk</xsl:with-param>
5143 </xsl:call-template>
5145 </xsl:call-template>
5148 <xsl:call-template name="part"/>
5151 <xsl:for-each select="marc:datafield[@tag='210']">
5152 <titleInfo type="abbreviated">
5154 <xsl:call-template name="chopPunctuation">
5155 <xsl:with-param name="chopString">
5156 <xsl:call-template name="subfieldSelect">
5157 <xsl:with-param name="codes">a</xsl:with-param>
5158 </xsl:call-template>
5160 </xsl:call-template>
5162 <xsl:call-template name="subtitle"/>
5165 <xsl:for-each select="marc:datafield[@tag='242']">
5166 <titleInfo type="translated">
5167 <!--09/01/04 Added subfield $y-->
5168 <xsl:for-each select="marc:subfield[@code='y']">
5169 <xsl:attribute name="lang">
5170 <xsl:value-of select="text()"/>
5173 <xsl:for-each select="marc:subfield[@code='i']">
5174 <xsl:attribute name="displayLabel">
5175 <xsl:value-of select="text()"/>
5179 <xsl:call-template name="chopPunctuation">
5180 <xsl:with-param name="chopString">
5181 <xsl:call-template name="subfieldSelect">
5182 <!-- 1/04 removed $h, b -->
5183 <xsl:with-param name="codes">a</xsl:with-param>
5184 </xsl:call-template>
5186 </xsl:call-template>
5189 <xsl:call-template name="subtitle"/>
5190 <xsl:call-template name="part"/>
5193 <xsl:for-each select="marc:datafield[@tag='246']">
5194 <titleInfo type="alternative">
5195 <xsl:for-each select="marc:subfield[@code='i']">
5196 <xsl:attribute name="displayLabel">
5197 <xsl:value-of select="text()"/>
5201 <xsl:call-template name="chopPunctuation">
5202 <xsl:with-param name="chopString">
5203 <xsl:call-template name="subfieldSelect">
5204 <!-- 1/04 removed $h, $b -->
5205 <xsl:with-param name="codes">af</xsl:with-param>
5206 </xsl:call-template>
5208 </xsl:call-template>
5210 <xsl:call-template name="subtitle"/>
5211 <xsl:call-template name="part"/>
5215 select="marc:datafield[@tag='130']|marc:datafield[@tag='240']|marc:datafield[@tag='730'][@ind2!='2']">
5216 <titleInfo type="uniform">
5218 <xsl:call-template name="uri"/>
5220 <xsl:variable name="str">
5221 <xsl:for-each select="marc:subfield">
5223 test="(contains('adfklmors',@code) and (not(../marc:subfield[@code='n' or @code='p']) or (following-sibling::marc:subfield[@code='n' or @code='p'])))">
5224 <xsl:value-of select="text()"/>
5225 <xsl:text> </xsl:text>
5229 <xsl:call-template name="chopPunctuation">
5230 <xsl:with-param name="chopString">
5231 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
5233 </xsl:call-template>
5235 <xsl:call-template name="part"/>
5238 <xsl:for-each select="marc:datafield[@tag='740'][@ind2!='2']">
5239 <titleInfo type="alternative">
5241 <xsl:call-template name="chopPunctuation">
5242 <xsl:with-param name="chopString">
5243 <xsl:call-template name="subfieldSelect">
5244 <xsl:with-param name="codes">ah</xsl:with-param>
5245 </xsl:call-template>
5247 </xsl:call-template>
5249 <xsl:call-template name="part"/>
5252 <xsl:for-each select="marc:datafield[@tag='100']">
5253 <name type="personal">
5255 <xsl:call-template name="uri"/>
5257 <xsl:call-template name="nameABCDQ"/>
5258 <xsl:call-template name="affiliation"/>
5260 <roleTerm authority="marcrelator" type="text">creator</roleTerm>
5262 <xsl:call-template name="role"/>
5265 <xsl:for-each select="marc:datafield[@tag='110']">
5266 <name type="corporate">
5268 <xsl:call-template name="uri"/>
5270 <xsl:call-template name="nameABCDN"/>
5272 <roleTerm authority="marcrelator" type="text">creator</roleTerm>
5274 <xsl:call-template name="role"/>
5277 <xsl:for-each select="marc:datafield[@tag='111']">
5278 <name type="conference">
5280 <xsl:call-template name="uri"/>
5282 <xsl:call-template name="nameACDEQ"/>
5284 <roleTerm authority="marcrelator" type="text">creator</roleTerm>
5286 <xsl:call-template name="role"/>
5289 <xsl:for-each select="marc:datafield[@tag='700'][not(marc:subfield[@code='t'])]">
5290 <name type="personal">
5292 <xsl:call-template name="uri"/>
5294 <xsl:call-template name="nameABCDQ"/>
5295 <xsl:call-template name="affiliation"/>
5296 <xsl:call-template name="role"/>
5299 <xsl:for-each select="marc:datafield[@tag='710'][not(marc:subfield[@code='t'])]">
5300 <name type="corporate">
5302 <xsl:call-template name="uri"/>
5304 <xsl:call-template name="nameABCDN"/>
5305 <xsl:call-template name="role"/>
5308 <xsl:for-each select="marc:datafield[@tag='711'][not(marc:subfield[@code='t'])]">
5309 <name type="conference">
5311 <xsl:call-template name="uri"/>
5313 <xsl:call-template name="nameACDEQ"/>
5314 <xsl:call-template name="role"/>
5317 <xsl:for-each select="marc:datafield[@tag='720'][not(marc:subfield[@code='t'])]">
5319 <xsl:if test="@ind1=1">
5320 <xsl:attribute name="type">
5321 <xsl:text>personal</xsl:text>
5325 <xsl:value-of select="marc:subfield[@code='a']"/>
5327 <xsl:call-template name="role"/>
5331 <xsl:if test="$leader7='c'">
5332 <xsl:attribute name="collection">yes</xsl:attribute>
5334 <xsl:if test="$leader6='d' or $leader6='f' or $leader6='p' or $leader6='t'">
5335 <xsl:attribute name="manuscript">yes</xsl:attribute>
5338 <xsl:when test="$leader6='a' or $leader6='t'">text</xsl:when>
5339 <xsl:when test="$leader6='e' or $leader6='f'">cartographic</xsl:when>
5340 <xsl:when test="$leader6='c' or $leader6='d'">notated music</xsl:when>
5341 <xsl:when test="$leader6='i'">sound recording-nonmusical</xsl:when>
5342 <xsl:when test="$leader6='j'">sound recording-musical</xsl:when>
5343 <xsl:when test="$leader6='k'">still image</xsl:when>
5344 <xsl:when test="$leader6='g'">moving image</xsl:when>
5345 <xsl:when test="$leader6='r'">three dimensional object</xsl:when>
5346 <xsl:when test="$leader6='m'">software, multimedia</xsl:when>
5347 <xsl:when test="$leader6='p'">mixed material</xsl:when>
5350 <xsl:if test="substring($controlField008,26,1)='d'">
5351 <genre authority="marcgt">globe</genre>
5354 test="marc:controlfield[@tag='007'][substring(text(),1,1)='a'][substring(text(),2,1)='r']">
5355 <genre authority="marcgt">remote-sensing image</genre>
5357 <xsl:if test="$typeOf008='MP'">
5358 <xsl:variable name="controlField008-25" select="substring($controlField008,26,1)"/>
5361 test="$controlField008-25='a' or $controlField008-25='b' or $controlField008-25='c' or marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='j']">
5362 <genre authority="marcgt">map</genre>
5365 test="$controlField008-25='e' or marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='d']">
5366 <genre authority="marcgt">atlas</genre>
5370 <xsl:if test="$typeOf008='SE'">
5371 <xsl:variable name="controlField008-21" select="substring($controlField008,22,1)"/>
5373 <xsl:when test="$controlField008-21='d'">
5374 <genre authority="marcgt">database</genre>
5376 <xsl:when test="$controlField008-21='l'">
5377 <genre authority="marcgt">loose-leaf</genre>
5379 <xsl:when test="$controlField008-21='m'">
5380 <genre authority="marcgt">series</genre>
5382 <xsl:when test="$controlField008-21='n'">
5383 <genre authority="marcgt">newspaper</genre>
5385 <xsl:when test="$controlField008-21='p'">
5386 <genre authority="marcgt">periodical</genre>
5388 <xsl:when test="$controlField008-21='w'">
5389 <genre authority="marcgt">web site</genre>
5393 <xsl:if test="$typeOf008='BK' or $typeOf008='SE'">
5394 <xsl:variable name="controlField008-24" select="substring($controlField008,25,4)"/>
5396 <xsl:when test="contains($controlField008-24,'a')">
5397 <genre authority="marcgt">abstract or summary</genre>
5399 <xsl:when test="contains($controlField008-24,'b')">
5400 <genre authority="marcgt">bibliography</genre>
5402 <xsl:when test="contains($controlField008-24,'c')">
5403 <genre authority="marcgt">catalog</genre>
5405 <xsl:when test="contains($controlField008-24,'d')">
5406 <genre authority="marcgt">dictionary</genre>
5408 <xsl:when test="contains($controlField008-24,'e')">
5409 <genre authority="marcgt">encyclopedia</genre>
5411 <xsl:when test="contains($controlField008-24,'f')">
5412 <genre authority="marcgt">handbook</genre>
5414 <xsl:when test="contains($controlField008-24,'g')">
5415 <genre authority="marcgt">legal article</genre>
5417 <xsl:when test="contains($controlField008-24,'i')">
5418 <genre authority="marcgt">index</genre>
5420 <xsl:when test="contains($controlField008-24,'k')">
5421 <genre authority="marcgt">discography</genre>
5423 <xsl:when test="contains($controlField008-24,'l')">
5424 <genre authority="marcgt">legislation</genre>
5426 <xsl:when test="contains($controlField008-24,'m')">
5427 <genre authority="marcgt">theses</genre>
5429 <xsl:when test="contains($controlField008-24,'n')">
5430 <genre authority="marcgt">survey of literature</genre>
5432 <xsl:when test="contains($controlField008-24,'o')">
5433 <genre authority="marcgt">review</genre>
5435 <xsl:when test="contains($controlField008-24,'p')">
5436 <genre authority="marcgt">programmed text</genre>
5438 <xsl:when test="contains($controlField008-24,'q')">
5439 <genre authority="marcgt">filmography</genre>
5441 <xsl:when test="contains($controlField008-24,'r')">
5442 <genre authority="marcgt">directory</genre>
5444 <xsl:when test="contains($controlField008-24,'s')">
5445 <genre authority="marcgt">statistics</genre>
5447 <xsl:when test="contains($controlField008-24,'t')">
5448 <genre authority="marcgt">technical report</genre>
5450 <xsl:when test="contains($controlField008-24,'v')">
5451 <genre authority="marcgt">legal case and case notes</genre>
5453 <xsl:when test="contains($controlField008-24,'w')">
5454 <genre authority="marcgt">law report or digest</genre>
5456 <xsl:when test="contains($controlField008-24,'z')">
5457 <genre authority="marcgt">treaty</genre>
5460 <xsl:variable name="controlField008-29" select="substring($controlField008,30,1)"/>
5462 <xsl:when test="$controlField008-29='1'">
5463 <genre authority="marcgt">conference publication</genre>
5467 <xsl:if test="$typeOf008='CF'">
5468 <xsl:variable name="controlField008-26" select="substring($controlField008,27,1)"/>
5470 <xsl:when test="$controlField008-26='a'">
5471 <genre authority="marcgt">numeric data</genre>
5473 <xsl:when test="$controlField008-26='e'">
5474 <genre authority="marcgt">database</genre>
5476 <xsl:when test="$controlField008-26='f'">
5477 <genre authority="marcgt">font</genre>
5479 <xsl:when test="$controlField008-26='g'">
5480 <genre authority="marcgt">game</genre>
5484 <xsl:if test="$typeOf008='BK'">
5485 <xsl:if test="substring($controlField008,25,1)='j'">
5486 <genre authority="marcgt">patent</genre>
5488 <xsl:if test="substring($controlField008,25,1)='2'">
5489 <genre authority="marcgt">offprint</genre>
5491 <xsl:if test="substring($controlField008,31,1)='1'">
5492 <genre authority="marcgt">festschrift</genre>
5494 <xsl:variable name="controlField008-34" select="substring($controlField008,35,1)"/>
5496 test="$controlField008-34='a' or $controlField008-34='b' or $controlField008-34='c' or $controlField008-34='d'">
5497 <genre authority="marcgt">biography</genre>
5499 <xsl:variable name="controlField008-33" select="substring($controlField008,34,1)"/>
5501 <xsl:when test="$controlField008-33='e'">
5502 <genre authority="marcgt">essay</genre>
5504 <xsl:when test="$controlField008-33='d'">
5505 <genre authority="marcgt">drama</genre>
5507 <xsl:when test="$controlField008-33='c'">
5508 <genre authority="marcgt">comic strip</genre>
5510 <xsl:when test="$controlField008-33='l'">
5511 <genre authority="marcgt">fiction</genre>
5513 <xsl:when test="$controlField008-33='h'">
5514 <genre authority="marcgt">humor, satire</genre>
5516 <xsl:when test="$controlField008-33='i'">
5517 <genre authority="marcgt">letter</genre>
5519 <xsl:when test="$controlField008-33='f'">
5520 <genre authority="marcgt">novel</genre>
5522 <xsl:when test="$controlField008-33='j'">
5523 <genre authority="marcgt">short story</genre>
5525 <xsl:when test="$controlField008-33='s'">
5526 <genre authority="marcgt">speech</genre>
5530 <xsl:if test="$typeOf008='MU'">
5531 <xsl:variable name="controlField008-30-31" select="substring($controlField008,31,2)"/>
5532 <xsl:if test="contains($controlField008-30-31,'b')">
5533 <genre authority="marcgt">biography</genre>
5535 <xsl:if test="contains($controlField008-30-31,'c')">
5536 <genre authority="marcgt">conference publication</genre>
5538 <xsl:if test="contains($controlField008-30-31,'d')">
5539 <genre authority="marcgt">drama</genre>
5541 <xsl:if test="contains($controlField008-30-31,'e')">
5542 <genre authority="marcgt">essay</genre>
5544 <xsl:if test="contains($controlField008-30-31,'f')">
5545 <genre authority="marcgt">fiction</genre>
5547 <xsl:if test="contains($controlField008-30-31,'o')">
5548 <genre authority="marcgt">folktale</genre>
5550 <xsl:if test="contains($controlField008-30-31,'h')">
5551 <genre authority="marcgt">history</genre>
5553 <xsl:if test="contains($controlField008-30-31,'k')">
5554 <genre authority="marcgt">humor, satire</genre>
5556 <xsl:if test="contains($controlField008-30-31,'m')">
5557 <genre authority="marcgt">memoir</genre>
5559 <xsl:if test="contains($controlField008-30-31,'p')">
5560 <genre authority="marcgt">poetry</genre>
5562 <xsl:if test="contains($controlField008-30-31,'r')">
5563 <genre authority="marcgt">rehearsal</genre>
5565 <xsl:if test="contains($controlField008-30-31,'g')">
5566 <genre authority="marcgt">reporting</genre>
5568 <xsl:if test="contains($controlField008-30-31,'s')">
5569 <genre authority="marcgt">sound</genre>
5571 <xsl:if test="contains($controlField008-30-31,'l')">
5572 <genre authority="marcgt">speech</genre>
5575 <xsl:if test="$typeOf008='VM'">
5576 <xsl:variable name="controlField008-33" select="substring($controlField008,34,1)"/>
5578 <xsl:when test="$controlField008-33='a'">
5579 <genre authority="marcgt">art original</genre>
5581 <xsl:when test="$controlField008-33='b'">
5582 <genre authority="marcgt">kit</genre>
5584 <xsl:when test="$controlField008-33='c'">
5585 <genre authority="marcgt">art reproduction</genre>
5587 <xsl:when test="$controlField008-33='d'">
5588 <genre authority="marcgt">diorama</genre>
5590 <xsl:when test="$controlField008-33='f'">
5591 <genre authority="marcgt">filmstrip</genre>
5593 <xsl:when test="$controlField008-33='g'">
5594 <genre authority="marcgt">legal article</genre>
5596 <xsl:when test="$controlField008-33='i'">
5597 <genre authority="marcgt">picture</genre>
5599 <xsl:when test="$controlField008-33='k'">
5600 <genre authority="marcgt">graphic</genre>
5602 <xsl:when test="$controlField008-33='l'">
5603 <genre authority="marcgt">technical drawing</genre>
5605 <xsl:when test="$controlField008-33='m'">
5606 <genre authority="marcgt">motion picture</genre>
5608 <xsl:when test="$controlField008-33='n'">
5609 <genre authority="marcgt">chart</genre>
5611 <xsl:when test="$controlField008-33='o'">
5612 <genre authority="marcgt">flash card</genre>
5614 <xsl:when test="$controlField008-33='p'">
5615 <genre authority="marcgt">microscope slide</genre>
5618 test="$controlField008-33='q' or marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='q']">
5619 <genre authority="marcgt">model</genre>
5621 <xsl:when test="$controlField008-33='r'">
5622 <genre authority="marcgt">realia</genre>
5624 <xsl:when test="$controlField008-33='s'">
5625 <genre authority="marcgt">slide</genre>
5627 <xsl:when test="$controlField008-33='t'">
5628 <genre authority="marcgt">transparency</genre>
5630 <xsl:when test="$controlField008-33='v'">
5631 <genre authority="marcgt">videorecording</genre>
5633 <xsl:when test="$controlField008-33='w'">
5634 <genre authority="marcgt">toy</genre>
5639 <!-- 1.20 047 genre tmee-->
5641 <xsl:for-each select="marc:datafield[@tag=047]">
5642 <genre authority="marcgt">
5643 <xsl:attribute name="authority">
5644 <xsl:value-of select="marc:subfield[@code='2']"/>
5646 <xsl:call-template name="subfieldSelect">
5647 <xsl:with-param name="codes">abcdef</xsl:with-param>
5648 <xsl:with-param name="delimeter">-</xsl:with-param>
5649 </xsl:call-template>
5652 <xsl:for-each select="marc:datafield[@tag=655]">
5653 <genre authority="marcgt">
5654 <xsl:attribute name="authority">
5655 <xsl:value-of select="marc:subfield[@code='2']"/>
5657 <xsl:call-template name="subfieldSelect">
5658 <xsl:with-param name="codes">abvxyz</xsl:with-param>
5659 <xsl:with-param name="delimeter">-</xsl:with-param>
5660 </xsl:call-template>
5664 <xsl:variable name="MARCpublicationCode"
5665 select="normalize-space(substring($controlField008,16,3))"/>
5666 <xsl:if test="translate($MARCpublicationCode,'|','')">
5669 <xsl:attribute name="type">code</xsl:attribute>
5670 <xsl:attribute name="authority">marccountry</xsl:attribute>
5671 <xsl:value-of select="$MARCpublicationCode"/>
5675 <xsl:for-each select="marc:datafield[@tag=044]/marc:subfield[@code='c']">
5678 <xsl:attribute name="type">code</xsl:attribute>
5679 <xsl:attribute name="authority">iso3166</xsl:attribute>
5680 <xsl:value-of select="."/>
5684 <xsl:for-each select="marc:datafield[@tag=260]/marc:subfield[@code='a']">
5687 <xsl:attribute name="type">text</xsl:attribute>
5688 <xsl:call-template name="chopPunctuationFront">
5689 <xsl:with-param name="chopString">
5690 <xsl:call-template name="chopPunctuation">
5691 <xsl:with-param name="chopString" select="."/>
5692 </xsl:call-template>
5694 </xsl:call-template>
5698 <xsl:for-each select="marc:datafield[@tag=046]/marc:subfield[@code='m']">
5699 <dateValid point="start">
5700 <xsl:value-of select="."/>
5703 <xsl:for-each select="marc:datafield[@tag=046]/marc:subfield[@code='n']">
5704 <dateValid point="end">
5705 <xsl:value-of select="."/>
5708 <xsl:for-each select="marc:datafield[@tag=046]/marc:subfield[@code='j']">
5710 <xsl:value-of select="."/>
5714 select="marc:datafield[@tag=260]/marc:subfield[@code='b' or @code='c' or @code='g']">
5716 <xsl:when test="@code='b'">
5718 <xsl:call-template name="chopPunctuation">
5719 <xsl:with-param name="chopString" select="."/>
5720 <xsl:with-param name="punctuation">
5721 <xsl:text>:,;/ </xsl:text>
5723 </xsl:call-template>
5726 <xsl:when test="@code='c'">
5728 <xsl:call-template name="chopPunctuation">
5729 <xsl:with-param name="chopString" select="."/>
5730 </xsl:call-template>
5733 <xsl:when test="@code='g'">
5735 <xsl:value-of select="."/>
5740 <xsl:variable name="dataField260c">
5741 <xsl:call-template name="chopPunctuation">
5742 <xsl:with-param name="chopString"
5743 select="marc:datafield[@tag=260]/marc:subfield[@code='c']"/>
5744 </xsl:call-template>
5746 <xsl:variable name="controlField008-7-10"
5747 select="normalize-space(substring($controlField008, 8, 4))"/>
5748 <xsl:variable name="controlField008-11-14"
5749 select="normalize-space(substring($controlField008, 12, 4))"/>
5750 <xsl:variable name="controlField008-6"
5751 select="normalize-space(substring($controlField008, 7, 1))"/>
5753 test="$controlField008-6='e' or $controlField008-6='p' or $controlField008-6='r' or $controlField008-6='t' or $controlField008-6='s'">
5754 <xsl:if test="$controlField008-7-10 and ($controlField008-7-10 != $dataField260c)">
5755 <dateIssued encoding="marc">
5756 <xsl:value-of select="$controlField008-7-10"/>
5761 test="$controlField008-6='c' or $controlField008-6='d' or $controlField008-6='i' or $controlField008-6='k' or $controlField008-6='m' or $controlField008-6='q' or $controlField008-6='u'">
5762 <xsl:if test="$controlField008-7-10">
5763 <dateIssued encoding="marc" point="start">
5764 <xsl:value-of select="$controlField008-7-10"/>
5769 test="$controlField008-6='c' or $controlField008-6='d' or $controlField008-6='i' or $controlField008-6='k' or $controlField008-6='m' or $controlField008-6='q' or $controlField008-6='u'">
5770 <xsl:if test="$controlField008-11-14">
5771 <dateIssued encoding="marc" point="end">
5772 <xsl:value-of select="$controlField008-11-14"/>
5776 <xsl:if test="$controlField008-6='q'">
5777 <xsl:if test="$controlField008-7-10">
5778 <dateIssued encoding="marc" point="start" qualifier="questionable">
5779 <xsl:value-of select="$controlField008-7-10"/>
5783 <xsl:if test="$controlField008-6='q'">
5784 <xsl:if test="$controlField008-11-14">
5785 <dateIssued encoding="marc" point="end" qualifier="questionable">
5786 <xsl:value-of select="$controlField008-11-14"/>
5790 <xsl:if test="$controlField008-6='t'">
5791 <xsl:if test="$controlField008-11-14">
5792 <copyrightDate encoding="marc">
5793 <xsl:value-of select="$controlField008-11-14"/>
5798 select="marc:datafield[@tag=033][@ind1=0 or @ind1=1]/marc:subfield[@code='a']">
5799 <dateCaptured encoding="iso8601">
5800 <xsl:value-of select="."/>
5803 <xsl:for-each select="marc:datafield[@tag=033][@ind1=2]/marc:subfield[@code='a'][1]">
5804 <dateCaptured encoding="iso8601" point="start">
5805 <xsl:value-of select="."/>
5808 <xsl:for-each select="marc:datafield[@tag=033][@ind1=2]/marc:subfield[@code='a'][2]">
5809 <dateCaptured encoding="iso8601" point="end">
5810 <xsl:value-of select="."/>
5813 <xsl:for-each select="marc:datafield[@tag=250]/marc:subfield[@code='a']">
5815 <xsl:value-of select="."/>
5818 <xsl:for-each select="marc:leader">
5822 test="$leader7='a' or $leader7='c' or $leader7='d' or $leader7='m'"
5823 >monographic</xsl:when>
5824 <xsl:when test="$leader7='b' or $leader7='i' or $leader7='s'"
5825 >continuing</xsl:when>
5829 <xsl:for-each select="marc:datafield[@tag=310]|marc:datafield[@tag=321]">
5831 <xsl:call-template name="subfieldSelect">
5832 <xsl:with-param name="codes">ab</xsl:with-param>
5833 </xsl:call-template>
5837 <xsl:variable name="controlField008-35-37"
5838 select="normalize-space(translate(substring($controlField008,36,3),'|#',''))"/>
5839 <xsl:if test="$controlField008-35-37">
5841 <languageTerm authority="iso639-2b" type="code">
5842 <xsl:value-of select="substring($controlField008,36,3)"/>
5846 <xsl:for-each select="marc:datafield[@tag=041]">
5848 select="marc:subfield[@code='a' or @code='b' or @code='d' or @code='e' or @code='f' or @code='g' or @code='h']">
5849 <xsl:variable name="langCodes" select="."/>
5851 <xsl:when test="../marc:subfield[@code='2']='rfc3066'">
5852 <!-- not stacked but could be repeated -->
5853 <xsl:call-template name="rfcLanguages">
5854 <xsl:with-param name="nodeNum">
5855 <xsl:value-of select="1"/>
5857 <xsl:with-param name="usedLanguages">
5860 <xsl:with-param name="controlField008-35-37">
5861 <xsl:value-of select="$controlField008-35-37"/>
5863 </xsl:call-template>
5867 <xsl:variable name="allLanguages">
5868 <xsl:copy-of select="$langCodes"/>
5870 <xsl:variable name="currentLanguage">
5871 <xsl:value-of select="substring($allLanguages,1,3)"/>
5873 <xsl:call-template name="isoLanguage">
5874 <xsl:with-param name="currentLanguage">
5875 <xsl:value-of select="substring($allLanguages,1,3)"/>
5877 <xsl:with-param name="remainingLanguages">
5879 select="substring($allLanguages,4,string-length($allLanguages)-3)"
5882 <xsl:with-param name="usedLanguages">
5883 <xsl:if test="$controlField008-35-37">
5884 <xsl:value-of select="$controlField008-35-37"/>
5887 </xsl:call-template>
5892 <xsl:variable name="physicalDescription">
5893 <!--3.2 change tmee 007/11 -->
5894 <xsl:if test="$typeOf008='CF' and marc:controlfield[@tag=007][substring(.,12,1)='a']">
5895 <digitalOrigin>reformatted digital</digitalOrigin>
5897 <xsl:if test="$typeOf008='CF' and marc:controlfield[@tag=007][substring(.,12,1)='b']">
5898 <digitalOrigin>digitized microfilm</digitalOrigin>
5900 <xsl:if test="$typeOf008='CF' and marc:controlfield[@tag=007][substring(.,12,1)='d']">
5901 <digitalOrigin>digitized other analog</digitalOrigin>
5903 <xsl:variable name="controlField008-23" select="substring($controlField008,24,1)"/>
5904 <xsl:variable name="controlField008-29" select="substring($controlField008,30,1)"/>
5905 <xsl:variable name="check008-23">
5907 test="$typeOf008='BK' or $typeOf008='MU' or $typeOf008='SE' or $typeOf008='MM'">
5908 <xsl:value-of select="true()"/>
5911 <xsl:variable name="check008-29">
5912 <xsl:if test="$typeOf008='MP' or $typeOf008='VM'">
5913 <xsl:value-of select="true()"/>
5918 test="($check008-23 and $controlField008-23='f') or ($check008-29 and $controlField008-29='f')">
5919 <form authority="marcform">braille</form>
5922 test="($controlField008-23=' ' and ($leader6='c' or $leader6='d')) or (($typeOf008='BK' or $typeOf008='SE') and ($controlField008-23=' ' or $controlField008='r'))">
5923 <form authority="marcform">print</form>
5926 test="$leader6 = 'm' or ($check008-23 and $controlField008-23='s') or ($check008-29 and $controlField008-29='s')">
5927 <form authority="marcform">electronic</form>
5930 test="($check008-23 and $controlField008-23='b') or ($check008-29 and $controlField008-29='b')">
5931 <form authority="marcform">microfiche</form>
5934 test="($check008-23 and $controlField008-23='a') or ($check008-29 and $controlField008-29='a')">
5935 <form authority="marcform">microfilm</form>
5939 <xsl:if test="marc:datafield[@tag=130]/marc:subfield[@code='h']">
5940 <form authority="gmd">
5941 <xsl:call-template name="chopBrackets">
5942 <xsl:with-param name="chopString">
5943 <xsl:value-of select="marc:datafield[@tag=130]/marc:subfield[@code='h']"
5946 </xsl:call-template>
5949 <xsl:if test="marc:datafield[@tag=240]/marc:subfield[@code='h']">
5950 <form authority="gmd">
5951 <xsl:call-template name="chopBrackets">
5952 <xsl:with-param name="chopString">
5953 <xsl:value-of select="marc:datafield[@tag=240]/marc:subfield[@code='h']"
5956 </xsl:call-template>
5959 <xsl:if test="marc:datafield[@tag=242]/marc:subfield[@code='h']">
5960 <form authority="gmd">
5961 <xsl:call-template name="chopBrackets">
5962 <xsl:with-param name="chopString">
5963 <xsl:value-of select="marc:datafield[@tag=242]/marc:subfield[@code='h']"
5966 </xsl:call-template>
5969 <xsl:if test="marc:datafield[@tag=245]/marc:subfield[@code='h']">
5970 <form authority="gmd">
5971 <xsl:call-template name="chopBrackets">
5972 <xsl:with-param name="chopString">
5973 <xsl:value-of select="marc:datafield[@tag=245]/marc:subfield[@code='h']"
5976 </xsl:call-template>
5979 <xsl:if test="marc:datafield[@tag=246]/marc:subfield[@code='h']">
5980 <form authority="gmd">
5981 <xsl:call-template name="chopBrackets">
5982 <xsl:with-param name="chopString">
5983 <xsl:value-of select="marc:datafield[@tag=246]/marc:subfield[@code='h']"
5986 </xsl:call-template>
5989 <xsl:if test="marc:datafield[@tag=730]/marc:subfield[@code='h']">
5990 <form authority="gmd">
5991 <xsl:call-template name="chopBrackets">
5992 <xsl:with-param name="chopString">
5993 <xsl:value-of select="marc:datafield[@tag=730]/marc:subfield[@code='h']"
5996 </xsl:call-template>
5999 <xsl:for-each select="marc:datafield[@tag=256]/marc:subfield[@code='a']">
6001 <xsl:value-of select="."/>
6004 <xsl:for-each select="marc:controlfield[@tag=007][substring(text(),1,1)='c']">
6006 <xsl:when test="substring(text(),14,1)='a'">
6007 <reformattingQuality>access</reformattingQuality>
6009 <xsl:when test="substring(text(),14,1)='p'">
6010 <reformattingQuality>preservation</reformattingQuality>
6012 <xsl:when test="substring(text(),14,1)='r'">
6013 <reformattingQuality>replacement</reformattingQuality>
6017 <!--3.2 change tmee 007/01 -->
6019 test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='b']">
6020 <form authority="smd">chip cartridge</form>
6023 test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='c']">
6024 <form authority="smd">computer optical disc cartridge</form>
6027 test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='j']">
6028 <form authority="smd">magnetic disc</form>
6031 test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='m']">
6032 <form authority="smd">magneto-optical disc</form>
6035 test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='o']">
6036 <form authority="smd">optical disc</form>
6039 test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='r']">
6040 <form authority="smd">remote</form>
6043 test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='a']">
6044 <form authority="smd">tape cartridge</form>
6047 test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='f']">
6048 <form authority="smd">tape cassette</form>
6051 test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='h']">
6052 <form authority="smd">tape reel</form>
6056 test="marc:controlfield[@tag=007][substring(text(),1,1)='d'][substring(text(),2,1)='a']">
6057 <form authority="smd">celestial globe</form>
6060 test="marc:controlfield[@tag=007][substring(text(),1,1)='d'][substring(text(),2,1)='e']">
6061 <form authority="smd">earth moon globe</form>
6064 test="marc:controlfield[@tag=007][substring(text(),1,1)='d'][substring(text(),2,1)='b']">
6065 <form authority="smd">planetary or lunar globe</form>
6068 test="marc:controlfield[@tag=007][substring(text(),1,1)='d'][substring(text(),2,1)='c']">
6069 <form authority="smd">terrestrial globe</form>
6073 test="marc:controlfield[@tag=007][substring(text(),1,1)='o'][substring(text(),2,1)='o']">
6074 <form authority="smd">kit</form>
6078 test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='d']">
6079 <form authority="smd">atlas</form>
6082 test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='g']">
6083 <form authority="smd">diagram</form>
6086 test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='j']">
6087 <form authority="smd">map</form>
6090 test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='q']">
6091 <form authority="smd">model</form>
6094 test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='k']">
6095 <form authority="smd">profile</form>
6098 test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='r']">
6099 <form authority="smd">remote-sensing image</form>
6102 test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='s']">
6103 <form authority="smd">section</form>
6106 test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='y']">
6107 <form authority="smd">view</form>
6111 test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='a']">
6112 <form authority="smd">aperture card</form>
6115 test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='e']">
6116 <form authority="smd">microfiche</form>
6119 test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='f']">
6120 <form authority="smd">microfiche cassette</form>
6123 test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='b']">
6124 <form authority="smd">microfilm cartridge</form>
6127 test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='c']">
6128 <form authority="smd">microfilm cassette</form>
6131 test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='d']">
6132 <form authority="smd">microfilm reel</form>
6135 test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='g']">
6136 <form authority="smd">microopaque</form>
6140 test="marc:controlfield[@tag=007][substring(text(),1,1)='m'][substring(text(),2,1)='c']">
6141 <form authority="smd">film cartridge</form>
6144 test="marc:controlfield[@tag=007][substring(text(),1,1)='m'][substring(text(),2,1)='f']">
6145 <form authority="smd">film cassette</form>
6148 test="marc:controlfield[@tag=007][substring(text(),1,1)='m'][substring(text(),2,1)='r']">
6149 <form authority="smd">film reel</form>
6153 test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='n']">
6154 <form authority="smd">chart</form>
6157 test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='c']">
6158 <form authority="smd">collage</form>
6161 test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='d']">
6162 <form authority="smd">drawing</form>
6165 test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='o']">
6166 <form authority="smd">flash card</form>
6169 test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='e']">
6170 <form authority="smd">painting</form>
6173 test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='f']">
6174 <form authority="smd">photomechanical print</form>
6177 test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='g']">
6178 <form authority="smd">photonegative</form>
6181 test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='h']">
6182 <form authority="smd">photoprint</form>
6185 test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='i']">
6186 <form authority="smd">picture</form>
6189 test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='j']">
6190 <form authority="smd">print</form>
6193 test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='l']">
6194 <form authority="smd">technical drawing</form>
6198 test="marc:controlfield[@tag=007][substring(text(),1,1)='q'][substring(text(),2,1)='q']">
6199 <form authority="smd">notated music</form>
6203 test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='d']">
6204 <form authority="smd">filmslip</form>
6207 test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='c']">
6208 <form authority="smd">filmstrip cartridge</form>
6211 test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='o']">
6212 <form authority="smd">filmstrip roll</form>
6215 test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='f']">
6216 <form authority="smd">other filmstrip type</form>
6219 test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='s']">
6220 <form authority="smd">slide</form>
6223 test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='t']">
6224 <form authority="smd">transparency</form>
6227 test="marc:controlfield[@tag=007][substring(text(),1,1)='r'][substring(text(),2,1)='r']">
6228 <form authority="smd">remote-sensing image</form>
6231 test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='e']">
6232 <form authority="smd">cylinder</form>
6235 test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='q']">
6236 <form authority="smd">roll</form>
6239 test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='g']">
6240 <form authority="smd">sound cartridge</form>
6243 test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='s']">
6244 <form authority="smd">sound cassette</form>
6247 test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='d']">
6248 <form authority="smd">sound disc</form>
6251 test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='t']">
6252 <form authority="smd">sound-tape reel</form>
6255 test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='i']">
6256 <form authority="smd">sound-track film</form>
6259 test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='w']">
6260 <form authority="smd">wire recording</form>
6264 test="marc:controlfield[@tag=007][substring(text(),1,1)='f'][substring(text(),2,1)='c']">
6265 <form authority="smd">braille</form>
6268 test="marc:controlfield[@tag=007][substring(text(),1,1)='f'][substring(text(),2,1)='b']">
6269 <form authority="smd">combination</form>
6272 test="marc:controlfield[@tag=007][substring(text(),1,1)='f'][substring(text(),2,1)='a']">
6273 <form authority="smd">moon</form>
6276 test="marc:controlfield[@tag=007][substring(text(),1,1)='f'][substring(text(),2,1)='d']">
6277 <form authority="smd">tactile, with no writing system</form>
6281 test="marc:controlfield[@tag=007][substring(text(),1,1)='t'][substring(text(),2,1)='c']">
6282 <form authority="smd">braille</form>
6285 test="marc:controlfield[@tag=007][substring(text(),1,1)='t'][substring(text(),2,1)='b']">
6286 <form authority="smd">large print</form>
6289 test="marc:controlfield[@tag=007][substring(text(),1,1)='t'][substring(text(),2,1)='a']">
6290 <form authority="smd">regular print</form>
6293 test="marc:controlfield[@tag=007][substring(text(),1,1)='t'][substring(text(),2,1)='d']">
6294 <form authority="smd">text in looseleaf binder</form>
6298 test="marc:controlfield[@tag=007][substring(text(),1,1)='v'][substring(text(),2,1)='c']">
6299 <form authority="smd">videocartridge</form>
6302 test="marc:controlfield[@tag=007][substring(text(),1,1)='v'][substring(text(),2,1)='f']">
6303 <form authority="smd">videocassette</form>
6306 test="marc:controlfield[@tag=007][substring(text(),1,1)='v'][substring(text(),2,1)='d']">
6307 <form authority="smd">videodisc</form>
6310 test="marc:controlfield[@tag=007][substring(text(),1,1)='v'][substring(text(),2,1)='r']">
6311 <form authority="smd">videoreel</form>
6315 select="marc:datafield[@tag=856]/marc:subfield[@code='q'][string-length(.)>1]">
6317 <xsl:value-of select="."/>
6318 </internetMediaType>
6320 <xsl:for-each select="marc:datafield[@tag=300]">
6322 <xsl:call-template name="subfieldSelect">
6323 <xsl:with-param name="codes">abce</xsl:with-param>
6324 </xsl:call-template>
6328 <xsl:if test="string-length(normalize-space($physicalDescription))">
6329 <physicalDescription>
6330 <xsl:copy-of select="$physicalDescription"/>
6331 </physicalDescription>
6333 <xsl:for-each select="marc:datafield[@tag=520]">
6335 <xsl:call-template name="uri"/>
6336 <xsl:call-template name="subfieldSelect">
6337 <xsl:with-param name="codes">ab</xsl:with-param>
6338 </xsl:call-template>
6341 <xsl:for-each select="marc:datafield[@tag=505]">
6343 <xsl:call-template name="uri"/>
6344 <xsl:call-template name="subfieldSelect">
6345 <xsl:with-param name="codes">agrt</xsl:with-param>
6346 </xsl:call-template>
6349 <xsl:for-each select="marc:datafield[@tag=521]">
6351 <xsl:call-template name="subfieldSelect">
6352 <xsl:with-param name="codes">ab</xsl:with-param>
6353 </xsl:call-template>
6356 <xsl:if test="$typeOf008='BK' or $typeOf008='CF' or $typeOf008='MU' or $typeOf008='VM'">
6357 <xsl:variable name="controlField008-22" select="substring($controlField008,23,1)"/>
6360 <xsl:when test="$controlField008-22='d'">
6361 <targetAudience authority="marctarget">adolescent</targetAudience>
6363 <xsl:when test="$controlField008-22='e'">
6364 <targetAudience authority="marctarget">adult</targetAudience>
6366 <xsl:when test="$controlField008-22='g'">
6367 <targetAudience authority="marctarget">general</targetAudience>
6370 test="$controlField008-22='b' or $controlField008-22='c' or $controlField008-22='j'">
6371 <targetAudience authority="marctarget">juvenile</targetAudience>
6373 <xsl:when test="$controlField008-22='a'">
6374 <targetAudience authority="marctarget">preschool</targetAudience>
6376 <xsl:when test="$controlField008-22='f'">
6377 <targetAudience authority="marctarget">specialized</targetAudience>
6381 <xsl:for-each select="marc:datafield[@tag=245]/marc:subfield[@code='c']">
6382 <note type="statement of responsibility">
6383 <xsl:value-of select="."/>
6386 <xsl:for-each select="marc:datafield[@tag=500]">
6388 <xsl:value-of select="marc:subfield[@code='a']"/>
6389 <xsl:call-template name="uri"/>
6393 <!--3.2 change tmee additional note fields-->
6395 <xsl:for-each select="marc:datafield[@tag=502]">
6396 <note type="thesis">
6397 <xsl:call-template name="uri"/>
6398 <xsl:variable name="str">
6399 <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
6400 <xsl:value-of select="."/>
6401 <xsl:text> </xsl:text>
6404 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
6408 <xsl:for-each select="marc:datafield[@tag=504]">
6409 <note type="bibliography">
6410 <xsl:call-template name="uri"/>
6411 <xsl:variable name="str">
6412 <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
6413 <xsl:value-of select="."/>
6414 <xsl:text> </xsl:text>
6417 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
6421 <xsl:for-each select="marc:datafield[@tag=508]">
6422 <note type="creation/production credits">
6423 <xsl:call-template name="uri"/>
6424 <xsl:variable name="str">
6425 <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
6426 <xsl:value-of select="."/>
6427 <xsl:text> </xsl:text>
6430 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
6434 <xsl:for-each select="marc:datafield[@tag=506]">
6435 <note type="restrictions">
6436 <xsl:call-template name="uri"/>
6437 <xsl:variable name="str">
6438 <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
6439 <xsl:value-of select="."/>
6440 <xsl:text> </xsl:text>
6443 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
6447 <xsl:for-each select="marc:datafield[@tag=510]">
6448 <note type="citation/reference">
6449 <xsl:call-template name="uri"/>
6450 <xsl:variable name="str">
6451 <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
6452 <xsl:value-of select="."/>
6453 <xsl:text> </xsl:text>
6456 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
6461 <xsl:for-each select="marc:datafield[@tag=511]">
6462 <note type="performers">
6463 <xsl:call-template name="uri"/>
6464 <xsl:value-of select="marc:subfield[@code='a']"/>
6467 <xsl:for-each select="marc:datafield[@tag=518]">
6469 <xsl:call-template name="uri"/>
6470 <xsl:value-of select="marc:subfield[@code='a']"/>
6474 <xsl:for-each select="marc:datafield[@tag=530]">
6475 <note type="additional physical form">
6476 <xsl:call-template name="uri"/>
6477 <xsl:variable name="str">
6478 <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
6479 <xsl:value-of select="."/>
6480 <xsl:text> </xsl:text>
6483 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
6487 <xsl:for-each select="marc:datafield[@tag=533]">
6488 <note type="reproduction">
6489 <xsl:call-template name="uri"/>
6490 <xsl:variable name="str">
6491 <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
6492 <xsl:value-of select="."/>
6493 <xsl:text> </xsl:text>
6496 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
6500 <xsl:for-each select="marc:datafield[@tag=534]">
6501 <note type="original version">
6502 <xsl:call-template name="uri"/>
6503 <xsl:variable name="str">
6504 <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
6505 <xsl:value-of select="."/>
6506 <xsl:text> </xsl:text>
6509 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
6513 <xsl:for-each select="marc:datafield[@tag=538]">
6514 <note type="system details">
6515 <xsl:call-template name="uri"/>
6516 <xsl:variable name="str">
6517 <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
6518 <xsl:value-of select="."/>
6519 <xsl:text> </xsl:text>
6522 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
6526 <xsl:for-each select="marc:datafield[@tag=583]">
6527 <note type="action">
6528 <xsl:call-template name="uri"/>
6529 <xsl:variable name="str">
6530 <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
6531 <xsl:value-of select="."/>
6532 <xsl:text> </xsl:text>
6535 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
6540 select="marc:datafield[@tag=501 or @tag=507 or @tag=513 or @tag=514 or @tag=515 or @tag=516 or @tag=522 or @tag=524 or @tag=525 or @tag=526 or @tag=535 or @tag=536 or @tag=540 or @tag=541 or @tag=544 or @tag=545 or @tag=546 or @tag=547 or @tag=550 or @tag=552 or @tag=555 or @tag=556 or @tag=561 or @tag=562 or @tag=565 or @tag=567 or @tag=580 or @tag=581 or @tag=584 or @tag=585 or @tag=586]">
6542 <xsl:call-template name="uri"/>
6543 <xsl:variable name="str">
6544 <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
6545 <xsl:value-of select="."/>
6546 <xsl:text> </xsl:text>
6549 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
6553 select="marc:datafield[@tag=034][marc:subfield[@code='d' or @code='e' or @code='f' or @code='g']]">
6557 <xsl:call-template name="subfieldSelect">
6558 <xsl:with-param name="codes">defg</xsl:with-param>
6559 </xsl:call-template>
6564 <xsl:for-each select="marc:datafield[@tag=043]">
6566 <xsl:for-each select="marc:subfield[@code='a' or @code='b' or @code='c']">
6568 <xsl:attribute name="authority">
6569 <xsl:if test="@code='a'">
6570 <xsl:text>marcgac</xsl:text>
6572 <xsl:if test="@code='b'">
6573 <xsl:value-of select="following-sibling::marc:subfield[@code=2]"/>
6575 <xsl:if test="@code='c'">
6576 <xsl:text>iso3166</xsl:text>
6579 <xsl:value-of select="self::marc:subfield"/>
6584 <!-- tmee 2006/11/27 -->
6585 <xsl:for-each select="marc:datafield[@tag=255]">
6587 <xsl:for-each select="marc:subfield[@code='a' or @code='b' or @code='c']">
6589 <xsl:if test="@code='a'">
6591 <xsl:value-of select="."/>
6594 <xsl:if test="@code='b'">
6596 <xsl:value-of select="."/>
6599 <xsl:if test="@code='c'">
6601 <xsl:value-of select="."/>
6609 <xsl:apply-templates select="marc:datafield[653 >= @tag and @tag >= 600]"/>
6610 <xsl:apply-templates select="marc:datafield[@tag=656]"/>
6611 <xsl:for-each select="marc:datafield[@tag=752 or @tag=662]">
6613 <hierarchicalGeographic>
6614 <xsl:for-each select="marc:subfield[@code='a']">
6616 <xsl:call-template name="chopPunctuation">
6617 <xsl:with-param name="chopString" select="."/>
6618 </xsl:call-template>
6621 <xsl:for-each select="marc:subfield[@code='b']">
6623 <xsl:call-template name="chopPunctuation">
6624 <xsl:with-param name="chopString" select="."/>
6625 </xsl:call-template>
6628 <xsl:for-each select="marc:subfield[@code='c']">
6630 <xsl:call-template name="chopPunctuation">
6631 <xsl:with-param name="chopString" select="."/>
6632 </xsl:call-template>
6635 <xsl:for-each select="marc:subfield[@code='d']">
6637 <xsl:call-template name="chopPunctuation">
6638 <xsl:with-param name="chopString" select="."/>
6639 </xsl:call-template>
6642 <xsl:for-each select="marc:subfield[@code='e']">
6644 <xsl:call-template name="chopPunctuation">
6645 <xsl:with-param name="chopString" select="."/>
6646 </xsl:call-template>
6649 <xsl:for-each select="marc:subfield[@code='g']">
6651 <xsl:call-template name="chopPunctuation">
6652 <xsl:with-param name="chopString" select="."/>
6653 </xsl:call-template>
6656 <xsl:for-each select="marc:subfield[@code='h']">
6657 <extraterrestrialArea>
6658 <xsl:call-template name="chopPunctuation">
6659 <xsl:with-param name="chopString" select="."/>
6660 </xsl:call-template>
6661 </extraterrestrialArea>
6663 </hierarchicalGeographic>
6666 <xsl:for-each select="marc:datafield[@tag=045][marc:subfield[@code='b']]">
6669 <xsl:when test="@ind1=2">
6670 <temporal encoding="iso8601" point="start">
6671 <xsl:call-template name="chopPunctuation">
6672 <xsl:with-param name="chopString">
6673 <xsl:value-of select="marc:subfield[@code='b'][1]"/>
6675 </xsl:call-template>
6677 <temporal encoding="iso8601" point="end">
6678 <xsl:call-template name="chopPunctuation">
6679 <xsl:with-param name="chopString">
6680 <xsl:value-of select="marc:subfield[@code='b'][2]"/>
6682 </xsl:call-template>
6686 <xsl:for-each select="marc:subfield[@code='b']">
6687 <temporal encoding="iso8601">
6688 <xsl:call-template name="chopPunctuation">
6689 <xsl:with-param name="chopString" select="."/>
6690 </xsl:call-template>
6697 <xsl:for-each select="marc:datafield[@tag=050]">
6698 <xsl:for-each select="marc:subfield[@code='b']">
6699 <classification authority="lcc">
6700 <xsl:if test="../marc:subfield[@code='3']">
6701 <xsl:attribute name="displayLabel">
6702 <xsl:value-of select="../marc:subfield[@code='3']"/>
6705 <xsl:value-of select="preceding-sibling::marc:subfield[@code='a'][1]"/>
6706 <xsl:text> </xsl:text>
6707 <xsl:value-of select="text()"/>
6711 select="marc:subfield[@code='a'][not(following-sibling::marc:subfield[@code='b'])]">
6712 <classification authority="lcc">
6713 <xsl:if test="../marc:subfield[@code='3']">
6714 <xsl:attribute name="displayLabel">
6715 <xsl:value-of select="../marc:subfield[@code='3']"/>
6718 <xsl:value-of select="text()"/>
6722 <xsl:for-each select="marc:datafield[@tag=082]">
6723 <classification authority="ddc">
6724 <xsl:if test="marc:subfield[@code='2']">
6725 <xsl:attribute name="edition">
6726 <xsl:value-of select="marc:subfield[@code='2']"/>
6729 <xsl:call-template name="subfieldSelect">
6730 <xsl:with-param name="codes">ab</xsl:with-param>
6731 </xsl:call-template>
6734 <xsl:for-each select="marc:datafield[@tag=080]">
6735 <classification authority="udc">
6736 <xsl:call-template name="subfieldSelect">
6737 <xsl:with-param name="codes">abx</xsl:with-param>
6738 </xsl:call-template>
6741 <xsl:for-each select="marc:datafield[@tag=060]">
6742 <classification authority="nlm">
6743 <xsl:call-template name="subfieldSelect">
6744 <xsl:with-param name="codes">ab</xsl:with-param>
6745 </xsl:call-template>
6748 <xsl:for-each select="marc:datafield[@tag=086][@ind1=0]">
6749 <classification authority="sudocs">
6750 <xsl:value-of select="marc:subfield[@code='a']"/>
6753 <xsl:for-each select="marc:datafield[@tag=086][@ind1=1]">
6754 <classification authority="candoc">
6755 <xsl:value-of select="marc:subfield[@code='a']"/>
6758 <xsl:for-each select="marc:datafield[@tag=086]">
6760 <xsl:attribute name="authority">
6761 <xsl:value-of select="marc:subfield[@code='2']"/>
6763 <xsl:value-of select="marc:subfield[@code='a']"/>
6766 <xsl:for-each select="marc:datafield[@tag=084]">
6768 <xsl:attribute name="authority">
6769 <xsl:value-of select="marc:subfield[@code='2']"/>
6771 <xsl:call-template name="subfieldSelect">
6772 <xsl:with-param name="codes">ab</xsl:with-param>
6773 </xsl:call-template>
6776 <xsl:for-each select="marc:datafield[@tag=440]">
6777 <relatedItem type="series">
6780 <xsl:call-template name="chopPunctuation">
6781 <xsl:with-param name="chopString">
6782 <xsl:call-template name="subfieldSelect">
6783 <xsl:with-param name="codes">av</xsl:with-param>
6784 </xsl:call-template>
6786 </xsl:call-template>
6788 <xsl:call-template name="part"/>
6792 <xsl:for-each select="marc:datafield[@tag=490][@ind1=0]">
6793 <relatedItem type="series">
6796 <xsl:call-template name="chopPunctuation">
6797 <xsl:with-param name="chopString">
6798 <xsl:call-template name="subfieldSelect">
6799 <xsl:with-param name="codes">av</xsl:with-param>
6800 </xsl:call-template>
6802 </xsl:call-template>
6804 <xsl:call-template name="part"/>
6808 <xsl:for-each select="marc:datafield[@tag=510]">
6809 <relatedItem type="isReferencedBy">
6811 <xsl:call-template name="subfieldSelect">
6812 <xsl:with-param name="codes">abcx3</xsl:with-param>
6813 </xsl:call-template>
6817 <xsl:for-each select="marc:datafield[@tag=534]">
6818 <relatedItem type="original">
6819 <xsl:call-template name="relatedTitle"/>
6820 <xsl:call-template name="relatedName"/>
6821 <xsl:if test="marc:subfield[@code='b' or @code='c']">
6823 <xsl:for-each select="marc:subfield[@code='c']">
6825 <xsl:value-of select="."/>
6828 <xsl:for-each select="marc:subfield[@code='b']">
6830 <xsl:value-of select="."/>
6835 <xsl:call-template name="relatedIdentifierISSN"/>
6836 <xsl:for-each select="marc:subfield[@code='z']">
6837 <identifier type="isbn">
6838 <xsl:value-of select="."/>
6841 <xsl:call-template name="relatedNote"/>
6844 <xsl:for-each select="marc:datafield[@tag=700][marc:subfield[@code='t']]">
6846 <xsl:call-template name="constituentOrRelatedType"/>
6849 <xsl:call-template name="chopPunctuation">
6850 <xsl:with-param name="chopString">
6851 <xsl:call-template name="specialSubfieldSelect">
6852 <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
6853 <xsl:with-param name="axis">t</xsl:with-param>
6854 <xsl:with-param name="afterCodes">g</xsl:with-param>
6855 </xsl:call-template>
6857 </xsl:call-template>
6859 <xsl:call-template name="part"/>
6861 <name type="personal">
6863 <xsl:call-template name="specialSubfieldSelect">
6864 <xsl:with-param name="anyCodes">aq</xsl:with-param>
6865 <xsl:with-param name="axis">t</xsl:with-param>
6866 <xsl:with-param name="beforeCodes">g</xsl:with-param>
6867 </xsl:call-template>
6869 <xsl:call-template name="termsOfAddress"/>
6870 <xsl:call-template name="nameDate"/>
6871 <xsl:call-template name="role"/>
6873 <xsl:call-template name="relatedForm"/>
6874 <xsl:call-template name="relatedIdentifierISSN"/>
6877 <xsl:for-each select="marc:datafield[@tag=710][marc:subfield[@code='t']]">
6879 <xsl:call-template name="constituentOrRelatedType"/>
6882 <xsl:call-template name="chopPunctuation">
6883 <xsl:with-param name="chopString">
6884 <xsl:call-template name="specialSubfieldSelect">
6885 <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
6886 <xsl:with-param name="axis">t</xsl:with-param>
6887 <xsl:with-param name="afterCodes">dg</xsl:with-param>
6888 </xsl:call-template>
6890 </xsl:call-template>
6892 <xsl:call-template name="relatedPartNumName"/>
6894 <name type="corporate">
6895 <xsl:for-each select="marc:subfield[@code='a']">
6897 <xsl:value-of select="."/>
6900 <xsl:for-each select="marc:subfield[@code='b']">
6902 <xsl:value-of select="."/>
6905 <xsl:variable name="tempNamePart">
6906 <xsl:call-template name="specialSubfieldSelect">
6907 <xsl:with-param name="anyCodes">c</xsl:with-param>
6908 <xsl:with-param name="axis">t</xsl:with-param>
6909 <xsl:with-param name="beforeCodes">dgn</xsl:with-param>
6910 </xsl:call-template>
6912 <xsl:if test="normalize-space($tempNamePart)">
6914 <xsl:value-of select="$tempNamePart"/>
6917 <xsl:call-template name="role"/>
6919 <xsl:call-template name="relatedForm"/>
6920 <xsl:call-template name="relatedIdentifierISSN"/>
6923 <xsl:for-each select="marc:datafield[@tag=711][marc:subfield[@code='t']]">
6925 <xsl:call-template name="constituentOrRelatedType"/>
6928 <xsl:call-template name="chopPunctuation">
6929 <xsl:with-param name="chopString">
6930 <xsl:call-template name="specialSubfieldSelect">
6931 <xsl:with-param name="anyCodes">tfklsv</xsl:with-param>
6932 <xsl:with-param name="axis">t</xsl:with-param>
6933 <xsl:with-param name="afterCodes">g</xsl:with-param>
6934 </xsl:call-template>
6936 </xsl:call-template>
6938 <xsl:call-template name="relatedPartNumName"/>
6940 <name type="conference">
6942 <xsl:call-template name="specialSubfieldSelect">
6943 <xsl:with-param name="anyCodes">aqdc</xsl:with-param>
6944 <xsl:with-param name="axis">t</xsl:with-param>
6945 <xsl:with-param name="beforeCodes">gn</xsl:with-param>
6946 </xsl:call-template>
6949 <xsl:call-template name="relatedForm"/>
6950 <xsl:call-template name="relatedIdentifierISSN"/>
6953 <xsl:for-each select="marc:datafield[@tag=730][@ind2=2]">
6955 <xsl:call-template name="constituentOrRelatedType"/>
6958 <xsl:call-template name="chopPunctuation">
6959 <xsl:with-param name="chopString">
6960 <xsl:call-template name="subfieldSelect">
6961 <xsl:with-param name="codes">adfgklmorsv</xsl:with-param>
6962 </xsl:call-template>
6964 </xsl:call-template>
6966 <xsl:call-template name="part"/>
6968 <xsl:call-template name="relatedForm"/>
6969 <xsl:call-template name="relatedIdentifierISSN"/>
6972 <xsl:for-each select="marc:datafield[@tag=740][@ind2=2]">
6974 <xsl:call-template name="constituentOrRelatedType"/>
6977 <xsl:call-template name="chopPunctuation">
6978 <xsl:with-param name="chopString">
6979 <xsl:value-of select="marc:subfield[@code='a']"/>
6981 </xsl:call-template>
6983 <xsl:call-template name="part"/>
6985 <xsl:call-template name="relatedForm"/>
6988 <xsl:for-each select="marc:datafield[@tag=760]|marc:datafield[@tag=762]">
6989 <relatedItem type="series">
6990 <xsl:call-template name="relatedItem76X-78X"/>
6994 select="marc:datafield[@tag=765]|marc:datafield[@tag=767]|marc:datafield[@tag=777]|marc:datafield[@tag=787]">
6996 <xsl:call-template name="relatedItem76X-78X"/>
6999 <xsl:for-each select="marc:datafield[@tag=775]">
7000 <relatedItem type="otherVersion">
7001 <xsl:call-template name="relatedItem76X-78X"/>
7004 <xsl:for-each select="marc:datafield[@tag=770]|marc:datafield[@tag=774]">
7005 <relatedItem type="constituent">
7006 <xsl:call-template name="relatedItem76X-78X"/>
7009 <xsl:for-each select="marc:datafield[@tag=772]|marc:datafield[@tag=773]">
7010 <relatedItem type="host">
7011 <xsl:call-template name="relatedItem76X-78X"/>
7014 <xsl:for-each select="marc:datafield[@tag=776]">
7015 <relatedItem type="otherFormat">
7016 <xsl:call-template name="relatedItem76X-78X"/>
7019 <xsl:for-each select="marc:datafield[@tag=780]">
7020 <relatedItem type="preceding">
7021 <xsl:call-template name="relatedItem76X-78X"/>
7024 <xsl:for-each select="marc:datafield[@tag=785]">
7025 <relatedItem type="succeeding">
7026 <xsl:call-template name="relatedItem76X-78X"/>
7029 <xsl:for-each select="marc:datafield[@tag=786]">
7030 <relatedItem type="original">
7031 <xsl:call-template name="relatedItem76X-78X"/>
7034 <xsl:for-each select="marc:datafield[@tag=800]">
7035 <relatedItem type="series">
7038 <xsl:call-template name="chopPunctuation">
7039 <xsl:with-param name="chopString">
7040 <xsl:call-template name="specialSubfieldSelect">
7041 <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
7042 <xsl:with-param name="axis">t</xsl:with-param>
7043 <xsl:with-param name="afterCodes">g</xsl:with-param>
7044 </xsl:call-template>
7046 </xsl:call-template>
7048 <xsl:call-template name="part"/>
7050 <name type="personal">
7052 <xsl:call-template name="chopPunctuation">
7053 <xsl:with-param name="chopString">
7054 <xsl:call-template name="specialSubfieldSelect">
7055 <xsl:with-param name="anyCodes">aq</xsl:with-param>
7056 <xsl:with-param name="axis">t</xsl:with-param>
7057 <xsl:with-param name="beforeCodes">g</xsl:with-param>
7058 </xsl:call-template>
7060 </xsl:call-template>
7062 <xsl:call-template name="termsOfAddress"/>
7063 <xsl:call-template name="nameDate"/>
7064 <xsl:call-template name="role"/>
7066 <xsl:call-template name="relatedForm"/>
7069 <xsl:for-each select="marc:datafield[@tag=810]">
7070 <relatedItem type="series">
7073 <xsl:call-template name="chopPunctuation">
7074 <xsl:with-param name="chopString">
7075 <xsl:call-template name="specialSubfieldSelect">
7076 <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
7077 <xsl:with-param name="axis">t</xsl:with-param>
7078 <xsl:with-param name="afterCodes">dg</xsl:with-param>
7079 </xsl:call-template>
7081 </xsl:call-template>
7083 <xsl:call-template name="relatedPartNumName"/>
7085 <name type="corporate">
7086 <xsl:for-each select="marc:subfield[@code='a']">
7088 <xsl:value-of select="."/>
7091 <xsl:for-each select="marc:subfield[@code='b']">
7093 <xsl:value-of select="."/>
7097 <xsl:call-template name="specialSubfieldSelect">
7098 <xsl:with-param name="anyCodes">c</xsl:with-param>
7099 <xsl:with-param name="axis">t</xsl:with-param>
7100 <xsl:with-param name="beforeCodes">dgn</xsl:with-param>
7101 </xsl:call-template>
7103 <xsl:call-template name="role"/>
7105 <xsl:call-template name="relatedForm"/>
7108 <xsl:for-each select="marc:datafield[@tag=811]">
7109 <relatedItem type="series">
7112 <xsl:call-template name="chopPunctuation">
7113 <xsl:with-param name="chopString">
7114 <xsl:call-template name="specialSubfieldSelect">
7115 <xsl:with-param name="anyCodes">tfklsv</xsl:with-param>
7116 <xsl:with-param name="axis">t</xsl:with-param>
7117 <xsl:with-param name="afterCodes">g</xsl:with-param>
7118 </xsl:call-template>
7120 </xsl:call-template>
7122 <xsl:call-template name="relatedPartNumName"/>
7124 <name type="conference">
7126 <xsl:call-template name="specialSubfieldSelect">
7127 <xsl:with-param name="anyCodes">aqdc</xsl:with-param>
7128 <xsl:with-param name="axis">t</xsl:with-param>
7129 <xsl:with-param name="beforeCodes">gn</xsl:with-param>
7130 </xsl:call-template>
7132 <xsl:call-template name="role"/>
7134 <xsl:call-template name="relatedForm"/>
7137 <xsl:for-each select="marc:datafield[@tag='830']">
7138 <relatedItem type="series">
7141 <xsl:call-template name="chopPunctuation">
7142 <xsl:with-param name="chopString">
7143 <xsl:call-template name="subfieldSelect">
7144 <xsl:with-param name="codes">adfgklmorsv</xsl:with-param>
7145 </xsl:call-template>
7147 </xsl:call-template>
7149 <xsl:call-template name="part"/>
7151 <xsl:call-template name="relatedForm"/>
7154 <xsl:for-each select="marc:datafield[@tag='856'][@ind2='2']/marc:subfield[@code='q']">
7157 <xsl:value-of select="."/>
7158 </internetMediaType>
7161 <xsl:for-each select="marc:datafield[@tag='020']">
7162 <xsl:call-template name="isInvalid">
7163 <xsl:with-param name="type">isbn</xsl:with-param>
7164 </xsl:call-template>
7165 <xsl:if test="marc:subfield[@code='a']">
7166 <identifier type="isbn">
7167 <xsl:value-of select="marc:subfield[@code='a']"/>
7171 <xsl:for-each select="marc:datafield[@tag='024'][@ind1='0']">
7172 <xsl:call-template name="isInvalid">
7173 <xsl:with-param name="type">isrc</xsl:with-param>
7174 </xsl:call-template>
7175 <xsl:if test="marc:subfield[@code='a']">
7176 <identifier type="isrc">
7177 <xsl:value-of select="marc:subfield[@code='a']"/>
7181 <xsl:for-each select="marc:datafield[@tag='024'][@ind1='2']">
7182 <xsl:call-template name="isInvalid">
7183 <xsl:with-param name="type">ismn</xsl:with-param>
7184 </xsl:call-template>
7185 <xsl:if test="marc:subfield[@code='a']">
7186 <identifier type="ismn">
7187 <xsl:value-of select="marc:subfield[@code='a']"/>
7191 <xsl:for-each select="marc:datafield[@tag='024'][@ind1='4']">
7192 <xsl:call-template name="isInvalid">
7193 <xsl:with-param name="type">sici</xsl:with-param>
7194 </xsl:call-template>
7195 <identifier type="sici">
7196 <xsl:call-template name="subfieldSelect">
7197 <xsl:with-param name="codes">ab</xsl:with-param>
7198 </xsl:call-template>
7201 <xsl:for-each select="marc:datafield[@tag='022']">
7202 <xsl:if test="marc:subfield[@code='a']">
7203 <xsl:call-template name="isInvalid">
7204 <xsl:with-param name="type">issn</xsl:with-param>
7205 </xsl:call-template>
7206 <identifier type="issn">
7207 <xsl:value-of select="marc:subfield[@code='a']"/>
7210 <xsl:if test="marc:subfield[@code='l']">
7211 <xsl:call-template name="isInvalid">
7212 <xsl:with-param name="type">issn-l</xsl:with-param>
7213 </xsl:call-template>
7214 <identifier type="issn-l">
7215 <xsl:value-of select="marc:subfield[@code='l']"/>
7222 <xsl:for-each select="marc:datafield[@tag='010']">
7223 <xsl:call-template name="isInvalid">
7224 <xsl:with-param name="type">lccn</xsl:with-param>
7225 </xsl:call-template>
7226 <identifier type="lccn">
7227 <xsl:value-of select="normalize-space(marc:subfield[@code='a'])"/>
7230 <xsl:for-each select="marc:datafield[@tag='028']">
7232 <xsl:attribute name="type">
7234 <xsl:when test="@ind1='0'">issue number</xsl:when>
7235 <xsl:when test="@ind1='1'">matrix number</xsl:when>
7236 <xsl:when test="@ind1='2'">music plate</xsl:when>
7237 <xsl:when test="@ind1='3'">music publisher</xsl:when>
7238 <xsl:when test="@ind1='4'">videorecording identifier</xsl:when>
7241 <!--<xsl:call-template name="isInvalid"/>-->
7242 <!-- no $z in 028 -->
7243 <xsl:call-template name="subfieldSelect">
7244 <xsl:with-param name="codes">
7246 <xsl:when test="@ind1='0'">ba</xsl:when>
7247 <xsl:otherwise>ab</xsl:otherwise>
7250 </xsl:call-template>
7253 <xsl:for-each select="marc:datafield[@tag='037']">
7254 <identifier type="stock number">
7255 <!--<xsl:call-template name="isInvalid"/>-->
7256 <!-- no $z in 037 -->
7257 <xsl:call-template name="subfieldSelect">
7258 <xsl:with-param name="codes">ab</xsl:with-param>
7259 </xsl:call-template>
7262 <xsl:for-each select="marc:datafield[@tag='856'][marc:subfield[@code='u']]">
7264 <xsl:attribute name="type">
7267 test="starts-with(marc:subfield[@code='u'],'urn:doi') or starts-with(marc:subfield[@code='u'],'doi')"
7270 test="starts-with(marc:subfield[@code='u'],'urn:hdl') or starts-with(marc:subfield[@code='u'],'hdl') or starts-with(marc:subfield[@code='u'],'http://hdl.loc.gov')"
7272 <xsl:otherwise>uri</xsl:otherwise>
7277 test="starts-with(marc:subfield[@code='u'],'urn:hdl') or starts-with(marc:subfield[@code='u'],'hdl') or starts-with(marc:subfield[@code='u'],'http://hdl.loc.gov') ">
7279 select="concat('hdl:',substring-after(marc:subfield[@code='u'],'http://hdl.loc.gov/'))"
7283 <xsl:value-of select="marc:subfield[@code='u']"/>
7288 test="starts-with(marc:subfield[@code='u'],'urn:hdl') or starts-with(marc:subfield[@code='u'],'hdl')">
7289 <identifier type="hdl">
7290 <xsl:if test="marc:subfield[@code='y' or @code='3' or @code='z']">
7291 <xsl:attribute name="displayLabel">
7292 <xsl:call-template name="subfieldSelect">
7293 <xsl:with-param name="codes">y3z</xsl:with-param>
7294 </xsl:call-template>
7298 select="concat('hdl:',substring-after(marc:subfield[@code='u'],'http://hdl.loc.gov/'))"
7303 <xsl:for-each select="marc:datafield[@tag=024][@ind1=1]">
7304 <identifier type="upc">
7305 <xsl:call-template name="isInvalid"/>
7306 <xsl:value-of select="marc:subfield[@code='a']"/>
7310 <!-- 1/04 fix added $y -->
7313 <xsl:for-each select="marc:datafield[@tag=856][@ind2=1][marc:subfield[@code='u']]">
7314 <relatedItem type="otherVersion">
7317 <xsl:if test="marc:subfield[@code='y' or @code='3']">
7318 <xsl:attribute name="displayLabel">
7319 <xsl:call-template name="subfieldSelect">
7320 <xsl:with-param name="codes">y3</xsl:with-param>
7321 </xsl:call-template>
7324 <xsl:if test="marc:subfield[@code='z' ]">
7325 <xsl:attribute name="note">
7326 <xsl:call-template name="subfieldSelect">
7327 <xsl:with-param name="codes">z</xsl:with-param>
7328 </xsl:call-template>
7331 <xsl:value-of select="marc:subfield[@code='u']"/>
7336 <xsl:for-each select="marc:datafield[@tag=856][@ind2=2][marc:subfield[@code='u']]">
7340 <xsl:if test="marc:subfield[@code='y' or @code='3']">
7341 <xsl:attribute name="displayLabel">
7342 <xsl:call-template name="subfieldSelect">
7343 <xsl:with-param name="codes">y3</xsl:with-param>
7344 </xsl:call-template>
7347 <xsl:if test="marc:subfield[@code='z' ]">
7348 <xsl:attribute name="note">
7349 <xsl:call-template name="subfieldSelect">
7350 <xsl:with-param name="codes">z</xsl:with-param>
7351 </xsl:call-template>
7354 <xsl:value-of select="marc:subfield[@code='u']"/>
7360 <!-- 3.2 change tmee 856z -->
7363 <xsl:for-each select="marc:datafield[@tag=852]">
7365 <xsl:if test="marc:subfield[@code='a' or @code='b' or @code='e']">
7367 <xsl:call-template name="subfieldSelect">
7368 <xsl:with-param name="codes">abe</xsl:with-param>
7369 </xsl:call-template>
7373 <xsl:if test="marc:subfield[@code='u']">
7375 <xsl:call-template name="uri"/>
7376 <xsl:call-template name="subfieldSelect">
7377 <xsl:with-param name="codes">u</xsl:with-param>
7378 </xsl:call-template>
7383 test="marc:subfield[@code='h' or @code='i' or @code='j' or @code='k' or @code='l' or @code='m' or @code='t']">
7385 <xsl:call-template name="subfieldSelect">
7386 <xsl:with-param name="codes">hijklmt</xsl:with-param>
7387 </xsl:call-template>
7393 <xsl:for-each select="marc:datafield[@tag=506]">
7394 <accessCondition type="restrictionOnAccess">
7395 <xsl:call-template name="subfieldSelect">
7396 <xsl:with-param name="codes">abcd35</xsl:with-param>
7397 </xsl:call-template>
7400 <xsl:for-each select="marc:datafield[@tag=540]">
7401 <accessCondition type="useAndReproduction">
7402 <xsl:call-template name="subfieldSelect">
7403 <xsl:with-param name="codes">abcde35</xsl:with-param>
7404 </xsl:call-template>
7412 <xsl:for-each select="marc:leader[substring($leader,19,1)='a']">
7413 <descriptionStandard>aacr2</descriptionStandard>
7416 <xsl:for-each select="marc:datafield[@tag=040]">
7417 <xsl:if test="marc:subfield[@code='e']">
7418 <descriptionStandard>
7419 <xsl:value-of select="marc:subfield[@code='e']"/>
7420 </descriptionStandard>
7422 <recordContentSource authority="marcorg">
7423 <xsl:value-of select="marc:subfield[@code='a']"/>
7424 </recordContentSource>
7426 <xsl:for-each select="marc:controlfield[@tag=008]">
7427 <recordCreationDate encoding="marc">
7428 <xsl:value-of select="substring(.,1,6)"/>
7429 </recordCreationDate>
7432 <xsl:for-each select="marc:controlfield[@tag=005]">
7433 <recordChangeDate encoding="iso8601">
7434 <xsl:value-of select="."/>
7437 <xsl:for-each select="marc:controlfield[@tag=001]">
7439 <xsl:if test="../marc:controlfield[@tag=003]">
7440 <xsl:attribute name="source">
7441 <xsl:value-of select="../marc:controlfield[@tag=003]"/>
7444 <xsl:value-of select="."/>
7447 <xsl:for-each select="marc:datafield[@tag=040]/marc:subfield[@code='b']">
7448 <languageOfCataloging>
7449 <languageTerm authority="iso639-2b" type="code">
7450 <xsl:value-of select="."/>
7452 </languageOfCataloging>
7456 <xsl:template name="displayForm">
7457 <xsl:for-each select="marc:subfield[@code='c']">
7459 <xsl:value-of select="."/>
7463 <xsl:template name="affiliation">
7464 <xsl:for-each select="marc:subfield[@code='u']">
7466 <xsl:value-of select="."/>
7470 <xsl:template name="uri">
7471 <xsl:for-each select="marc:subfield[@code='u']">
7472 <xsl:attribute name="xlink:href">
7473 <xsl:value-of select="."/>
7476 <xsl:for-each select="marc:subfield[@code='0']">
7478 <xsl:when test="contains(text(), ')')">
7479 <xsl:attribute name="xlink:href">
7480 <xsl:value-of select="substring-after(text(), ')')"></xsl:value-of>
7484 <xsl:attribute name="xlink:href">
7485 <xsl:value-of select="."></xsl:value-of>
7491 <xsl:template name="role">
7492 <xsl:for-each select="marc:subfield[@code='e']">
7494 <roleTerm type="text">
7495 <xsl:value-of select="."/>
7499 <xsl:for-each select="marc:subfield[@code='4']">
7501 <roleTerm authority="marcrelator" type="code">
7502 <xsl:value-of select="."/>
7507 <xsl:template name="part">
7508 <xsl:variable name="partNumber">
7509 <xsl:call-template name="specialSubfieldSelect">
7510 <xsl:with-param name="axis">n</xsl:with-param>
7511 <xsl:with-param name="anyCodes">n</xsl:with-param>
7512 <xsl:with-param name="afterCodes">fgkdlmor</xsl:with-param>
7513 </xsl:call-template>
7515 <xsl:variable name="partName">
7516 <xsl:call-template name="specialSubfieldSelect">
7517 <xsl:with-param name="axis">p</xsl:with-param>
7518 <xsl:with-param name="anyCodes">p</xsl:with-param>
7519 <xsl:with-param name="afterCodes">fgkdlmor</xsl:with-param>
7520 </xsl:call-template>
7522 <xsl:if test="string-length(normalize-space($partNumber))">
7524 <xsl:call-template name="chopPunctuation">
7525 <xsl:with-param name="chopString" select="$partNumber"/>
7526 </xsl:call-template>
7529 <xsl:if test="string-length(normalize-space($partName))">
7531 <xsl:call-template name="chopPunctuation">
7532 <xsl:with-param name="chopString" select="$partName"/>
7533 </xsl:call-template>
7537 <xsl:template name="relatedPart">
7538 <xsl:if test="@tag=773">
7539 <xsl:for-each select="marc:subfield[@code='g']">
7542 <xsl:value-of select="."/>
7546 <xsl:for-each select="marc:subfield[@code='q']">
7548 <xsl:call-template name="parsePart"/>
7553 <xsl:template name="relatedPartNumName">
7554 <xsl:variable name="partNumber">
7555 <xsl:call-template name="specialSubfieldSelect">
7556 <xsl:with-param name="axis">g</xsl:with-param>
7557 <xsl:with-param name="anyCodes">g</xsl:with-param>
7558 <xsl:with-param name="afterCodes">pst</xsl:with-param>
7559 </xsl:call-template>
7561 <xsl:variable name="partName">
7562 <xsl:call-template name="specialSubfieldSelect">
7563 <xsl:with-param name="axis">p</xsl:with-param>
7564 <xsl:with-param name="anyCodes">p</xsl:with-param>
7565 <xsl:with-param name="afterCodes">fgkdlmor</xsl:with-param>
7566 </xsl:call-template>
7568 <xsl:if test="string-length(normalize-space($partNumber))">
7570 <xsl:value-of select="$partNumber"/>
7573 <xsl:if test="string-length(normalize-space($partName))">
7575 <xsl:value-of select="$partName"/>
7579 <xsl:template name="relatedName">
7580 <xsl:for-each select="marc:subfield[@code='a']">
7583 <xsl:value-of select="."/>
7588 <xsl:template name="relatedForm">
7589 <xsl:for-each select="marc:subfield[@code='h']">
7590 <physicalDescription>
7592 <xsl:value-of select="."/>
7594 </physicalDescription>
7597 <xsl:template name="relatedExtent">
7598 <xsl:for-each select="marc:subfield[@code='h']">
7599 <physicalDescription>
7601 <xsl:value-of select="."/>
7603 </physicalDescription>
7606 <xsl:template name="relatedNote">
7607 <xsl:for-each select="marc:subfield[@code='n']">
7609 <xsl:value-of select="."/>
7613 <xsl:template name="relatedSubject">
7614 <xsl:for-each select="marc:subfield[@code='j']">
7616 <temporal encoding="iso8601">
7617 <xsl:call-template name="chopPunctuation">
7618 <xsl:with-param name="chopString" select="."/>
7619 </xsl:call-template>
7624 <xsl:template name="relatedIdentifierISSN">
7625 <xsl:for-each select="marc:subfield[@code='x']">
7626 <identifier type="issn">
7627 <xsl:value-of select="."/>
7631 <xsl:template name="relatedIdentifierLocal">
7632 <xsl:for-each select="marc:subfield[@code='w']">
7633 <identifier type="local">
7634 <xsl:value-of select="."/>
7638 <xsl:template name="relatedIdentifier">
7639 <xsl:for-each select="marc:subfield[@code='o']">
7641 <xsl:value-of select="."/>
7645 <xsl:template name="relatedItem76X-78X">
7646 <xsl:call-template name="displayLabel"/>
7647 <xsl:call-template name="relatedTitle76X-78X"/>
7648 <xsl:call-template name="relatedName"/>
7649 <xsl:call-template name="relatedOriginInfo"/>
7650 <xsl:call-template name="relatedLanguage"/>
7651 <xsl:call-template name="relatedExtent"/>
7652 <xsl:call-template name="relatedNote"/>
7653 <xsl:call-template name="relatedSubject"/>
7654 <xsl:call-template name="relatedIdentifier"/>
7655 <xsl:call-template name="relatedIdentifierISSN"/>
7656 <xsl:call-template name="relatedIdentifierLocal"/>
7657 <xsl:call-template name="relatedPart"/>
7659 <xsl:template name="subjectGeographicZ">
7661 <xsl:call-template name="chopPunctuation">
7662 <xsl:with-param name="chopString" select="."/>
7663 </xsl:call-template>
7666 <xsl:template name="subjectTemporalY">
7668 <xsl:call-template name="chopPunctuation">
7669 <xsl:with-param name="chopString" select="."/>
7670 </xsl:call-template>
7673 <xsl:template name="subjectTopic">
7675 <xsl:call-template name="chopPunctuation">
7676 <xsl:with-param name="chopString" select="."/>
7677 </xsl:call-template>
7680 <!-- 3.2 change tmee 6xx $v genre -->
7681 <xsl:template name="subjectGenre">
7683 <xsl:call-template name="chopPunctuation">
7684 <xsl:with-param name="chopString" select="."/>
7685 </xsl:call-template>
7689 <xsl:template name="nameABCDN">
7690 <xsl:for-each select="marc:subfield[@code='a']">
7692 <xsl:call-template name="chopPunctuation">
7693 <xsl:with-param name="chopString" select="."/>
7694 </xsl:call-template>
7697 <xsl:for-each select="marc:subfield[@code='b']">
7699 <xsl:value-of select="."/>
7703 test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">
7705 <xsl:call-template name="subfieldSelect">
7706 <xsl:with-param name="codes">cdn</xsl:with-param>
7707 </xsl:call-template>
7711 <xsl:template name="nameABCDQ">
7713 <xsl:call-template name="chopPunctuation">
7714 <xsl:with-param name="chopString">
7715 <xsl:call-template name="subfieldSelect">
7716 <xsl:with-param name="codes">aq</xsl:with-param>
7717 </xsl:call-template>
7719 <xsl:with-param name="punctuation">
7720 <xsl:text>:,;/ </xsl:text>
7722 </xsl:call-template>
7724 <xsl:call-template name="termsOfAddress"/>
7725 <xsl:call-template name="nameDate"/>
7727 <xsl:template name="nameACDEQ">
7729 <xsl:call-template name="subfieldSelect">
7730 <xsl:with-param name="codes">acdeq</xsl:with-param>
7731 </xsl:call-template>
7734 <xsl:template name="constituentOrRelatedType">
7735 <xsl:if test="@ind2=2">
7736 <xsl:attribute name="type">constituent</xsl:attribute>
7739 <xsl:template name="relatedTitle">
7740 <xsl:for-each select="marc:subfield[@code='t']">
7743 <xsl:call-template name="chopPunctuation">
7744 <xsl:with-param name="chopString">
7745 <xsl:value-of select="."/>
7747 </xsl:call-template>
7752 <xsl:template name="relatedTitle76X-78X">
7753 <xsl:for-each select="marc:subfield[@code='t']">
7756 <xsl:call-template name="chopPunctuation">
7757 <xsl:with-param name="chopString">
7758 <xsl:value-of select="."/>
7760 </xsl:call-template>
7762 <xsl:if test="marc:datafield[@tag!=773]and marc:subfield[@code='g']">
7763 <xsl:call-template name="relatedPartNumName"/>
7767 <xsl:for-each select="marc:subfield[@code='p']">
7768 <titleInfo type="abbreviated">
7770 <xsl:call-template name="chopPunctuation">
7771 <xsl:with-param name="chopString">
7772 <xsl:value-of select="."/>
7774 </xsl:call-template>
7776 <xsl:if test="marc:datafield[@tag!=773]and marc:subfield[@code='g']">
7777 <xsl:call-template name="relatedPartNumName"/>
7781 <xsl:for-each select="marc:subfield[@code='s']">
7782 <titleInfo type="uniform">
7784 <xsl:call-template name="chopPunctuation">
7785 <xsl:with-param name="chopString">
7786 <xsl:value-of select="."/>
7788 </xsl:call-template>
7790 <xsl:if test="marc:datafield[@tag!=773]and marc:subfield[@code='g']">
7791 <xsl:call-template name="relatedPartNumName"/>
7796 <xsl:template name="relatedOriginInfo">
7797 <xsl:if test="marc:subfield[@code='b' or @code='d'] or marc:subfield[@code='f']">
7799 <xsl:if test="@tag=775">
7800 <xsl:for-each select="marc:subfield[@code='f']">
7803 <xsl:attribute name="type">code</xsl:attribute>
7804 <xsl:attribute name="authority">marcgac</xsl:attribute>
7805 <xsl:value-of select="."/>
7810 <xsl:for-each select="marc:subfield[@code='d']">
7812 <xsl:value-of select="."/>
7815 <xsl:for-each select="marc:subfield[@code='b']">
7817 <xsl:value-of select="."/>
7823 <xsl:template name="relatedLanguage">
7824 <xsl:for-each select="marc:subfield[@code='e']">
7825 <xsl:call-template name="getLanguage">
7826 <xsl:with-param name="langString">
7827 <xsl:value-of select="."/>
7829 </xsl:call-template>
7832 <xsl:template name="nameDate">
7833 <xsl:for-each select="marc:subfield[@code='d']">
7834 <namePart type="date">
7835 <xsl:call-template name="chopPunctuation">
7836 <xsl:with-param name="chopString" select="."/>
7837 </xsl:call-template>
7841 <xsl:template name="subjectAuthority">
7842 <xsl:if test="@ind2!=4">
7843 <xsl:if test="@ind2!=' '">
7844 <xsl:if test="@ind2!=8">
7845 <xsl:if test="@ind2!=9">
7846 <xsl:attribute name="authority">
7848 <xsl:when test="@ind2=0">lcsh</xsl:when>
7849 <xsl:when test="@ind2=1">lcshac</xsl:when>
7850 <xsl:when test="@ind2=2">mesh</xsl:when>
7852 <xsl:when test="@ind2=3">nal</xsl:when>
7853 <xsl:when test="@ind2=5">csh</xsl:when>
7854 <xsl:when test="@ind2=6">rvm</xsl:when>
7855 <xsl:when test="@ind2=7">
7856 <xsl:value-of select="marc:subfield[@code='2']"/>
7865 <xsl:template name="subjectAnyOrder">
7866 <xsl:for-each select="marc:subfield[@code='v' or @code='x' or @code='y' or @code='z']">
7868 <xsl:when test="@code='v'">
7869 <xsl:call-template name="subjectGenre"/>
7871 <xsl:when test="@code='x'">
7872 <xsl:call-template name="subjectTopic"/>
7874 <xsl:when test="@code='y'">
7875 <xsl:call-template name="subjectTemporalY"/>
7877 <xsl:when test="@code='z'">
7878 <xsl:call-template name="subjectGeographicZ"/>
7883 <xsl:template name="specialSubfieldSelect">
7884 <xsl:param name="anyCodes"/>
7885 <xsl:param name="axis"/>
7886 <xsl:param name="beforeCodes"/>
7887 <xsl:param name="afterCodes"/>
7888 <xsl:variable name="str">
7889 <xsl:for-each select="marc:subfield">
7891 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])">
7892 <xsl:value-of select="text()"/>
7893 <xsl:text> </xsl:text>
7897 <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
7900 <!-- 3.2 change tmee 6xx $v genre -->
7901 <xsl:template match="marc:datafield[@tag=600]">
7903 <xsl:call-template name="subjectAuthority"/>
7904 <name type="personal">
7905 <xsl:call-template name="termsOfAddress"/>
7907 <xsl:call-template name="chopPunctuation">
7908 <xsl:with-param name="chopString">
7909 <xsl:call-template name="subfieldSelect">
7910 <xsl:with-param name="codes">aq</xsl:with-param>
7911 </xsl:call-template>
7913 </xsl:call-template>
7915 <xsl:call-template name="nameDate"/>
7916 <xsl:call-template name="affiliation"/>
7917 <xsl:call-template name="role"/>
7919 <xsl:call-template name="subjectAnyOrder"/>
7922 <xsl:template match="marc:datafield[@tag=610]">
7924 <xsl:call-template name="subjectAuthority"/>
7925 <name type="corporate">
7926 <xsl:for-each select="marc:subfield[@code='a']">
7928 <xsl:value-of select="."/>
7931 <xsl:for-each select="marc:subfield[@code='b']">
7933 <xsl:value-of select="."/>
7936 <xsl:if test="marc:subfield[@code='c' or @code='d' or @code='n' or @code='p']">
7938 <xsl:call-template name="subfieldSelect">
7939 <xsl:with-param name="codes">cdnp</xsl:with-param>
7940 </xsl:call-template>
7943 <xsl:call-template name="role"/>
7945 <xsl:call-template name="subjectAnyOrder"/>
7948 <xsl:template match="marc:datafield[@tag=611]">
7950 <xsl:call-template name="subjectAuthority"/>
7951 <name type="conference">
7953 <xsl:call-template name="subfieldSelect">
7954 <xsl:with-param name="codes">abcdeqnp</xsl:with-param>
7955 </xsl:call-template>
7957 <xsl:for-each select="marc:subfield[@code='4']">
7959 <roleTerm authority="marcrelator" type="code">
7960 <xsl:value-of select="."/>
7965 <xsl:call-template name="subjectAnyOrder"/>
7968 <xsl:template match="marc:datafield[@tag=630]">
7970 <xsl:call-template name="subjectAuthority"/>
7973 <xsl:call-template name="chopPunctuation">
7974 <xsl:with-param name="chopString">
7975 <xsl:call-template name="subfieldSelect">
7976 <xsl:with-param name="codes">adfhklor</xsl:with-param>
7977 </xsl:call-template>
7979 </xsl:call-template>
7981 <xsl:call-template name="part"/>
7983 <xsl:call-template name="subjectAnyOrder"/>
7986 <!-- 1.27 648 tmee-->
7987 <xsl:template match="marc:datafield[@tag=648]">
7989 <xsl:if test="marc:subfield[@code=2]">
7990 <xsl:attribute name="authority">
7991 <xsl:value-of select="marc:subfield[@code=2]"/>
7994 <xsl:call-template name="uri"/>
7996 <xsl:call-template name="subjectAuthority"/>
7998 <xsl:call-template name="chopPunctuation">
7999 <xsl:with-param name="chopString">
8000 <xsl:call-template name="subfieldSelect">
8001 <xsl:with-param name="codes">abcd</xsl:with-param>
8002 </xsl:call-template>
8004 </xsl:call-template>
8006 <xsl:call-template name="subjectAnyOrder"/>
8010 <xsl:template match="marc:datafield[@tag=650]">
8012 <xsl:call-template name="subjectAuthority"/>
8014 <xsl:call-template name="chopPunctuation">
8015 <xsl:with-param name="chopString">
8016 <xsl:call-template name="subfieldSelect">
8017 <xsl:with-param name="codes">abcd</xsl:with-param>
8018 </xsl:call-template>
8020 </xsl:call-template>
8022 <xsl:call-template name="subjectAnyOrder"/>
8025 <xsl:template match="marc:datafield[@tag=651]">
8027 <xsl:call-template name="subjectAuthority"/>
8028 <xsl:for-each select="marc:subfield[@code='a']">
8030 <xsl:call-template name="chopPunctuation">
8031 <xsl:with-param name="chopString" select="."/>
8032 </xsl:call-template>
8035 <xsl:call-template name="subjectAnyOrder"/>
8038 <xsl:template match="marc:datafield[@tag=653]">
8040 <xsl:for-each select="marc:subfield[@code='a']">
8042 <xsl:value-of select="."/>
8047 <xsl:template match="marc:datafield[@tag=656]">
8049 <xsl:if test="marc:subfield[@code=2]">
8050 <xsl:attribute name="authority">
8051 <xsl:value-of select="marc:subfield[@code=2]"/>
8055 <xsl:call-template name="chopPunctuation">
8056 <xsl:with-param name="chopString">
8057 <xsl:value-of select="marc:subfield[@code='a']"/>
8059 </xsl:call-template>
8063 <xsl:template name="termsOfAddress">
8064 <xsl:if test="marc:subfield[@code='b' or @code='c']">
8065 <namePart type="termsOfAddress">
8066 <xsl:call-template name="chopPunctuation">
8067 <xsl:with-param name="chopString">
8068 <xsl:call-template name="subfieldSelect">
8069 <xsl:with-param name="codes">bc</xsl:with-param>
8070 </xsl:call-template>
8072 </xsl:call-template>
8076 <xsl:template name="displayLabel">
8077 <xsl:if test="marc:subfield[@code='i']">
8078 <xsl:attribute name="displayLabel">
8079 <xsl:value-of select="marc:subfield[@code='i']"/>
8082 <xsl:if test="marc:subfield[@code='3']">
8083 <xsl:attribute name="displayLabel">
8084 <xsl:value-of select="marc:subfield[@code='3']"/>
8088 <xsl:template name="isInvalid">
8089 <xsl:param name="type"/>
8091 test="marc:subfield[@code='z'] or marc:subfield[@code='y'] or marc:subfield[@code='m']">
8093 <xsl:attribute name="type">
8094 <xsl:value-of select="$type"/>
8096 <xsl:attribute name="invalid">
8097 <xsl:text>yes</xsl:text>
8099 <xsl:if test="marc:subfield[@code='z']">
8100 <xsl:value-of select="marc:subfield[@code='z']"/>
8102 <xsl:if test="marc:subfield[@code='y']">
8103 <xsl:value-of select="marc:subfield[@code='y']"/>
8105 <xsl:if test="marc:subfield[@code='m']">
8106 <xsl:value-of select="marc:subfield[@code='m']"/>
8111 <xsl:template name="subtitle">
8112 <xsl:if test="marc:subfield[@code='b']">
8114 <xsl:call-template name="chopPunctuation">
8115 <xsl:with-param name="chopString">
8116 <xsl:value-of select="marc:subfield[@code='b']"/>
8117 <!--<xsl:call-template name="subfieldSelect">
8118 <xsl:with-param name="codes">b</xsl:with-param>
8119 </xsl:call-template>-->
8121 </xsl:call-template>
8125 <xsl:template name="script">
8126 <xsl:param name="scriptCode"/>
8127 <xsl:attribute name="script">
8129 <xsl:when test="$scriptCode='(3'">Arabic</xsl:when>
8130 <xsl:when test="$scriptCode='(B'">Latin</xsl:when>
8131 <xsl:when test="$scriptCode='$1'">Chinese, Japanese, Korean</xsl:when>
8132 <xsl:when test="$scriptCode='(N'">Cyrillic</xsl:when>
8133 <xsl:when test="$scriptCode='(2'">Hebrew</xsl:when>
8134 <xsl:when test="$scriptCode='(S'">Greek</xsl:when>
8138 <xsl:template name="parsePart">
8139 <!-- assumes 773$q= 1:2:3<4
8140 with up to 3 levels and one optional start page
8142 <xsl:variable name="level1">
8144 <xsl:when test="contains(text(),':')">
8146 <xsl:value-of select="substring-before(text(),':')"/>
8148 <xsl:when test="not(contains(text(),':'))">
8150 <xsl:if test="contains(text(),'<')">
8152 <xsl:value-of select="substring-before(text(),'<')"/>
8154 <xsl:if test="not(contains(text(),'<'))">
8156 <xsl:value-of select="text()"/>
8161 <xsl:variable name="sici2">
8163 <xsl:when test="starts-with(substring-after(text(),$level1),':')">
8164 <xsl:value-of select="substring(substring-after(text(),$level1),2)"/>
8167 <xsl:value-of select="substring-after(text(),$level1)"/>
8171 <xsl:variable name="level2">
8173 <xsl:when test="contains($sici2,':')">
8175 <xsl:value-of select="substring-before($sici2,':')"/>
8177 <xsl:when test="contains($sici2,'<')">
8179 <xsl:value-of select="substring-before($sici2,'<')"/>
8182 <xsl:value-of select="$sici2"/>
8187 <xsl:variable name="sici3">
8189 <xsl:when test="starts-with(substring-after($sici2,$level2),':')">
8190 <xsl:value-of select="substring(substring-after($sici2,$level2),2)"/>
8193 <xsl:value-of select="substring-after($sici2,$level2)"/>
8197 <xsl:variable name="level3">
8199 <xsl:when test="contains($sici3,'<')">
8201 <xsl:value-of select="substring-before($sici3,'<')"/>
8204 <xsl:value-of select="$sici3"/>
8209 <xsl:variable name="page">
8210 <xsl:if test="contains(text(),'<')">
8211 <xsl:value-of select="substring-after(text(),'<')"/>
8214 <xsl:if test="$level1">
8217 <xsl:value-of select="$level1"/>
8221 <xsl:if test="$level2">
8224 <xsl:value-of select="$level2"/>
8228 <xsl:if test="$level3">
8231 <xsl:value-of select="$level3"/>
8235 <xsl:if test="$page">
8236 <extent unit="page">
8238 <xsl:value-of select="$page"/>
8243 <xsl:template name="getLanguage">
8244 <xsl:param name="langString"/>
8245 <xsl:param name="controlField008-35-37"/>
8246 <xsl:variable name="length" select="string-length($langString)"/>
8248 <xsl:when test="$length=0"/>
8249 <xsl:when test="$controlField008-35-37=substring($langString,1,3)">
8250 <xsl:call-template name="getLanguage">
8251 <xsl:with-param name="langString" select="substring($langString,4,$length)"/>
8252 <xsl:with-param name="controlField008-35-37" select="$controlField008-35-37"/>
8253 </xsl:call-template>
8257 <languageTerm authority="iso639-2b" type="code">
8258 <xsl:value-of select="substring($langString,1,3)"/>
8261 <xsl:call-template name="getLanguage">
8262 <xsl:with-param name="langString" select="substring($langString,4,$length)"/>
8263 <xsl:with-param name="controlField008-35-37" select="$controlField008-35-37"/>
8264 </xsl:call-template>
8268 <xsl:template name="isoLanguage">
8269 <xsl:param name="currentLanguage"/>
8270 <xsl:param name="usedLanguages"/>
8271 <xsl:param name="remainingLanguages"/>
8273 <xsl:when test="string-length($currentLanguage)=0"/>
8274 <xsl:when test="not(contains($usedLanguages, $currentLanguage))">
8276 <xsl:if test="@code!='a'">
8277 <xsl:attribute name="objectPart">
8279 <xsl:when test="@code='b'">summary or subtitle</xsl:when>
8280 <xsl:when test="@code='d'">sung or spoken text</xsl:when>
8281 <xsl:when test="@code='e'">libretto</xsl:when>
8282 <xsl:when test="@code='f'">table of contents</xsl:when>
8283 <xsl:when test="@code='g'">accompanying material</xsl:when>
8284 <xsl:when test="@code='h'">translation</xsl:when>
8288 <languageTerm authority="iso639-2b" type="code">
8289 <xsl:value-of select="$currentLanguage"/>
8292 <xsl:call-template name="isoLanguage">
8293 <xsl:with-param name="currentLanguage">
8294 <xsl:value-of select="substring($remainingLanguages,1,3)"/>
8296 <xsl:with-param name="usedLanguages">
8297 <xsl:value-of select="concat($usedLanguages,$currentLanguage)"/>
8299 <xsl:with-param name="remainingLanguages">
8301 select="substring($remainingLanguages,4,string-length($remainingLanguages))"
8304 </xsl:call-template>
8307 <xsl:call-template name="isoLanguage">
8308 <xsl:with-param name="currentLanguage">
8309 <xsl:value-of select="substring($remainingLanguages,1,3)"/>
8311 <xsl:with-param name="usedLanguages">
8312 <xsl:value-of select="concat($usedLanguages,$currentLanguage)"/>
8314 <xsl:with-param name="remainingLanguages">
8316 select="substring($remainingLanguages,4,string-length($remainingLanguages))"
8319 </xsl:call-template>
8323 <xsl:template name="chopBrackets">
8324 <xsl:param name="chopString"/>
8325 <xsl:variable name="string">
8326 <xsl:call-template name="chopPunctuation">
8327 <xsl:with-param name="chopString" select="$chopString"/>
8328 </xsl:call-template>
8330 <xsl:if test="substring($string, 1,1)='['">
8331 <xsl:value-of select="substring($string,2, string-length($string)-2)"/>
8333 <xsl:if test="substring($string, 1,1)!='['">
8334 <xsl:value-of select="$string"/>
8337 <xsl:template name="rfcLanguages">
8338 <xsl:param name="nodeNum"/>
8339 <xsl:param name="usedLanguages"/>
8340 <xsl:param name="controlField008-35-37"/>
8341 <xsl:variable name="currentLanguage" select="."/>
8343 <xsl:when test="not($currentLanguage)"/>
8345 test="$currentLanguage!=$controlField008-35-37 and $currentLanguage!='rfc3066'">
8346 <xsl:if test="not(contains($usedLanguages,$currentLanguage))">
8348 <xsl:if test="@code!='a'">
8349 <xsl:attribute name="objectPart">
8351 <xsl:when test="@code='b'">summary or subtitle</xsl:when>
8352 <xsl:when test="@code='d'">sung or spoken text</xsl:when>
8353 <xsl:when test="@code='e'">libretto</xsl:when>
8354 <xsl:when test="@code='f'">table of contents</xsl:when>
8355 <xsl:when test="@code='g'">accompanying material</xsl:when>
8356 <xsl:when test="@code='h'">translation</xsl:when>
8360 <languageTerm authority="rfc3066" type="code">
8361 <xsl:value-of select="$currentLanguage"/>
8366 <xsl:otherwise> </xsl:otherwise>
8370 <xsl:template name="datafield">
8371 <xsl:param name="tag"/>
8372 <xsl:param name="ind1">
8373 <xsl:text> </xsl:text>
8375 <xsl:param name="ind2">
8376 <xsl:text> </xsl:text>
8378 <xsl:param name="subfields"/>
8379 <xsl:element name="marc:datafield">
8380 <xsl:attribute name="tag">
8381 <xsl:value-of select="$tag"/>
8383 <xsl:attribute name="ind1">
8384 <xsl:value-of select="$ind1"/>
8386 <xsl:attribute name="ind2">
8387 <xsl:value-of select="$ind2"/>
8389 <xsl:copy-of select="$subfields"/>
8393 <xsl:template name="subfieldSelect">
8394 <xsl:param name="codes">abcdefghijklmnopqrstuvwxyz</xsl:param>
8395 <xsl:param name="delimeter">
8396 <xsl:text> </xsl:text>
8398 <xsl:variable name="str">
8399 <xsl:for-each select="marc:subfield">
8400 <xsl:if test="contains($codes, @code)">
8401 <xsl:value-of select="text()"/>
8402 <xsl:value-of select="$delimeter"/>
8406 <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
8409 <xsl:template name="buildSpaces">
8410 <xsl:param name="spaces"/>
8411 <xsl:param name="char">
8412 <xsl:text> </xsl:text>
8414 <xsl:if test="$spaces>0">
8415 <xsl:value-of select="$char"/>
8416 <xsl:call-template name="buildSpaces">
8417 <xsl:with-param name="spaces" select="$spaces - 1"/>
8418 <xsl:with-param name="char" select="$char"/>
8419 </xsl:call-template>
8423 <xsl:template name="chopPunctuation">
8424 <xsl:param name="chopString"/>
8425 <xsl:param name="punctuation">
8426 <xsl:text>.:,;/ </xsl:text>
8428 <xsl:variable name="length" select="string-length($chopString)"/>
8430 <xsl:when test="$length=0"/>
8431 <xsl:when test="contains($punctuation, substring($chopString,$length,1))">
8432 <xsl:call-template name="chopPunctuation">
8433 <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
8434 <xsl:with-param name="punctuation" select="$punctuation"/>
8435 </xsl:call-template>
8437 <xsl:when test="not($chopString)"/>
8439 <xsl:value-of select="$chopString"/>
8444 <xsl:template name="chopPunctuationFront">
8445 <xsl:param name="chopString"/>
8446 <xsl:variable name="length" select="string-length($chopString)"/>
8448 <xsl:when test="$length=0"/>
8449 <xsl:when test="contains('.:,;/[ ', substring($chopString,1,1))">
8450 <xsl:call-template name="chopPunctuationFront">
8451 <xsl:with-param name="chopString" select="substring($chopString,2,$length - 1)"
8453 </xsl:call-template>
8455 <xsl:when test="not($chopString)"/>
8457 <xsl:value-of select="$chopString"/>
8462 <xsl:template name="chopPunctuationBack">
8463 <xsl:param name="chopString"/>
8464 <xsl:param name="punctuation">
8465 <xsl:text>.:,;/] </xsl:text>
8467 <xsl:variable name="length" select="string-length($chopString)"/>
8469 <xsl:when test="$length=0"/>
8470 <xsl:when test="contains($punctuation, substring($chopString,$length,1))">
8471 <xsl:call-template name="chopPunctuation">
8472 <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
8473 <xsl:with-param name="punctuation" select="$punctuation"/>
8474 </xsl:call-template>
8476 <xsl:when test="not($chopString)"/>
8478 <xsl:value-of select="$chopString"/>
8483 <!-- nate added 12/14/2007 for lccn.loc.gov: url encode ampersand, etc. -->
8484 <xsl:template name="url-encode">
8486 <xsl:param name="str"/>
8488 <xsl:if test="$str">
8489 <xsl:variable name="first-char" select="substring($str,1,1)"/>
8491 <xsl:when test="contains($safe,$first-char)">
8492 <xsl:value-of select="$first-char"/>
8495 <xsl:variable name="codepoint">
8497 <xsl:when test="contains($ascii,$first-char)">
8499 select="string-length(substring-before($ascii,$first-char)) + 32"
8502 <xsl:when test="contains($latin1,$first-char)">
8504 select="string-length(substring-before($latin1,$first-char)) + 160"/>
8508 <xsl:message terminate="no">Warning: string contains a character
8509 that is out of range! Substituting "?".</xsl:message>
8510 <xsl:text>63</xsl:text>
8514 <xsl:variable name="hex-digit1"
8515 select="substring($hex,floor($codepoint div 16) + 1,1)"/>
8516 <xsl:variable name="hex-digit2" select="substring($hex,$codepoint mod 16 + 1,1)"/>
8517 <!-- <xsl:value-of select="concat('%',$hex-digit2)"/> -->
8518 <xsl:value-of select="concat('%',$hex-digit1,$hex-digit2)"/>
8521 <xsl:if test="string-length($str) > 1">
8522 <xsl:call-template name="url-encode">
8523 <xsl:with-param name="str" select="substring($str,2)"/>
8524 </xsl:call-template>
8528 </xsl:stylesheet>$XXXX$ where name = $$mods33$$;
8532 SELECT evergreen.upgrade_deps_block_check('1103', :eg_version);
8534 INSERT INTO config.metabib_field (id, field_class, name, label, browse_field)
8535 VALUES (45, 'keyword', 'blob', 'All searchable fields', FALSE);
8537 INSERT INTO config.metabib_field (id, field_class, name, format, weight,
8538 label, xpath, display_field, search_field, browse_field, facet_field)
8540 53, 'title', 'maintitle', 'marcxml', 10,
8541 oils_i18n_gettext(53, 'Main Title', 'cmf', 'label'),
8542 $$//*[@tag='245']/*[@code='a']$$,
8543 FALSE, TRUE, FALSE, FALSE
8546 INSERT INTO config.metabib_field_virtual_map (real, virtual)
8549 FROM config.metabib_field
8551 AND id NOT IN (15, 45, 38, 40) -- keyword|keyword, self, edition, publisher
8552 AND id NOT IN (SELECT real FROM config.metabib_field_virtual_map);
8554 UPDATE config.metabib_field SET xpath=$$//mods32:mods/mods32:subject[not(descendant::mods32:geographicCode)]$$ WHERE id = 16;
8556 UPDATE config.metabib_field_virtual_map SET weight = -1 WHERE real = 39;
8557 UPDATE config.metabib_field_virtual_map SET weight = 0 WHERE real = 41;
8558 UPDATE config.metabib_field_virtual_map SET weight = 0 WHERE real = 42;
8559 UPDATE config.metabib_field_virtual_map SET weight = 0 WHERE real = 46;
8560 UPDATE config.metabib_field_virtual_map SET weight = 0 WHERE real = 47;
8561 UPDATE config.metabib_field_virtual_map SET weight = 0 WHERE real = 48;
8562 UPDATE config.metabib_field_virtual_map SET weight = 0 WHERE real = 50;
8563 UPDATE config.metabib_field_virtual_map SET weight = 8 WHERE real = 6;
8564 UPDATE config.metabib_field_virtual_map SET weight = 8 WHERE real = 8;
8565 UPDATE config.metabib_field_virtual_map SET weight = 8 WHERE real = 16;
8566 UPDATE config.metabib_field_virtual_map SET weight = 12 WHERE real = 53;
8568 -- Stemming for genre
8569 INSERT INTO config.metabib_field_ts_map (metabib_field, ts_config)
8570 SELECT 33, 'english_nostop' WHERE NOT EXISTS (
8571 SELECT 1 FROM config.metabib_field_ts_map WHERE metabib_field = 33 AND ts_config = 'english_nostop'
8576 SELECT evergreen.upgrade_deps_block_check('1104', :eg_version);
8578 INSERT INTO config.org_unit_setting_type
8579 ( name, grp, label, description, datatype )
8581 ('circ.clear_hold_on_checkout',
8583 oils_i18n_gettext('circ.clear_hold_on_checkout',
8584 'Clear hold when other patron checks out item',
8586 oils_i18n_gettext('circ.clear_hold_on_checkout',
8587 'Default to cancel the hold when patron A checks out item on hold for patron B.',
8588 'coust', 'description'),
8593 SELECT evergreen.upgrade_deps_block_check('1105', :eg_version);
8595 INSERT into config.org_unit_setting_type (name, label, grp, description, datatype)
8596 values ('webstaff.circ.itemsout_notice_count_excludes_courtesies','Exclude Courtesy Notices from Patrons Itemsout Notices Count',
8597 'circ', 'Exclude Courtesy Notices from Patron Itemsout Notices Count', 'bool');
8600 SELECT evergreen.upgrade_deps_block_check('1106', :eg_version);
8602 ALTER TABLE money.billing
8603 ADD COLUMN create_date TIMESTAMP WITH TIME ZONE,
8604 ADD COLUMN period_start TIMESTAMP WITH TIME ZONE,
8605 ADD COLUMN period_end TIMESTAMP WITH TIME ZONE;
8607 --Disable materialized update trigger
8608 --It takes forever, and doesn't matter yet for what we are doing, as the
8609 --view definition is unchanged (still using billing_ts)
8610 ALTER TABLE money.billing DISABLE TRIGGER mat_summary_upd_tgr;
8612 --Limit to btype=1 / 'Overdue Materials'
8613 --Update day-granular fines first (i.e. 24 hour, 1 day, 2 day, etc., all of which are multiples of 86400 seconds), and simply remove the time portion of timestamp
8614 UPDATE money.billing mb
8615 SET period_start = date_trunc('day', billing_ts), period_end = date_trunc('day', billing_ts) + (ac.fine_interval - '1 second')
8616 FROM action.circulation ac
8617 WHERE mb.xact = ac.id
8619 AND (EXTRACT(EPOCH FROM ac.fine_interval))::integer % 86400 = 0;
8621 --Update fines for non-day intervals
8622 UPDATE money.billing mb
8623 SET period_start = billing_ts - ac.fine_interval + interval '1 sec', period_end = billing_ts
8624 FROM action.circulation ac
8625 WHERE mb.xact = ac.id
8627 AND (EXTRACT(EPOCH FROM ac.fine_interval))::integer % 86400 > 0;
8629 SET CONSTRAINTS ALL IMMEDIATE;
8630 UPDATE money.billing SET create_date = COALESCE(period_start, billing_ts);
8632 --Re-enable update trigger
8633 ALTER TABLE money.billing ENABLE TRIGGER mat_summary_upd_tgr;
8635 ALTER TABLE money.billing ALTER COLUMN create_date SET DEFAULT NOW();
8636 ALTER TABLE money.billing ALTER COLUMN create_date SET NOT NULL;
8638 CREATE INDEX m_b_create_date_idx ON money.billing (create_date);
8639 CREATE INDEX m_b_period_start_idx ON money.billing (period_start);
8640 CREATE INDEX m_b_period_end_idx ON money.billing (period_end);
8642 CREATE OR REPLACE FUNCTION money.maintain_billing_ts () RETURNS TRIGGER AS $$
8644 NEW.billing_ts := COALESCE(NEW.period_end, NEW.create_date);
8647 $$ LANGUAGE PLPGSQL;
8648 CREATE TRIGGER maintain_billing_ts_tgr BEFORE INSERT OR UPDATE ON money.billing FOR EACH ROW EXECUTE PROCEDURE money.maintain_billing_ts();
8651 SELECT evergreen.upgrade_deps_block_check('1108', :eg_version);
8653 CREATE OR REPLACE FUNCTION asset.merge_record_assets( target_record BIGINT, source_record BIGINT ) RETURNS INT AS $func$
8655 moved_objects INT := 0;
8656 source_cn asset.call_number%ROWTYPE;
8657 target_cn asset.call_number%ROWTYPE;
8658 metarec metabib.metarecord%ROWTYPE;
8659 hold action.hold_request%ROWTYPE;
8660 ser_rec serial.record_entry%ROWTYPE;
8661 ser_sub serial.subscription%ROWTYPE;
8662 acq_lineitem acq.lineitem%ROWTYPE;
8663 acq_request acq.user_request%ROWTYPE;
8664 booking booking.resource_type%ROWTYPE;
8665 source_part biblio.monograph_part%ROWTYPE;
8666 target_part biblio.monograph_part%ROWTYPE;
8667 multi_home biblio.peer_bib_copy_map%ROWTYPE;
8671 uri_text TEXT := '';
8674 -- move any 856 entries on records that have at least one MARC-mapped URI entry
8675 SELECT INTO uri_count COUNT(*)
8676 FROM asset.uri_call_number_map m
8677 JOIN asset.call_number cn ON (m.call_number = cn.id)
8678 WHERE cn.record = source_record;
8680 IF uri_count > 0 THEN
8682 -- This returns more nodes than you might expect:
8683 -- 7 instead of 1 for an 856 with $u $y $9
8684 SELECT COUNT(*) INTO counter
8685 FROM oils_xpath_table(
8688 'biblio.record_entry',
8690 'id=' || source_record
8691 ) as t(i int,c text);
8693 FOR i IN 1 .. counter LOOP
8694 SELECT '<datafield xmlns="http://www.loc.gov/MARC21/slim"' ||
8696 ' ind1="' || FIRST(ind1) || '"' ||
8697 ' ind2="' || FIRST(ind2) || '">' ||
8699 '<subfield code="' || subfield || '">' ||
8702 regexp_replace(data,'&','&','g'),
8706 ) || '</subfield>', ''
8707 ) || '</datafield>' INTO uri_datafield
8708 FROM oils_xpath_table(
8711 'biblio.record_entry',
8712 '//*[@tag="856"][position()=' || i || ']/@ind1|' ||
8713 '//*[@tag="856"][position()=' || i || ']/@ind2|' ||
8714 '//*[@tag="856"][position()=' || i || ']/*/@code|' ||
8715 '//*[@tag="856"][position()=' || i || ']/*[@code]',
8716 'id=' || source_record
8717 ) as t(id int,ind1 text, ind2 text,subfield text,data text);
8719 -- As most of the results will be NULL, protect against NULLifying
8720 -- the valid content that we do generate
8721 uri_text := uri_text || COALESCE(uri_datafield, '');
8724 IF uri_text <> '' THEN
8725 UPDATE biblio.record_entry
8726 SET marc = regexp_replace(marc,'(</[^>]*record>)', uri_text || E'\\1')
8727 WHERE id = target_record;
8732 -- Find and move metarecords to the target record
8733 SELECT INTO metarec *
8734 FROM metabib.metarecord
8735 WHERE master_record = source_record;
8738 UPDATE metabib.metarecord
8739 SET master_record = target_record,
8741 WHERE id = metarec.id;
8743 moved_objects := moved_objects + 1;
8746 -- Find call numbers attached to the source ...
8747 FOR source_cn IN SELECT * FROM asset.call_number WHERE record = source_record LOOP
8749 SELECT INTO target_cn *
8750 FROM asset.call_number
8751 WHERE label = source_cn.label
8752 AND prefix = source_cn.prefix
8753 AND suffix = source_cn.suffix
8754 AND owning_lib = source_cn.owning_lib
8755 AND record = target_record
8758 -- ... and if there's a conflicting one on the target ...
8761 -- ... move the copies to that, and ...
8763 SET call_number = target_cn.id
8764 WHERE call_number = source_cn.id;
8766 -- ... move V holds to the move-target call number
8767 FOR hold IN SELECT * FROM action.hold_request WHERE target = source_cn.id AND hold_type = 'V' LOOP
8769 UPDATE action.hold_request
8770 SET target = target_cn.id
8773 moved_objects := moved_objects + 1;
8776 UPDATE asset.call_number SET deleted = TRUE WHERE id = source_cn.id;
8780 -- ... just move the call number to the target record
8781 UPDATE asset.call_number
8782 SET record = target_record
8783 WHERE id = source_cn.id;
8786 moved_objects := moved_objects + 1;
8789 -- Find T holds targeting the source record ...
8790 FOR hold IN SELECT * FROM action.hold_request WHERE target = source_record AND hold_type = 'T' LOOP
8792 -- ... and move them to the target record
8793 UPDATE action.hold_request
8794 SET target = target_record
8797 moved_objects := moved_objects + 1;
8800 -- Find serial records targeting the source record ...
8801 FOR ser_rec IN SELECT * FROM serial.record_entry WHERE record = source_record LOOP
8802 -- ... and move them to the target record
8803 UPDATE serial.record_entry
8804 SET record = target_record
8805 WHERE id = ser_rec.id;
8807 moved_objects := moved_objects + 1;
8810 -- Find serial subscriptions targeting the source record ...
8811 FOR ser_sub IN SELECT * FROM serial.subscription WHERE record_entry = source_record LOOP
8812 -- ... and move them to the target record
8813 UPDATE serial.subscription
8814 SET record_entry = target_record
8815 WHERE id = ser_sub.id;
8817 moved_objects := moved_objects + 1;
8820 -- Find booking resource types targeting the source record ...
8821 FOR booking IN SELECT * FROM booking.resource_type WHERE record = source_record LOOP
8822 -- ... and move them to the target record
8823 UPDATE booking.resource_type
8824 SET record = target_record
8825 WHERE id = booking.id;
8827 moved_objects := moved_objects + 1;
8830 -- Find acq lineitems targeting the source record ...
8831 FOR acq_lineitem IN SELECT * FROM acq.lineitem WHERE eg_bib_id = source_record LOOP
8832 -- ... and move them to the target record
8834 SET eg_bib_id = target_record
8835 WHERE id = acq_lineitem.id;
8837 moved_objects := moved_objects + 1;
8840 -- Find acq user purchase requests targeting the source record ...
8841 FOR acq_request IN SELECT * FROM acq.user_request WHERE eg_bib = source_record LOOP
8842 -- ... and move them to the target record
8843 UPDATE acq.user_request
8844 SET eg_bib = target_record
8845 WHERE id = acq_request.id;
8847 moved_objects := moved_objects + 1;
8850 -- Find parts attached to the source ...
8851 FOR source_part IN SELECT * FROM biblio.monograph_part WHERE record = source_record LOOP
8853 SELECT INTO target_part *
8854 FROM biblio.monograph_part
8855 WHERE label = source_part.label
8856 AND record = target_record;
8858 -- ... and if there's a conflicting one on the target ...
8861 -- ... move the copy-part maps to that, and ...
8862 UPDATE asset.copy_part_map
8863 SET part = target_part.id
8864 WHERE part = source_part.id;
8866 -- ... move P holds to the move-target part
8867 FOR hold IN SELECT * FROM action.hold_request WHERE target = source_part.id AND hold_type = 'P' LOOP
8869 UPDATE action.hold_request
8870 SET target = target_part.id
8873 moved_objects := moved_objects + 1;
8878 -- ... just move the part to the target record
8879 UPDATE biblio.monograph_part
8880 SET record = target_record
8881 WHERE id = source_part.id;
8884 moved_objects := moved_objects + 1;
8887 -- Find multi_home items attached to the source ...
8888 FOR multi_home IN SELECT * FROM biblio.peer_bib_copy_map WHERE peer_record = source_record LOOP
8889 -- ... and move them to the target record
8890 UPDATE biblio.peer_bib_copy_map
8891 SET peer_record = target_record
8892 WHERE id = multi_home.id;
8894 moved_objects := moved_objects + 1;
8897 -- And delete mappings where the item's home bib was merged with the peer bib
8898 DELETE FROM biblio.peer_bib_copy_map WHERE peer_record = (
8899 SELECT (SELECT record FROM asset.call_number WHERE id = call_number)
8900 FROM asset.copy WHERE id = target_copy
8903 -- Apply merge tracking
8904 UPDATE biblio.record_entry
8905 SET merge_date = NOW() WHERE id = target_record;
8907 UPDATE biblio.record_entry
8908 SET merge_date = NOW(), merged_to = target_record
8909 WHERE id = source_record;
8911 -- replace book bag entries of source_record with target_record
8912 UPDATE container.biblio_record_entry_bucket_item
8913 SET target_biblio_record_entry = target_record
8914 WHERE bucket IN (SELECT id FROM container.biblio_record_entry_bucket WHERE btype = 'bookbag')
8915 AND target_biblio_record_entry = source_record;
8917 -- Finally, "delete" the source record
8918 DELETE FROM biblio.record_entry WHERE id = source_record;
8920 -- That's all, folks!
8921 RETURN moved_objects;
8923 $func$ LANGUAGE plpgsql;
8926 SELECT evergreen.upgrade_deps_block_check('1109', :eg_version);
8928 INSERT into config.org_unit_setting_type (name, label, grp, description, datatype)
8929 values ('circ.staff_placed_holds_fallback_to_ws_ou','Workstation OU fallback for staff-placed holds',
8930 'circ', 'For staff-placed holds, in the absence of a patron preferred pickup location, fall back to using the staff workstation OU (rather than patron home OU)', 'bool');
8936 \qecho Reingesting all records. This may take a while.
8937 \qecho This command can be stopped (control-c) and rerun later if needed:
8941 \qecho same_marc BOOL;
8943 \qecho SELECT INTO same_marc enabled FROM config.internal_flag WHERE name = 'ingest.reingest.force_on_same_marc';
8944 \qecho UPDATE config.internal_flag SET enabled = true WHERE name = 'ingest.reingest.force_on_same_marc';
8945 \qecho UPDATE biblio.record_entry SET id=id WHERE not deleted AND id > 0;
8946 \qecho UPDATE config.internal_flag SET enabled = same_marc WHERE name = 'ingest.reingest.force_on_same_marc';
8954 SELECT INTO same_marc enabled FROM config.internal_flag WHERE name = 'ingest.reingest.force_on_same_marc';
8955 UPDATE config.internal_flag SET enabled = true WHERE name = 'ingest.reingest.force_on_same_marc';
8956 UPDATE biblio.record_entry SET id=id WHERE not deleted AND id > 0;
8957 UPDATE config.internal_flag SET enabled = same_marc WHERE name = 'ingest.reingest.force_on_same_marc';