From: miker Date: Tue, 16 Mar 2010 14:16:52 +0000 (+0000) Subject: Patch from Galen Charlton: removes empty controlfield elements, which can be produced... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d32d5cb98351066f0f6d6259f042803dc62cf127;p=evergreen%2Fpines.git Patch from Galen Charlton: removes empty controlfield elements, which can be produced in a couple different ways during the ingest of slightly invalid MARC records git-svn-id: svn://svn.open-ils.org/ILS/trunk@15858 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Cat/BibCommon.pm b/Open-ILS/src/perlmods/OpenILS/Application/Cat/BibCommon.pm index dc06a9c067..1b1fbae4d1 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Cat/BibCommon.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Cat/BibCommon.pm @@ -111,6 +111,11 @@ sub __make_marc_doc { my $marcxml = XML::LibXML->new->parse_string($xml); $marcxml->documentElement->setNamespace($MARC_NAMESPACE, "marc", 1 ); $marcxml->documentElement->setNamespace($MARC_NAMESPACE); + # remove empty control fields - at least one source of records adds ersatz blank 008s + # that become empty controlfield elements + foreach my $controlfield ($marcxml->documentElement->getElementsByTagNameNS($MARC_NAMESPACE, 'controlfield')) { + $controlfield->parentNode->removeChild($controlfield) unless $controlfield->hasChildNodes(); + } return $marcxml; }