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

- added seperate marc21 to mods transformation

parent 3a4973c5
No related branches found
No related tags found
No related merge requests found
...@@ -188,6 +188,36 @@ package SLUB::LZA::SIPBuilderBagIt; ...@@ -188,6 +188,36 @@ package SLUB::LZA::SIPBuilderBagIt;
return; return;
} }
sub get_mods_from_marc21($) {
if(! $_[0]){ croak "marc21 empty!"; }
my $marc21 = shift;
my $ua = LWP::UserAgent->new;
$ua->agent("MyApp/0.1 ");
$ua->timeout(3600); #1h
my $xsl_dir = SLUB::LZA::SIPBuilderBagIt::check_xsl_directory();
SLUB::LZA::SIPBuilderBagIt::check_marc21_mods_xsl($xsl_dir, $ua);
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 $parser = XML::LibXML->new();
my $marc = $parser->parse_string($marc21);
my $result = $stylesheet->transform($marc);
my $mods = $stylesheet->output_string($result);
my $mods_patched = $stylesheet->output_string( patch_mods($result) );
if ($with_debug) {
say "write DEBUG_mods_unpatched.xml";
SLUB::LZA::SIPBuilderBagIt::write_file("DEBUG_mods_unpatched.xml", $mods);
say "write DEBUG_mods.xml";
SLUB::LZA::SIPBuilderBagIt::write_file("DEBUG_mods.xml", $mods_patched);
}
return $mods_patched;
}
sub write_file($$){ sub write_file($$){
if(! defined $_[0]) { croak "filename not defined!"; } if(! defined $_[0]) { croak "filename not defined!"; }
if(! defined $_[1]) { croak "value not defined!"; } if(! defined $_[1]) { croak "value not defined!"; }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment