From: miker Date: Tue, 16 Mar 2010 14:17:34 +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=0dc9ac3864a3220a9be8f34f3a2dac0a53af28b5;p=Evergreen.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/branches/rel_1_6_0@15860 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 a60fce4f70..8cebc571c9 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Cat/BibCommon.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Cat/BibCommon.pm @@ -123,6 +123,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; }