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

- add MARCXML schema location for potential automated validation

parent 8e2c64c7
No related branches found
No related tags found
No related merge requests found
......@@ -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!"; }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment