PICA::Modification - Idempotent modification of an identified PICA+ record
use PICA::Modification; # delete field '0123A' from record 'foo:ppn:123' my $mod = PICA::Modification->new( id => 'foo:ppn:123', del => '0123A' ); $after = $mod->apply( $before );
PICA::Modification models a modification of an identified PICA+ record (PICA::Record). The modification consist of the following attributes:
A stringified PICA+ record with fields to be added.
A comma-separated list of PICA+ field tags to be removed. All tags of fields to be added must also be included for deletion so modifications are idempotent.
The fully qualified record identifier of form
The ILN of level 1 record to modify. Only required for modifications that include level 1 fields.
The EPN of the level 2 record to modify. Only required for modifications that include level 2 fields.
A modification instance may be malformed. A mapping from malformed attributes to error messages is stored together with the PICA::Modification object.
Creates a new modification from attributes, given as hash, as hash reference or as another PICA::Modification. The modification is checked on creation, so all attributes are normalized, missing attributes are set to the empty string and invalid attributes result in errors.
Returns a new hash reference with attributes of this modification.
Gets or sets an error message connected to an attribute. Without arguments this method returns the current number of errors.
Normalizes and checks all attributes. Missing values are set to the empty string and invalid attributes result in errors. Returns the modification.
Applies the modification on a given PICA+ record and returns the resulting record as PICA::Record or
undef on malformed modifications.
Only edits at level 0 and level 1 are supported by now.
PPN/ILN/EPN must match or an error is set.
Applies the modification to a given PICA+ record and returns a diff on success. The context attribute specifies the number of fields before/after each deleted or added field. If undefines, all fields are included in the diff.
See PICA::Record for information about PICA+ record format.
Jakob Voß <firstname.lastname@example.org>
This software is copyright (c) 2012 by Jakob Voß.