component_xpath TEXT NOT NULL,
type_xpath TEXT NULL, -- to extract related or variant type
thesaurus_xpath TEXT NULL,
+ thesaurus_override_xpath TEXT NULL,
joiner TEXT NULL
);
-INSERT INTO authority.heading_field(heading_type, heading_purpose, label, heading_xpath, component_xpath, type_xpath, thesaurus_xpath) VALUES
-( 'topical_term', 'main', 'Main Topical Term', '/mads21:mads/mads21:authority', '//mads21:topic', NULL, '//mads21:topic[1]/@authority' ),
-( 'topical_term', 'variant', 'Variant Topical Term', '/mads21:mads/mads21:variant', '//mads21:topic', '/mads21:variant/@type', '//mads21:topic[1]/@authority'),
-( 'topical_term', 'related', 'Broader Topical Term', '/mads21:mads/mads21:related', '//mads21:topic', '/mads21:related/@type', '//mads21:topic[1]/@authority'),
-( 'personal_name', 'main', 'Main Personal name', '/mads21:mads/mads21:authority', '//mads21:name', NULL, NULL ),
-( 'personal_name', 'variant', 'Variant Personal name', '/mads21:mads/mads21:variant', '//mads21:name', NULL, NULL )
+INSERT INTO authority.heading_field(heading_type, heading_purpose, label, heading_xpath, component_xpath, type_xpath, thesaurus_xpath, thesaurus_override_xpath) VALUES
+( 'topical_term', 'main', 'Main Topical Term', '/mads21:mads/mads21:authority', '//mads21:topic', NULL, '/mads21:mads/mads21:authority/mads21:topic[1]/@authority', NULL ),
+( 'topical_term', 'variant', 'Variant Topical Term', '/mads21:mads/mads21:variant', '//mads21:topic', '/mads21:variant/@type', '/mads21:mads/mads21:authority/mads21:topic[1]/@authority', '//mads21:topic[1]/@authority'),
+( 'topical_term', 'related', 'Broader Topical Term', '/mads21:mads/mads21:related', '//mads21:topic', '/mads21:related/@type', '/mads21:mads/mads21:authority/mads21:topic[1]/@authority', '//mads21:topic[1]/@authority'),
+( 'personal_name', 'main', 'Main Personal name', '/mads21:mads/mads21:authority', '//mads21:name', NULL, NULL, NULL ),
+( 'personal_name', 'variant', 'Variant Personal name', '/mads21:mads/mads21:variant', '//mads21:name', NULL, NULL, NULL )
;
CREATE TYPE authority.heading AS (
curr_text TEXT;
joiner TEXT;
type_value TEXT;
+ base_thesaurus TEXT := NULL;
output_row authority.heading;
BEGIN
prev_xfrm := xfrm.name;
END IF;
+ IF idx.thesaurus_xpath IS NOT NULL THEN
+ base_thesaurus := ARRAY_TO_STRING(oils_xpath(idx.thesaurus_xpath, transformed_xml, ARRAY[ARRAY[xfrm.prefix, xfrm.namespace_uri]]), '');
+ END IF;
+
heading_node_list := oils_xpath( idx.heading_xpath, transformed_xml, ARRAY[ARRAY[xfrm.prefix, xfrm.namespace_uri]] );
FOR heading_node IN SELECT x FROM unnest(heading_node_list) AS x LOOP
END;
END IF;
- IF idx.thesaurus_xpath IS NOT NULL THEN
- output_row.thesaurus = ARRAY_TO_STRING(oils_xpath(idx.thesaurus_xpath, heading_node, ARRAY[ARRAY[xfrm.prefix, xfrm.namespace_uri]]), '');
+ IF idx.thesaurus_override_xpath IS NOT NULL THEN
+ output_row.thesaurus := ARRAY_TO_STRING(oils_xpath(idx.thesaurus_override_xpath, heading_node, ARRAY[ARRAY[xfrm.prefix, xfrm.namespace_uri]]), '');
+ END IF;
+ IF output_row.thesaurus IS NULL THEN
+ output_row.thesaurus := base_thesaurus;
END IF;
raw_text := NULL;