MARC::Schema(3pm)
π 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 areerror,tag,typeandvalueβ those are the keys of the violated field. Theerrorkey 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 β
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::ValidatorJSON::SchemaPICA::SchemaMARC::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
- debian trixie: libmarc-schema-perl 0.16-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmarc-schema-perl 0.16-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmarc-schema-perl 0.16-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms