From 0a898be3b6c184fe29c959cbbc2c39385f7f084b Mon Sep 17 00:00:00 2001 From: Jens Steidl <Jens.Steidl@slub-dresden.de> Date: Fri, 19 Jul 2019 13:22:18 +0200 Subject: [PATCH] - use patched offline MARC21->MODS xsl --- bin/slubsipbuilder.pl | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/bin/slubsipbuilder.pl b/bin/slubsipbuilder.pl index 16a6a9b..85c1a12 100755 --- a/bin/slubsipbuilder.pl +++ b/bin/slubsipbuilder.pl @@ -191,7 +191,7 @@ sub get_mods_from ($$) { # $mods = ($url, $ppn) # my $marc_dc_url = 'http://www.loc.gov/standards/marcxml/xslt/MARC21slim2RDFDC.xsl'; my $marc_mods_url = 'http://www.loc.gov/standards/mods/v3/MARC21slim2MODS3-6.xsl'; my $marc_mods_path = $xsl_dir . basename($marc_mods_url); - my $marc_mods_modified_path = $xsl_dir . basename($marc_mods_url, ".xsl") . ".modified.xsl"; + my $marc_mods_patched_path = $xsl_dir . basename($marc_mods_url, ".xsl") . ".patched.xsl"; my $marc_utils_url = 'http://www.loc.gov/standards/marcxml/xslt/MARC21slimUtils.xsl'; my $marc_utils_path = $xsl_dir . basename($marc_utils_url); @@ -212,7 +212,7 @@ sub get_mods_from ($$) { # $mods = ($url, $ppn) } # check MARC21->MODS xsl - if (! -f $marc_mods_path) { + if (! -f $marc_mods_patched_path) { say "Downloading MARC21->MODS xsl '$marc_mods_url'"; my $result = $ua->get($marc_mods_url); if ($result->is_error) { @@ -224,8 +224,9 @@ sub get_mods_from ($$) { # $mods = ($url, $ppn) my $xsl_modified = $xsl; $xsl_modified =~ s#$marc_utils_url#$marc_utils_path#g; say "Saving MARC21->MODS xsl to file '$marc_mods_path'"; - write_file($marc_mods_modified_path, $xsl_modified); + write_file($marc_mods_patched_path, $xsl_modified); } + my $srubase=$url; # host my $srusearchkey="pica.ppn"; my $sruvalue=$ppn; @@ -255,15 +256,15 @@ sub get_mods_from ($$) { # $mods = ($url, $ppn) write_file("DEBUG_${ppn}_marc.xml", $marcblob_patched); } my $xslt = XML::LibXSLT->new(); - my $marcmods = XML::LibXML->load_xml(location=>$marc_mods_url, no_cdata=>1); - my $stylesheet = $xslt->parse_stylesheet ( $marcmods); + 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); + my $result = $stylesheet->transform( $marc ); if ($with_debug) { say "write DEBUG_${ppn}_unpatched_mods.xml"; write_file("DEBUG_${ppn}_unpatched_mods.xml", $stylesheet->output_string( $result )); } - $result = patch_mods( $result); + $result = patch_mods( $result ); my $result_string = $stylesheet->output_string( $result ); return $result_string; } else { -- GitLab