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

- use patched offline MARC21->MODS xsl

parent 2d6505a3
No related branches found
No related tags found
No related merge requests found
...@@ -191,7 +191,7 @@ sub get_mods_from ($$) { # $mods = ($url, $ppn) ...@@ -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_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_url = 'http://www.loc.gov/standards/mods/v3/MARC21slim2MODS3-6.xsl';
my $marc_mods_path = $xsl_dir . basename($marc_mods_url); 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_url = 'http://www.loc.gov/standards/marcxml/xslt/MARC21slimUtils.xsl';
my $marc_utils_path = $xsl_dir . basename($marc_utils_url); my $marc_utils_path = $xsl_dir . basename($marc_utils_url);
...@@ -212,7 +212,7 @@ sub get_mods_from ($$) { # $mods = ($url, $ppn) ...@@ -212,7 +212,7 @@ sub get_mods_from ($$) { # $mods = ($url, $ppn)
} }
# check MARC21->MODS xsl # check MARC21->MODS xsl
if (! -f $marc_mods_path) { if (! -f $marc_mods_patched_path) {
say "Downloading MARC21->MODS xsl '$marc_mods_url'"; say "Downloading MARC21->MODS xsl '$marc_mods_url'";
my $result = $ua->get($marc_mods_url); my $result = $ua->get($marc_mods_url);
if ($result->is_error) { if ($result->is_error) {
...@@ -224,8 +224,9 @@ sub get_mods_from ($$) { # $mods = ($url, $ppn) ...@@ -224,8 +224,9 @@ sub get_mods_from ($$) { # $mods = ($url, $ppn)
my $xsl_modified = $xsl; my $xsl_modified = $xsl;
$xsl_modified =~ s#$marc_utils_url#$marc_utils_path#g; $xsl_modified =~ s#$marc_utils_url#$marc_utils_path#g;
say "Saving MARC21->MODS xsl to file '$marc_mods_path'"; 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 $srubase=$url; # host
my $srusearchkey="pica.ppn"; my $srusearchkey="pica.ppn";
my $sruvalue=$ppn; my $sruvalue=$ppn;
...@@ -255,15 +256,15 @@ sub get_mods_from ($$) { # $mods = ($url, $ppn) ...@@ -255,15 +256,15 @@ sub get_mods_from ($$) { # $mods = ($url, $ppn)
write_file("DEBUG_${ppn}_marc.xml", $marcblob_patched); write_file("DEBUG_${ppn}_marc.xml", $marcblob_patched);
} }
my $xslt = XML::LibXSLT->new(); my $xslt = XML::LibXSLT->new();
my $marcmods = XML::LibXML->load_xml(location=>$marc_mods_url, no_cdata=>1); my $marcmods = XML::LibXML->load_xml( location=>$marc_mods_patched_path, no_cdata=>1 );
my $stylesheet = $xslt->parse_stylesheet ( $marcmods); my $stylesheet = $xslt->parse_stylesheet( $marcmods );
my $marc = $parser->parse_string( $marcblob_patched ); my $marc = $parser->parse_string( $marcblob_patched );
my $result = $stylesheet->transform( $marc); my $result = $stylesheet->transform( $marc );
if ($with_debug) { if ($with_debug) {
say "write DEBUG_${ppn}_unpatched_mods.xml"; say "write DEBUG_${ppn}_unpatched_mods.xml";
write_file("DEBUG_${ppn}_unpatched_mods.xml", $stylesheet->output_string( $result )); 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 ); my $result_string = $stylesheet->output_string( $result );
return $result_string; return $result_string;
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment