NAME
Net::OAI::Record::DocumentHelper - filter class for fine tuning document events and collecting processing results
SYNOPSIS
$filter = Net::OAI::Record::DocumentHelper->new(
Handler => 'XML::SAX::Writer'
provideDocumentEvents => 1,
# since XML::SAX::Writer->new() returns objects of a differentClass
dontVerifyHandler => 1,
);
$records = $harvester->listRecords(
'metadataPrefix' => 'oai_dc',
'metadataHandler' => $filter;
);
$builder = XML::LibXML::SAX::Builder->new();
$helper = Net::OAI::Recrd::DocumentHelper->new(
Handler => $builder,
provideDocumentEvents => 1,
finalizeHook => sub { return $_[0]->finalize()->serialize() }
);
$records = $harvester->listRecords(
'metadataPrefix' => 'oai_dc',
'metadataHandler' => $helper;
);
DESCRIPTION
This helper class acts as a SAX filter and can be used as recordHandler or metadataHandler for Net::OAI::Harvester->listRecord() or getRecord() requests or within a SAX filter chain.
The Handler may be a class name, in which case a new object of that class is created on instantiation of a DocumentHelper object, or an existing SAX filter which then will be reused. (In this case it is your responsibility to use only filters which support the processing of multiple documents by one instance.)
If the option provideDocumentEvents
is set to a true value, the filter will generate start_document() and end_document() events.
If the (exlusive to the previous) option suppressDocumentEvents
is set to a true value, the filter will stop start_document() and end_document() events from propagating up the chain.
If the option dontVerifyHandler
is set to a true value, class sanity checks for existing or freshly created ones are skipped.
The option finalizeHook
may specify a callback for postprocessing the result just after an end_document() event has been forwarded. It is called with two arguments, the handler object and the result of the forwarded end_document() and should return something suitable for processing with Storable.
METHODS
new( %options )
Creates a Handler suitable as recordHandler or metadataHandler or intermediate filter.
result ( )
Returns the result of the last end_document() forwarded to the handler, usually this is the result of some sort of finalizing process.
AUTHOR
Thomas Berger <ThB@gymel.com>