1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
package HTTP::OAI::ListIdentifiers;
@ISA = qw( HTTP::OAI::PartialList );
use strict;
sub identifier { shift->item(@_) }
sub start_element
{
my ($self,$hash, $r) = @_;
if( $hash->{Depth} == 3 && $hash->{LocalName} eq "header" )
{
$self->set_handler(HTTP::OAI::Header->new);
}
$self->SUPER::start_element($hash, $r);
}
sub end_element {
my ($self,$hash, $r) = @_;
$self->SUPER::end_element($hash);
# OAI 1.x
if( $hash->{Depth} == 3 && $hash->{LocalName} eq "identifier" )
{
$r->callback(HTTP::OAI::Header->new(
identifier=>$hash->{Text},
datestamp=>'0000-00-00',
));
}
elsif( $hash->{Depth} == 3 && $hash->{LocalName} eq "header" )
{
$r->callback( $self->get_handler, $self );
$self->set_handler( undef );
}
}
1;
__END__
=head1 NAME
HTTP::OAI::ListIdentifiers - Provide access to an OAI ListIdentifiers response
=head1 SYNOPSIS
my $r = $h->ListIdentifiers;
while(my $rec = $r->next) {
print "identifier => ", $rec->identifier, "\n",
print "datestamp => ", $rec->datestamp, "\n" if $rec->datestamp;
print "status => ", ($rec->status || 'undef'), "\n";
}
die $r->message if $r->is_error;
=head1 METHODS
=over 4
=item $li = new OAI::ListIdentifiers
This constructor method returns a new OAI::ListIdentifiers object.
=item $rec = $li->next
Returns either an L<HTTP::OAI::Header|HTTP::OAI::Header> object, or undef, if there are no more records. Use $rec->is_error to test whether there was an error getting the next record (otherwise things will break).
If -resume was set to false in the Harvest Agent, next may return a string (the resumptionToken).
=item @il = $li->identifier([$idobj])
Returns the identifier list and optionally adds an identifier or resumptionToken, $idobj. Returns an array ref of L<HTTP::OAI::Header|HTTP::OAI::Header>s.
=item $dom = $li->toDOM
Returns a XML::DOM object representing the ListIdentifiers response.
=item $token = $li->resumptionToken([$token])
Returns and optionally sets the L<HTTP::OAI::ResumptionToken|HTTP::OAI::ResumptionToken>.
=back
|