LibreCat / Catmandu-MARC

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

Add a basic validation on field lengths in fixed length fields #83

Open phochste opened 6 years ago

phochste commented 6 years ago

Errors in the field length of the leader will crash the Catmandu::Exporter::MARC::ISO with an error message

This Oops! substr outside of string at
/usr/local/share/perl/5.22.1/MARC/Record.pm line 573, <GEN0> line 30.

There could be a more informative message given.

phochste commented 6 years ago

Also other errors in the leader will generate illegal ISO ouput. E.g. leader ^^^^^nam^^22^^^^^^a^^4500 (too many positions before nam)

CaptSolo commented 1 year ago

We are getting this error when converting data from MARC/XML to ISO MARC.

Is there a way to make Catmandu ignore the records with errors and continue processing other records?

phochste commented 1 year ago

In Catmandu we are very dependent on the capabilities of the underlying parser. For, MARC/XML skipping of records needs to be supported by MARC::File::XML, which is by itself dependent on XML::LibXML. As far as I know, XML parsers can't skip XML with syntax errors. These errors can't be recovered.

I don't know if MARC::File::XML supports skipping records that are syntactically valid XML, but not valid MARC/XML.