LibreCat / Catmandu-MARC

Catmandu modules for working with MARC data
https://metacpan.org/release/Catmandu-MARC
Other
8 stars 10 forks source link

Processing file with no matching datasets leads to broken output #119

Open FaMIbine opened 1 year ago

FaMIbine commented 1 year ago

While processing MARC-XML-files with a filter we notices that there seems to be a problem if no record from a file matches a filter or where returned at all. In this case we got a broken output: a closing xml-tag

You can reproduce the problem also with processing an empty XML file:

echo "<?xml version="1.0" encoding="UTF-8"?>
<collection xmlns="http://www.loc.gov/MARC21/slim" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd">
</collection>" | catmandu convert MARC --type XML to MARC --type XML

We filterted for example for MARC-field 924, which was not set in our file. So we expected to get an empty XML-file as output. Instead we got this output: "</marc:collection>" The fix we used was the following:

marc_map(924,sigel,split:1)
select any_match(sigel.*,DE-1a)
marc_add(951,a,AR)

Our catmandu command was: catmandu convert MARC --type XML to MARC --type XML --fix fixname.fix < filename.xml

We used Catmandu version 1.2020 on a Debian system.

Furthermore the MARC-ISO-Exporter delivers an incomplete MARC-dataset:

echo '{}' | catmandu convert JSON to MARC
00026     2200025   4500  
phochste commented 1 year ago

Thank you for this bug report. The code has been fixed and version 1.31 is on its way to cpan.

FaMIbine commented 1 year ago

Thank you so much for the bugfix and the fast response! :D