Merge remote branch 'working/user/dbs/fix-nonfiling-titles'
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Mon, 30 Jan 2012 22:16:08 +0000 (17:16 -0500)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Mon, 30 Jan 2012 22:16:08 +0000 (17:16 -0500)
Conflicts:
Open-ILS/src/sql/Pg/950.data.seed-values.sql

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>

1  2 
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/0672.fix-nonfiling-titles.sql

@@@ -86,22 -86,19 +86,22 @@@ CREATE TRIGGER no_overlapping_dep
      BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
      FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
  
- INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0671', :eg_version); -- tsbere/berick
 -INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0646', :eg_version); -- jamesrf/senator
++INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0672', :eg_version); -- dbs/senator
  
  CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
        quality         INT     CHECK ( quality BETWEEN 0 AND 100 ),
        source          TEXT    NOT NULL UNIQUE,
 -      transcendant    BOOL    NOT NULL DEFAULT FALSE
 +      transcendant    BOOL    NOT NULL DEFAULT FALSE,
 +      can_have_copies BOOL    NOT NULL DEFAULT TRUE
  );
  COMMENT ON TABLE config.bib_source IS $$
  This is table is used to set up the relative "quality" of each
  MARC source, such as OCLC.  Also identifies "transcendant" sources,
  i.e., sources of bib records that should display in the OPAC
 -even if no copies or located URIs are attached.
 +even if no copies or located URIs are attached. Also indicates if
 +the source is allowed to have actual copies on its bibs. Volumes
 +for targeted URIs are unaffected by this setting.
  $$;
  
  CREATE TABLE config.standing (
@@@ -122,9 -119,30 +122,9 @@@ CREATE TABLE config.standing_penalty 
        name            TEXT    NOT NULL UNIQUE,
        label           TEXT    NOT NULL,
        block_list      TEXT,
 +      staff_alert     BOOL    NOT NULL DEFAULT FALSE,
        org_depth       INTEGER
  );
 -INSERT INTO config.standing_penalty (id,name,label,block_list)
 -      VALUES (1,'PATRON_EXCEEDS_FINES','Patron exceeds fine threshold','CIRC|HOLD|RENEW');
 -INSERT INTO config.standing_penalty (id,name,label,block_list)
 -      VALUES (2,'PATRON_EXCEEDS_OVERDUE_COUNT','Patron exceeds max overdue item threshold','CIRC|HOLD|RENEW');
 -INSERT INTO config.standing_penalty (id,name,label,block_list)
 -      VALUES (3,'PATRON_EXCEEDS_CHECKOUT_COUNT','Patron exceeds max checked out item threshold','CIRC');
 -INSERT INTO config.standing_penalty (id,name,label,block_list)
 -      VALUES (4,'PATRON_EXCEEDS_COLLECTIONS_WARNING','Patron exceeds pre-collections warning fine threshold','CIRC|HOLD|RENEW');
 -
 -INSERT INTO config.standing_penalty (id,name,label) VALUES (20,'ALERT_NOTE','Alerting Note, no blocks');
 -INSERT INTO config.standing_penalty (id,name,label) VALUES (21,'SILENT_NOTE','Note, no blocks');
 -INSERT INTO config.standing_penalty (id,name,label,block_list) VALUES (22,'STAFF_C','Alerting block on Circ','CIRC');
 -INSERT INTO config.standing_penalty (id,name,label,block_list) VALUES (23,'STAFF_CH','Alerting block on Circ and Hold','CIRC|HOLD');
 -INSERT INTO config.standing_penalty (id,name,label,block_list) VALUES (24,'STAFF_CR','Alerting block on Circ and Renew','CIRC|RENEW');
 -INSERT INTO config.standing_penalty (id,name,label,block_list) VALUES (25,'STAFF_CHR','Alerting block on Circ, Hold and Renew','CIRC|HOLD|RENEW');
 -INSERT INTO config.standing_penalty (id,name,label,block_list) VALUES (26,'STAFF_HR','Alerting block on Hold and Renew','HOLD|RENEW');
 -INSERT INTO config.standing_penalty (id,name,label,block_list) VALUES (27,'STAFF_H','Alerting block on Hold','HOLD');
 -INSERT INTO config.standing_penalty (id,name,label,block_list) VALUES (28,'STAFF_R','Alerting block on Renew','RENEW');
 -INSERT INTO config.standing_penalty (id,name,label) VALUES (29,'INVALID_PATRON_ADDRESS','Patron has an invalid address');
 -INSERT INTO config.standing_penalty (id,name,label) VALUES (30,'PATRON_IN_COLLECTIONS','Patron has been referred to a collections agency');
 -
 -SELECT SETVAL('config.standing_penalty_id_seq', 100);
  
  CREATE TABLE config.xml_transform (
        name            TEXT    PRIMARY KEY,
@@@ -934,12 -952,4 +934,12 @@@ CREATE TRIGGER limit_logs_ous
      BEFORE INSERT OR UPDATE ON config.org_unit_setting_type_log
      FOR EACH ROW EXECUTE PROCEDURE limit_oustl();
  
 +CREATE TABLE config.sms_carrier (
 +    id              SERIAL PRIMARY KEY,
 +    region          TEXT,
 +    name            TEXT,
 +    email_gateway   TEXT,
 +    active          BOOLEAN DEFAULT TRUE
 +);
 +
  COMMIT;
@@@ -1,10 -1,10 +1,10 @@@
  --002.schema.config.sql:
 -INSERT INTO config.bib_source (id, quality, source, transcendant) VALUES 
 -    (1, 90, oils_i18n_gettext(1, 'oclc', 'cbs', 'source'), FALSE);
 -INSERT INTO config.bib_source (id, quality, source, transcendant) VALUES 
 -    (2, 10, oils_i18n_gettext(2, 'System Local', 'cbs', 'source'), FALSE);
 -INSERT INTO config.bib_source (id, quality, source, transcendant) VALUES 
 -    (3, 1, oils_i18n_gettext(3, 'Project Gutenberg', 'cbs', 'source'), TRUE);
 +INSERT INTO config.bib_source (id, quality, source, transcendant, can_have_copies) VALUES 
 +    (1, 90, oils_i18n_gettext(1, 'oclc', 'cbs', 'source'), FALSE, TRUE);
 +INSERT INTO config.bib_source (id, quality, source, transcendant, can_have_copies) VALUES 
 +    (2, 10, oils_i18n_gettext(2, 'System Local', 'cbs', 'source'), FALSE, TRUE);
 +INSERT INTO config.bib_source (id, quality, source, transcendant, can_have_copies) VALUES 
 +    (3, 1, oils_i18n_gettext(3, 'Project Gutenberg', 'cbs', 'source'), TRUE, TRUE);
  SELECT SETVAL('config.bib_source_id_seq'::TEXT, 100);
  
  INSERT INTO biblio.peer_type (id,name) VALUES
@@@ -19,79 -19,6 +19,79 @@@ INSERT INTO config.standing (id, value
  INSERT INTO config.standing (id, value) VALUES (2, oils_i18n_gettext(2, 'Barred', 'cst', 'value'));
  SELECT SETVAL('config.standing_id_seq'::TEXT, 100);
  
 +INSERT INTO config.standing_penalty (id,name,label,block_list,staff_alert)
 +      VALUES (1,'PATRON_EXCEEDS_FINES',oils_i18n_gettext(1, 'Patron exceeds fine threshold', 'csp', 'label'),'CIRC|HOLD|RENEW', TRUE);
 +INSERT INTO config.standing_penalty (id,name,label,block_list,staff_alert)
 +      VALUES (2,'PATRON_EXCEEDS_OVERDUE_COUNT',oils_i18n_gettext(2, 'Patron exceeds max overdue item threshold', 'csp', 'label'),'CIRC|HOLD|RENEW', TRUE);
 +INSERT INTO config.standing_penalty (id,name,label,block_list,staff_alert)
 +      VALUES (3,'PATRON_EXCEEDS_CHECKOUT_COUNT',oils_i18n_gettext(3, 'Patron exceeds max checked out item threshold', 'csp', 'label'),'CIRC', TRUE);
 +INSERT INTO config.standing_penalty (id,name,label,block_list,staff_alert)
 +      VALUES (4,'PATRON_EXCEEDS_COLLECTIONS_WARNING',oils_i18n_gettext(4, 'Patron exceeds pre-collections warning fine threshold', 'csp', 'label'),'CIRC|HOLD|RENEW', TRUE);
 +
 +INSERT INTO config.standing_penalty (id,name,label,staff_alert) VALUES (20,'ALERT_NOTE',oils_i18n_gettext(20, 'Alerting Note, no blocks', 'csp', 'label'),TRUE);
 +INSERT INTO config.standing_penalty (id,name,label) VALUES (21,'SILENT_NOTE',oils_i18n_gettext(21, 'Note, no blocks', 'csp', 'label'));
 +INSERT INTO config.standing_penalty (id,name,label,block_list,staff_alert) VALUES (22,'STAFF_C',oils_i18n_gettext(22, 'Alerting block on Circ', 'csp', 'label'),'CIRC', TRUE);
 +INSERT INTO config.standing_penalty (id,name,label,block_list,staff_alert) VALUES (23,'STAFF_CH',oils_i18n_gettext(23, 'Alerting block on Circ and Hold', 'csp', 'label'),'CIRC|HOLD', TRUE);
 +INSERT INTO config.standing_penalty (id,name,label,block_list,staff_alert) VALUES (24,'STAFF_CR',oils_i18n_gettext(24, 'Alerting block on Circ and Renew', 'csp', 'label'),'CIRC|RENEW', TRUE);
 +INSERT INTO config.standing_penalty (id,name,label,block_list,staff_alert) VALUES (25,'STAFF_CHR',oils_i18n_gettext(25, 'Alerting block on Circ, Hold and Renew', 'csp', 'label'),'CIRC|HOLD|RENEW', TRUE);
 +INSERT INTO config.standing_penalty (id,name,label,block_list,staff_alert) VALUES (26,'STAFF_HR',oils_i18n_gettext(26, 'Alerting block on Hold and Renew', 'csp', 'label'),'HOLD|RENEW', TRUE);
 +INSERT INTO config.standing_penalty (id,name,label,block_list,staff_alert) VALUES (27,'STAFF_H',oils_i18n_gettext(27, 'Alerting block on Hold', 'csp', 'label'),'HOLD', TRUE);
 +INSERT INTO config.standing_penalty (id,name,label,block_list,staff_alert) VALUES (28,'STAFF_R',oils_i18n_gettext(28, 'Alerting block on Renew', 'csp', 'label'),'RENEW', TRUE);
 +INSERT INTO config.standing_penalty (id,name,label) VALUES (29,'INVALID_PATRON_ADDRESS',oils_i18n_gettext(29, 'Patron has an invalid address', 'csp', 'label'));
 +INSERT INTO config.standing_penalty (id,name,label) VALUES (30,'PATRON_IN_COLLECTIONS',oils_i18n_gettext(30, 'Patron has been referred to a collections agency', 'csp', 'label'));
 +INSERT INTO config.standing_penalty (id, name, label, staff_alert, org_depth) VALUES
 +    (
 +        31,
 +        'INVALID_PATRON_EMAIL_ADDRESS',
 +        oils_i18n_gettext(
 +            31,
 +            'Patron had an invalid email address',
 +            'csp',
 +            'label'
 +        ),
 +        TRUE,
 +        0
 +    ),
 +    (
 +        32,
 +        'INVALID_PATRON_DAY_PHONE',
 +        oils_i18n_gettext(
 +            32,
 +            'Patron had an invalid daytime phone number',
 +            'csp',
 +            'label'
 +        ),
 +        TRUE,
 +        0
 +    ),
 +    (
 +        33,
 +        'INVALID_PATRON_EVENING_PHONE',
 +        oils_i18n_gettext(
 +            33,
 +            'Patron had an invalid evening phone number',
 +            'csp',
 +            'label'
 +        ),
 +        TRUE,
 +        0
 +    ),
 +    (
 +        34,
 +        'INVALID_PATRON_OTHER_PHONE',
 +        oils_i18n_gettext(
 +            34,
 +            'Patron had an invalid other phone number',
 +            'csp',
 +            'label'
 +        ),
 +        TRUE,
 +        0
 +    );
 +
 +
 +SELECT SETVAL('config.standing_penalty_id_seq', 100);
 +
  INSERT INTO config.metabib_class ( name, label ) VALUES ( 'identifier', oils_i18n_gettext('identifier', 'Identifier', 'cmc', 'label') );
  INSERT INTO config.metabib_class ( name, label ) VALUES ( 'keyword', oils_i18n_gettext('keyword', 'Keyword', 'cmc', 'label') );
  INSERT INTO config.metabib_class ( name, label ) VALUES ( 'title', oils_i18n_gettext('title', 'Title', 'cmc', 'label') );
@@@ -120,7 -47,7 +120,7 @@@ INSERT INTO config.metabib_field ( id, 
  INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath ) VALUES 
      (5, 'title', 'uniform', oils_i18n_gettext(5, 'Uniform Title', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:titleInfo[mods32:title and (@type='uniform')]$$ );
  INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath ) VALUES 
-     (6, 'title', 'proper', oils_i18n_gettext(6, 'Title Proper', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:titleInfo[mods32:title and not (@type)]$$ );
+     (6, 'title', 'proper', oils_i18n_gettext(6, 'Title Proper', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:titleNonfiling[mods32:title and not (@type)]$$ );
  
  INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, facet_xpath, facet_field ) VALUES 
      (7, 'author', 'corporate', oils_i18n_gettext(7, 'Corporate Author', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:name[@type='corporate' and mods32:role/mods32:roleTerm[text()='creator']]$$, $$//*[local-name()='namePart']$$, TRUE ); -- /* to fool vim */;
@@@ -1515,20 -1442,7 +1515,20 @@@ INSERT INTO permission.perm_list ( id, 
   ( 512, 'ACQ_INVOICE_REOPEN', oils_i18n_gettext( 512,
      'Allows a user to reopen an Acquisitions invoice', 'ppl', 'description' )),
   ( 513, 'DEBUG_CLIENT', oils_i18n_gettext( 513,
 -    'Allows a user to use debug functions in the staff client', 'ppl', 'description' ));
 +    'Allows a user to use debug functions in the staff client', 'ppl', 'description' )),
 + ( 514, 'UPDATE_PATRON_ACTIVE_CARD', oils_i18n_gettext( 514,
 +    'Allows a user to manually adjust a patron''s active cards', 'ppl', 'description')),
 + ( 515, 'UPDATE_PATRON_PRIMARY_CARD', oils_i18n_gettext( 515,
 +    'Allows a user to manually adjust a patron''s primary card', 'ppl', 'description')),
 + ( 516, 'CREATE_REPORT_TEMPLATE', oils_i18n_gettext( 516,
 +    'Allows a user to create report templates', 'ppl', 'description' )),
 + ( 517, 'COPY_HOLDS_FORCE', oils_i18n_gettext( 517, 
 +    'Allow a user to place a force hold on a specific copy', 'ppl', 'description' )),
 + ( 518, 'COPY_HOLDS_RECALL', oils_i18n_gettext( 518, 
 +    'Allow a user to place a cataloging recall on a specific copy', 'ppl', 'description' )),
 + ( 519, 'ADMIN_SMS_CARRIER', oils_i18n_gettext( 519,
 +    'Allows a user to add/create/delete SMS Carrier entries.', 'ppl', 'description' ));
 +
  
  SELECT SETVAL('permission.perm_list_id_seq'::TEXT, 1000);
  
@@@ -1877,7 -1791,6 +1877,7 @@@ INSERT INTO permission.grp_perm_map (gr
                        'CREATE_COPY_STAT_CAT_ENTRY',
                        'CREATE_COPY_STAT_CAT_ENTRY_MAP',
                        'RUN_REPORTS',
 +                      'CREATE_REPORT_TEMPLATE',
                        'SHARE_REPORT_FOLDER',
                        'UPDATE_COPY_LOCATION',
                        'UPDATE_COPY_STAT_CAT',
@@@ -2278,7 -2191,6 +2278,7 @@@ INSERT INTO permission.grp_perm_map (gr
                        'DELETE_INVOICE_METHOD',
                        'DELETE_PROVIDER',
                        'RUN_REPORTS',
 +                      'CREATE_REPORT_TEMPLATE',
                        'SHARE_REPORT_FOLDER',
                        'UPDATE_ACQ_FUNDING_SOURCE',
                        'UPDATE_INVOICE_ITEM_TYPE',
@@@ -2445,10 -2357,7 +2445,10 @@@ INSERT INTO config.settings_group (name
  ('recall', oils_i18n_gettext('config.settings_group.recall', 'Recalls', 'coust', 'label')),
  ('booking', oils_i18n_gettext('config.settings_group.booking', 'Booking', 'coust', 'label')),
  ('offline', oils_i18n_gettext('config.settings_group.offline', 'Offline', 'coust', 'label')),
 -('receipt_template', oils_i18n_gettext('config.settings_group.receipt_template', 'Receipt Template', 'coust', 'label'));
 +('receipt_template', oils_i18n_gettext('config.settings_group.receipt_template', 'Receipt Template', 'coust', 'label')),
 +('sms', oils_i18n_gettext('sms','SMS Text Messages','csg','label'))
 +;
 +
  
  
  -- org_unit setting types
@@@ -4582,47 -4491,6 +4582,47 @@@ INSERT into config.org_unit_setting_typ
          'coust', 'description'),
      'bool', null)
  
 +,( 'opac.search.tag_circulated_items', 'opac',
 +    oils_i18n_gettext(
 +        'opac.search.tag_circulated_items',
 +        'Tag Circulated Items in Results',
 +        'coust', 'label'
 +    ),
 +    oils_i18n_gettext(
 +        'opac.search.tag_circulated_items',
 +        'When a user is both logged in and has opted in to circulation history tracking, turning on this setting will cause previous (or currently) circulated items to be highlighted in search results',
 +        'coust', 'description'
 +    ),
 +    'bool', null)
 +
 +,( 'sms.enable', 'sms',
 +    oils_i18n_gettext(
 +        'sms.enable',
 +        'Enable features that send SMS text messages.',
 +        'coust',
 +        'label'
 +    ),
 +    oils_i18n_gettext(
 +        'sms.enable',
 +        'Current features that use SMS include hold-ready-for-pickup notifications and a "Send Text" action for call numbers in the OPAC. If this setting is not enabled, the SMS options will not be offered to the user.  Unless you are carefully silo-ing patrons and their use of the OPAC, the context org for this setting should be the top org in the org hierarchy, otherwise patrons can trample their user settings when jumping between orgs.',
 +        'coust',
 +        'description'
 +    ),
 +    'bool', null)
 +,( 'sms.disable_authentication_requirement.callnumbers', 'sms',
 +    oils_i18n_gettext(
 +        'sms.disable_authentication_requirement.callnumbers',
 +        'Disable auth requirement for texting call numbers.',
 +        'coust',
 +        'label'
 +    ),
 +    oils_i18n_gettext(
 +        'sms.disable_authentication_requirement.callnumbers',
 +        'Disable authentication requirement for sending call number information via SMS from the OPAC.',
 +        'coust',
 +        'description'
 +    ),
 +    'bool', null)
  ;
  
  UPDATE config.org_unit_setting_type
@@@ -6473,18 -6341,9 +6473,18 @@@ INSERT INTO action_trigger.environment 
      (4, 'lineitems.lineitem_notes'),
      (4, 'notes');
  
 +INSERT INTO action_trigger.cleanup ( module, description ) VALUES (
 +    'CreateHoldNotification',
 +    oils_i18n_gettext(
 +        'CreateHoldNotification',
 +        'Creates a hold_notification record for each notified hold',
 +        'atclean',
 +        'description'
 +    )
 +);
  
 -INSERT INTO action_trigger.event_definition (id, active, owner, name, hook, validator, reactor, delay, delay_field, group_field, template)
 -    VALUES (5, 'f', 1, 'Hold Ready for Pickup Email Notification', 'hold.available', 'HoldIsAvailable', 'SendEmail', '30 minutes', 'shelf_time', 'usr',
 +INSERT INTO action_trigger.event_definition (id, active, owner, name, hook, validator, reactor, delay, delay_field, group_field, cleanup_success, template)
 +    VALUES (5, 'f', 1, 'Hold Ready for Pickup Email Notification', 'hold.available', 'HoldIsAvailable', 'SendEmail', '30 minutes', 'shelf_time', 'usr', 'CreateHoldNotification',
  $$
  [%- USE date -%]
  [%- user = target.0.usr -%]
@@@ -7312,12 -7171,11 +7312,18 @@@ INSERT INTO config.index_normalizer (na
  );
  
  INSERT INTO config.index_normalizer (name, description, func, param_count) VALUES (
 +    'Coded Value Map Normalizer', 
 +    'Applies coded_value_map mapping of values',
 +    'coded_value_map_normalizer', 
 +    1
 +);
 +
++INSERT INTO config.index_normalizer (name, description, func, param_count) VALUES (
+       'Search Normalize',
+       'Apply search normalization rules to the extracted text. A less extreme version of NACO normalization.',
+       'search_normalize',
+       0
+ );
  
  -- make use of the index normalizers
  
@@@ -7326,7 -7184,7 +7332,7 @@@ INSERT INTO config.metabib_field_index_
              i.id
        FROM  config.metabib_field m,
          config.index_normalizer i
-       WHERE i.func IN ('naco_normalize','split_date_range')
+       WHERE i.func IN ('search_normalize','split_date_range')
              AND m.id NOT IN (18, 19);
  
  INSERT INTO config.metabib_field_index_norm_map (field,norm,pos)
  # the environment because a special reactor will take care of filling it in.
  
  FOR item IN items;
 -    bibxml = helpers.xml_doc(item.target_biblio_record_entry.marc);
 +    bibxml = helpers.unapi_bre(item.target_biblio_record_entry, {flesh => '{mra}'});
      title = "";
      FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]');
          title = title _ part.textContent;
      END;
      author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent;
 +    item_type = bibxml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]').getAttribute('coded-value');
  
 -    helpers.csv_datum(title) %],[% helpers.csv_datum(author) %],[% FOR note IN item.notes; helpers.csv_datum(note.note); ","; END; "\n";
 +    helpers.csv_datum(title) %],[% helpers.csv_datum(author) %],[% helpers.csv_datum(item_type) %],[% FOR note IN item.notes; helpers.csv_datum(note.note); ","; END; "\n";
  END -%]
  $$
  );
@@@ -10537,1332 -10394,3 +10543,1332 @@@ INSERT INTO action_trigger.validator ( 
      'ReservationIsAvailable',
      'Checked that a reserved resource is available for checkout'
  );
 +
 +INSERT INTO container.biblio_record_entry_bucket_type (code, label) VALUES (
 +    'vandelay_queue',
 +    oils_i18n_gettext('vandelay_queue', 'Vandelay Queue', 'cbrebt', 'label')
 +);
 +
 +INSERT INTO config.usr_setting_type (name,grp,opac_visible,label,description,datatype,fm_class) VALUES (
 +    'opac.default_sms_carrier',
 +    'sms',
 +    TRUE,
 +    oils_i18n_gettext(
 +        'opac.default_sms_carrier',
 +        'Default SMS/Text Carrier',
 +        'cust',
 +        'label'
 +    ),
 +    oils_i18n_gettext(
 +        'opac.default_sms_carrier',
 +        'Default SMS/Text Carrier',
 +        'cust',
 +        'description'
 +    ),
 +    'link',
 +    'csc'
 +);
 +
 +INSERT INTO config.usr_setting_type (name,grp,opac_visible,label,description,datatype) VALUES (
 +    'opac.default_sms_notify',
 +    'sms',
 +    TRUE,
 +    oils_i18n_gettext(
 +        'opac.default_sms_notify',
 +        'Default SMS/Text Number',
 +        'cust',
 +        'label'
 +    ),
 +    oils_i18n_gettext(
 +        'opac.default_sms_notify',
 +        'Default SMS/Text Number',
 +        'cust',
 +        'description'
 +    ),
 +    'string'
 +);
 +
 +INSERT INTO config.usr_setting_type (name,grp,opac_visible,label,description,datatype) VALUES (
 +    'opac.default_phone',
 +    'opac',
 +    TRUE,
 +    oils_i18n_gettext(
 +        'opac.default_phone',
 +        'Default Phone Number',
 +        'cust',
 +        'label'
 +    ),
 +    oils_i18n_gettext(
 +        'opac.default_phone',
 +        'Default Phone Number',
 +        'cust',
 +        'description'
 +    ),
 +    'string'
 +);
 +
 +SELECT setval( 'config.sms_carrier_id_seq', 1000 );
 +INSERT INTO config.sms_carrier VALUES
 +
 +    -- Testing
 +    (
 +        1,
 +        oils_i18n_gettext(
 +            1,
 +            'Local',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            1,
 +            'Test Carrier',
 +            'csc',
 +            'name'
 +        ),
 +        'opensrf+$number@localhost',
 +        FALSE
 +    ),
 +
 +    -- Canada & USA
 +    (
 +        2,
 +        oils_i18n_gettext(
 +            2,
 +            'Canada & USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            2,
 +            'Rogers Wireless',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@pcs.rogers.com',
 +        TRUE
 +    ),
 +    (
 +        3,
 +        oils_i18n_gettext(
 +            3,
 +            'Canada & USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            3,
 +            'Rogers Wireless (Alternate)',
 +            'csc',
 +            'name'
 +        ),
 +        '1$number@mms.rogers.com',
 +        TRUE
 +    ),
 +    (
 +        4,
 +        oils_i18n_gettext(
 +            4,
 +            'Canada & USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            4,
 +            'Telus Mobility',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@msg.telus.com',
 +        TRUE
 +    ),
 +
 +    -- Canada
 +    (
 +        5,
 +        oils_i18n_gettext(
 +            5,
 +            'Canada',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            5,
 +            'Koodo Mobile',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@msg.telus.com',
 +        TRUE
 +    ),
 +    (
 +        6,
 +        oils_i18n_gettext(
 +            6,
 +            'Canada',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            6,
 +            'Fido',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@fido.ca',
 +        TRUE
 +    ),
 +    (
 +        7,
 +        oils_i18n_gettext(
 +            7,
 +            'Canada',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            7,
 +            'Bell Mobility & Solo Mobile',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@txt.bell.ca',
 +        TRUE
 +    ),
 +    (
 +        8,
 +        oils_i18n_gettext(
 +            8,
 +            'Canada',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            8,
 +            'Bell Mobility & Solo Mobile (Alternate)',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@txt.bellmobility.ca',
 +        TRUE
 +    ),
 +    (
 +        9,
 +        oils_i18n_gettext(
 +            9,
 +            'Canada',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            9,
 +            'Aliant',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@sms.wirefree.informe.ca',
 +        TRUE
 +    ),
 +    (
 +        10,
 +        oils_i18n_gettext(
 +            10,
 +            'Canada',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            10,
 +            'PC Telecom',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@mobiletxt.ca',
 +        TRUE
 +    ),
 +    (
 +        11,
 +        oils_i18n_gettext(
 +            11,
 +            'Canada',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            11,
 +            'SaskTel',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@sms.sasktel.com',
 +        TRUE
 +    ),
 +    (
 +        12,
 +        oils_i18n_gettext(
 +            12,
 +            'Canada',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            12,
 +            'MTS Mobility',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@text.mtsmobility.com',
 +        TRUE
 +    ),
 +    (
 +        13,
 +        oils_i18n_gettext(
 +            13,
 +            'Canada',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            13,
 +            'Virgin Mobile',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@vmobile.ca',
 +        TRUE
 +    ),
 +
 +    -- International
 +    (
 +        14,
 +        oils_i18n_gettext(
 +            14,
 +            'International',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            14,
 +            'Iridium',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@msg.iridium.com',
 +        TRUE
 +    ),
 +    (
 +        15,
 +        oils_i18n_gettext(
 +            15,
 +            'International',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            15,
 +            'Globalstar',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@msg.globalstarusa.com',
 +        TRUE
 +    ),
 +    (
 +        16,
 +        oils_i18n_gettext(
 +            16,
 +            'International',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            16,
 +            'Bulletin.net',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@bulletinmessenger.net', -- International Formatted number
 +        TRUE
 +    ),
 +    (
 +        17,
 +        oils_i18n_gettext(
 +            17,
 +            'International',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            17,
 +            'Panacea Mobile',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@api.panaceamobile.com',
 +        TRUE
 +    ),
 +
 +    -- USA
 +    (
 +        18,
 +        oils_i18n_gettext(
 +            18,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            18,
 +            'C Beyond',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@cbeyond.sprintpcs.com',
 +        TRUE
 +    ),
 +    (
 +        19,
 +        oils_i18n_gettext(
 +            19,
 +            'Alaska, USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            19,
 +            'General Communications, Inc.',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@mobile.gci.net',
 +        TRUE
 +    ),
 +    (
 +        20,
 +        oils_i18n_gettext(
 +            20,
 +            'California, USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            20,
 +            'Golden State Cellular',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@gscsms.com',
 +        TRUE
 +    ),
 +    (
 +        21,
 +        oils_i18n_gettext(
 +            21,
 +            'Cincinnati, Ohio, USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            21,
 +            'Cincinnati Bell',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@gocbw.com',
 +        TRUE
 +    ),
 +    (
 +        22,
 +        oils_i18n_gettext(
 +            22,
 +            'Hawaii, USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            22,
 +            'Hawaiian Telcom Wireless',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@hawaii.sprintpcs.com',
 +        TRUE
 +    ),
 +    (
 +        23,
 +        oils_i18n_gettext(
 +            23,
 +            'Midwest, USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            23,
 +            'i wireless (T-Mobile)',
 +            'csc',
 +            'name'
 +        ),
 +        '$number.iws@iwspcs.net',
 +        TRUE
 +    ),
 +    (
 +        24,
 +        oils_i18n_gettext(
 +            24,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            24,
 +            'i-wireless (Sprint PCS)',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@iwirelesshometext.com',
 +        TRUE
 +    ),
 +    (
 +        25,
 +        oils_i18n_gettext(
 +            25,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            25,
 +            'MetroPCS',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@mymetropcs.com',
 +        TRUE
 +    ),
 +    (
 +        26,
 +        oils_i18n_gettext(
 +            26,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            26,
 +            'Kajeet',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@mobile.kajeet.net',
 +        TRUE
 +    ),
 +    (
 +        27,
 +        oils_i18n_gettext(
 +            27,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            27,
 +            'Element Mobile',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@SMS.elementmobile.net',
 +        TRUE
 +    ),
 +    (
 +        28,
 +        oils_i18n_gettext(
 +            28,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            28,
 +            'Esendex',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@echoemail.net',
 +        TRUE
 +    ),
 +    (
 +        29,
 +        oils_i18n_gettext(
 +            29,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            29,
 +            'Boost Mobile',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@myboostmobile.com',
 +        TRUE
 +    ),
 +    (
 +        30,
 +        oils_i18n_gettext(
 +            30,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            30,
 +            'BellSouth',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@bellsouth.com',
 +        TRUE
 +    ),
 +    (
 +        31,
 +        oils_i18n_gettext(
 +            31,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            31,
 +            'Bluegrass Cellular',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@sms.bluecell.com',
 +        TRUE
 +    ),
 +    (
 +        32,
 +        oils_i18n_gettext(
 +            32,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            32,
 +            'AT&T Enterprise Paging',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@page.att.net',
 +        TRUE
 +    ),
 +    (
 +        33,
 +        oils_i18n_gettext(
 +            33,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            33,
 +            'AT&T Mobility/Wireless',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@txt.att.net',
 +        TRUE
 +    ),
 +    (
 +        34,
 +        oils_i18n_gettext(
 +            34,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            34,
 +            'AT&T Global Smart Messaging Suite',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@sms.smartmessagingsuite.com',
 +        TRUE
 +    ),
 +    (
 +        35,
 +        oils_i18n_gettext(
 +            35,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            35,
 +            'Alltel (Allied Wireless)',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@sms.alltelwireless.com',
 +        TRUE
 +    ),
 +    (
 +        36,
 +        oils_i18n_gettext(
 +            36,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            36,
 +            'Alaska Communications',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@msg.acsalaska.com',
 +        TRUE
 +    ),
 +    (
 +        37,
 +        oils_i18n_gettext(
 +            37,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            37,
 +            'Ameritech',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@paging.acswireless.com',
 +        TRUE
 +    ),
 +    (
 +        38,
 +        oils_i18n_gettext(
 +            38,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            38,
 +            'Cingular (GoPhone prepaid)',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@cingulartext.com',
 +        TRUE
 +    ),
 +    (
 +        39,
 +        oils_i18n_gettext(
 +            39,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            39,
 +            'Cingular (Postpaid)',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@cingular.com',
 +        TRUE
 +    ),
 +    (
 +        40,
 +        oils_i18n_gettext(
 +            40,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            40,
 +            'Cellular One (Dobson) / O2 / Orange',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@mobile.celloneusa.com',
 +        TRUE
 +    ),
 +    (
 +        41,
 +        oils_i18n_gettext(
 +            41,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            41,
 +            'Cellular South',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@csouth1.com',
 +        TRUE
 +    ),
 +    (
 +        42,
 +        oils_i18n_gettext(
 +            42,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            42,
 +            'Cellcom',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@cellcom.quiktxt.com',
 +        TRUE
 +    ),
 +    (
 +        43,
 +        oils_i18n_gettext(
 +            43,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            43,
 +            'Chariton Valley Wireless',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@sms.cvalley.net',
 +        TRUE
 +    ),
 +    (
 +        44,
 +        oils_i18n_gettext(
 +            44,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            44,
 +            'Cricket',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@sms.mycricket.com',
 +        TRUE
 +    ),
 +    (
 +        45,
 +        oils_i18n_gettext(
 +            45,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            45,
 +            'Cleartalk Wireless',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@sms.cleartalk.us',
 +        TRUE
 +    ),
 +    (
 +        46,
 +        oils_i18n_gettext(
 +            46,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            46,
 +            'Edge Wireless',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@sms.edgewireless.com',
 +        TRUE
 +    ),
 +    (
 +        47,
 +        oils_i18n_gettext(
 +            47,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            47,
 +            'Syringa Wireless',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@rinasms.com',
 +        TRUE
 +    ),
 +    (
 +        48,
 +        oils_i18n_gettext(
 +            48,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            48,
 +            'T-Mobile',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@tmomail.net',
 +        TRUE
 +    ),
 +    (
 +        49,
 +        oils_i18n_gettext(
 +            49,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            49,
 +            'Straight Talk / PagePlus Cellular',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@vtext.com',
 +        TRUE
 +    ),
 +    (
 +        50,
 +        oils_i18n_gettext(
 +            50,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            50,
 +            'South Central Communications',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@rinasms.com',
 +        TRUE
 +    ),
 +    (
 +        51,
 +        oils_i18n_gettext(
 +            51,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            51,
 +            'Simple Mobile',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@smtext.com',
 +        TRUE
 +    ),
 +    (
 +        52,
 +        oils_i18n_gettext(
 +            52,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            52,
 +            'Sprint (PCS)',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@messaging.sprintpcs.com',
 +        TRUE
 +    ),
 +    (
 +        53,
 +        oils_i18n_gettext(
 +            53,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            53,
 +            'Nextel',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@messaging.nextel.com',
 +        TRUE
 +    ),
 +    (
 +        54,
 +        oils_i18n_gettext(
 +            54,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            54,
 +            'Pioneer Cellular',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@zsend.com', -- nine digit number
 +        TRUE
 +    ),
 +    (
 +        55,
 +        oils_i18n_gettext(
 +            55,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            55,
 +            'Qwest Wireless',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@qwestmp.com',
 +        TRUE
 +    ),
 +    (
 +        56,
 +        oils_i18n_gettext(
 +            56,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            56,
 +            'US Cellular',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@email.uscc.net',
 +        TRUE
 +    ),
 +    (
 +        57,
 +        oils_i18n_gettext(
 +            57,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            57,
 +            'Unicel',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@utext.com',
 +        TRUE
 +    ),
 +    (
 +        58,
 +        oils_i18n_gettext(
 +            58,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            58,
 +            'Teleflip',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@teleflip.com',
 +        TRUE
 +    ),
 +    (
 +        59,
 +        oils_i18n_gettext(
 +            59,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            59,
 +            'Virgin Mobile',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@vmobl.com',
 +        TRUE
 +    ),
 +    (
 +        60,
 +        oils_i18n_gettext(
 +            60,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            60,
 +            'Verizon Wireless',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@vtext.com',
 +        TRUE
 +    ),
 +    (
 +        61,
 +        oils_i18n_gettext(
 +            61,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            61,
 +            'USA Mobility',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@usamobility.net',
 +        TRUE
 +    ),
 +    (
 +        62,
 +        oils_i18n_gettext(
 +            62,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            62,
 +            'Viaero',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@viaerosms.com',
 +        TRUE
 +    ),
 +    (
 +        63,
 +        oils_i18n_gettext(
 +            63,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            63,
 +            'TracFone',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@mmst5.tracfone.com',
 +        TRUE
 +    ),
 +    (
 +        64,
 +        oils_i18n_gettext(
 +            64,
 +            'USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            64,
 +            'Centennial Wireless',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@cwemail.com',
 +        TRUE
 +    ),
 +
 +    -- South Korea and USA
 +    (
 +        65,
 +        oils_i18n_gettext(
 +            65,
 +            'South Korea and USA',
 +            'csc',
 +            'region'
 +        ),
 +        oils_i18n_gettext(
 +            65,
 +            'Helio',
 +            'csc',
 +            'name'
 +        ),
 +        '$number@myhelio.com',
 +        TRUE
 +    )
 +;
 +
 +INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable)
 +    SELECT
 +        pgt.id, perm.id, aout.depth, TRUE
 +    FROM
 +        permission.grp_tree pgt,
 +        permission.perm_list perm,
 +        actor.org_unit_type aout
 +    WHERE
 +        pgt.name = 'Global Administrator' AND
 +        aout.name = 'Consortium' AND
 +        perm.code = 'ADMIN_SMS_CARRIER';
 +
 +INSERT INTO action_trigger.reactor (
 +    module,
 +    description
 +) VALUES (
 +    'SendSMS',
 +    'Send an SMS text message based on a user-defined template'
 +);
 +
 +INSERT INTO action_trigger.event_definition (
 +    active,
 +    owner,
 +    name,
 +    hook,
 +    validator,
 +    reactor,
 +    cleanup_success,
 +    delay,
 +    delay_field,
 +    group_field,
 +    template
 +) VALUES (
 +    true,
 +    1, -- admin
 +    'Hold Ready for Pickup SMS Notification',
 +    'hold.available',
 +    'HoldIsAvailable',
 +    'SendSMS',
 +    'CreateHoldNotification',
 +    '00:30:00',
 +    'shelf_time',
 +    'sms_notify',
 +    '[%- USE date -%]
 +[%- user = target.0.usr -%]
 +From: [%- params.sender_email || default_sender %]
 +To: [%- params.recipient_email || helpers.get_sms_gateway_email(target.0.sms_carrier,target.0.sms_notify) %]
 +Subject: [% target.size %] hold(s) ready
 +
 +[% FOR hold IN target %][%-
 +  bibxml = helpers.xml_doc( hold.current_copy.call_number.record.marc );
 +  title = "";
 +  FOR part IN bibxml.findnodes(''//*[@tag="245"]/*[@code="a"]'');
 +    title = title _ part.textContent;
 +  END;
 +  author = bibxml.findnodes(''//*[@tag="100"]/*[@code="a"]'').textContent;
 +%][% hold.usr.first_given_name %]:[% title %] @ [% hold.pickup_lib.name %]
 +[% END %]
 +'
 +);
 +
 +INSERT INTO action_trigger.environment (
 +    event_def,
 +    path
 +) VALUES (
 +    currval('action_trigger.event_definition_id_seq'),
 +    'current_copy.call_number.record.simple_record'
 +), (
 +    currval('action_trigger.event_definition_id_seq'),
 +    'usr'
 +), (
 +    currval('action_trigger.event_definition_id_seq'),
 +    'pickup_lib.billing_address'
 +);
 +
 +INSERT INTO action_trigger.hook(
 +    key,
 +    core_type,
 +    description,
 +    passive
 +) VALUES (
 +    'acn.format.sms_text',
 +    'acn',
 +    oils_i18n_gettext(
 +        'acn.format.sms_text',
 +        'A text message has been requested for a call number.',
 +        'ath',
 +        'description'
 +    ),
 +    FALSE
 +);
 +
 +INSERT INTO action_trigger.event_definition (
 +    active,
 +    owner,
 +    name,
 +    hook,
 +    validator,
 +    reactor,
 +    template
 +) VALUES (
 +    true,
 +    1, -- admin
 +    'SMS Call Number',
 +    'acn.format.sms_text',
 +    'NOOP_True',
 +    'SendSMS',
 +    '[%- USE date -%]
 +From: [%- params.sender_email || default_sender %]
 +To: [%- params.recipient_email || helpers.get_sms_gateway_email(user_data.sms_carrier,user_data.sms_notify) %]
 +Subject: Call Number
 +
 +[%-
 +  bibxml = helpers.xml_doc( target.record.marc );
 +  title = "";
 +  FOR part IN bibxml.findnodes(''//*[@tag="245"]/*[@code="a" or @code="b"]'');
 +    title = title _ part.textContent;
 +  END;
 +  author = bibxml.findnodes(''//*[@tag="100"]/*[@code="a"]'').textContent;
 +%]
 +Call Number: [% target.label %]
 +Location: [% helpers.get_most_populous_location( target.id ).name %]
 +Library: [% target.owning_lib.name %]
 +[%- IF title %]
 +Title: [% title %]
 +[%- END %]
 +[%- IF author %]
 +Author: [% author %]
 +[%- END %]
 +'
 +);
 +
 +INSERT INTO action_trigger.environment (
 +    event_def,
 +    path
 +) VALUES (
 +    currval('action_trigger.event_definition_id_seq'),
 +    'record.simple_record'
 +), (
 +    currval('action_trigger.event_definition_id_seq'),
 +    'owning_lib.billing_address'
 +);
 +
 +
index 0000000,dad8614..dcfde3e
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,3245 +1,3245 @@@
 --- Evergreen DB patch XXXX.fix-nonfiling-titles.sql
++-- Evergreen DB patch 0672.fix-nonfiling-titles.sql
+ --
+ -- Titles that begin with non-filing articles using apostrophes
+ -- (for example, "L'armée") get spaces injected between the article
+ -- and the subsequent text, which then breaks searching for titles
+ -- beginning with those articles.
+ --
+ -- This patch adds a nonfiling title element to MODS32 that can then
+ -- be used to retrieve the title proper without affecting the spaces
+ -- in the title. It's what we want, what we really really want, for
+ -- title searches.
+ --
+ BEGIN;
+ -- check whether patch can be applied
 -SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
++SELECT evergreen.upgrade_deps_block_check('0672', :eg_version);
+ -- Update the XPath definition before the titleNonfiling element exists;
+ -- but are you really going to read through the whole XSL below before
+ -- seeing this important bit?
+ UPDATE config.metabib_field
+     SET xpath = $$//mods32:mods/mods32:titleNonfiling[mods32:title and not (@type)]$$,
+         format = 'mods32'
+     WHERE field_class = 'title' AND name = 'proper';
+ UPDATE config.xml_transform SET xslt=$$<?xml version="1.0" encoding="UTF-8"?>
+ <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">
+       <xsl:output encoding="UTF-8" indent="yes" method="xml"/>
+ <!--
+ 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
+ Revision 1.13 - Changed order of output under cartographics to reflect schema  2006/11/28 tmee
+       
+ Revision 1.12 - Updated to reflect MODS 3.2 Mapping  2006/10/11 tmee
+               
+ Revision 1.11 - The attribute objectPart moved from <languageTerm> to <language>
+       2006/04/08  jrad
+ 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
+ Revision 1.9 subfield $y was added to field 242 2004/09/02 10:57 jrad
+ Revision 1.8 Subject chopPunctuation expanded and attribute fixes 2004/08/12 jrad
+ Revision 1.7 2004/03/25 08:29 jrad
+ Revision 1.6 various validation fixes 2004/02/20 ntra
+ Revision 1.5  2003/10/02 16:18:58  ntra
+ MODS2 to MODS3 updates, language unstacking and 
+ de-duping, chopPunctuation expanded
+ Revision 1.3  2003/04/03 00:07:19  ntra
+ Revision 1.3 Additional Changes not related to MODS Version 2.0 by ntra
+ Revision 1.2  2003/03/24 19:37:42  ckeith
+ Added Log Comment
+ -->
+       <xsl:template match="/">
+               <xsl:choose>
+                       <xsl:when test="//marc:collection">
+                               <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">
+                                       <xsl:for-each select="//marc:collection/marc:record">
+                                               <mods version="3.2">
+                                                       <xsl:call-template name="marcRecord"/>
+                                               </mods>
+                                       </xsl:for-each>
+                               </modsCollection>
+                       </xsl:when>
+                       <xsl:otherwise>
+                               <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">
+                                       <xsl:for-each select="//marc:record">
+                                               <xsl:call-template name="marcRecord"/>
+                                       </xsl:for-each>
+                               </mods>
+                       </xsl:otherwise>
+               </xsl:choose>
+       </xsl:template>
+       <xsl:template name="marcRecord">
+               <xsl:variable name="leader" select="marc:leader"/>
+               <xsl:variable name="leader6" select="substring($leader,7,1)"/>
+               <xsl:variable name="leader7" select="substring($leader,8,1)"/>
+               <xsl:variable name="controlField008" select="marc:controlfield[@tag='008']"/>
+               <xsl:variable name="typeOf008">
+                       <xsl:choose>
+                               <xsl:when test="$leader6='a'">
+                                       <xsl:choose>
+                                               <xsl:when test="$leader7='a' or $leader7='c' or $leader7='d' or $leader7='m'">BK</xsl:when>
+                                               <xsl:when test="$leader7='b' or $leader7='i' or $leader7='s'">SE</xsl:when>
+                                       </xsl:choose>
+                               </xsl:when>
+                               <xsl:when test="$leader6='t'">BK</xsl:when>
+                               <xsl:when test="$leader6='p'">MM</xsl:when>
+                               <xsl:when test="$leader6='m'">CF</xsl:when>
+                               <xsl:when test="$leader6='e' or $leader6='f'">MP</xsl:when>
+                               <xsl:when test="$leader6='g' or $leader6='k' or $leader6='o' or $leader6='r'">VM</xsl:when>
+                               <xsl:when test="$leader6='c' or $leader6='d' or $leader6='i' or $leader6='j'">MU</xsl:when>
+                       </xsl:choose>
+               </xsl:variable>
+               <xsl:for-each select="marc:datafield[@tag='245']">
+                       <titleInfo>
+                               <xsl:variable name="title">
+                                       <xsl:choose>
+                                               <xsl:when test="marc:subfield[@code='b']">
+                                                       <xsl:call-template name="specialSubfieldSelect">
+                                                               <xsl:with-param name="axis">b</xsl:with-param>
+                                                               <xsl:with-param name="beforeCodes">afgk</xsl:with-param>
+                                                       </xsl:call-template>
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                       <xsl:call-template name="subfieldSelect">
+                                                               <xsl:with-param name="codes">abfgk</xsl:with-param>
+                                                       </xsl:call-template>
+                                               </xsl:otherwise>
+                                       </xsl:choose>
+                               </xsl:variable>
+                               <xsl:variable name="titleChop">
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:value-of select="$title"/>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </xsl:variable>
+                               <xsl:choose>
+                                       <xsl:when test="@ind2>0">
+                                               <nonSort>
+                                                       <xsl:value-of select="substring($titleChop,1,@ind2)"/>
+                                               </nonSort>
+                                               <title>
+                                                       <xsl:value-of select="substring($titleChop,@ind2+1)"/>
+                                               </title>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <title>
+                                                       <xsl:value-of select="$titleChop"/>
+                                               </title>
+                                       </xsl:otherwise>
+                               </xsl:choose>
+                               <xsl:if test="marc:subfield[@code='b']">
+                                       <subTitle>
+                                               <xsl:call-template name="chopPunctuation">
+                                                       <xsl:with-param name="chopString">
+                                                               <xsl:call-template name="specialSubfieldSelect">
+                                                                       <xsl:with-param name="axis">b</xsl:with-param>
+                                                                       <xsl:with-param name="anyCodes">b</xsl:with-param>
+                                                                       <xsl:with-param name="afterCodes">afgk</xsl:with-param>
+                                                               </xsl:call-template>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </subTitle>
+                               </xsl:if>
+                               <xsl:call-template name="part"></xsl:call-template>
+                       </titleInfo>
+                       <!-- A form of title that ignores non-filing characters; useful
+                                for not converting "L'Oreal" into "L' Oreal" at index time -->
+                       <titleNonfiling>
+                               <xsl:variable name="title">
+                                       <xsl:choose>
+                                               <xsl:when test="marc:subfield[@code='b']">
+                                                       <xsl:call-template name="specialSubfieldSelect">
+                                                               <xsl:with-param name="axis">b</xsl:with-param>
+                                                               <xsl:with-param name="beforeCodes">afgk</xsl:with-param>
+                                                       </xsl:call-template>
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                       <xsl:call-template name="subfieldSelect">
+                                                               <xsl:with-param name="codes">abfgk</xsl:with-param>
+                                                       </xsl:call-template>
+                                               </xsl:otherwise>
+                                       </xsl:choose>
+                               </xsl:variable>
+                               <title>
+                                       <xsl:value-of select="$title"/>
+                               </title>
+                               <xsl:if test="marc:subfield[@code='b']">
+                                       <subTitle>
+                                               <xsl:call-template name="chopPunctuation">
+                                                       <xsl:with-param name="chopString">
+                                                               <xsl:call-template name="specialSubfieldSelect">
+                                                                       <xsl:with-param name="axis">b</xsl:with-param>
+                                                                       <xsl:with-param name="anyCodes">b</xsl:with-param>
+                                                                       <xsl:with-param name="afterCodes">afgk</xsl:with-param>
+                                                               </xsl:call-template>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </subTitle>
+                               </xsl:if>
+                               <xsl:call-template name="part"></xsl:call-template>
+                       </titleNonfiling>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag='210']">
+                       <titleInfo type="abbreviated">
+                               <title>
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:call-template name="subfieldSelect">
+                                                               <xsl:with-param name="codes">a</xsl:with-param>
+                                                       </xsl:call-template>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </title>
+                               <xsl:call-template name="subtitle"/>
+                       </titleInfo>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag='242']">
+                       <titleInfo type="translated">
+                               <!--09/01/04 Added subfield $y-->
+                               <xsl:for-each select="marc:subfield[@code='y']">
+                                       <xsl:attribute name="lang">
+                                               <xsl:value-of select="text()"/>
+                                       </xsl:attribute>
+                               </xsl:for-each>
+                               <title>
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:call-template name="subfieldSelect">
+                                                               <!-- 1/04 removed $h, b -->
+                                                               <xsl:with-param name="codes">a</xsl:with-param>
+                                                       </xsl:call-template>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </title>
+                               <!-- 1/04 fix -->
+                               <xsl:call-template name="subtitle"/>
+                               <xsl:call-template name="part"/>
+                       </titleInfo>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag='246']">
+                       <titleInfo type="alternative">
+                               <xsl:for-each select="marc:subfield[@code='i']">
+                                       <xsl:attribute name="displayLabel">
+                                               <xsl:value-of select="text()"/>
+                                       </xsl:attribute>
+                               </xsl:for-each>
+                               <title>
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:call-template name="subfieldSelect">
+                                                               <!-- 1/04 removed $h, $b -->
+                                                               <xsl:with-param name="codes">af</xsl:with-param>
+                                                       </xsl:call-template>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </title>
+                               <xsl:call-template name="subtitle"/>
+                               <xsl:call-template name="part"/>
+                       </titleInfo>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag='130']|marc:datafield[@tag='240']|marc:datafield[@tag='730'][@ind2!='2']">
+                       <titleInfo type="uniform">
+                               <title>
+                                       <xsl:variable name="str">
+                                               <xsl:for-each select="marc:subfield">
+                                                       <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'])))">
+                                                               <xsl:value-of select="text()"/>
+                                                               <xsl:text> </xsl:text>
+                                                       </xsl:if>
+                                               </xsl:for-each>
+                                       </xsl:variable>
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </title>
+                               <xsl:call-template name="part"/>
+                       </titleInfo>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag='740'][@ind2!='2']">
+                       <titleInfo type="alternative">
+                               <title>
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:call-template name="subfieldSelect">
+                                                               <xsl:with-param name="codes">ah</xsl:with-param>
+                                                       </xsl:call-template>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </title>
+                               <xsl:call-template name="part"/>
+                       </titleInfo>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag='100']">
+                       <name type="personal">
+                               <xsl:call-template name="nameABCDQ"/>
+                               <xsl:call-template name="affiliation"/>
+                               <role>
+                                       <roleTerm authority="marcrelator" type="text">creator</roleTerm>
+                               </role>
+                               <xsl:call-template name="role"/>
+                       </name>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag='110']">
+                       <name type="corporate">
+                               <xsl:call-template name="nameABCDN"/>
+                               <role>
+                                       <roleTerm authority="marcrelator" type="text">creator</roleTerm>
+                               </role>
+                               <xsl:call-template name="role"/>
+                       </name>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag='111']">
+                       <name type="conference">
+                               <xsl:call-template name="nameACDEQ"/>
+                               <role>
+                                       <roleTerm authority="marcrelator" type="text">creator</roleTerm>
+                               </role>
+                               <xsl:call-template name="role"/>
+                       </name>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag='700'][not(marc:subfield[@code='t'])]">
+                       <name type="personal">
+                               <xsl:call-template name="nameABCDQ"/>
+                               <xsl:call-template name="affiliation"/>
+                               <xsl:call-template name="role"/>
+                       </name>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag='710'][not(marc:subfield[@code='t'])]">
+                       <name type="corporate">
+                               <xsl:call-template name="nameABCDN"/>
+                               <xsl:call-template name="role"/>
+                       </name>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag='711'][not(marc:subfield[@code='t'])]">
+                       <name type="conference">
+                               <xsl:call-template name="nameACDEQ"/>
+                               <xsl:call-template name="role"/>
+                       </name>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag='720'][not(marc:subfield[@code='t'])]">
+                       <name>
+                               <xsl:if test="@ind1=1">
+                                       <xsl:attribute name="type">
+                                               <xsl:text>personal</xsl:text>
+                                       </xsl:attribute>
+                               </xsl:if>
+                               <namePart>
+                                       <xsl:value-of select="marc:subfield[@code='a']"/>
+                               </namePart>
+                               <xsl:call-template name="role"/>
+                       </name>
+               </xsl:for-each>
+               <typeOfResource>
+                       <xsl:if test="$leader7='c'">
+                               <xsl:attribute name="collection">yes</xsl:attribute>
+                       </xsl:if>
+                       <xsl:if test="$leader6='d' or $leader6='f' or $leader6='p' or $leader6='t'">
+                               <xsl:attribute name="manuscript">yes</xsl:attribute>
+                       </xsl:if>
+                       <xsl:choose>
+                               <xsl:when test="$leader6='a' or $leader6='t'">text</xsl:when>
+                               <xsl:when test="$leader6='e' or $leader6='f'">cartographic</xsl:when>
+                               <xsl:when test="$leader6='c' or $leader6='d'">notated music</xsl:when>
+                               <xsl:when test="$leader6='i'">sound recording-nonmusical</xsl:when>
+                               <xsl:when test="$leader6='j'">sound recording-musical</xsl:when>
+                               <xsl:when test="$leader6='k'">still image</xsl:when>
+                               <xsl:when test="$leader6='g'">moving image</xsl:when>
+                               <xsl:when test="$leader6='r'">three dimensional object</xsl:when>
+                               <xsl:when test="$leader6='m'">software, multimedia</xsl:when>
+                               <xsl:when test="$leader6='p'">mixed material</xsl:when>
+                       </xsl:choose>
+               </typeOfResource>
+               <xsl:if test="substring($controlField008,26,1)='d'">
+                       <genre authority="marc">globe</genre>
+               </xsl:if>
+               <xsl:if test="marc:controlfield[@tag='007'][substring(text(),1,1)='a'][substring(text(),2,1)='r']">
+                       <genre authority="marc">remote sensing image</genre>
+               </xsl:if>
+               <xsl:if test="$typeOf008='MP'">
+                       <xsl:variable name="controlField008-25" select="substring($controlField008,26,1)"></xsl:variable>
+                       <xsl:choose>
+                               <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']">
+                                       <genre authority="marc">map</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-25='e' or marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='d']">
+                                       <genre authority="marc">atlas</genre>
+                               </xsl:when>
+                       </xsl:choose>
+               </xsl:if>
+               <xsl:if test="$typeOf008='SE'">
+                       <xsl:variable name="controlField008-21" select="substring($controlField008,22,1)"></xsl:variable>
+                       <xsl:choose>
+                               <xsl:when test="$controlField008-21='d'">
+                                       <genre authority="marc">database</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-21='l'">
+                                       <genre authority="marc">loose-leaf</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-21='m'">
+                                       <genre authority="marc">series</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-21='n'">
+                                       <genre authority="marc">newspaper</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-21='p'">
+                                       <genre authority="marc">periodical</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-21='w'">
+                                       <genre authority="marc">web site</genre>
+                               </xsl:when>
+                       </xsl:choose>
+               </xsl:if>
+               <xsl:if test="$typeOf008='BK' or $typeOf008='SE'">
+                       <xsl:variable name="controlField008-24" select="substring($controlField008,25,4)"></xsl:variable>
+                       <xsl:choose>
+                               <xsl:when test="contains($controlField008-24,'a')">
+                                       <genre authority="marc">abstract or summary</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'b')">
+                                       <genre authority="marc">bibliography</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'c')">
+                                       <genre authority="marc">catalog</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'d')">
+                                       <genre authority="marc">dictionary</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'e')">
+                                       <genre authority="marc">encyclopedia</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'f')">
+                                       <genre authority="marc">handbook</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'g')">
+                                       <genre authority="marc">legal article</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'i')">
+                                       <genre authority="marc">index</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'k')">
+                                       <genre authority="marc">discography</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'l')">
+                                       <genre authority="marc">legislation</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'m')">
+                                       <genre authority="marc">theses</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'n')">
+                                       <genre authority="marc">survey of literature</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'o')">
+                                       <genre authority="marc">review</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'p')">
+                                       <genre authority="marc">programmed text</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'q')">
+                                       <genre authority="marc">filmography</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'r')">
+                                       <genre authority="marc">directory</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'s')">
+                                       <genre authority="marc">statistics</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'t')">
+                                       <genre authority="marc">technical report</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'v')">
+                                       <genre authority="marc">legal case and case notes</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'w')">
+                                       <genre authority="marc">law report or digest</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'z')">
+                                       <genre authority="marc">treaty</genre>
+                               </xsl:when>
+                       </xsl:choose>
+                       <xsl:variable name="controlField008-29" select="substring($controlField008,30,1)"></xsl:variable>
+                       <xsl:choose>
+                               <xsl:when test="$controlField008-29='1'">
+                                       <genre authority="marc">conference publication</genre>
+                               </xsl:when>
+                       </xsl:choose>
+               </xsl:if>
+               <xsl:if test="$typeOf008='CF'">
+                       <xsl:variable name="controlField008-26" select="substring($controlField008,27,1)"></xsl:variable>
+                       <xsl:choose>
+                               <xsl:when test="$controlField008-26='a'">
+                                       <genre authority="marc">numeric data</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-26='e'">
+                                       <genre authority="marc">database</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-26='f'">
+                                       <genre authority="marc">font</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-26='g'">
+                                       <genre authority="marc">game</genre>
+                               </xsl:when>
+                       </xsl:choose>
+               </xsl:if>
+               <xsl:if test="$typeOf008='BK'">
+                       <xsl:if test="substring($controlField008,25,1)='j'">
+                               <genre authority="marc">patent</genre>
+                       </xsl:if>
+                       <xsl:if test="substring($controlField008,31,1)='1'">
+                               <genre authority="marc">festschrift</genre>
+                       </xsl:if>
+                       <xsl:variable name="controlField008-34" select="substring($controlField008,35,1)"></xsl:variable>
+                       <xsl:if test="$controlField008-34='a' or $controlField008-34='b' or $controlField008-34='c' or $controlField008-34='d'">
+                               <genre authority="marc">biography</genre>
+                       </xsl:if>
+                       <xsl:variable name="controlField008-33" select="substring($controlField008,34,1)"></xsl:variable>
+                       <xsl:choose>
+                               <xsl:when test="$controlField008-33='e'">
+                                       <genre authority="marc">essay</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='d'">
+                                       <genre authority="marc">drama</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='c'">
+                                       <genre authority="marc">comic strip</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='l'">
+                                       <genre authority="marc">fiction</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='h'">
+                                       <genre authority="marc">humor, satire</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='i'">
+                                       <genre authority="marc">letter</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='f'">
+                                       <genre authority="marc">novel</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='j'">
+                                       <genre authority="marc">short story</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='s'">
+                                       <genre authority="marc">speech</genre>
+                               </xsl:when>
+                       </xsl:choose>
+               </xsl:if>
+               <xsl:if test="$typeOf008='MU'">
+                       <xsl:variable name="controlField008-30-31" select="substring($controlField008,31,2)"></xsl:variable>
+                       <xsl:if test="contains($controlField008-30-31,'b')">
+                               <genre authority="marc">biography</genre>
+                       </xsl:if>
+                       <xsl:if test="contains($controlField008-30-31,'c')">
+                               <genre authority="marc">conference publication</genre>
+                       </xsl:if>
+                       <xsl:if test="contains($controlField008-30-31,'d')">
+                               <genre authority="marc">drama</genre>
+                       </xsl:if>
+                       <xsl:if test="contains($controlField008-30-31,'e')">
+                               <genre authority="marc">essay</genre>
+                       </xsl:if>
+                       <xsl:if test="contains($controlField008-30-31,'f')">
+                               <genre authority="marc">fiction</genre>
+                       </xsl:if>
+                       <xsl:if test="contains($controlField008-30-31,'o')">
+                               <genre authority="marc">folktale</genre>
+                       </xsl:if>
+                       <xsl:if test="contains($controlField008-30-31,'h')">
+                               <genre authority="marc">history</genre>
+                       </xsl:if>
+                       <xsl:if test="contains($controlField008-30-31,'k')">
+                               <genre authority="marc">humor, satire</genre>
+                       </xsl:if>
+                       <xsl:if test="contains($controlField008-30-31,'m')">
+                               <genre authority="marc">memoir</genre>
+                       </xsl:if>
+                       <xsl:if test="contains($controlField008-30-31,'p')">
+                               <genre authority="marc">poetry</genre>
+                       </xsl:if>
+                       <xsl:if test="contains($controlField008-30-31,'r')">
+                               <genre authority="marc">rehearsal</genre>
+                       </xsl:if>
+                       <xsl:if test="contains($controlField008-30-31,'g')">
+                               <genre authority="marc">reporting</genre>
+                       </xsl:if>
+                       <xsl:if test="contains($controlField008-30-31,'s')">
+                               <genre authority="marc">sound</genre>
+                       </xsl:if>
+                       <xsl:if test="contains($controlField008-30-31,'l')">
+                               <genre authority="marc">speech</genre>
+                       </xsl:if>
+               </xsl:if>
+               <xsl:if test="$typeOf008='VM'">
+                       <xsl:variable name="controlField008-33" select="substring($controlField008,34,1)"></xsl:variable>
+                       <xsl:choose>
+                               <xsl:when test="$controlField008-33='a'">
+                                       <genre authority="marc">art original</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='b'">
+                                       <genre authority="marc">kit</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='c'">
+                                       <genre authority="marc">art reproduction</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='d'">
+                                       <genre authority="marc">diorama</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='f'">
+                                       <genre authority="marc">filmstrip</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='g'">
+                                       <genre authority="marc">legal article</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='i'">
+                                       <genre authority="marc">picture</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='k'">
+                                       <genre authority="marc">graphic</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='l'">
+                                       <genre authority="marc">technical drawing</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='m'">
+                                       <genre authority="marc">motion picture</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='n'">
+                                       <genre authority="marc">chart</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='o'">
+                                       <genre authority="marc">flash card</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='p'">
+                                       <genre authority="marc">microscope slide</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='q' or marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='q']">
+                                       <genre authority="marc">model</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='r'">
+                                       <genre authority="marc">realia</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='s'">
+                                       <genre authority="marc">slide</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='t'">
+                                       <genre authority="marc">transparency</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='v'">
+                                       <genre authority="marc">videorecording</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='w'">
+                                       <genre authority="marc">toy</genre>
+                               </xsl:when>
+                       </xsl:choose>
+               </xsl:if>
+               <xsl:for-each select="marc:datafield[@tag=655]">
+                       <genre authority="marc">
+                               <xsl:attribute name="authority">
+                                       <xsl:value-of select="marc:subfield[@code='2']"/>
+                               </xsl:attribute>
+                               <xsl:call-template name="subfieldSelect">
+                                       <xsl:with-param name="codes">abvxyz</xsl:with-param>
+                                       <xsl:with-param name="delimeter">-</xsl:with-param>
+                               </xsl:call-template>
+                       </genre>
+               </xsl:for-each>
+               <originInfo>
+                       <xsl:variable name="MARCpublicationCode" select="normalize-space(substring($controlField008,16,3))"></xsl:variable>
+                       <xsl:if test="translate($MARCpublicationCode,'|','')">
+                               <place>
+                                       <placeTerm>
+                                               <xsl:attribute name="type">code</xsl:attribute>
+                                               <xsl:attribute name="authority">marccountry</xsl:attribute>
+                                               <xsl:value-of select="$MARCpublicationCode"/>
+                                       </placeTerm>
+                               </place>
+                       </xsl:if>
+                       <xsl:for-each select="marc:datafield[@tag=044]/marc:subfield[@code='c']">
+                               <place>
+                                       <placeTerm>
+                                               <xsl:attribute name="type">code</xsl:attribute>
+                                               <xsl:attribute name="authority">iso3166</xsl:attribute>
+                                               <xsl:value-of select="."/>
+                                       </placeTerm>
+                               </place>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:datafield[@tag=260]/marc:subfield[@code='a']">
+                               <place>
+                                       <placeTerm>
+                                               <xsl:attribute name="type">text</xsl:attribute>
+                                               <xsl:call-template name="chopPunctuationFront">
+                                                       <xsl:with-param name="chopString">
+                                                               <xsl:call-template name="chopPunctuation">
+                                                                       <xsl:with-param name="chopString" select="."/>
+                                                               </xsl:call-template>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </placeTerm>
+                               </place>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:datafield[@tag=046]/marc:subfield[@code='m']">
+                               <dateValid point="start">
+                                       <xsl:value-of select="."/>
+                               </dateValid>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:datafield[@tag=046]/marc:subfield[@code='n']">
+                               <dateValid point="end">
+                                       <xsl:value-of select="."/>
+                               </dateValid>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:datafield[@tag=046]/marc:subfield[@code='j']">
+                               <dateModified>
+                                       <xsl:value-of select="."/>
+                               </dateModified>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:datafield[@tag=260]/marc:subfield[@code='b' or @code='c' or @code='g']">
+                               <xsl:choose>
+                                       <xsl:when test="@code='b'">
+                                               <publisher>
+                                                       <xsl:call-template name="chopPunctuation">
+                                                               <xsl:with-param name="chopString" select="."/>
+                                                               <xsl:with-param name="punctuation">
+                                                                       <xsl:text>:,;/ </xsl:text>
+                                                               </xsl:with-param>
+                                                       </xsl:call-template>
+                                               </publisher>
+                                       </xsl:when>
+                                       <xsl:when test="@code='c'">
+                                               <dateIssued>
+                                                       <xsl:call-template name="chopPunctuation">
+                                                               <xsl:with-param name="chopString" select="."/>
+                                                       </xsl:call-template>
+                                               </dateIssued>
+                                       </xsl:when>
+                                       <xsl:when test="@code='g'">
+                                               <dateCreated>
+                                                       <xsl:value-of select="."/>
+                                               </dateCreated>
+                                       </xsl:when>
+                               </xsl:choose>
+                       </xsl:for-each>
+                       <xsl:variable name="dataField260c">
+                               <xsl:call-template name="chopPunctuation">
+                                       <xsl:with-param name="chopString" select="marc:datafield[@tag=260]/marc:subfield[@code='c']"></xsl:with-param>
+                               </xsl:call-template>
+                       </xsl:variable>
+                       <xsl:variable name="controlField008-7-10" select="normalize-space(substring($controlField008, 8, 4))"></xsl:variable>
+                       <xsl:variable name="controlField008-11-14" select="normalize-space(substring($controlField008, 12, 4))"></xsl:variable>
+                       <xsl:variable name="controlField008-6" select="normalize-space(substring($controlField008, 7, 1))"></xsl:variable>
+                       <xsl:if test="$controlField008-6='e' or $controlField008-6='p' or $controlField008-6='r' or $controlField008-6='t' or $controlField008-6='s'">
+                               <xsl:if test="$controlField008-7-10 and ($controlField008-7-10 != $dataField260c)">
+                                       <dateIssued encoding="marc">
+                                               <xsl:value-of select="$controlField008-7-10"/>
+                                       </dateIssued>
+                               </xsl:if>
+                       </xsl:if>
+                       <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'">
+                               <xsl:if test="$controlField008-7-10">
+                                       <dateIssued encoding="marc" point="start">
+                                               <xsl:value-of select="$controlField008-7-10"/>
+                                       </dateIssued>
+                               </xsl:if>
+                       </xsl:if>
+                       <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'">
+                               <xsl:if test="$controlField008-11-14">
+                                       <dateIssued encoding="marc" point="end">
+                                               <xsl:value-of select="$controlField008-11-14"/>
+                                       </dateIssued>
+                               </xsl:if>
+                       </xsl:if>
+                       <xsl:if test="$controlField008-6='q'">
+                               <xsl:if test="$controlField008-7-10">
+                                       <dateIssued encoding="marc" point="start" qualifier="questionable">
+                                               <xsl:value-of select="$controlField008-7-10"/>
+                                       </dateIssued>
+                               </xsl:if>
+                       </xsl:if>
+                       <xsl:if test="$controlField008-6='q'">
+                               <xsl:if test="$controlField008-11-14">
+                                       <dateIssued encoding="marc" point="end" qualifier="questionable">
+                                               <xsl:value-of select="$controlField008-11-14"/>
+                                       </dateIssued>
+                               </xsl:if>
+                       </xsl:if>
+                       <xsl:if test="$controlField008-6='t'">
+                               <xsl:if test="$controlField008-11-14">
+                                       <copyrightDate encoding="marc">
+                                               <xsl:value-of select="$controlField008-11-14"/>
+                                       </copyrightDate>
+                               </xsl:if>
+                       </xsl:if>
+                       <xsl:for-each select="marc:datafield[@tag=033][@ind1=0 or @ind1=1]/marc:subfield[@code='a']">
+                               <dateCaptured encoding="iso8601">
+                                       <xsl:value-of select="."/>
+                               </dateCaptured>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:datafield[@tag=033][@ind1=2]/marc:subfield[@code='a'][1]">
+                               <dateCaptured encoding="iso8601" point="start">
+                                       <xsl:value-of select="."/>
+                               </dateCaptured>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:datafield[@tag=033][@ind1=2]/marc:subfield[@code='a'][2]">
+                               <dateCaptured encoding="iso8601" point="end">
+                                       <xsl:value-of select="."/>
+                               </dateCaptured>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:datafield[@tag=250]/marc:subfield[@code='a']">
+                               <edition>
+                                       <xsl:value-of select="."/>
+                               </edition>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:leader">
+                               <issuance>
+                                       <xsl:choose>
+                                               <xsl:when test="$leader7='a' or $leader7='c' or $leader7='d' or $leader7='m'">monographic</xsl:when>
+                                               <xsl:when test="$leader7='b' or $leader7='i' or $leader7='s'">continuing</xsl:when>
+                                       </xsl:choose>
+                               </issuance>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:datafield[@tag=310]|marc:datafield[@tag=321]">
+                               <frequency>
+                                       <xsl:call-template name="subfieldSelect">
+                                               <xsl:with-param name="codes">ab</xsl:with-param>
+                                       </xsl:call-template>
+                               </frequency>
+                       </xsl:for-each>
+               </originInfo>
+               <xsl:variable name="controlField008-35-37" select="normalize-space(translate(substring($controlField008,36,3),'|#',''))"></xsl:variable>
+               <xsl:if test="$controlField008-35-37">
+                       <language>
+                               <languageTerm authority="iso639-2b" type="code">
+                                       <xsl:value-of select="substring($controlField008,36,3)"/>
+                               </languageTerm>
+                       </language>
+               </xsl:if>
+               <xsl:for-each select="marc:datafield[@tag=041]">
+                       <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']">
+                               <xsl:variable name="langCodes" select="."/>
+                               <xsl:choose>
+                                       <xsl:when test="../marc:subfield[@code='2']='rfc3066'">
+                                               <!-- not stacked but could be repeated -->
+                                               <xsl:call-template name="rfcLanguages">
+                                                       <xsl:with-param name="nodeNum">
+                                                               <xsl:value-of select="1"/>
+                                                       </xsl:with-param>
+                                                       <xsl:with-param name="usedLanguages">
+                                                               <xsl:text></xsl:text>
+                                                       </xsl:with-param>
+                                                       <xsl:with-param name="controlField008-35-37">
+                                                               <xsl:value-of select="$controlField008-35-37"></xsl:value-of>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <!-- iso -->
+                                               <xsl:variable name="allLanguages">
+                                                       <xsl:copy-of select="$langCodes"></xsl:copy-of>
+                                               </xsl:variable>
+                                               <xsl:variable name="currentLanguage">
+                                                       <xsl:value-of select="substring($allLanguages,1,3)"></xsl:value-of>
+                                               </xsl:variable>
+                                               <xsl:call-template name="isoLanguage">
+                                                       <xsl:with-param name="currentLanguage">
+                                                               <xsl:value-of select="substring($allLanguages,1,3)"></xsl:value-of>
+                                                       </xsl:with-param>
+                                                       <xsl:with-param name="remainingLanguages">
+                                                               <xsl:value-of select="substring($allLanguages,4,string-length($allLanguages)-3)"></xsl:value-of>
+                                                       </xsl:with-param>
+                                                       <xsl:with-param name="usedLanguages">
+                                                               <xsl:if test="$controlField008-35-37">
+                                                                       <xsl:value-of select="$controlField008-35-37"></xsl:value-of>
+                                                               </xsl:if>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </xsl:otherwise>
+                               </xsl:choose>
+                       </xsl:for-each>
+               </xsl:for-each>
+               <xsl:variable name="physicalDescription">
+                       <!--3.2 change tmee 007/11 -->
+                       <xsl:if test="$typeOf008='CF' and marc:controlfield[@tag=007][substring(.,12,1)='a']">
+                               <digitalOrigin>reformatted digital</digitalOrigin>
+                       </xsl:if>
+                       <xsl:if test="$typeOf008='CF' and marc:controlfield[@tag=007][substring(.,12,1)='b']">
+                               <digitalOrigin>digitized microfilm</digitalOrigin>
+                       </xsl:if>
+                       <xsl:if test="$typeOf008='CF' and marc:controlfield[@tag=007][substring(.,12,1)='d']">
+                               <digitalOrigin>digitized other analog</digitalOrigin>
+                       </xsl:if>
+                       <xsl:variable name="controlField008-23" select="substring($controlField008,24,1)"></xsl:variable>
+                       <xsl:variable name="controlField008-29" select="substring($controlField008,30,1)"></xsl:variable>
+                       <xsl:variable name="check008-23">
+                               <xsl:if test="$typeOf008='BK' or $typeOf008='MU' or $typeOf008='SE' or $typeOf008='MM'">
+                                       <xsl:value-of select="true()"></xsl:value-of>
+                               </xsl:if>
+                       </xsl:variable>
+                       <xsl:variable name="check008-29">
+                               <xsl:if test="$typeOf008='MP' or $typeOf008='VM'">
+                                       <xsl:value-of select="true()"></xsl:value-of>
+                               </xsl:if>
+                       </xsl:variable>
+                       <xsl:choose>
+                               <xsl:when test="($check008-23 and $controlField008-23='f') or ($check008-29 and $controlField008-29='f')">
+                                       <form authority="marcform">braille</form>
+                               </xsl:when>
+                               <xsl:when test="($controlField008-23=' ' and ($leader6='c' or $leader6='d')) or (($typeOf008='BK' or $typeOf008='SE') and ($controlField008-23=' ' or $controlField008='r'))">
+                                       <form authority="marcform">print</form>
+                               </xsl:when>
+                               <xsl:when test="$leader6 = 'm' or ($check008-23 and $controlField008-23='s') or ($check008-29 and $controlField008-29='s')">
+                                       <form authority="marcform">electronic</form>
+                               </xsl:when>
+                               <xsl:when test="($check008-23 and $controlField008-23='b') or ($check008-29 and $controlField008-29='b')">
+                                       <form authority="marcform">microfiche</form>
+                               </xsl:when>
+                               <xsl:when test="($check008-23 and $controlField008-23='a') or ($check008-29 and $controlField008-29='a')">
+                                       <form authority="marcform">microfilm</form>
+                               </xsl:when>
+                       </xsl:choose>
+                       <!-- 1/04 fix -->
+                       <xsl:if test="marc:datafield[@tag=130]/marc:subfield[@code='h']">
+                               <form authority="gmd">
+                                       <xsl:call-template name="chopBrackets">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:value-of select="marc:datafield[@tag=130]/marc:subfield[@code='h']"></xsl:value-of>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </form>
+                       </xsl:if>
+                       <xsl:if test="marc:datafield[@tag=240]/marc:subfield[@code='h']">
+                               <form authority="gmd">
+                                       <xsl:call-template name="chopBrackets">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:value-of select="marc:datafield[@tag=240]/marc:subfield[@code='h']"></xsl:value-of>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </form>
+                       </xsl:if>
+                       <xsl:if test="marc:datafield[@tag=242]/marc:subfield[@code='h']">
+                               <form authority="gmd">
+                                       <xsl:call-template name="chopBrackets">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:value-of select="marc:datafield[@tag=242]/marc:subfield[@code='h']"></xsl:value-of>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </form>
+                       </xsl:if>
+                       <xsl:if test="marc:datafield[@tag=245]/marc:subfield[@code='h']">
+                               <form authority="gmd">
+                                       <xsl:call-template name="chopBrackets">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:value-of select="marc:datafield[@tag=245]/marc:subfield[@code='h']"></xsl:value-of>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </form>
+                       </xsl:if>
+                       <xsl:if test="marc:datafield[@tag=246]/marc:subfield[@code='h']">
+                               <form authority="gmd">
+                                       <xsl:call-template name="chopBrackets">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:value-of select="marc:datafield[@tag=246]/marc:subfield[@code='h']"></xsl:value-of>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </form>
+                       </xsl:if>
+                       <xsl:if test="marc:datafield[@tag=730]/marc:subfield[@code='h']">
+                               <form authority="gmd">
+                                       <xsl:call-template name="chopBrackets">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:value-of select="marc:datafield[@tag=730]/marc:subfield[@code='h']"></xsl:value-of>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </form>
+                       </xsl:if>
+                       <xsl:for-each select="marc:datafield[@tag=256]/marc:subfield[@code='a']">
+                               <form>
+                                       <xsl:value-of select="."></xsl:value-of>
+                               </form>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:controlfield[@tag=007][substring(text(),1,1)='c']">
+                               <xsl:choose>
+                                       <xsl:when test="substring(text(),14,1)='a'">
+                                               <reformattingQuality>access</reformattingQuality>
+                                       </xsl:when>
+                                       <xsl:when test="substring(text(),14,1)='p'">
+                                               <reformattingQuality>preservation</reformattingQuality>
+                                       </xsl:when>
+                                       <xsl:when test="substring(text(),14,1)='r'">
+                                               <reformattingQuality>replacement</reformattingQuality>
+                                       </xsl:when>
+                               </xsl:choose>
+                       </xsl:for-each>
+                       <!--3.2 change tmee 007/01 -->
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='b']">
+                               <form authority="smd">chip cartridge</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='c']">
+                               <form authority="smd">computer optical disc cartridge</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='j']">
+                               <form authority="smd">magnetic disc</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='m']">
+                               <form authority="smd">magneto-optical disc</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='o']">
+                               <form authority="smd">optical disc</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='r']">
+                               <form authority="smd">remote</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='a']">
+                               <form authority="smd">tape cartridge</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='f']">
+                               <form authority="smd">tape cassette</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='c'][substring(text(),2,1)='h']">
+                               <form authority="smd">tape reel</form>
+                       </xsl:if>
+                       
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='d'][substring(text(),2,1)='a']">
+                               <form authority="smd">celestial globe</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='d'][substring(text(),2,1)='e']">
+                               <form authority="smd">earth moon globe</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='d'][substring(text(),2,1)='b']">
+                               <form authority="smd">planetary or lunar globe</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='d'][substring(text(),2,1)='c']">
+                               <form authority="smd">terrestrial globe</form>
+                       </xsl:if>
+                       
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='o'][substring(text(),2,1)='o']">
+                               <form authority="smd">kit</form>
+                       </xsl:if>
+                       
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='d']">
+                               <form authority="smd">atlas</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='g']">
+                               <form authority="smd">diagram</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='j']">
+                               <form authority="smd">map</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='q']">
+                               <form authority="smd">model</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='k']">
+                               <form authority="smd">profile</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='r']">
+                               <form authority="smd">remote-sensing image</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='s']">
+                               <form authority="smd">section</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='y']">
+                               <form authority="smd">view</form>
+                       </xsl:if>
+                       
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='a']">
+                               <form authority="smd">aperture card</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='e']">
+                               <form authority="smd">microfiche</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='f']">
+                               <form authority="smd">microfiche cassette</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='b']">
+                               <form authority="smd">microfilm cartridge</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='c']">
+                               <form authority="smd">microfilm cassette</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='d']">
+                               <form authority="smd">microfilm reel</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='h'][substring(text(),2,1)='g']">
+                               <form authority="smd">microopaque</form>
+                       </xsl:if>
+                       
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='m'][substring(text(),2,1)='c']">
+                               <form authority="smd">film cartridge</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='m'][substring(text(),2,1)='f']">
+                               <form authority="smd">film cassette</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='m'][substring(text(),2,1)='r']">
+                               <form authority="smd">film reel</form>
+                       </xsl:if>
+                       
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='n']">
+                               <form authority="smd">chart</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='c']">
+                               <form authority="smd">collage</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='d']">
+                               <form authority="smd">drawing</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='o']">
+                               <form authority="smd">flash card</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='e']">
+                               <form authority="smd">painting</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='f']">
+                               <form authority="smd">photomechanical print</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='g']">
+                               <form authority="smd">photonegative</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='h']">
+                               <form authority="smd">photoprint</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='i']">
+                               <form authority="smd">picture</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='j']">
+                               <form authority="smd">print</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='k'][substring(text(),2,1)='l']">
+                               <form authority="smd">technical drawing</form>
+                       </xsl:if>
+                       
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='q'][substring(text(),2,1)='q']">
+                               <form authority="smd">notated music</form>
+                       </xsl:if>
+                       
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='d']">
+                               <form authority="smd">filmslip</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='c']">
+                               <form authority="smd">filmstrip cartridge</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='o']">
+                               <form authority="smd">filmstrip roll</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='f']">
+                               <form authority="smd">other filmstrip type</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='s']">
+                               <form authority="smd">slide</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='g'][substring(text(),2,1)='t']">
+                               <form authority="smd">transparency</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='r'][substring(text(),2,1)='r']">
+                               <form authority="smd">remote-sensing image</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='e']">
+                               <form authority="smd">cylinder</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='q']">
+                               <form authority="smd">roll</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='g']">
+                               <form authority="smd">sound cartridge</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='s']">
+                               <form authority="smd">sound cassette</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='d']">
+                               <form authority="smd">sound disc</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='t']">
+                               <form authority="smd">sound-tape reel</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='i']">
+                               <form authority="smd">sound-track film</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='s'][substring(text(),2,1)='w']">
+                               <form authority="smd">wire recording</form>
+                       </xsl:if>
+                       
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='f'][substring(text(),2,1)='c']">
+                               <form authority="smd">braille</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='f'][substring(text(),2,1)='b']">
+                               <form authority="smd">combination</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='f'][substring(text(),2,1)='a']">
+                               <form authority="smd">moon</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='f'][substring(text(),2,1)='d']">
+                               <form authority="smd">tactile, with no writing system</form>
+                       </xsl:if>
+                       
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='t'][substring(text(),2,1)='c']">
+                               <form authority="smd">braille</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='t'][substring(text(),2,1)='b']">
+                               <form authority="smd">large print</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='t'][substring(text(),2,1)='a']">
+                               <form authority="smd">regular print</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='t'][substring(text(),2,1)='d']">
+                               <form authority="smd">text in looseleaf binder</form>
+                       </xsl:if>
+                       
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='v'][substring(text(),2,1)='c']">
+                               <form authority="smd">videocartridge</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='v'][substring(text(),2,1)='f']">
+                               <form authority="smd">videocassette</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='v'][substring(text(),2,1)='d']">
+                               <form authority="smd">videodisc</form>
+                       </xsl:if>
+                       <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='v'][substring(text(),2,1)='r']">
+                               <form authority="smd">videoreel</form>
+                       </xsl:if>
+                       
+                       <xsl:for-each select="marc:datafield[@tag=856]/marc:subfield[@code='q'][string-length(.)>1]">
+                               <internetMediaType>
+                                       <xsl:value-of select="."></xsl:value-of>
+                               </internetMediaType>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:datafield[@tag=300]">
+                               <extent>
+                                       <xsl:call-template name="subfieldSelect">
+                                               <xsl:with-param name="codes">abce</xsl:with-param>
+                                       </xsl:call-template>
+                               </extent>
+                       </xsl:for-each>
+               </xsl:variable>
+               <xsl:if test="string-length(normalize-space($physicalDescription))">
+                       <physicalDescription>
+                               <xsl:copy-of select="$physicalDescription"></xsl:copy-of>
+                       </physicalDescription>
+               </xsl:if>
+               <xsl:for-each select="marc:datafield[@tag=520]">
+                       <abstract>
+                               <xsl:call-template name="uri"></xsl:call-template>
+                               <xsl:call-template name="subfieldSelect">
+                                       <xsl:with-param name="codes">ab</xsl:with-param>
+                               </xsl:call-template>
+                       </abstract>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=505]">
+                       <tableOfContents>
+                               <xsl:call-template name="uri"></xsl:call-template>
+                               <xsl:call-template name="subfieldSelect">
+                                       <xsl:with-param name="codes">agrt</xsl:with-param>
+                               </xsl:call-template>
+                       </tableOfContents>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=521]">
+                       <targetAudience>
+                               <xsl:call-template name="subfieldSelect">
+                                       <xsl:with-param name="codes">ab</xsl:with-param>
+                               </xsl:call-template>
+                       </targetAudience>
+               </xsl:for-each>
+               <xsl:if test="$typeOf008='BK' or $typeOf008='CF' or $typeOf008='MU' or $typeOf008='VM'">
+                       <xsl:variable name="controlField008-22" select="substring($controlField008,23,1)"></xsl:variable>
+                       <xsl:choose>
+                               <!-- 01/04 fix -->
+                               <xsl:when test="$controlField008-22='d'">
+                                       <targetAudience authority="marctarget">adolescent</targetAudience>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-22='e'">
+                                       <targetAudience authority="marctarget">adult</targetAudience>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-22='g'">
+                                       <targetAudience authority="marctarget">general</targetAudience>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-22='b' or $controlField008-22='c' or $controlField008-22='j'">
+                                       <targetAudience authority="marctarget">juvenile</targetAudience>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-22='a'">
+                                       <targetAudience authority="marctarget">preschool</targetAudience>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-22='f'">
+                                       <targetAudience authority="marctarget">specialized</targetAudience>
+                               </xsl:when>
+                       </xsl:choose>
+               </xsl:if>
+               <xsl:for-each select="marc:datafield[@tag=245]/marc:subfield[@code='c']">
+                       <note type="statement of responsibility">
+                               <xsl:value-of select="."></xsl:value-of>
+                       </note>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=500]">
+                       <note>
+                               <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
+                               <xsl:call-template name="uri"></xsl:call-template>
+                       </note>
+               </xsl:for-each>
+               
+               <!--3.2 change tmee additional note fields-->
+               
+               <xsl:for-each select="marc:datafield[@tag=506]">
+                       <note type="restrictions">
+                               <xsl:call-template name="uri"></xsl:call-template>
+                               <xsl:variable name="str">
+                                       <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
+                                               <xsl:value-of select="."></xsl:value-of>
+                                               <xsl:text> </xsl:text>
+                                       </xsl:for-each>
+                               </xsl:variable>
+                               <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
+                       </note>
+               </xsl:for-each>
+               
+               <xsl:for-each select="marc:datafield[@tag=510]">
+                       <note  type="citation/reference">
+                               <xsl:call-template name="uri"></xsl:call-template>
+                               <xsl:variable name="str">
+                                       <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
+                                               <xsl:value-of select="."></xsl:value-of>
+                                               <xsl:text> </xsl:text>
+                                       </xsl:for-each>
+                               </xsl:variable>
+                               <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
+                       </note>
+               </xsl:for-each>
+               
+                       
+               <xsl:for-each select="marc:datafield[@tag=511]">
+                       <note type="performers">
+                               <xsl:call-template name="uri"></xsl:call-template>
+                               <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
+                       </note>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=518]">
+                       <note type="venue">
+                               <xsl:call-template name="uri"></xsl:call-template>
+                               <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
+                       </note>
+               </xsl:for-each>
+               
+               <xsl:for-each select="marc:datafield[@tag=530]">
+                       <note  type="additional physical form">
+                               <xsl:call-template name="uri"></xsl:call-template>
+                               <xsl:variable name="str">
+                                       <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
+                                               <xsl:value-of select="."></xsl:value-of>
+                                               <xsl:text> </xsl:text>
+                                       </xsl:for-each>
+                               </xsl:variable>
+                               <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
+                       </note>
+               </xsl:for-each>
+               
+               <xsl:for-each select="marc:datafield[@tag=533]">
+                       <note  type="reproduction">
+                               <xsl:call-template name="uri"></xsl:call-template>
+                               <xsl:variable name="str">
+                                       <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
+                                               <xsl:value-of select="."></xsl:value-of>
+                                               <xsl:text> </xsl:text>
+                                       </xsl:for-each>
+                               </xsl:variable>
+                               <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
+                       </note>
+               </xsl:for-each>
+               
+               <xsl:for-each select="marc:datafield[@tag=534]">
+                       <note  type="original version">
+                               <xsl:call-template name="uri"></xsl:call-template>
+                               <xsl:variable name="str">
+                                       <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
+                                               <xsl:value-of select="."></xsl:value-of>
+                                               <xsl:text> </xsl:text>
+                                       </xsl:for-each>
+                               </xsl:variable>
+                               <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
+                       </note>
+               </xsl:for-each>
+               
+               <xsl:for-each select="marc:datafield[@tag=538]">
+                       <note  type="system details">
+                               <xsl:call-template name="uri"></xsl:call-template>
+                               <xsl:variable name="str">
+                                       <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
+                                               <xsl:value-of select="."></xsl:value-of>
+                                               <xsl:text> </xsl:text>
+                                       </xsl:for-each>
+                               </xsl:variable>
+                               <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
+                       </note>
+               </xsl:for-each>
+               
+               <xsl:for-each select="marc:datafield[@tag=583]">
+                       <note type="action">
+                               <xsl:call-template name="uri"></xsl:call-template>
+                               <xsl:variable name="str">
+                                       <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
+                                               <xsl:value-of select="."></xsl:value-of>
+                                               <xsl:text> </xsl:text>
+                                       </xsl:for-each>
+                               </xsl:variable>
+                               <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
+                       </note>
+               </xsl:for-each>
+               
+               
+               
+               
+               <xsl:for-each select="marc:datafield[@tag=501 or @tag=502 or @tag=504 or @tag=507 or @tag=508 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]">
+                       <note>
+                               <xsl:call-template name="uri"></xsl:call-template>
+                               <xsl:variable name="str">
+                                       <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
+                                               <xsl:value-of select="."></xsl:value-of>
+                                               <xsl:text> </xsl:text>
+                                       </xsl:for-each>
+                               </xsl:variable>
+                               <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
+                       </note>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=034][marc:subfield[@code='d' or @code='e' or @code='f' or @code='g']]">
+                       <subject>
+                               <cartographics>
+                                       <coordinates>
+                                               <xsl:call-template name="subfieldSelect">
+                                                       <xsl:with-param name="codes">defg</xsl:with-param>
+                                               </xsl:call-template>
+                                       </coordinates>
+                               </cartographics>
+                       </subject>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=043]">
+                       <subject>
+                               <xsl:for-each select="marc:subfield[@code='a' or @code='b' or @code='c']">
+                                       <geographicCode>
+                                               <xsl:attribute name="authority">
+                                                       <xsl:if test="@code='a'">
+                                                               <xsl:text>marcgac</xsl:text>
+                                                       </xsl:if>
+                                                       <xsl:if test="@code='b'">
+                                                               <xsl:value-of select="following-sibling::marc:subfield[@code=2]"></xsl:value-of>
+                                                       </xsl:if>
+                                                       <xsl:if test="@code='c'">
+                                                               <xsl:text>iso3166</xsl:text>
+                                                       </xsl:if>
+                                               </xsl:attribute>
+                                               <xsl:value-of select="self::marc:subfield"></xsl:value-of>
+                                       </geographicCode>
+                               </xsl:for-each>
+                       </subject>
+               </xsl:for-each>
+               <!-- tmee 2006/11/27 -->
+               <xsl:for-each select="marc:datafield[@tag=255]">
+                       <subject>
+                               <xsl:for-each select="marc:subfield[@code='a' or @code='b' or @code='c']">
+                               <cartographics>
+                                       <xsl:if test="@code='a'">
+                                               <scale>
+                                                       <xsl:value-of select="."></xsl:value-of>
+                                               </scale>
+                                       </xsl:if>
+                                       <xsl:if test="@code='b'">
+                                               <projection>
+                                                       <xsl:value-of select="."></xsl:value-of>
+                                               </projection>
+                                       </xsl:if>
+                                       <xsl:if test="@code='c'">
+                                               <coordinates>
+                                                       <xsl:value-of select="."></xsl:value-of>
+                                               </coordinates>
+                                       </xsl:if>
+                               </cartographics>
+                               </xsl:for-each>
+                       </subject>
+               </xsl:for-each>
+                               
+               <xsl:apply-templates select="marc:datafield[653 >= @tag and @tag >= 600]"></xsl:apply-templates>
+               <xsl:apply-templates select="marc:datafield[@tag=656]"></xsl:apply-templates>
+               <xsl:for-each select="marc:datafield[@tag=752]">
+                       <subject>
+                               <hierarchicalGeographic>
+                                       <xsl:for-each select="marc:subfield[@code='a']">
+                                               <country>
+                                                       <xsl:call-template name="chopPunctuation">
+                                                               <xsl:with-param name="chopString" select="."></xsl:with-param>
+                                                       </xsl:call-template>
+                                               </country>
+                                       </xsl:for-each>
+                                       <xsl:for-each select="marc:subfield[@code='b']">
+                                               <state>
+                                                       <xsl:call-template name="chopPunctuation">
+                                                               <xsl:with-param name="chopString" select="."></xsl:with-param>
+                                                       </xsl:call-template>
+                                               </state>
+                                       </xsl:for-each>
+                                       <xsl:for-each select="marc:subfield[@code='c']">
+                                               <county>
+                                                       <xsl:call-template name="chopPunctuation">
+                                                               <xsl:with-param name="chopString" select="."></xsl:with-param>
+                                                       </xsl:call-template>
+                                               </county>
+                                       </xsl:for-each>
+                                       <xsl:for-each select="marc:subfield[@code='d']">
+                                               <city>
+                                                       <xsl:call-template name="chopPunctuation">
+                                                               <xsl:with-param name="chopString" select="."></xsl:with-param>
+                                                       </xsl:call-template>
+                                               </city>
+                                       </xsl:for-each>
+                               </hierarchicalGeographic>
+                       </subject>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=045][marc:subfield[@code='b']]">
+                       <subject>
+                               <xsl:choose>
+                                       <xsl:when test="@ind1=2">
+                                               <temporal encoding="iso8601" point="start">
+                                                       <xsl:call-template name="chopPunctuation">
+                                                               <xsl:with-param name="chopString">
+                                                                       <xsl:value-of select="marc:subfield[@code='b'][1]"></xsl:value-of>
+                                                               </xsl:with-param>
+                                                       </xsl:call-template>
+                                               </temporal>
+                                               <temporal encoding="iso8601" point="end">
+                                                       <xsl:call-template name="chopPunctuation">
+                                                               <xsl:with-param name="chopString">
+                                                                       <xsl:value-of select="marc:subfield[@code='b'][2]"></xsl:value-of>
+                                                               </xsl:with-param>
+                                                       </xsl:call-template>
+                                               </temporal>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <xsl:for-each select="marc:subfield[@code='b']">
+                                                       <temporal encoding="iso8601">
+                                                               <xsl:call-template name="chopPunctuation">
+                                                                       <xsl:with-param name="chopString" select="."></xsl:with-param>
+                                                               </xsl:call-template>
+                                                       </temporal>
+                                               </xsl:for-each>
+                                       </xsl:otherwise>
+                               </xsl:choose>
+                       </subject>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=050]">
+                       <xsl:for-each select="marc:subfield[@code='b']">
+                               <classification authority="lcc">
+                                       <xsl:if test="../marc:subfield[@code='3']">
+                                               <xsl:attribute name="displayLabel">
+                                                       <xsl:value-of select="../marc:subfield[@code='3']"></xsl:value-of>
+                                               </xsl:attribute>
+                                       </xsl:if>
+                                       <xsl:value-of select="preceding-sibling::marc:subfield[@code='a'][1]"></xsl:value-of>
+                                       <xsl:text> </xsl:text>
+                                       <xsl:value-of select="text()"></xsl:value-of>
+                               </classification>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:subfield[@code='a'][not(following-sibling::marc:subfield[@code='b'])]">
+                               <classification authority="lcc">
+                                       <xsl:if test="../marc:subfield[@code='3']">
+                                               <xsl:attribute name="displayLabel">
+                                                       <xsl:value-of select="../marc:subfield[@code='3']"></xsl:value-of>
+                                               </xsl:attribute>
+                                       </xsl:if>
+                                       <xsl:value-of select="text()"></xsl:value-of>
+                               </classification>
+                       </xsl:for-each>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=082]">
+                       <classification authority="ddc">
+                               <xsl:if test="marc:subfield[@code='2']">
+                                       <xsl:attribute name="edition">
+                                               <xsl:value-of select="marc:subfield[@code='2']"></xsl:value-of>
+                                       </xsl:attribute>
+                               </xsl:if>
+                               <xsl:call-template name="subfieldSelect">
+                                       <xsl:with-param name="codes">ab</xsl:with-param>
+                               </xsl:call-template>
+                       </classification>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=080]">
+                       <classification authority="udc">
+                               <xsl:call-template name="subfieldSelect">
+                                       <xsl:with-param name="codes">abx</xsl:with-param>
+                               </xsl:call-template>
+                       </classification>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=060]">
+                       <classification authority="nlm">
+                               <xsl:call-template name="subfieldSelect">
+                                       <xsl:with-param name="codes">ab</xsl:with-param>
+                               </xsl:call-template>
+                       </classification>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=086][@ind1=0]">
+                       <classification authority="sudocs">
+                               <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
+                       </classification>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=086][@ind1=1]">
+                       <classification authority="candoc">
+                               <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
+                       </classification>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=086]">
+                       <classification>
+                               <xsl:attribute name="authority">
+                                       <xsl:value-of select="marc:subfield[@code='2']"></xsl:value-of>
+                               </xsl:attribute>
+                               <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
+                       </classification>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=084]">
+                       <classification>
+                               <xsl:attribute name="authority">
+                                       <xsl:value-of select="marc:subfield[@code='2']"></xsl:value-of>
+                               </xsl:attribute>
+                               <xsl:call-template name="subfieldSelect">
+                                       <xsl:with-param name="codes">ab</xsl:with-param>
+                               </xsl:call-template>
+                       </classification>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=440]">
+                       <relatedItem type="series">
+                               <titleInfo>
+                                       <title>
+                                               <xsl:call-template name="chopPunctuation">
+                                                       <xsl:with-param name="chopString">
+                                                               <xsl:call-template name="subfieldSelect">
+                                                                       <xsl:with-param name="codes">av</xsl:with-param>
+                                                               </xsl:call-template>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </title>
+                                       <xsl:call-template name="part"></xsl:call-template>
+                               </titleInfo>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=490][@ind1=0]">
+                       <relatedItem type="series">
+                               <titleInfo>
+                                       <title>
+                                               <xsl:call-template name="chopPunctuation">
+                                                       <xsl:with-param name="chopString">
+                                                               <xsl:call-template name="subfieldSelect">
+                                                                       <xsl:with-param name="codes">av</xsl:with-param>
+                                                               </xsl:call-template>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </title>
+                                       <xsl:call-template name="part"></xsl:call-template>
+                               </titleInfo>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=510]">
+                       <relatedItem type="isReferencedBy">
+                               <note>
+                                       <xsl:call-template name="subfieldSelect">
+                                               <xsl:with-param name="codes">abcx3</xsl:with-param>
+                                       </xsl:call-template>
+                               </note>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=534]">
+                       <relatedItem type="original">
+                               <xsl:call-template name="relatedTitle"></xsl:call-template>
+                               <xsl:call-template name="relatedName"></xsl:call-template>
+                               <xsl:if test="marc:subfield[@code='b' or @code='c']">
+                                       <originInfo>
+                                               <xsl:for-each select="marc:subfield[@code='c']">
+                                                       <publisher>
+                                                               <xsl:value-of select="."></xsl:value-of>
+                                                       </publisher>
+                                               </xsl:for-each>
+                                               <xsl:for-each select="marc:subfield[@code='b']">
+                                                       <edition>
+                                                               <xsl:value-of select="."></xsl:value-of>
+                                                       </edition>
+                                               </xsl:for-each>
+                                       </originInfo>
+                               </xsl:if>
+                               <xsl:call-template name="relatedIdentifierISSN"></xsl:call-template>
+                               <xsl:for-each select="marc:subfield[@code='z']">
+                                       <identifier type="isbn">
+                                               <xsl:value-of select="."></xsl:value-of>
+                                       </identifier>
+                               </xsl:for-each>
+                               <xsl:call-template name="relatedNote"></xsl:call-template>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=700][marc:subfield[@code='t']]">
+                       <relatedItem>
+                               <xsl:call-template name="constituentOrRelatedType"></xsl:call-template>
+                               <titleInfo>
+                                       <title>
+                                               <xsl:call-template name="chopPunctuation">
+                                                       <xsl:with-param name="chopString">
+                                                               <xsl:call-template name="specialSubfieldSelect">
+                                                                       <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
+                                                                       <xsl:with-param name="axis">t</xsl:with-param>
+                                                                       <xsl:with-param name="afterCodes">g</xsl:with-param>
+                                                               </xsl:call-template>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </title>
+                                       <xsl:call-template name="part"></xsl:call-template>
+                               </titleInfo>
+                               <name type="personal">
+                                       <namePart>
+                                               <xsl:call-template name="specialSubfieldSelect">
+                                                       <xsl:with-param name="anyCodes">aq</xsl:with-param>
+                                                       <xsl:with-param name="axis">t</xsl:with-param>
+                                                       <xsl:with-param name="beforeCodes">g</xsl:with-param>
+                                               </xsl:call-template>
+                                       </namePart>
+                                       <xsl:call-template name="termsOfAddress"></xsl:call-template>
+                                       <xsl:call-template name="nameDate"></xsl:call-template>
+                                       <xsl:call-template name="role"></xsl:call-template>
+                               </name>
+                               <xsl:call-template name="relatedForm"></xsl:call-template>
+                               <xsl:call-template name="relatedIdentifierISSN"></xsl:call-template>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=710][marc:subfield[@code='t']]">
+                       <relatedItem>
+                               <xsl:call-template name="constituentOrRelatedType"></xsl:call-template>
+                               <titleInfo>
+                                       <title>
+                                               <xsl:call-template name="chopPunctuation">
+                                                       <xsl:with-param name="chopString">
+                                                               <xsl:call-template name="specialSubfieldSelect">
+                                                                       <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
+                                                                       <xsl:with-param name="axis">t</xsl:with-param>
+                                                                       <xsl:with-param name="afterCodes">dg</xsl:with-param>
+                                                               </xsl:call-template>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </title>
+                                       <xsl:call-template name="relatedPartNumName"></xsl:call-template>
+                               </titleInfo>
+                               <name type="corporate">
+                                       <xsl:for-each select="marc:subfield[@code='a']">
+                                               <namePart>
+                                                       <xsl:value-of select="."></xsl:value-of>
+                                               </namePart>
+                                       </xsl:for-each>
+                                       <xsl:for-each select="marc:subfield[@code='b']">
+                                               <namePart>
+                                                       <xsl:value-of select="."></xsl:value-of>
+                                               </namePart>
+                                       </xsl:for-each>
+                                       <xsl:variable name="tempNamePart">
+                                               <xsl:call-template name="specialSubfieldSelect">
+                                                       <xsl:with-param name="anyCodes">c</xsl:with-param>
+                                                       <xsl:with-param name="axis">t</xsl:with-param>
+                                                       <xsl:with-param name="beforeCodes">dgn</xsl:with-param>
+                                               </xsl:call-template>
+                                       </xsl:variable>
+                                       <xsl:if test="normalize-space($tempNamePart)">
+                                               <namePart>
+                                                       <xsl:value-of select="$tempNamePart"></xsl:value-of>
+                                               </namePart>
+                                       </xsl:if>
+                                       <xsl:call-template name="role"></xsl:call-template>
+                               </name>
+                               <xsl:call-template name="relatedForm"></xsl:call-template>
+                               <xsl:call-template name="relatedIdentifierISSN"></xsl:call-template>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=711][marc:subfield[@code='t']]">
+                       <relatedItem>
+                               <xsl:call-template name="constituentOrRelatedType"></xsl:call-template>
+                               <titleInfo>
+                                       <title>
+                                               <xsl:call-template name="chopPunctuation">
+                                                       <xsl:with-param name="chopString">
+                                                               <xsl:call-template name="specialSubfieldSelect">
+                                                                       <xsl:with-param name="anyCodes">tfklsv</xsl:with-param>
+                                                                       <xsl:with-param name="axis">t</xsl:with-param>
+                                                                       <xsl:with-param name="afterCodes">g</xsl:with-param>
+                                                               </xsl:call-template>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </title>
+                                       <xsl:call-template name="relatedPartNumName"></xsl:call-template>
+                               </titleInfo>
+                               <name type="conference">
+                                       <namePart>
+                                               <xsl:call-template name="specialSubfieldSelect">
+                                                       <xsl:with-param name="anyCodes">aqdc</xsl:with-param>
+                                                       <xsl:with-param name="axis">t</xsl:with-param>
+                                                       <xsl:with-param name="beforeCodes">gn</xsl:with-param>
+                                               </xsl:call-template>
+                                       </namePart>
+                               </name>
+                               <xsl:call-template name="relatedForm"></xsl:call-template>
+                               <xsl:call-template name="relatedIdentifierISSN"></xsl:call-template>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=730][@ind2=2]">
+                       <relatedItem>
+                               <xsl:call-template name="constituentOrRelatedType"></xsl:call-template>
+                               <titleInfo>
+                                       <title>
+                                               <xsl:call-template name="chopPunctuation">
+                                                       <xsl:with-param name="chopString">
+                                                               <xsl:call-template name="subfieldSelect">
+                                                                       <xsl:with-param name="codes">adfgklmorsv</xsl:with-param>
+                                                               </xsl:call-template>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </title>
+                                       <xsl:call-template name="part"></xsl:call-template>
+                               </titleInfo>
+                               <xsl:call-template name="relatedForm"></xsl:call-template>
+                               <xsl:call-template name="relatedIdentifierISSN"></xsl:call-template>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=740][@ind2=2]">
+                       <relatedItem>
+                               <xsl:call-template name="constituentOrRelatedType"></xsl:call-template>
+                               <titleInfo>
+                                       <title>
+                                               <xsl:call-template name="chopPunctuation">
+                                                       <xsl:with-param name="chopString">
+                                                               <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </title>
+                                       <xsl:call-template name="part"></xsl:call-template>
+                               </titleInfo>
+                               <xsl:call-template name="relatedForm"></xsl:call-template>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=760]|marc:datafield[@tag=762]">
+                       <relatedItem type="series">
+                               <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=765]|marc:datafield[@tag=767]|marc:datafield[@tag=777]|marc:datafield[@tag=787]">
+                       <relatedItem>
+                               <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=775]">
+                       <relatedItem type="otherVersion">
+                               <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=770]|marc:datafield[@tag=774]">
+                       <relatedItem type="constituent">
+                               <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=772]|marc:datafield[@tag=773]">
+                       <relatedItem type="host">
+                               <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=776]">
+                       <relatedItem type="otherFormat">
+                               <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=780]">
+                       <relatedItem type="preceding">
+                               <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=785]">
+                       <relatedItem type="succeeding">
+                               <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=786]">
+                       <relatedItem type="original">
+                               <xsl:call-template name="relatedItem76X-78X"></xsl:call-template>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=800]">
+                       <relatedItem type="series">
+                               <titleInfo>
+                                       <title>
+                                               <xsl:call-template name="chopPunctuation">
+                                                       <xsl:with-param name="chopString">
+                                                               <xsl:call-template name="specialSubfieldSelect">
+                                                                       <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
+                                                                       <xsl:with-param name="axis">t</xsl:with-param>
+                                                                       <xsl:with-param name="afterCodes">g</xsl:with-param>
+                                                               </xsl:call-template>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </title>
+                                       <xsl:call-template name="part"></xsl:call-template>
+                               </titleInfo>
+                               <name type="personal">
+                                       <namePart>
+                                               <xsl:call-template name="chopPunctuation">
+                                                       <xsl:with-param name="chopString">
+                                                               <xsl:call-template name="specialSubfieldSelect">
+                                                                       <xsl:with-param name="anyCodes">aq</xsl:with-param>
+                                                                       <xsl:with-param name="axis">t</xsl:with-param>
+                                                                       <xsl:with-param name="beforeCodes">g</xsl:with-param>
+                                                               </xsl:call-template>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </namePart>
+                                       <xsl:call-template name="termsOfAddress"></xsl:call-template>
+                                       <xsl:call-template name="nameDate"></xsl:call-template>
+                                       <xsl:call-template name="role"></xsl:call-template>
+                               </name>
+                               <xsl:call-template name="relatedForm"></xsl:call-template>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=810]">
+                       <relatedItem type="series">
+                               <titleInfo>
+                                       <title>
+                                               <xsl:call-template name="chopPunctuation">
+                                                       <xsl:with-param name="chopString">
+                                                               <xsl:call-template name="specialSubfieldSelect">
+                                                                       <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
+                                                                       <xsl:with-param name="axis">t</xsl:with-param>
+                                                                       <xsl:with-param name="afterCodes">dg</xsl:with-param>
+                                                               </xsl:call-template>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </title>
+                                       <xsl:call-template name="relatedPartNumName"></xsl:call-template>
+                               </titleInfo>
+                               <name type="corporate">
+                                       <xsl:for-each select="marc:subfield[@code='a']">
+                                               <namePart>
+                                                       <xsl:value-of select="."></xsl:value-of>
+                                               </namePart>
+                                       </xsl:for-each>
+                                       <xsl:for-each select="marc:subfield[@code='b']">
+                                               <namePart>
+                                                       <xsl:value-of select="."></xsl:value-of>
+                                               </namePart>
+                                       </xsl:for-each>
+                                       <namePart>
+                                               <xsl:call-template name="specialSubfieldSelect">
+                                                       <xsl:with-param name="anyCodes">c</xsl:with-param>
+                                                       <xsl:with-param name="axis">t</xsl:with-param>
+                                                       <xsl:with-param name="beforeCodes">dgn</xsl:with-param>
+                                               </xsl:call-template>
+                                       </namePart>
+                                       <xsl:call-template name="role"></xsl:call-template>
+                               </name>
+                               <xsl:call-template name="relatedForm"></xsl:call-template>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=811]">
+                       <relatedItem type="series">
+                               <titleInfo>
+                                       <title>
+                                               <xsl:call-template name="chopPunctuation">
+                                                       <xsl:with-param name="chopString">
+                                                               <xsl:call-template name="specialSubfieldSelect">
+                                                                       <xsl:with-param name="anyCodes">tfklsv</xsl:with-param>
+                                                                       <xsl:with-param name="axis">t</xsl:with-param>
+                                                                       <xsl:with-param name="afterCodes">g</xsl:with-param>
+                                                               </xsl:call-template>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </title>
+                                       <xsl:call-template name="relatedPartNumName"/>
+                               </titleInfo>
+                               <name type="conference">
+                                       <namePart>
+                                               <xsl:call-template name="specialSubfieldSelect">
+                                                       <xsl:with-param name="anyCodes">aqdc</xsl:with-param>
+                                                       <xsl:with-param name="axis">t</xsl:with-param>
+                                                       <xsl:with-param name="beforeCodes">gn</xsl:with-param>
+                                               </xsl:call-template>
+                                       </namePart>
+                                       <xsl:call-template name="role"/>
+                               </name>
+                               <xsl:call-template name="relatedForm"/>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag='830']">
+                       <relatedItem type="series">
+                               <titleInfo>
+                                       <title>
+                                               <xsl:call-template name="chopPunctuation">
+                                                       <xsl:with-param name="chopString">
+                                                               <xsl:call-template name="subfieldSelect">
+                                                                       <xsl:with-param name="codes">adfgklmorsv</xsl:with-param>
+                                                               </xsl:call-template>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </title>
+                                       <xsl:call-template name="part"/>
+                               </titleInfo>
+                               <xsl:call-template name="relatedForm"/>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag='856'][@ind2='2']/marc:subfield[@code='q']">
+                       <relatedItem>
+                               <internetMediaType>
+                                       <xsl:value-of select="."/>
+                               </internetMediaType>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag='020']">
+                       <xsl:call-template name="isInvalid">
+                               <xsl:with-param name="type">isbn</xsl:with-param>
+                       </xsl:call-template>
+                       <xsl:if test="marc:subfield[@code='a']">
+                               <identifier type="isbn">
+                                       <xsl:value-of select="marc:subfield[@code='a']"/>
+                               </identifier>
+                       </xsl:if>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag='024'][@ind1='0']">
+                       <xsl:call-template name="isInvalid">
+                               <xsl:with-param name="type">isrc</xsl:with-param>
+                       </xsl:call-template>
+                       <xsl:if test="marc:subfield[@code='a']">
+                               <identifier type="isrc">
+                                       <xsl:value-of select="marc:subfield[@code='a']"/>
+                               </identifier>
+                       </xsl:if>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag='024'][@ind1='2']">
+                       <xsl:call-template name="isInvalid">
+                               <xsl:with-param name="type">ismn</xsl:with-param>
+                       </xsl:call-template>
+                       <xsl:if test="marc:subfield[@code='a']">
+                               <identifier type="ismn">
+                                       <xsl:value-of select="marc:subfield[@code='a']"/>
+                               </identifier>
+                       </xsl:if>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag='024'][@ind1='4']">
+                       <xsl:call-template name="isInvalid">
+                               <xsl:with-param name="type">sici</xsl:with-param>
+                       </xsl:call-template>
+                       <identifier type="sici">
+                               <xsl:call-template name="subfieldSelect">
+                                       <xsl:with-param name="codes">ab</xsl:with-param>
+                               </xsl:call-template>
+                       </identifier>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag='022']">
+                       <xsl:call-template name="isInvalid">
+                               <xsl:with-param name="type">issn</xsl:with-param>
+                       </xsl:call-template>
+                       <identifier type="issn">
+                               <xsl:value-of select="marc:subfield[@code='a']"/>
+                       </identifier>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag='010']">
+                       <xsl:call-template name="isInvalid">
+                               <xsl:with-param name="type">lccn</xsl:with-param>
+                       </xsl:call-template>
+                       <identifier type="lccn">
+                               <xsl:value-of select="normalize-space(marc:subfield[@code='a'])"/>
+                       </identifier>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag='028']">
+                       <identifier>
+                               <xsl:attribute name="type">
+                                       <xsl:choose>
+                                               <xsl:when test="@ind1='0'">issue number</xsl:when>
+                                               <xsl:when test="@ind1='1'">matrix number</xsl:when>
+                                               <xsl:when test="@ind1='2'">music plate</xsl:when>
+                                               <xsl:when test="@ind1='3'">music publisher</xsl:when>
+                                               <xsl:when test="@ind1='4'">videorecording identifier</xsl:when>
+                                       </xsl:choose>
+                               </xsl:attribute>
+                               <!--<xsl:call-template name="isInvalid"/>--> <!-- no $z in 028 -->
+                               <xsl:call-template name="subfieldSelect">
+                                       <xsl:with-param name="codes">
+                                               <xsl:choose>
+                                                       <xsl:when test="@ind1='0'">ba</xsl:when>
+                                                       <xsl:otherwise>ab</xsl:otherwise>
+                                               </xsl:choose>
+                                       </xsl:with-param>
+                               </xsl:call-template>
+                       </identifier>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag='037']">
+                       <identifier type="stock number">
+                               <!--<xsl:call-template name="isInvalid"/>--> <!-- no $z in 037 -->
+                               <xsl:call-template name="subfieldSelect">
+                                       <xsl:with-param name="codes">ab</xsl:with-param>
+                               </xsl:call-template>
+                       </identifier>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag='856'][marc:subfield[@code='u']]">
+                       <identifier>
+                               <xsl:attribute name="type">
+                                       <xsl:choose>
+                                               <xsl:when test="starts-with(marc:subfield[@code='u'],'urn:doi') or starts-with(marc:subfield[@code='u'],'doi')">doi</xsl:when>
+                                               <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>
+                                               <xsl:otherwise>uri</xsl:otherwise>
+                                       </xsl:choose>
+                               </xsl:attribute>
+                               <xsl:choose>
+                                       <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') ">
+                                               <xsl:value-of select="concat('hdl:',substring-after(marc:subfield[@code='u'],'http://hdl.loc.gov/'))"></xsl:value-of>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <xsl:value-of select="marc:subfield[@code='u']"></xsl:value-of>
+                                       </xsl:otherwise>
+                               </xsl:choose>
+                       </identifier>
+                       <xsl:if test="starts-with(marc:subfield[@code='u'],'urn:hdl') or starts-with(marc:subfield[@code='u'],'hdl')">
+                               <identifier type="hdl">
+                                       <xsl:if test="marc:subfield[@code='y' or @code='3' or @code='z']">
+                                               <xsl:attribute name="displayLabel">
+                                                       <xsl:call-template name="subfieldSelect">
+                                                               <xsl:with-param name="codes">y3z</xsl:with-param>
+                                                       </xsl:call-template>
+                                               </xsl:attribute>
+                                       </xsl:if>
+                                       <xsl:value-of select="concat('hdl:',substring-after(marc:subfield[@code='u'],'http://hdl.loc.gov/'))"></xsl:value-of>
+                               </identifier>
+                       </xsl:if>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=024][@ind1=1]">
+                       <identifier type="upc">
+                               <xsl:call-template name="isInvalid"/>
+                               <xsl:value-of select="marc:subfield[@code='a']"/>
+                       </identifier>
+               </xsl:for-each>
+               <!-- 1/04 fix added $y -->
+               <xsl:for-each select="marc:datafield[@tag=856][marc:subfield[@code='u']]">
+                       <location>
+                               <url>
+                                       <xsl:if test="marc:subfield[@code='y' or @code='3']">
+                                               <xsl:attribute name="displayLabel">
+                                                       <xsl:call-template name="subfieldSelect">
+                                                               <xsl:with-param name="codes">y3</xsl:with-param>
+                                                       </xsl:call-template>
+                                               </xsl:attribute>
+                                       </xsl:if>
+                                       <xsl:if test="marc:subfield[@code='z' ]">
+                                               <xsl:attribute name="note">
+                                                       <xsl:call-template name="subfieldSelect">
+                                                               <xsl:with-param name="codes">z</xsl:with-param>
+                                                       </xsl:call-template>
+                                               </xsl:attribute>
+                                       </xsl:if>
+                                       <xsl:value-of select="marc:subfield[@code='u']"></xsl:value-of>
+                               </url>
+                       </location>
+               </xsl:for-each>
+                       
+                       <!-- 3.2 change tmee 856z  -->
+               
+               <xsl:for-each select="marc:datafield[@tag=852]">
+                       <location>
+                               <physicalLocation>
+                                       <xsl:call-template name="displayLabel"></xsl:call-template>
+                                       <xsl:call-template name="subfieldSelect">
+                                               <xsl:with-param name="codes">abje</xsl:with-param>
+                                       </xsl:call-template>
+                               </physicalLocation>
+                       </location>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=506]">
+                       <accessCondition type="restrictionOnAccess">
+                               <xsl:call-template name="subfieldSelect">
+                                       <xsl:with-param name="codes">abcd35</xsl:with-param>
+                               </xsl:call-template>
+                       </accessCondition>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=540]">
+                       <accessCondition type="useAndReproduction">
+                               <xsl:call-template name="subfieldSelect">
+                                       <xsl:with-param name="codes">abcde35</xsl:with-param>
+                               </xsl:call-template>
+                       </accessCondition>
+               </xsl:for-each>
+               <recordInfo>
+                       <xsl:for-each select="marc:datafield[@tag=040]">
+                               <recordContentSource authority="marcorg">
+                                       <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
+                               </recordContentSource>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:controlfield[@tag=008]">
+                               <recordCreationDate encoding="marc">
+                                       <xsl:value-of select="substring(.,1,6)"></xsl:value-of>
+                               </recordCreationDate>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:controlfield[@tag=005]">
+                               <recordChangeDate encoding="iso8601">
+                                       <xsl:value-of select="."></xsl:value-of>
+                               </recordChangeDate>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:controlfield[@tag=001]">
+                               <recordIdentifier>
+                                       <xsl:if test="../marc:controlfield[@tag=003]">
+                                               <xsl:attribute name="source">
+                                                       <xsl:value-of select="../marc:controlfield[@tag=003]"></xsl:value-of>
+                                               </xsl:attribute>
+                                       </xsl:if>
+                                       <xsl:value-of select="."></xsl:value-of>
+                               </recordIdentifier>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:datafield[@tag=040]/marc:subfield[@code='b']">
+                               <languageOfCataloging>
+                                       <languageTerm authority="iso639-2b" type="code">
+                                               <xsl:value-of select="."></xsl:value-of>
+                                       </languageTerm>
+                               </languageOfCataloging>
+                       </xsl:for-each>
+               </recordInfo>
+       </xsl:template>
+       <xsl:template name="displayForm">
+               <xsl:for-each select="marc:subfield[@code='c']">
+                       <displayForm>
+                               <xsl:value-of select="."></xsl:value-of>
+                       </displayForm>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="affiliation">
+               <xsl:for-each select="marc:subfield[@code='u']">
+                       <affiliation>
+                               <xsl:value-of select="."></xsl:value-of>
+                       </affiliation>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="uri">
+               <xsl:for-each select="marc:subfield[@code='u']">
+                       <xsl:attribute name="xlink:href">
+                               <xsl:value-of select="."></xsl:value-of>
+                       </xsl:attribute>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="role">
+               <xsl:for-each select="marc:subfield[@code='e']">
+                       <role>
+                               <roleTerm type="text">
+                                       <xsl:value-of select="."></xsl:value-of>
+                               </roleTerm>
+                       </role>
+               </xsl:for-each>
+               <xsl:for-each select="marc:subfield[@code='4']">
+                       <role>
+                               <roleTerm authority="marcrelator" type="code">
+                                       <xsl:value-of select="."></xsl:value-of>
+                               </roleTerm>
+                       </role>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="part">
+               <xsl:variable name="partNumber">
+                       <xsl:call-template name="specialSubfieldSelect">
+                               <xsl:with-param name="axis">n</xsl:with-param>
+                               <xsl:with-param name="anyCodes">n</xsl:with-param>
+                               <xsl:with-param name="afterCodes">fgkdlmor</xsl:with-param>
+                       </xsl:call-template>
+               </xsl:variable>
+               <xsl:variable name="partName">
+                       <xsl:call-template name="specialSubfieldSelect">
+                               <xsl:with-param name="axis">p</xsl:with-param>
+                               <xsl:with-param name="anyCodes">p</xsl:with-param>
+                               <xsl:with-param name="afterCodes">fgkdlmor</xsl:with-param>
+                       </xsl:call-template>
+               </xsl:variable>
+               <xsl:if test="string-length(normalize-space($partNumber))">
+                       <partNumber>
+                               <xsl:call-template name="chopPunctuation">
+                                       <xsl:with-param name="chopString" select="$partNumber"></xsl:with-param>
+                               </xsl:call-template>
+                       </partNumber>
+               </xsl:if>
+               <xsl:if test="string-length(normalize-space($partName))">
+                       <partName>
+                               <xsl:call-template name="chopPunctuation">
+                                       <xsl:with-param name="chopString" select="$partName"></xsl:with-param>
+                               </xsl:call-template>
+                       </partName>
+               </xsl:if>
+       </xsl:template>
+       <xsl:template name="relatedPart">
+               <xsl:if test="@tag=773">
+                       <xsl:for-each select="marc:subfield[@code='g']">
+                               <part>
+                                       <text>
+                                               <xsl:value-of select="."></xsl:value-of>
+                                       </text>
+                               </part>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:subfield[@code='q']">
+                               <part>
+                                       <xsl:call-template name="parsePart"></xsl:call-template>
+                               </part>
+                       </xsl:for-each>
+               </xsl:if>
+       </xsl:template>
+       <xsl:template name="relatedPartNumName">
+               <xsl:variable name="partNumber">
+                       <xsl:call-template name="specialSubfieldSelect">
+                               <xsl:with-param name="axis">g</xsl:with-param>
+                               <xsl:with-param name="anyCodes">g</xsl:with-param>
+                               <xsl:with-param name="afterCodes">pst</xsl:with-param>
+                       </xsl:call-template>
+               </xsl:variable>
+               <xsl:variable name="partName">
+                       <xsl:call-template name="specialSubfieldSelect">
+                               <xsl:with-param name="axis">p</xsl:with-param>
+                               <xsl:with-param name="anyCodes">p</xsl:with-param>
+                               <xsl:with-param name="afterCodes">fgkdlmor</xsl:with-param>
+                       </xsl:call-template>
+               </xsl:variable>
+               <xsl:if test="string-length(normalize-space($partNumber))">
+                       <partNumber>
+                               <xsl:value-of select="$partNumber"></xsl:value-of>
+                       </partNumber>
+               </xsl:if>
+               <xsl:if test="string-length(normalize-space($partName))">
+                       <partName>
+                               <xsl:value-of select="$partName"></xsl:value-of>
+                       </partName>
+               </xsl:if>
+       </xsl:template>
+       <xsl:template name="relatedName">
+               <xsl:for-each select="marc:subfield[@code='a']">
+                       <name>
+                               <namePart>
+                                       <xsl:value-of select="."></xsl:value-of>
+                               </namePart>
+                       </name>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="relatedForm">
+               <xsl:for-each select="marc:subfield[@code='h']">
+                       <physicalDescription>
+                               <form>
+                                       <xsl:value-of select="."></xsl:value-of>
+                               </form>
+                       </physicalDescription>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="relatedExtent">
+               <xsl:for-each select="marc:subfield[@code='h']">
+                       <physicalDescription>
+                               <extent>
+                                       <xsl:value-of select="."></xsl:value-of>
+                               </extent>
+                       </physicalDescription>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="relatedNote">
+               <xsl:for-each select="marc:subfield[@code='n']">
+                       <note>
+                               <xsl:value-of select="."></xsl:value-of>
+                       </note>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="relatedSubject">
+               <xsl:for-each select="marc:subfield[@code='j']">
+                       <subject>
+                               <temporal encoding="iso8601">
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString" select="."></xsl:with-param>
+                                       </xsl:call-template>
+                               </temporal>
+                       </subject>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="relatedIdentifierISSN">
+               <xsl:for-each select="marc:subfield[@code='x']">
+                       <identifier type="issn">
+                               <xsl:value-of select="."></xsl:value-of>
+                       </identifier>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="relatedIdentifierLocal">
+               <xsl:for-each select="marc:subfield[@code='w']">
+                       <identifier type="local">
+                               <xsl:value-of select="."></xsl:value-of>
+                       </identifier>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="relatedIdentifier">
+               <xsl:for-each select="marc:subfield[@code='o']">
+                       <identifier>
+                               <xsl:value-of select="."></xsl:value-of>
+                       </identifier>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="relatedItem76X-78X">
+               <xsl:call-template name="displayLabel"></xsl:call-template>
+               <xsl:call-template name="relatedTitle76X-78X"></xsl:call-template>
+               <xsl:call-template name="relatedName"></xsl:call-template>
+               <xsl:call-template name="relatedOriginInfo"></xsl:call-template>
+               <xsl:call-template name="relatedLanguage"></xsl:call-template>
+               <xsl:call-template name="relatedExtent"></xsl:call-template>
+               <xsl:call-template name="relatedNote"></xsl:call-template>
+               <xsl:call-template name="relatedSubject"></xsl:call-template>
+               <xsl:call-template name="relatedIdentifier"></xsl:call-template>
+               <xsl:call-template name="relatedIdentifierISSN"></xsl:call-template>
+               <xsl:call-template name="relatedIdentifierLocal"></xsl:call-template>
+               <xsl:call-template name="relatedPart"></xsl:call-template>
+       </xsl:template>
+       <xsl:template name="subjectGeographicZ">
+               <geographic>
+                       <xsl:call-template name="chopPunctuation">
+                               <xsl:with-param name="chopString" select="."></xsl:with-param>
+                       </xsl:call-template>
+               </geographic>
+       </xsl:template>
+       <xsl:template name="subjectTemporalY">
+               <temporal>
+                       <xsl:call-template name="chopPunctuation">
+                               <xsl:with-param name="chopString" select="."></xsl:with-param>
+                       </xsl:call-template>
+               </temporal>
+       </xsl:template>
+       <xsl:template name="subjectTopic">
+               <topic>
+                       <xsl:call-template name="chopPunctuation">
+                               <xsl:with-param name="chopString" select="."></xsl:with-param>
+                       </xsl:call-template>
+               </topic>
+       </xsl:template> 
+       <!-- 3.2 change tmee 6xx $v genre -->
+       <xsl:template name="subjectGenre">
+               <genre>
+                       <xsl:call-template name="chopPunctuation">
+                               <xsl:with-param name="chopString" select="."></xsl:with-param>
+                       </xsl:call-template>
+               </genre>
+       </xsl:template>
+       
+       <xsl:template name="nameABCDN">
+               <xsl:for-each select="marc:subfield[@code='a']">
+                       <namePart>
+                               <xsl:call-template name="chopPunctuation">
+                                       <xsl:with-param name="chopString" select="."></xsl:with-param>
+                               </xsl:call-template>
+                       </namePart>
+               </xsl:for-each>
+               <xsl:for-each select="marc:subfield[@code='b']">
+                       <namePart>
+                               <xsl:value-of select="."></xsl:value-of>
+                       </namePart>
+               </xsl:for-each>
+               <xsl:if test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">
+                       <namePart>
+                               <xsl:call-template name="subfieldSelect">
+                                       <xsl:with-param name="codes">cdn</xsl:with-param>
+                               </xsl:call-template>
+                       </namePart>
+               </xsl:if>
+       </xsl:template>
+       <xsl:template name="nameABCDQ">
+               <namePart>
+                       <xsl:call-template name="chopPunctuation">
+                               <xsl:with-param name="chopString">
+                                       <xsl:call-template name="subfieldSelect">
+                                               <xsl:with-param name="codes">aq</xsl:with-param>
+                                       </xsl:call-template>
+                               </xsl:with-param>
+                               <xsl:with-param name="punctuation">
+                                       <xsl:text>:,;/ </xsl:text>
+                               </xsl:with-param>
+                       </xsl:call-template>
+               </namePart>
+               <xsl:call-template name="termsOfAddress"></xsl:call-template>
+               <xsl:call-template name="nameDate"></xsl:call-template>
+       </xsl:template>
+       <xsl:template name="nameACDEQ">
+               <namePart>
+                       <xsl:call-template name="subfieldSelect">
+                               <xsl:with-param name="codes">acdeq</xsl:with-param>
+                       </xsl:call-template>
+               </namePart>
+       </xsl:template>
+       <xsl:template name="constituentOrRelatedType">
+               <xsl:if test="@ind2=2">
+                       <xsl:attribute name="type">constituent</xsl:attribute>
+               </xsl:if>
+       </xsl:template>
+       <xsl:template name="relatedTitle">
+               <xsl:for-each select="marc:subfield[@code='t']">
+                       <titleInfo>
+                               <title>
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:value-of select="."></xsl:value-of>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </title>
+                       </titleInfo>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="relatedTitle76X-78X">
+               <xsl:for-each select="marc:subfield[@code='t']">
+                       <titleInfo>
+                               <title>
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:value-of select="."></xsl:value-of>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </title>
+                               <xsl:if test="marc:datafield[@tag!=773]and marc:subfield[@code='g']">
+                                       <xsl:call-template name="relatedPartNumName"></xsl:call-template>
+                               </xsl:if>
+                       </titleInfo>
+               </xsl:for-each>
+               <xsl:for-each select="marc:subfield[@code='p']">
+                       <titleInfo type="abbreviated">
+                               <title>
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:value-of select="."></xsl:value-of>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </title>
+                               <xsl:if test="marc:datafield[@tag!=773]and marc:subfield[@code='g']">
+                                       <xsl:call-template name="relatedPartNumName"></xsl:call-template>
+                               </xsl:if>
+                       </titleInfo>
+               </xsl:for-each>
+               <xsl:for-each select="marc:subfield[@code='s']">
+                       <titleInfo type="uniform">
+                               <title>
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:value-of select="."></xsl:value-of>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </title>
+                               <xsl:if test="marc:datafield[@tag!=773]and marc:subfield[@code='g']">
+                                       <xsl:call-template name="relatedPartNumName"></xsl:call-template>
+                               </xsl:if>
+                       </titleInfo>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="relatedOriginInfo">
+               <xsl:if test="marc:subfield[@code='b' or @code='d'] or marc:subfield[@code='f']">
+                       <originInfo>
+                               <xsl:if test="@tag=775">
+                                       <xsl:for-each select="marc:subfield[@code='f']">
+                                               <place>
+                                                       <placeTerm>
+                                                               <xsl:attribute name="type">code</xsl:attribute>
+                                                               <xsl:attribute name="authority">marcgac</xsl:attribute>
+                                                               <xsl:value-of select="."></xsl:value-of>
+                                                       </placeTerm>
+                                               </place>
+                                       </xsl:for-each>
+                               </xsl:if>
+                               <xsl:for-each select="marc:subfield[@code='d']">
+                                       <publisher>
+                                               <xsl:value-of select="."></xsl:value-of>
+                                       </publisher>
+                               </xsl:for-each>
+                               <xsl:for-each select="marc:subfield[@code='b']">
+                                       <edition>
+                                               <xsl:value-of select="."></xsl:value-of>
+                                       </edition>
+                               </xsl:for-each>
+                       </originInfo>
+               </xsl:if>
+       </xsl:template>
+       <xsl:template name="relatedLanguage">
+               <xsl:for-each select="marc:subfield[@code='e']">
+                       <xsl:call-template name="getLanguage">
+                               <xsl:with-param name="langString">
+                                       <xsl:value-of select="."></xsl:value-of>
+                               </xsl:with-param>
+                       </xsl:call-template>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="nameDate">
+               <xsl:for-each select="marc:subfield[@code='d']">
+                       <namePart type="date">
+                               <xsl:call-template name="chopPunctuation">
+                                       <xsl:with-param name="chopString" select="."></xsl:with-param>
+                               </xsl:call-template>
+                       </namePart>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="subjectAuthority">
+               <xsl:if test="@ind2!=4">
+                       <xsl:if test="@ind2!=' '">
+                               <xsl:if test="@ind2!=8">
+                                       <xsl:if test="@ind2!=9">
+                                               <xsl:attribute name="authority">
+                                                       <xsl:choose>
+                                                               <xsl:when test="@ind2=0">lcsh</xsl:when>
+                                                               <xsl:when test="@ind2=1">lcshac</xsl:when>
+                                                               <xsl:when test="@ind2=2">mesh</xsl:when>
+                                                               <!-- 1/04 fix -->
+                                                               <xsl:when test="@ind2=3">nal</xsl:when>
+                                                               <xsl:when test="@ind2=5">csh</xsl:when>
+                                                               <xsl:when test="@ind2=6">rvm</xsl:when>
+                                                               <xsl:when test="@ind2=7">
+                                                                       <xsl:value-of select="marc:subfield[@code='2']"></xsl:value-of>
+                                                               </xsl:when>
+                                                       </xsl:choose>
+                                               </xsl:attribute>
+                                       </xsl:if>
+                               </xsl:if>
+                       </xsl:if>
+               </xsl:if>
+       </xsl:template>
+       <xsl:template name="subjectAnyOrder">
+               <xsl:for-each select="marc:subfield[@code='v' or @code='x' or @code='y' or @code='z']">
+                       <xsl:choose>
+                               <xsl:when test="@code='v'">
+                                       <xsl:call-template name="subjectGenre"></xsl:call-template>
+                               </xsl:when>
+                               <xsl:when test="@code='x'">
+                                       <xsl:call-template name="subjectTopic"></xsl:call-template>
+                               </xsl:when>
+                               <xsl:when test="@code='y'">
+                                       <xsl:call-template name="subjectTemporalY"></xsl:call-template>
+                               </xsl:when>
+                               <xsl:when test="@code='z'">
+                                       <xsl:call-template name="subjectGeographicZ"></xsl:call-template>
+                               </xsl:when>
+                       </xsl:choose>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="specialSubfieldSelect">
+               <xsl:param name="anyCodes"></xsl:param>
+               <xsl:param name="axis"></xsl:param>
+               <xsl:param name="beforeCodes"></xsl:param>
+               <xsl:param name="afterCodes"></xsl:param>
+               <xsl:variable name="str">
+                       <xsl:for-each select="marc:subfield">
+                               <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])">
+                                       <xsl:value-of select="text()"></xsl:value-of>
+                                       <xsl:text> </xsl:text>
+                               </xsl:if>
+                       </xsl:for-each>
+               </xsl:variable>
+               <xsl:value-of select="substring($str,1,string-length($str)-1)"></xsl:value-of>
+       </xsl:template>
+       
+       <!-- 3.2 change tmee 6xx $v genre -->
+       <xsl:template match="marc:datafield[@tag=600]">
+               <subject>
+                       <xsl:call-template name="subjectAuthority"></xsl:call-template>
+                       <name type="personal">
+                               <xsl:call-template name="termsOfAddress"></xsl:call-template>
+                               <namePart>
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:call-template name="subfieldSelect">
+                                                               <xsl:with-param name="codes">aq</xsl:with-param>
+                                                       </xsl:call-template>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </namePart>
+                               <xsl:call-template name="nameDate"></xsl:call-template>
+                               <xsl:call-template name="affiliation"></xsl:call-template>
+                               <xsl:call-template name="role"></xsl:call-template>
+                       </name>
+                       <xsl:call-template name="subjectAnyOrder"></xsl:call-template>
+               </subject>
+       </xsl:template>
+       <xsl:template match="marc:datafield[@tag=610]">
+               <subject>
+                       <xsl:call-template name="subjectAuthority"></xsl:call-template>
+                       <name type="corporate">
+                               <xsl:for-each select="marc:subfield[@code='a']">
+                                       <namePart>
+                                               <xsl:value-of select="."></xsl:value-of>
+                                       </namePart>
+                               </xsl:for-each>
+                               <xsl:for-each select="marc:subfield[@code='b']">
+                                       <namePart>
+                                               <xsl:value-of select="."></xsl:value-of>
+                                       </namePart>
+                               </xsl:for-each>
+                               <xsl:if test="marc:subfield[@code='c' or @code='d' or @code='n' or @code='p']">
+                                       <namePart>
+                                               <xsl:call-template name="subfieldSelect">
+                                                       <xsl:with-param name="codes">cdnp</xsl:with-param>
+                                               </xsl:call-template>
+                                       </namePart>
+                               </xsl:if>
+                               <xsl:call-template name="role"></xsl:call-template>
+                       </name>
+                       <xsl:call-template name="subjectAnyOrder"></xsl:call-template>
+               </subject>
+       </xsl:template>
+       <xsl:template match="marc:datafield[@tag=611]">
+               <subject>
+                       <xsl:call-template name="subjectAuthority"></xsl:call-template>
+                       <name type="conference">
+                               <namePart>
+                                       <xsl:call-template name="subfieldSelect">
+                                               <xsl:with-param name="codes">abcdeqnp</xsl:with-param>
+                                       </xsl:call-template>
+                               </namePart>
+                               <xsl:for-each select="marc:subfield[@code='4']">
+                                       <role>
+                                               <roleTerm authority="marcrelator" type="code">
+                                                       <xsl:value-of select="."></xsl:value-of>
+                                               </roleTerm>
+                                       </role>
+                               </xsl:for-each>
+                       </name>
+                       <xsl:call-template name="subjectAnyOrder"></xsl:call-template>
+               </subject>
+       </xsl:template>
+       <xsl:template match="marc:datafield[@tag=630]">
+               <subject>
+                       <xsl:call-template name="subjectAuthority"></xsl:call-template>
+                       <titleInfo>
+                               <title>
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:call-template name="subfieldSelect">
+                                                               <xsl:with-param name="codes">adfhklor</xsl:with-param>
+                                                       </xsl:call-template>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                                       <xsl:call-template name="part"></xsl:call-template>
+                               </title>
+                       </titleInfo>
+                       <xsl:call-template name="subjectAnyOrder"></xsl:call-template>
+               </subject>
+       </xsl:template>
+       <xsl:template match="marc:datafield[@tag=650]">
+               <subject>
+                       <xsl:call-template name="subjectAuthority"></xsl:call-template>
+                       <topic>
+                               <xsl:call-template name="chopPunctuation">
+                                       <xsl:with-param name="chopString">
+                                               <xsl:call-template name="subfieldSelect">
+                                                       <xsl:with-param name="codes">abcd</xsl:with-param>
+                                               </xsl:call-template>
+                                       </xsl:with-param>
+                               </xsl:call-template>
+                       </topic>
+                       <xsl:call-template name="subjectAnyOrder"></xsl:call-template>
+               </subject>
+       </xsl:template>
+       <xsl:template match="marc:datafield[@tag=651]">
+               <subject>
+                       <xsl:call-template name="subjectAuthority"></xsl:call-template>
+                       <xsl:for-each select="marc:subfield[@code='a']">
+                               <geographic>
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString" select="."></xsl:with-param>
+                                       </xsl:call-template>
+                               </geographic>
+                       </xsl:for-each>
+                       <xsl:call-template name="subjectAnyOrder"></xsl:call-template>
+               </subject>
+       </xsl:template>
+       <xsl:template match="marc:datafield[@tag=653]">
+               <subject>
+                       <xsl:for-each select="marc:subfield[@code='a']">
+                               <topic>
+                                       <xsl:value-of select="."></xsl:value-of>
+                               </topic>
+                       </xsl:for-each>
+               </subject>
+       </xsl:template>
+       <xsl:template match="marc:datafield[@tag=656]">
+               <subject>
+                       <xsl:if test="marc:subfield[@code=2]">
+                               <xsl:attribute name="authority">
+                                       <xsl:value-of select="marc:subfield[@code=2]"></xsl:value-of>
+                               </xsl:attribute>
+                       </xsl:if>
+                       <occupation>
+                               <xsl:call-template name="chopPunctuation">
+                                       <xsl:with-param name="chopString">
+                                               <xsl:value-of select="marc:subfield[@code='a']"></xsl:value-of>
+                                       </xsl:with-param>
+                               </xsl:call-template>
+                       </occupation>
+               </subject>
+       </xsl:template>
+       <xsl:template name="termsOfAddress">
+               <xsl:if test="marc:subfield[@code='b' or @code='c']">
+                       <namePart type="termsOfAddress">
+                               <xsl:call-template name="chopPunctuation">
+                                       <xsl:with-param name="chopString">
+                                               <xsl:call-template name="subfieldSelect">
+                                                       <xsl:with-param name="codes">bc</xsl:with-param>
+                                               </xsl:call-template>
+                                       </xsl:with-param>
+                               </xsl:call-template>
+                       </namePart>
+               </xsl:if>
+       </xsl:template>
+       <xsl:template name="displayLabel">
+               <xsl:if test="marc:subfield[@code='i']">
+                       <xsl:attribute name="displayLabel">
+                               <xsl:value-of select="marc:subfield[@code='i']"></xsl:value-of>
+                       </xsl:attribute>
+               </xsl:if>
+               <xsl:if test="marc:subfield[@code='3']">
+                       <xsl:attribute name="displayLabel">
+                               <xsl:value-of select="marc:subfield[@code='3']"></xsl:value-of>
+                       </xsl:attribute>
+               </xsl:if>
+       </xsl:template>
+       <xsl:template name="isInvalid">
+               <xsl:param name="type"/>
+               <xsl:if test="marc:subfield[@code='z'] or marc:subfield[@code='y']">
+                       <identifier>
+                               <xsl:attribute name="type">
+                                       <xsl:value-of select="$type"/>
+                               </xsl:attribute>
+                               <xsl:attribute name="invalid">
+                                       <xsl:text>yes</xsl:text>
+                               </xsl:attribute>
+                               <xsl:if test="marc:subfield[@code='z']">
+                                       <xsl:value-of select="marc:subfield[@code='z']"/>
+                               </xsl:if>
+                               <xsl:if test="marc:subfield[@code='y']">
+                                       <xsl:value-of select="marc:subfield[@code='y']"/>
+                               </xsl:if>
+                       </identifier>
+               </xsl:if>
+       </xsl:template>
+       <xsl:template name="subtitle">
+               <xsl:if test="marc:subfield[@code='b']">
+                       <subTitle>
+                               <xsl:call-template name="chopPunctuation">
+                                       <xsl:with-param name="chopString">
+                                               <xsl:value-of select="marc:subfield[@code='b']"/>
+                                               <!--<xsl:call-template name="subfieldSelect">
+                                                       <xsl:with-param name="codes">b</xsl:with-param>                                                                 
+                                               </xsl:call-template>-->
+                                       </xsl:with-param>
+                               </xsl:call-template>
+                       </subTitle>
+               </xsl:if>
+       </xsl:template>
+       <xsl:template name="script">
+               <xsl:param name="scriptCode"></xsl:param>
+               <xsl:attribute name="script">
+                       <xsl:choose>
+                               <xsl:when test="$scriptCode='(3'">Arabic</xsl:when>
+                               <xsl:when test="$scriptCode='(B'">Latin</xsl:when>
+                               <xsl:when test="$scriptCode='$1'">Chinese, Japanese, Korean</xsl:when>
+                               <xsl:when test="$scriptCode='(N'">Cyrillic</xsl:when>
+                               <xsl:when test="$scriptCode='(2'">Hebrew</xsl:when>
+                               <xsl:when test="$scriptCode='(S'">Greek</xsl:when>
+                       </xsl:choose>
+               </xsl:attribute>
+       </xsl:template>
+       <xsl:template name="parsePart">
+               <!-- assumes 773$q= 1:2:3<4
+                    with up to 3 levels and one optional start page
+               -->
+               <xsl:variable name="level1">
+                       <xsl:choose>
+                               <xsl:when test="contains(text(),':')">
+                                       <!-- 1:2 -->
+                                       <xsl:value-of select="substring-before(text(),':')"></xsl:value-of>
+                               </xsl:when>
+                               <xsl:when test="not(contains(text(),':'))">
+                                       <!-- 1 or 1<3 -->
+                                       <xsl:if test="contains(text(),'&lt;')">
+                                               <!-- 1<3 -->
+                                               <xsl:value-of select="substring-before(text(),'&lt;')"></xsl:value-of>
+                                       </xsl:if>
+                                       <xsl:if test="not(contains(text(),'&lt;'))">
+                                               <!-- 1 -->
+                                               <xsl:value-of select="text()"></xsl:value-of>
+                                       </xsl:if>
+                               </xsl:when>
+                       </xsl:choose>
+               </xsl:variable>
+               <xsl:variable name="sici2">
+                       <xsl:choose>
+                               <xsl:when test="starts-with(substring-after(text(),$level1),':')">
+                                       <xsl:value-of select="substring(substring-after(text(),$level1),2)"></xsl:value-of>
+                               </xsl:when>
+                               <xsl:otherwise>
+                                       <xsl:value-of select="substring-after(text(),$level1)"></xsl:value-of>
+                               </xsl:otherwise>
+                       </xsl:choose>
+               </xsl:variable>
+               <xsl:variable name="level2">
+                       <xsl:choose>
+                               <xsl:when test="contains($sici2,':')">
+                                       <!--  2:3<4  -->
+                                       <xsl:value-of select="substring-before($sici2,':')"></xsl:value-of>
+                               </xsl:when>
+                               <xsl:when test="contains($sici2,'&lt;')">
+                                       <!-- 1: 2<4 -->
+                                       <xsl:value-of select="substring-before($sici2,'&lt;')"></xsl:value-of>
+                               </xsl:when>
+                               <xsl:otherwise>
+                                       <xsl:value-of select="$sici2"></xsl:value-of>
+                                       <!-- 1:2 -->
+                               </xsl:otherwise>
+                       </xsl:choose>
+               </xsl:variable>
+               <xsl:variable name="sici3">
+                       <xsl:choose>
+                               <xsl:when test="starts-with(substring-after($sici2,$level2),':')">
+                                       <xsl:value-of select="substring(substring-after($sici2,$level2),2)"></xsl:value-of>
+                               </xsl:when>
+                               <xsl:otherwise>
+                                       <xsl:value-of select="substring-after($sici2,$level2)"></xsl:value-of>
+                               </xsl:otherwise>
+                       </xsl:choose>
+               </xsl:variable>
+               <xsl:variable name="level3">
+                       <xsl:choose>
+                               <xsl:when test="contains($sici3,'&lt;')">
+                                       <!-- 2<4 -->
+                                       <xsl:value-of select="substring-before($sici3,'&lt;')"></xsl:value-of>
+                               </xsl:when>
+                               <xsl:otherwise>
+                                       <xsl:value-of select="$sici3"></xsl:value-of>
+                                       <!-- 3 -->
+                               </xsl:otherwise>
+                       </xsl:choose>
+               </xsl:variable>
+               <xsl:variable name="page">
+                       <xsl:if test="contains(text(),'&lt;')">
+                               <xsl:value-of select="substring-after(text(),'&lt;')"></xsl:value-of>
+                       </xsl:if>
+               </xsl:variable>
+               <xsl:if test="$level1">
+                       <detail level="1">
+                               <number>
+                                       <xsl:value-of select="$level1"></xsl:value-of>
+                               </number>
+                       </detail>
+               </xsl:if>
+               <xsl:if test="$level2">
+                       <detail level="2">
+                               <number>
+                                       <xsl:value-of select="$level2"></xsl:value-of>
+                               </number>
+                       </detail>
+               </xsl:if>
+               <xsl:if test="$level3">
+                       <detail level="3">
+                               <number>
+                                       <xsl:value-of select="$level3"></xsl:value-of>
+                               </number>
+                       </detail>
+               </xsl:if>
+               <xsl:if test="$page">
+                       <extent unit="page">
+                               <start>
+                                       <xsl:value-of select="$page"></xsl:value-of>
+                               </start>
+                       </extent>
+               </xsl:if>
+       </xsl:template>
+       <xsl:template name="getLanguage">
+               <xsl:param name="langString"></xsl:param>
+               <xsl:param name="controlField008-35-37"></xsl:param>
+               <xsl:variable name="length" select="string-length($langString)"></xsl:variable>
+               <xsl:choose>
+                       <xsl:when test="$length=0"></xsl:when>
+                       <xsl:when test="$controlField008-35-37=substring($langString,1,3)">
+                               <xsl:call-template name="getLanguage">
+                                       <xsl:with-param name="langString" select="substring($langString,4,$length)"></xsl:with-param>
+                                       <xsl:with-param name="controlField008-35-37" select="$controlField008-35-37"></xsl:with-param>
+                               </xsl:call-template>
+                       </xsl:when>
+                       <xsl:otherwise>
+                               <language>
+                                       <languageTerm authority="iso639-2b" type="code">
+                                               <xsl:value-of select="substring($langString,1,3)"></xsl:value-of>
+                                       </languageTerm>
+                               </language>
+                               <xsl:call-template name="getLanguage">
+                                       <xsl:with-param name="langString" select="substring($langString,4,$length)"></xsl:with-param>
+                                       <xsl:with-param name="controlField008-35-37" select="$controlField008-35-37"></xsl:with-param>
+                               </xsl:call-template>
+                       </xsl:otherwise>
+               </xsl:choose>
+       </xsl:template>
+       <xsl:template name="isoLanguage">
+               <xsl:param name="currentLanguage"></xsl:param>
+               <xsl:param name="usedLanguages"></xsl:param>
+               <xsl:param name="remainingLanguages"></xsl:param>
+               <xsl:choose>
+                       <xsl:when test="string-length($currentLanguage)=0"></xsl:when>
+                       <xsl:when test="not(contains($usedLanguages, $currentLanguage))">
+                               <language>
+                                       <xsl:if test="@code!='a'">
+                                               <xsl:attribute name="objectPart">
+                                                       <xsl:choose>
+                                                               <xsl:when test="@code='b'">summary or subtitle</xsl:when>
+                                                               <xsl:when test="@code='d'">sung or spoken text</xsl:when>
+                                                               <xsl:when test="@code='e'">libretto</xsl:when>
+                                                               <xsl:when test="@code='f'">table of contents</xsl:when>
+                                                               <xsl:when test="@code='g'">accompanying material</xsl:when>
+                                                               <xsl:when test="@code='h'">translation</xsl:when>
+                                                       </xsl:choose>
+                                               </xsl:attribute>
+                                       </xsl:if>
+                                       <languageTerm authority="iso639-2b" type="code">
+                                               <xsl:value-of select="$currentLanguage"></xsl:value-of>
+                                       </languageTerm>
+                               </language>
+                               <xsl:call-template name="isoLanguage">
+                                       <xsl:with-param name="currentLanguage">
+                                               <xsl:value-of select="substring($remainingLanguages,1,3)"></xsl:value-of>
+                                       </xsl:with-param>
+                                       <xsl:with-param name="usedLanguages">
+                                               <xsl:value-of select="concat($usedLanguages,$currentLanguage)"></xsl:value-of>
+                                       </xsl:with-param>
+                                       <xsl:with-param name="remainingLanguages">
+                                               <xsl:value-of select="substring($remainingLanguages,4,string-length($remainingLanguages))"></xsl:value-of>
+                                       </xsl:with-param>
+                               </xsl:call-template>
+                       </xsl:when>
+                       <xsl:otherwise>
+                               <xsl:call-template name="isoLanguage">
+                                       <xsl:with-param name="currentLanguage">
+                                               <xsl:value-of select="substring($remainingLanguages,1,3)"></xsl:value-of>
+                                       </xsl:with-param>
+                                       <xsl:with-param name="usedLanguages">
+                                               <xsl:value-of select="concat($usedLanguages,$currentLanguage)"></xsl:value-of>
+                                       </xsl:with-param>
+                                       <xsl:with-param name="remainingLanguages">
+                                               <xsl:value-of select="substring($remainingLanguages,4,string-length($remainingLanguages))"></xsl:value-of>
+                                       </xsl:with-param>
+                               </xsl:call-template>
+                       </xsl:otherwise>
+               </xsl:choose>
+       </xsl:template>
+       <xsl:template name="chopBrackets">
+               <xsl:param name="chopString"></xsl:param>
+               <xsl:variable name="string">
+                       <xsl:call-template name="chopPunctuation">
+                               <xsl:with-param name="chopString" select="$chopString"></xsl:with-param>
+                       </xsl:call-template>
+               </xsl:variable>
+               <xsl:if test="substring($string, 1,1)='['">
+                       <xsl:value-of select="substring($string,2, string-length($string)-2)"></xsl:value-of>
+               </xsl:if>
+               <xsl:if test="substring($string, 1,1)!='['">
+                       <xsl:value-of select="$string"></xsl:value-of>
+               </xsl:if>
+       </xsl:template>
+       <xsl:template name="rfcLanguages">
+               <xsl:param name="nodeNum"></xsl:param>
+               <xsl:param name="usedLanguages"></xsl:param>
+               <xsl:param name="controlField008-35-37"></xsl:param>
+               <xsl:variable name="currentLanguage" select="."></xsl:variable>
+               <xsl:choose>
+                       <xsl:when test="not($currentLanguage)"></xsl:when>
+                       <xsl:when test="$currentLanguage!=$controlField008-35-37 and $currentLanguage!='rfc3066'">
+                               <xsl:if test="not(contains($usedLanguages,$currentLanguage))">
+                                       <language>
+                                               <xsl:if test="@code!='a'">
+                                                       <xsl:attribute name="objectPart">
+                                                               <xsl:choose>
+                                                                       <xsl:when test="@code='b'">summary or subtitle</xsl:when>
+                                                                       <xsl:when test="@code='d'">sung or spoken text</xsl:when>
+                                                                       <xsl:when test="@code='e'">libretto</xsl:when>
+                                                                       <xsl:when test="@code='f'">table of contents</xsl:when>
+                                                                       <xsl:when test="@code='g'">accompanying material</xsl:when>
+                                                                       <xsl:when test="@code='h'">translation</xsl:when>
+                                                               </xsl:choose>
+                                                       </xsl:attribute>
+                                               </xsl:if>
+                                               <languageTerm authority="rfc3066" type="code">
+                                                       <xsl:value-of select="$currentLanguage"/>
+                                               </languageTerm>
+                                       </language>
+                               </xsl:if>
+                       </xsl:when>
+                       <xsl:otherwise>
+                       </xsl:otherwise>
+               </xsl:choose>
+       </xsl:template>
+       <xsl:template name="datafield">
+               <xsl:param name="tag"/>
+               <xsl:param name="ind1"><xsl:text> </xsl:text></xsl:param>
+               <xsl:param name="ind2"><xsl:text> </xsl:text></xsl:param>
+               <xsl:param name="subfields"/>
+               <xsl:element name="marc:datafield">
+                       <xsl:attribute name="tag">
+                               <xsl:value-of select="$tag"/>
+                       </xsl:attribute>
+                       <xsl:attribute name="ind1">
+                               <xsl:value-of select="$ind1"/>
+                       </xsl:attribute>
+                       <xsl:attribute name="ind2">
+                               <xsl:value-of select="$ind2"/>
+                       </xsl:attribute>
+                       <xsl:copy-of select="$subfields"/>
+               </xsl:element>
+       </xsl:template>
+       <xsl:template name="subfieldSelect">
+               <xsl:param name="codes"/>
+               <xsl:param name="delimeter"><xsl:text> </xsl:text></xsl:param>
+               <xsl:variable name="str">
+                       <xsl:for-each select="marc:subfield">
+                               <xsl:if test="contains($codes, @code)">
+                                       <xsl:value-of select="text()"/><xsl:value-of select="$delimeter"/>
+                               </xsl:if>
+                       </xsl:for-each>
+               </xsl:variable>
+               <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
+       </xsl:template>
+       <xsl:template name="buildSpaces">
+               <xsl:param name="spaces"/>
+               <xsl:param name="char"><xsl:text> </xsl:text></xsl:param>
+               <xsl:if test="$spaces>0">
+                       <xsl:value-of select="$char"/>
+                       <xsl:call-template name="buildSpaces">
+                               <xsl:with-param name="spaces" select="$spaces - 1"/>
+                               <xsl:with-param name="char" select="$char"/>
+                       </xsl:call-template>
+               </xsl:if>
+       </xsl:template>
+       <xsl:template name="chopPunctuation">
+               <xsl:param name="chopString"/>
+               <xsl:param name="punctuation"><xsl:text>.:,;/ </xsl:text></xsl:param>
+               <xsl:variable name="length" select="string-length($chopString)"/>
+               <xsl:choose>
+                       <xsl:when test="$length=0"/>
+                       <xsl:when test="contains($punctuation, substring($chopString,$length,1))">
+                               <xsl:call-template name="chopPunctuation">
+                                       <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
+                                       <xsl:with-param name="punctuation" select="$punctuation"/>
+                               </xsl:call-template>
+                       </xsl:when>
+                       <xsl:when test="not($chopString)"/>
+                       <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>
+               </xsl:choose>
+       </xsl:template>
+       <xsl:template name="chopPunctuationFront">
+               <xsl:param name="chopString"/>
+               <xsl:variable name="length" select="string-length($chopString)"/>
+               <xsl:choose>
+                       <xsl:when test="$length=0"/>
+                       <xsl:when test="contains('.:,;/[ ', substring($chopString,1,1))">
+                               <xsl:call-template name="chopPunctuationFront">
+                                       <xsl:with-param name="chopString" select="substring($chopString,2,$length - 1)"/>
+                               </xsl:call-template>
+                       </xsl:when>
+                       <xsl:when test="not($chopString)"/>
+                       <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>
+               </xsl:choose>
+       </xsl:template>
+ </xsl:stylesheet>$$ WHERE name = 'mods32';
+ -- Currently, the only difference from naco_normalize is that search_normalize
+ -- turns apostrophes into spaces, while naco_normalize collapses them.
+ CREATE OR REPLACE FUNCTION public.search_normalize( TEXT, TEXT ) RETURNS TEXT AS $func$
+     use strict;
+     use Unicode::Normalize;
+     use Encode;
+     my $str = decode_utf8(shift);
+     my $sf = shift;
+     # Apply NACO normalization to input string; based on
+     # http://www.loc.gov/catdir/pcc/naco/SCA_PccNormalization_Final_revised.pdf
+     #
+     # Note that unlike a strict reading of the NACO normalization rules,
+     # output is returned as lowercase instead of uppercase for compatibility
+     # with previous versions of the Evergreen naco_normalize routine.
+     # Convert to upper-case first; even though final output will be lowercase, doing this will
+     # ensure that the German eszett (ß) and certain ligatures (ff, fi, ffl, etc.) will be handled correctly.
+     # If there are any bugs in Perl's implementation of upcasing, they will be passed through here.
+     $str = uc $str;
+     # remove non-filing strings
+     $str =~ s/\x{0098}.*?\x{009C}//g;
+     $str = NFKD($str);
+     # additional substitutions - 3.6.
+     $str =~ s/\x{00C6}/AE/g;
+     $str =~ s/\x{00DE}/TH/g;
+     $str =~ s/\x{0152}/OE/g;
+     $str =~ tr/\x{0110}\x{00D0}\x{00D8}\x{0141}\x{2113}\x{02BB}\x{02BC}][/DDOLl/d;
+     # transformations based on Unicode category codes
+     $str =~ s/[\p{Cc}\p{Cf}\p{Co}\p{Cs}\p{Lm}\p{Mc}\p{Me}\p{Mn}]//g;
+       if ($sf && $sf =~ /^a/o) {
+               my $commapos = index($str, ',');
+               if ($commapos > -1) {
+                       if ($commapos != length($str) - 1) {
+                 $str =~ s/,/\x07/; # preserve first comma
+                       }
+               }
+       }
+     # since we've stripped out the control characters, we can now
+     # use a few as placeholders temporarily
+     $str =~ tr/+&@\x{266D}\x{266F}#/\x01\x02\x03\x04\x05\x06/;
+     $str =~ s/[\p{Pc}\p{Pd}\p{Pe}\p{Pf}\p{Pi}\p{Po}\p{Ps}\p{Sk}\p{Sm}\p{So}\p{Zl}\p{Zp}\p{Zs}]/ /g;
+     $str =~ tr/\x01\x02\x03\x04\x05\x06\x07/+&@\x{266D}\x{266F}#,/;
+     # decimal digits
+     $str =~ tr/\x{0660}-\x{0669}\x{06F0}-\x{06F9}\x{07C0}-\x{07C9}\x{0966}-\x{096F}\x{09E6}-\x{09EF}\x{0A66}-\x{0A6F}\x{0AE6}-\x{0AEF}\x{0B66}-\x{0B6F}\x{0BE6}-\x{0BEF}\x{0C66}-\x{0C6F}\x{0CE6}-\x{0CEF}\x{0D66}-\x{0D6F}\x{0E50}-\x{0E59}\x{0ED0}-\x{0ED9}\x{0F20}-\x{0F29}\x{1040}-\x{1049}\x{1090}-\x{1099}\x{17E0}-\x{17E9}\x{1810}-\x{1819}\x{1946}-\x{194F}\x{19D0}-\x{19D9}\x{1A80}-\x{1A89}\x{1A90}-\x{1A99}\x{1B50}-\x{1B59}\x{1BB0}-\x{1BB9}\x{1C40}-\x{1C49}\x{1C50}-\x{1C59}\x{A620}-\x{A629}\x{A8D0}-\x{A8D9}\x{A900}-\x{A909}\x{A9D0}-\x{A9D9}\x{AA50}-\x{AA59}\x{ABF0}-\x{ABF9}\x{FF10}-\x{FF19}/0-90-90-90-90-90-90-90-90-90-90-90-90-90-90-90-90-90-90-90-90-90-90-90-90-90-90-90-90-90-90-90-90-90-9/;
+     # intentionally skipping step 8 of the NACO algorithm; if the string
+     # gets normalized away, that's fine.
+     # leading and trailing spaces
+     $str =~ s/\s+/ /g;
+     $str =~ s/^\s+//;
+     $str =~ s/\s+$//g;
+     return lc $str;
+ $func$ LANGUAGE 'plperlu' STRICT IMMUTABLE;
+ CREATE OR REPLACE FUNCTION public.search_normalize_keep_comma( TEXT ) RETURNS TEXT AS $func$
+         SELECT public.search_normalize($1,'a');
+ $func$ LANGUAGE SQL STRICT IMMUTABLE;
+ CREATE OR REPLACE FUNCTION public.search_normalize( TEXT ) RETURNS TEXT AS $func$
+       SELECT public.search_normalize($1,'');
+ $func$ LANGUAGE 'sql' STRICT IMMUTABLE;
+ INSERT INTO config.index_normalizer (name, description, func, param_count) VALUES (
+       'Search Normalize',
+       'Apply search normalization rules to the extracted text. A less extreme version of NACO normalization.',
+       'search_normalize',
+       0
+ );
+ UPDATE config.metabib_field_index_norm_map
+     SET norm = (
+         SELECT id FROM config.index_normalizer WHERE func = 'search_normalize'
+     )
+     WHERE norm = (
+         SELECT id FROM config.index_normalizer WHERE func = 'naco_normalize'
+     )
+ ;
+ COMMIT;
+ -- This could take a long time if you have a very non-English bib database
+ -- Run it outside of a transaction to avoid lock escalation
+ SELECT metabib.reingest_metabib_field_entries(record)
+     FROM metabib.full_rec
+     WHERE tag = '245'
+     AND subfield = 'a'
+     AND value LIKE '%''%'
+ ;