VuFind-Marc API Documentation

MarcLint
in package

Class for testing validity of MARC records against MARC21 standard.

Tags
category

VuFind

author

Demian Katz demian.katz@villanova.edu

author

Dan Scott dscott@laurentian.ca

author

Ere Maijala ere.maijala@helsinki.fi

license

http://opensource.org/licenses/gpl-2.0.php GNU General Public License

link

Wiki

Table of Contents

$data  : CodeData
A Lint\CodeData object for validating codes
$rules  : array<string|int, mixed>
Rules used for testing records
$warnings  : array<string|int, mixed>
Warnings generated during analysis
__construct()  : true
Start function
checkRecord()  : array<string|int, mixed>
Check the provided MARC record and return an array of warning messages.
check020()  : void
Looks at 020$a and reports errors if the check digit is wrong.
check041()  : void
Warns if subfields are not evenly divisible by 3 unless second indicator is 7 (future implementation would ensure that each subfield is exactly 3 characters unless ind2 is 7--since subfields are now repeatable. This is not implemented here due to the large number of records needing to be corrected.). Validates against the MARC Code List for Languages (<http://www.loc.gov/marc/>).
check043()  : void
Warns if each subfield a is not exactly 7 characters. Validates each code against the MARC code list for Geographic Areas (<http://www.loc.gov/marc/>).
check245()  : void
-Makes sure $a exists (and is first subfield).
checkArticle()  : void
Check of articles is based on code from Ian Hamilton. This version is more limited in that it focuses on English, Spanish, French, Italian and German articles. Certain possible articles have been removed if they are valid English non-articles. This version also disregards 008_language/041 codes and just uses the list of articles to provide warnings/suggestions.
checkDuplicate1xx()  : void
Check for multiple 1xx fields.
checkIndicators()  : void
Check the indicators for the provided field.
checkMissing245()  : void
Check for missing 245 field.
checkSubfields()  : void
Check the subfields for the provided field.
getHumanReadableIndicatorValues()  : string
Turn a set of indicator rules into a human-readable list.
getRawRules()  : string
Support method for parseRules() -- get the raw rules from MARC::Lint.
parseRules()  : void
Support method for constructor to load MARC rules.
processRuleGroup()  : void
Support method for parseRules() -- process one group of lines representing a single tag.
standardFieldChecks()  : void
Check all fields against the standard rules encoded in the class.
warn()  : void
Add a warning.

Properties

$rules

Rules used for testing records

protected array<string|int, mixed> $rules

$warnings

Warnings generated during analysis

protected array<string|int, mixed> $warnings = []

Methods

__construct()

Start function

public __construct() : true

Set up rules for testing MARC records.

Return values
true

checkRecord()

Check the provided MARC record and return an array of warning messages.

public checkRecord(MarcReader $marc) : array<string|int, mixed>
Parameters
$marc : MarcReader

Record to check

Return values
array<string|int, mixed>

check020()

Looks at 020$a and reports errors if the check digit is wrong.

protected check020(array<string|int, mixed> $field, MarcReader $marc) : void

Looks at 020$z and validates number if hyphens are present.

Parameters
$field : array<string|int, mixed>

Field to check

$marc : MarcReader

MARC record

Tags
SuppressWarnings

(PHPMD.UnusedFormalParameter)

Return values
void

check041()

Warns if subfields are not evenly divisible by 3 unless second indicator is 7 (future implementation would ensure that each subfield is exactly 3 characters unless ind2 is 7--since subfields are now repeatable. This is not implemented here due to the large number of records needing to be corrected.). Validates against the MARC Code List for Languages (<http://www.loc.gov/marc/>).

protected check041(array<string|int, mixed> $field, MarcReader $marc) : void
Parameters
$field : array<string|int, mixed>

Field to check

$marc : MarcReader

MARC record

Tags
SuppressWarnings

(PHPMD.UnusedFormalParameter)

Return values
void

check043()

Warns if each subfield a is not exactly 7 characters. Validates each code against the MARC code list for Geographic Areas (<http://www.loc.gov/marc/>).

protected check043(array<string|int, mixed> $field, MarcReader $marc) : void
Parameters
$field : array<string|int, mixed>

Field to check

$marc : MarcReader

MARC record

Tags
SuppressWarnings

(PHPMD.UnusedFormalParameter)

Return values
void

check245()

-Makes sure $a exists (and is first subfield).

protected check245(array<string|int, mixed> $field, MarcReader $marc) : void

-Warns if last character of field is not a period --Follows LCRI 1.0C, Nov. 2003 rather than MARC21 rule -Verifies that $c is preceded by / (space-/) -Verifies that initials in $c are not spaced -Verifies that $b is preceded by :;= (space-colon, space-semicolon, space-equals) -Verifies that $h is not preceded by space unless it is dash-space -Verifies that data of $h is enclosed in square brackets -Verifies that $n is preceded by . (period) --As part of that, looks for no-space period, or dash-space-period (for replaced elipses) -Verifies that $p is preceded by , (no-space-comma) when following $n and . (period) when following other subfields. -Performs rudimentary article check of 245 2nd indicator vs. 1st word of 245$a (for manual verification).

Article checking is done by internal checkArticle method, which should work for 130, 240, 245, 440, 630, 730, and 830.

Parameters
$field : array<string|int, mixed>

Field to check

$marc : MarcReader

MARC record

Return values
void

checkArticle()

Check of articles is based on code from Ian Hamilton. This version is more limited in that it focuses on English, Spanish, French, Italian and German articles. Certain possible articles have been removed if they are valid English non-articles. This version also disregards 008_language/041 codes and just uses the list of articles to provide warnings/suggestions.

protected checkArticle(array<string|int, mixed> $field, MarcReader $marc) : void

Source for articles = http://www.loc.gov/marc/bibliographic/bdapp-e.html

Should work with fields 130, 240, 245, 440, 630, 730, and 830. Reports error if another field is passed in.

Parameters
$field : array<string|int, mixed>

Field to check

$marc : MarcReader

MARC record

Return values
void

checkDuplicate1xx()

Check for multiple 1xx fields.

protected checkDuplicate1xx(MarcReader $marc) : void
Parameters
$marc : MarcReader

Record to check

Return values
void

checkIndicators()

Check the indicators for the provided field.

protected checkIndicators(string $tagNo, array<string|int, mixed> $field, array<string|int, mixed> $rules) : void
Parameters
$tagNo : string

Tag number being checked

$field : array<string|int, mixed>

Field to check

$rules : array<string|int, mixed>

Rules to use for checking

Return values
void

checkMissing245()

Check for missing 245 field.

protected checkMissing245(MarcReader $marc) : void
Parameters
$marc : MarcReader

Record to check

Return values
void

checkSubfields()

Check the subfields for the provided field.

protected checkSubfields(string $tagNo, array<string|int, mixed> $field, array<string|int, mixed> $rules) : void
Parameters
$tagNo : string

Tag number being checked

$field : array<string|int, mixed>

Field to check

$rules : array<string|int, mixed>

Rules to use for checking

Return values
void

getHumanReadableIndicatorValues()

Turn a set of indicator rules into a human-readable list.

protected getHumanReadableIndicatorValues(string $rules) : string
Parameters
$rules : string

Indicator rules

Return values
string

getRawRules()

Support method for parseRules() -- get the raw rules from MARC::Lint.

protected getRawRules() : string
Return values
string

parseRules()

Support method for constructor to load MARC rules.

protected parseRules() : void
Return values
void

processRuleGroup()

Support method for parseRules() -- process one group of lines representing a single tag.

protected processRuleGroup(array<string|int, mixed> $rules) : void
Parameters
$rules : array<string|int, mixed>

Rule lines to process

Return values
void

standardFieldChecks()

Check all fields against the standard rules encoded in the class.

protected standardFieldChecks(MarcReader $marc) : void
Parameters
$marc : MarcReader

Record to check

Return values
void

warn()

Add a warning.

protected warn(string $warning) : void
Parameters
$warning : string

Warning to add

Return values
void

Search results