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

- refactor: removed MARCXML patching, no longer needed, removed LibXSLT dependency

parent 0839099a
No related branches found
No related tags found
No related merge requests found
......@@ -71,7 +71,6 @@ package SLUB::LZA::SIPBuilderBagIt;
use Try::Tiny;
use XML::LibXML;
use XML::XPath;
use XML::LibXSLT;
our $VERBOSE = 0; # print output switch 0 => on, 1 and larger = off
our $with_debug = 0; # output debug infos and files
......@@ -185,8 +184,6 @@ package SLUB::LZA::SIPBuilderBagIt;
my $key = shift;
my $schema = shift;
#### get XSLT
my $ua = LWP::UserAgent->new;
$ua->agent("MyApp/0.1 ");
$ua->timeout(3600); #1h
......@@ -212,17 +209,11 @@ package SLUB::LZA::SIPBuilderBagIt;
my $recordData = $xp->findnodes_as_string('/*[local-name()="searchRetrieveResponse"]/*[local-name()="records"]/*[local-name()="record"]/*[local-name()="recordData"]/*');
if (!$recordData) { croak("ERROR: Did not get any <recordData/> for PPN '$ppn' using '$sru'");}
my $marcblob = $parser->parse_string($recordData);
my $marcblob_patched = SLUB::LZA::SIPBuilderBagIt::patch_marc_response($marcblob);
if ($with_debug) {
say "write DEBUG_${ppn}_marc_unpatched.xml";
SLUB::LZA::SIPBuilderBagIt::write_file("DEBUG_${ppn}_marc_unpatched.xml", $marcblob);
say "write DEBUG_${ppn}_marc.xml";
SLUB::LZA::SIPBuilderBagIt::write_file("DEBUG_${ppn}_extracted_marc_record.xml", $marcblob);
}
return $marcblob_patched->toString();
return $marcblob;
}
else {
carp("Problem asking catalogue at $url using $ppn");
......@@ -246,43 +237,6 @@ package SLUB::LZA::SIPBuilderBagIt;
return 1;
}
sub patch_marc_response($){
if(! defined $_[0]) { croak "marcobject not defined!"; }
if($_[0] eq ""){ die "invalid parameters."; }
my $marcobj = shift; # marcobj expected as XML Parser object
my $xslt_patch_string = <<'PATCH2';
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.loc.gov/MARC21/slim" xmlns:srw="http://www.loc.gov/zing/srw/"
exclude-result-prefixes="srw" version="1.0">
<xsl:template match="/record">
<xsl:element name="collection">
<xsl:element name="record" namespace="http://www.loc.gov/MARC21/slim">
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="node()"/>
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:template match="*">
<xsl:element name="{local-name()}" namespace="http://www.loc.gov/MARC21/slim">
<xsl:apply-templates select="node() | @*"/>
</xsl:element>
</xsl:template>
<xsl:template match="@*">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
PATCH2
my $xslt = XML::LibXSLT->new();
my $xslt_patch = XML::LibXML->load_xml(string => $xslt_patch_string, no_cdata => 1);
my $stylesheet = $xslt->parse_stylesheet($xslt_patch);
my $result = $stylesheet->transform($marcobj);
return $result;
}
sub generateBagName($$$){
my $file_date = $_[0];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment