From 71948964b5361b5084f762a518c7cd23a37c3f92 Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Sat, 28 May 2011 12:23:24 -0400 Subject: [PATCH] correcting template generation; filter out subfields that we do not use in the authority record Signed-off-by: Mike Rylander --- Open-ILS/src/sql/Pg/011.schema.authority.sql | 6 +++--- Open-ILS/src/sql/Pg/012.schema.vandelay.sql | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Open-ILS/src/sql/Pg/011.schema.authority.sql b/Open-ILS/src/sql/Pg/011.schema.authority.sql index 44933326bc..35fd6e33f6 100644 --- a/Open-ILS/src/sql/Pg/011.schema.authority.sql +++ b/Open-ILS/src/sql/Pg/011.schema.authority.sql @@ -242,7 +242,7 @@ DECLARE auth_id INT DEFAULT oils_xpath_string('//*[@tag="901"]/*[local-name()="subfield" and @code="c"]', source_xml)::INT; replace_data XML[] DEFAULT '{}'::XML[]; replace_rules TEXT[] DEFAULT '{}'::TEXT[]; - auth_field TEXT; + auth_field XML[]; BEGIN IF auth_id IS NULL THEN RETURN NULL; @@ -252,8 +252,8 @@ BEGIN SELECT COALESCE(control_set,1) INTO cset FROM authority.record_entry WHERE id = auth_id; FOR main_entry IN SELECT * FROM authority.control_set_authority_field WHERE control_set = cset LOOP - auth_field := XPATH('//*[@tag="'||main_entry.tag||'"][1]',source_xml); - IF ARRAY_LENGTH(auth_field) > 0 THEN + auth_field := XPATH('//*[@tag="'||main_entry.tag||'"][1]',source_xml::XML); + IF ARRAY_LENGTH(auth_field,1) > 0 THEN FOR bib_field IN SELECT * FROM authority.control_set_bib_field WHERE authority_field = main_entry.id LOOP replace_data := replace_data || XMLELEMENT( name datafield, XMLATTRIBUTES(bib_field.tag AS tag), XPATH('//*[local-name()="subfield"]',auth_field[1])::XML[]); replace_rules := replace_rules || ( bib_field.tag || main_entry.sf_list || E'[0~\\)' || auth_id || '$]' ); diff --git a/Open-ILS/src/sql/Pg/012.schema.vandelay.sql b/Open-ILS/src/sql/Pg/012.schema.vandelay.sql index 8095e3bbb1..9906804d6d 100644 --- a/Open-ILS/src/sql/Pg/012.schema.vandelay.sql +++ b/Open-ILS/src/sql/Pg/012.schema.vandelay.sql @@ -979,7 +979,7 @@ CREATE OR REPLACE FUNCTION vandelay.add_field ( target_xml TEXT, source_xml TEXT if (exists($fields{$f}{match})) { next unless (grep { $_ =~ $fields{$f}{match}{re} } $to_field->subfield($fields{$f}{match}{sf})); } - my @new_sf = map { ($_ => $from_field->subfield($_)) } @{$fields{$f}{sf}}; + my @new_sf = map { ($_ => $from_field->subfield($_)) } grep { defined($from_field->subfield($_)) } @{$fields{$f}{sf}}; $to_field->add_subfields( @new_sf ); } } -- 2.11.0