NAME
PICA::Parser::Base - abstract base class of PICA parsers
SYNOPSIS
use PICA::Parser::Plain;
my $parser = PICA::Parser::Plain->new( $filename );
while ( my $record = $parser->next ) {
# do something
}
use PICA::Parser::Plus;
my $parser = PICA::Parser::Plus->new( $filename );
... # records will be instances of PICA::Data
use PICA::Parser::XML;
my $parser = PICA::Parser::XML->new( $filename, start => 1 );
...
my $records = $parser->all;
DESCRIPTION
This abstract base class of PICA+ parsers should not be instantiated directly. Use one of the following subclasses instead:
- PICA::Parser::Plain
- PICA::Parser::Plus
- PICA::Parser::Binary
- PICA::Parser::Import
- PICA::Parser::XML
- PICA::Parser::PPXML
- PICA::Parser::JSON
- PICA::Parser::Patch
CONFIGURATION
- strict
-
By default faulty fields in records are skipped with warnings. You can make them fatal by setting the strict parameter to 1.
- annotate
-
By default some parsers also support annotated PICA. Set to true to enforce field annotations or to false to forbid them. Default value (undefined or empty string) allows annotations.
METHODS
new( [ $input | fh => $input ] [ %options ] )
Initialize parser to read from a given file, handle (e.g. IO::Handle), or reference to a Unicode string. PICA::Parser::XML also detects plain XML strings.
next
Read the next PICA+ record and return a PICA::Data object (that is a blessed hash with keys record
and optional _id
).
count
Get the number of records read so far.
all
Read all records and return as array reference.
SEE ALSO
See Catmandu::Importer::PICA for usage of this module in Catmandu.
Alternative PICA parsers had been implemented as PICA::PlainParser and PICA::XMLParser and included in the release of PICA::Record (DEPRECATED).