| 1 |
NAME |
| 2 |
|
| 3 |
MARC::Schema - Specification of the MARC21 format |
| 4 |
|
| 5 |
SYNOPSIS |
| 6 |
|
| 7 |
# in Perl |
| 8 |
use MARC::Schema; |
| 9 |
|
| 10 |
my $record = { |
| 11 |
_id => 'fol05865967', |
| 12 |
record => [ |
| 13 |
[ 'LDR', undef, undef, '_', '00661nam 22002538a 4500' ], |
| 14 |
[ '001', undef, undef, '_', 'fol05865967' ], |
| 15 |
[ '001', undef, undef, '_', 'field is not repeatable' ], |
| 16 |
[ '245', '1', '0', 'a', 'Programming Perl /', |
| 17 |
'c', 'Larry Wall, Tom Christiansen & Jon Orwant.', |
| 18 |
'a', 'subfield is not repeatable', |
| 19 |
'x', 'unknown subfield', |
| 20 |
], |
| 21 |
[ '999', undef, undef, '_', 'not a standard field'] |
| 22 |
] |
| 23 |
}; |
| 24 |
|
| 25 |
# load default schema |
| 26 |
my $schema = MARC::Schema->new(); |
| 27 |
|
| 28 |
# load custom schema from file |
| 29 |
my $schema = MARC::Schema->new({ file => share/marc-schema.json }); |
| 30 |
|
| 31 |
|
| 32 |
# load custom schema |
| 33 |
my $schema = MARC::Schema->new( |
| 34 |
{ fields => { |
| 35 |
'001' => { label => 'Control Number', repetable => 0 } |
| 36 |
} |
| 37 |
} |
| 38 |
); |
| 39 |
my @check = $schema->check($record); |
| 40 |
|
| 41 |
# via the command line |
| 42 |
$ marcvalidate t/camel.mrc |
| 43 |
$ marcvalidate --schema marc_schema.json t/camel.mrc |
| 44 |
$ marcvalidate --type XML marc.xml |
| 45 |
|
| 46 |
DESCRIPTION |
| 47 |
|
| 48 |
MARC::Schema defines a set of MARC21 fields and subfields to validate |
| 49 |
Catmandu::MARC records. A schema is given as hash reference such as: |
| 50 |
|
| 51 |
{ fields => { |
| 52 |
LDR => { |
| 53 |
positions => |
| 54 |
[ { position => '00-04', label => 'Record length' } ], |
| 55 |
repeatable => 0, |
| 56 |
}, |
| 57 |
'001' => { label => 'Control Number', repeatable => 0 } |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
For a more detailed description of the (default) schema see MARC21 |
| 62 |
structure in JSON |
| 63 |
<https://pkiraly.github.io/2018/01/28/marc21-in-json/>. |
| 64 |
|
| 65 |
METHODS |
| 66 |
|
| 67 |
check( $record [, %options ] ) |
| 68 |
|
| 69 |
Check whether a given "Catmandu::Importer::MARC" or "MARC::Parser::*" |
| 70 |
<https://metacpan.org/search?q=%22MARC%3A%3AParser%22> record confirms |
| 71 |
to the schema and return a list of detected violations. Possible |
| 72 |
options include: |
| 73 |
|
| 74 |
ignore_unknown_fields |
| 75 |
|
| 76 |
Don't report fields not included in the schema. |
| 77 |
|
| 78 |
ignore_unknown_subfields |
| 79 |
|
| 80 |
Don't report subfields not included in the schema. |
| 81 |
|
| 82 |
Errors are given as list of hash references with keys error, tag, type |
| 83 |
and value of the violated field. error contains a human-readable error |
| 84 |
message for each violated field and/or subfield. |
| 85 |
|
| 86 |
check_field( $field [, %options ] ) |
| 87 |
|
| 88 |
Check whether a MARC21 field confirms to the schema. Use same options |
| 89 |
as method check. |
| 90 |
|
| 91 |
AUTHOR |
| 92 |
|
| 93 |
Johann Rolschewski <[email protected]> |
| 94 |
|
| 95 |
CONTRIBUTORS |
| 96 |
|
| 97 |
Patrick Hochstenbach |
| 98 |
|
| 99 |
Steve Rogerson |
| 100 |
|
| 101 |
COPYRIGHT |
| 102 |
|
| 103 |
Copyright 2018- Johann Rolschewski |
| 104 |
|
| 105 |
LICENSE |
| 106 |
|
| 107 |
This library is free software; you can redistribute it and/or modify it |
| 108 |
under the same terms as Perl itself. |
| 109 |
|
| 110 |
SEE ALSO |
| 111 |
|
| 112 |
Catmandu::Validator |
| 113 |
|
| 114 |
JSON::Schema |
| 115 |
|
| 116 |
PICA::Schema |
| 117 |
|
| 118 |
MARC::Lint |
| 119 |
|
| 120 |
ACKNOWLEDGEMENT |
| 121 |
|
| 122 |
MARC::Schema uses the MARC21 schema developed by Péter Király |
| 123 |
<https://github.com/pkiraly> as default. For more information see |
| 124 |
"Metadata assessment for MARC records" |
| 125 |
<https://github.com/pkiraly/metadata-qa-marc> and "MARC21 structure in |
| 126 |
JSON" <https://pkiraly.github.io/2018/01/28/marc21-in-json/>. |
| 127 |
|