MARC::Schema(3pm)

πŸ“¦
version 0.16 Β· 3 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– MARC::Schema πŸ’–

okay bestie, so this is a page from the User Contributed Perl Documentation β€” and it's literally the spec of the MARC21 format, no cap. It's a Perl module, it's giving librarian-chic, and it will absolutely vibe-check your MARC records for you. πŸ¦‹


✨ NAME ✨

MARC::Schema β€” the specification of the MARC21 format. That's it, that's the whole name, iconic behavior. πŸ’…


🌸 SYNOPSIS 🌸

okay so here's the tea, here's how you use it in Perl:

# in Perl
use MARC::Schema;

my $record = {
    _id    => 'fol05865967',
    record => [
        [ 'LDR', undef, undef, '_', '00661nam  22002538a 4500' ],
        [ '001', undef, undef, '_', 'fol05865967' ],
        [ '001', undef, undef, '_', 'field is not repeatable' ],
        [   '245', '1', '0', 'a', 'Programming Perl /',
            'c', 'Larry Wall, Tom Christiansen & Jon Orwant.',
            'a', 'subfield is not repeatable',
            'x', 'unknown subfield',
        ],
        [ '999', undef, undef, '_', 'not a standard field']
    ]
};

# load default schema
my $schema = MARC::Schema->new();

# load custom schema from file
my $schema = MARC::Schema->new({ file => share/marc-schema.json });

# load custom schema
my $schema = MARC::Schema->new(
    {   fields => {
            '001' => { label => 'Control Number', repetable => 0 }
        }
    }
);
my @check = $schema->check($record);

# via the command line
$ marcvalidate t/camel.mrc
$ marcvalidate --schema marc_schema.json t/camel.mrc
$ marcvalidate --type XML marc.xml

like, look at that record up there πŸ‘€ it's got deliberately messy fields so you can watch the validator catch them. the drama. the intrigue. πŸ“


πŸ’œ DESCRIPTION πŸ’œ

MARC::Schema defines a set of MARC21 fields and subfields so you can validate Catmandu::MARC records. You hand it a schema as a hash reference, kinda like this:

{   fields => {
        LDR => {
            positions =>
                [ { position => '00-04', label => 'Record length' } ],
            repeatable => 0,
        },
        '001' => { label => 'Control Number', repeatable => 0 }
    }
}

And if you want the whole deep-dive on the (default) schema, go peek at MARC21 structure in JSON over at https://pkiraly.github.io/2018/01/28/marc21-in-json/ ✨


πŸ‘‘ METHODS πŸ‘‘

check( $record [, %options ] )

Checks whether a given Catmandu::Importer::MARC or MARC::Parser::* record (there's a whole search for those at https://metacpan.org/search?q=%22MARC%3A%3AParser%22) actually confirms to the schema, and hands you back a list of every violation it spotted. πŸ•΅οΈβ™€οΈ

The options you can pass include:

  • ignore_unknown_fields β€” don't report fields that aren't in the schema. like, let them live, bestie. πŸ™ˆ
  • ignore_unknown_subfields β€” don't report subfields that aren't in the schema. same energy, but for subfields. πŸ’«
Errors come back as a list of hash references, and their keys are error, tag, type and value β€” those are the keys of the violated field. The error key holds a human-readable error message for every violated field and/or subfield. πŸ“

check_field( $field [, %options ] )

Checks whether a single MARC21 field confirms to the schema. Same options as the check method above β€” literally the same ones, no surprises. πŸŽ€


🫢 AUTHOR 🫢

Johann Rolschewski <jorol@cpan.org> β€” the main character who made this happen. πŸ‘‘


🌈 CONTRIBUTORS 🌈

  • Patrick Hochstenbach
  • Steve Rogerson

the supporting cast, and we love them for it. πŸ’–


Copyright 2018- Johann Rolschewski


🧚 LICENSE 🧚

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. so go off, remix it, slay. ✨


πŸ”₯ SEE ALSO πŸ”₯

  • Catmandu::Validator
  • JSON::Schema
  • PICA::Schema
  • MARC::Lint

the whole friend group. go say hi. 🫢


πŸŽ€ ACKNOWLEDGEMENT πŸŽ€

MARC::Schema uses the MARC21 schema developed by PΓ©ter KirΓ‘ly (https://github.com/pkiraly) as the default β€” king behavior, fr fr. For more info, go read "Metadata assessment for MARC records" at https://github.com/pkiraly/metadata-qa-marc and "MARC21 structure in JSON" at https://pkiraly.github.io/2018/01/28/marc21-in-json/. 🌸


and that's the whole page, bestie!! this one shipped as perl v5.40.0, dated 2024-11-15, and yes it is literally the MARC::Schema(3pm) page β€” go validate something iconic today πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from