After a few days of work, I’ve finally published the MARC import/export plugins for the GNU EPrints3 archiving software. Thanks goes to Ailé Filippi, who wrote the MARC to EPrints to MARC again mappings!Writing software that uses MARC records is not easy. There are two mainstream MARC flavours: MARC21 and UNIMARC. Therefore, the software must allow the collection administrator to specify any correspondence between EPrints metadata and MARC fields. This must happen in both MARC input and output, therefore developers must aim for centralized configuration means (Koha, for example, does this in dedicated DB tables)The other problem is that libraries introduce separators in MARC fields so the data recovered through public catalogues pops with the right format. Therefore, when working with MARC developers should trim and add those characters accordingly. It helps if you have a librarian as your girlfriend.Finally, MARC mappings are never one-to-one, since MARC has repeatable fields/subfields and replicated values all around the record. This means that, in Perl, you need to handle data mapping using hashes of array references or hashes of hash references. That’s some beautiful code.The MARC import/export plugins for GNU EPrints3 were developed with these considerations in mind:
- Writing the least quantity of code for data processing; that is, do not work on each field with punctuation and special characters, since this would require additional logic.
- Reuse code. For example, the whole MARC-XML support for the plugins uses the MARC::File::XML module from CPAN in order to work with traditional MARC21 records.
- Centralized configuration. Administrators can use marc.pl in order to specify new mappings, and even write his/her own field processing routines.
Other interesting applications I experimented with were using the (already written) Dublin Core import/export plugins for GNU EPrints 3 and Library of Congress’ unqualified Dublin Core to MARC21 and back crosswalks. I could even use the already written CPAN module for that!