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

- download transformation xsl and modify for offline use

parent 1d24bd60
No related branches found
No related tags found
No related merge requests found
......@@ -181,11 +181,43 @@ sub get_mods_from ($$) { # $mods = ($url, $ppn)
my $ppn = shift; # example: "457035137" for "Der Fichtelberg"
#### where to find XSLT
# 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_modified_path = $xsl_dir . basename($marc_mods_url, ".xsl") . ".modified.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 $ua = LWP::UserAgent->new;
$ua->agent("MyApp/0.1 ");
$ua->timeout(3600); #1h
# check MARC21 utility xsl
if (! -f $marc_utils_path) {
say "Downloading MARC21 utility xsl '$marc_utils_url'";
my $result = $ua->get($marc_utils_url);
if ($result->is_error) {
die "Failed to download '$marc_utils_url', " . $result->error_as_HTML;
}
say "Saving MARC21 utility xsl to file '$marc_utils_path'";
my $xsl = $result->decoded_content;
write_file($marc_utils_path, $xsl);
}
# check MARC21->MODS xsl
if (! -f $marc_mods_path) {
say "Downloading MARC21->MODS xsl '$marc_mods_url'";
my $result = $ua->get($marc_mods_url);
if ($result->is_error) {
die "Failed to download '$marc_mods_url', " . $result->error_as_HTML;
}
say "Modifying MARC21->MODS xsl for offline use";
my $xsl = $result->decoded_content;
write_file($marc_mods_path, $xsl);
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);
}
my $srubase=$url; # host
my $srusearchkey="pica.ppn";
my $sruvalue=$ppn;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment