Patch from Galen Charlton: removes empty controlfield elements, which can be produced...
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 16 Mar 2010 14:16:52 +0000 (14:16 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 16 Mar 2010 14:16:52 +0000 (14:16 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@15858 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Cat/BibCommon.pm

index dc06a9c..1b1fbae 100644 (file)
@@ -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;
 }