NAME
PICA::Patch - Implementation of PICA diff and patch
DESCRIPTION
This file contains the implementation of diff and patch algorithm for PICA+ records. See functions pica_diff and pica_patch (or object methods diff and patch) of PICA::Data for usage.
FORMAT
The difference between two records or the change to be applied to a record is referred to as diff, delta or patch. In any case the format must encode a set of modifications. PICA Patch format encodes modifications to PICA records in form of annotated PICA records. PICA fields can be annotated with:
- +
-
To denote a field that should be added.
- -
-
To denote a field that should be removed.
- blank
-
To denote a field that should be kept as it is.
Modification of a field can be encoded by removal of the old version followed by addition of the new version.
APPLICATION
Records are always sorted before application of diff or patch. It is not recommended to diff or patch records that subsumes multiple sub-records on level 1 or level 2.
Fields are not added with a patch if the records already contains a fully identical field.
FUNCTIONS
pica_diff( $before, $after )
Return the difference between two records as annotated record.
pica_patch( $record, $diff )
Apply a difference given as annotated PICA and return the result as new record.