Net::OAI::ListMetadataFormats - Results of the ListMetadataFormats OAI-PMH verb.


OAI-Harvester documentation Contained in the OAI-Harvester distribution.

Index


Code Index:

NAME

Top

Net::OAI::ListMetadataFormats - Results of the ListMetadataFormats OAI-PMH verb.

SYNOPSIS

Top

DESCRIPTION

Top

METHODS

Top

new()

prefixes()

namespaces()

namespaces_byprefix()

Returns the namespace URI associated to a given metadataPrefix.

schemas()

schemas_byprefix()

Returns the schema URI associated to a given metadataPrefix.


OAI-Harvester documentation Contained in the OAI-Harvester distribution.
package Net::OAI::ListMetadataFormats;

use strict;
use base qw( XML::SAX::Base );
use base qw( Net::OAI::Base );

sub new {
    my ( $class, %opts ) = @_;
    my $self = bless \%opts, ref( $class ) || $class;
    $self->{ insideList } = 0;
    $self->{ metadataPrefixes } = [];
    $self->{ namespaces } = [];
    $self->{ schemas } = [];
    return( $self );
}

sub prefixes() {
    my $self = shift;
    return( @{ $self->{ metadataPrefixes } } );
}

sub namespaces {
    my $self = shift;
    return( @{ $self->{ namespaces } } );
}

sub namespaces_byprefix {
    my ($self, $prefix) = @_;
    return $self->{namespaces_byprefix}->{$prefix};
}


sub schemas {
    my $self = shift;
    return( @{ $self->{ schemas } } );
}

sub schemas_byprefix {
    my ($self, $prefix) = @_;
    return $self->{schemas_byprefix}->{$prefix};
}


## SAX Handlers

sub start_element {
    my ( $self, $element ) = @_;
    if ( $element->{ Name } eq 'ListMetadataFormats' ) { 
	$self->{ insideList } = 1;
    } else {
	$self->SUPER::start_element( $element );
    }
    push( @{ $self->{ tagStack } }, $element->{ Name } );
}

sub end_element {
    my ( $self, $element ) = @_;
    my $name = $element->{ Name };
    if ( $name eq 'ListMetadataFormats' ) {
	$self->{ insideList } = 0;
    } elsif ( $name eq 'metadataFormat' ) {
        my $nspf = delete $self->{ _currpf };
        $self->{ namespaces_byprefix }->{ $nspf } = delete $self->{ _currns };
        $self->{ schemas_byprefix }->{ $nspf } = delete $self->{ _currxs };
    } elsif ( $name eq 'metadataPrefix' ) {
	push( @{ $self->{ metadataPrefixes } }, $self->{ metadataPrefix } );
        $self->{ _currpf } = $self->{ metadataPrefix };
	$self->{ metadataPrefix } = '';
    } elsif ( $name eq 'schema' ) {
        push( @{ $self->{ schemas } }, $self->{schema } );
        $self->{ _currxs } = $self->{ schema };
        $self->{ schema } = '';
    } elsif ( $name eq 'metadataNamespace' ) {
        push( @{ $self->{ namespaces } }, $self->{ metadataNamespace } );
        $self->{ _currns } = $self->{ metadataNamespace };
        $self->{ metadataNamespace } = '';
    } else {
	$self->SUPER::end_element( $element );
    }
    pop( @{ $self->{ tagStack } } );
}

sub characters {
    my ( $self, $characters ) = @_;
    $self->SUPER::characters( $characters );
    $self->{ $self->{ tagStack }[-1] } .= $characters->{ Data };
}

1;