diff --git a/bin/slubsipbuilderbagit.pl b/bin/slubsipbuilderbagit.pl index 63e7f43256f02f18ec00968192930fa946492663..d217e3d19544b52cf2d237e5aa73da365f381c91 100644 --- a/bin/slubsipbuilderbagit.pl +++ b/bin/slubsipbuilderbagit.pl @@ -207,6 +207,7 @@ 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 $marc_doc = $parser->parse_string($recordData); + add_marc21_schema_location($marc_doc); if ($with_debug) { say "write DEBUG_${ppn}_extracted_marc_record.xml"; SLUB::LZA::SIPBuilderBagIt::write_file("DEBUG_${ppn}_extracted_marc_record.xml", $marc_doc); @@ -220,6 +221,16 @@ package SLUB::LZA::SIPBuilderBagIt; return; } + sub add_marc21_schema_location($) { + if(! defined $_[0]) { croak "marc xml document required!"; } + my $marc_doc = $_[0]; + my $root = $marc_doc->findnodes('/*[local-name()="record"]')->[0]; # get root element (XML::LibXML::Element) + $root->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); # add xsi namespace (simple) + $root->setAttribute('xsi:schemaLocation', 'http://www.loc.gov/MARC21/slim https://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd'); # add MARCXML schema location + # HINT: method sets or replaces the node's attribute + 1; + } + sub write_file($$){ if(! defined $_[0]) { croak "filename not defined!"; } if(! defined $_[1]) { croak "value not defined!"; }