Skip to content
Snippets Groups Projects
Commit 3df8377c authored by Jens Steidl's avatar Jens Steidl :baby_chick:
Browse files

- refactor: get only marc21 from catalogue, removed transformation to mods

parent 8ea49d23
No related branches found
No related tags found
No related merge requests found
......@@ -84,19 +84,19 @@ package SLUB::LZA::SIPBuilderBagIt;
my $recordschema_k10p = 'marcxmlk10os';
our $with_debug = 0;
sub prepare_mods_section_with_ppn($){
sub get_marc21_from_catalogue($){
if(! defined $_[0]){ croak "ppn not defined!"; }
my $ppn = shift;
my $mods;
my $marc21;
eval {
$mods = SLUB::LZA::SIPBuilderBagIt::get_mods_from($swb_url, $ppn, $searchkey_swb, $recordschema_swb);
$marc21 = SLUB::LZA::SIPBuilderBagIt::get_marc21_from($swb_url, $ppn, $searchkey_swb, $recordschema_swb);
};
if ($@) {
# Fallback to K10plus PPN
if ($@ =~ m#ERROR: Did not get any <recordData/> for PPN#) {
print_scalar_data("", "WARNING: '$ppn' not a SWB PPN, fallback to K10plus", "", "yellow");
$mods = SLUB::LZA::SIPBuilderBagIt::get_mods_from($swb_url, $ppn, $searchkey_k10p, $recordschema_k10p);
$marc21 = SLUB::LZA::SIPBuilderBagIt::get_marc21_from($swb_url, $ppn, $searchkey_k10p, $recordschema_k10p);
}
else {
die "$@"; # throw exception again
......@@ -104,15 +104,10 @@ package SLUB::LZA::SIPBuilderBagIt;
}
print_scalar_data("", "INFO: Found metadata for PPN '$ppn'", "", "white");
if($with_debug){
SLUB::LZA::SIPBuilderBagIt::write_file("DEBUG_${ppn}_mods.xml", $mods);
}
return $mods;
return $marc21;
}
sub get_mods_from($$$$){
sub get_marc21_from($$$$){
# specification SRU/SRW BSZ: https://wiki.k10plus.de/pages/viewpage.action?pageId=132874251
if(! defined $_[0]) { croak "url not defined!"; }
if(! defined $_[1]) { croak "ppn not defined!"; }
......@@ -134,7 +129,6 @@ package SLUB::LZA::SIPBuilderBagIt;
my $xsl_dir = SLUB::LZA::SIPBuilderBagIt::check_xsl_directory();
SLUB::LZA::SIPBuilderBagIt::check_marc21_utility($xsl_dir, $ua);
SLUB::LZA::SIPBuilderBagIt::check_marc21_mods_xsl($xsl_dir, $ua);
my $srubase = $url; # host
my $srusearchkey = $key; # SRU search key
......@@ -167,19 +161,7 @@ package SLUB::LZA::SIPBuilderBagIt;
SLUB::LZA::SIPBuilderBagIt::write_file("DEBUG_${ppn}_marc.xml", $marcblob_patched);
}
my $marc_mods_patched_path = SLUB::LZA::SIPBuilderBagIt::check_marc21_mods_xsl($xsl_dir, $ua);
my $xslt = XML::LibXSLT->new();
my $marcmods = XML::LibXML->load_xml(location => $marc_mods_patched_path, no_cdata => 1);
my $stylesheet = $xslt->parse_stylesheet($marcmods);
my $marc = $parser->parse_string($marcblob_patched);
my $result = $stylesheet->transform($marc);
if ($with_debug) {
say "write DEBUG_${ppn}_unpatched_mods.xml";
SLUB::LZA::SIPBuilderBagIt::write_file("DEBUG_${ppn}_unpatched_mods.xml", $stylesheet->output_string($result));
}
$result = patch_mods($result);
my $result_string = $stylesheet->output_string($result);
return $result_string;
return $marcblob_patched;
}
else {
carp("Problem asking catalogue at $url using $ppn");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment