File: METS.pm

package info (click to toggle)
libhttp-oai-perl 4.03-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 416 kB
  • ctags: 326
  • sloc: perl: 2,531; xml: 224; makefile: 12
file content (64 lines) | stat: -rw-r--r-- 1,028 bytes parent folder | download
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
package HTTP::OAI::Metadata::METS;

use XML::LibXML;
use XML::LibXML::XPathContext;

@ISA = qw( HTTP::OAI::Metadata );

use strict;

sub new {
	my $class = shift;
	my $self = $class->SUPER::new(@_);
	my %args = @_;
	$self;
}

sub _xc
{
	my $xc = XML::LibXML::XPathContext->new( @_ );
	$xc->registerNs( 'oai_dc', HTTP::OAI::OAI_NS );
	$xc->registerNs( 'mets', 'http://www.loc.gov/METS/' );
	$xc->registerNs( 'xlink', 'http://www.w3.org/1999/xlink' );
	return $xc;
}

sub files
{
	my $self = shift;
	my $dom = $self->dom;

	my $xc = _xc($dom);

	my @files;
	foreach my $file ($xc->findnodes( '*//mets:file' ))
	{
		my $f = {};
		foreach my $attr ($file->attributes)
		{
			$f->{ $attr->nodeName } = $attr->nodeValue;
		}
		$file = _xc($file);
		foreach my $locat ($file->findnodes( 'mets:FLocat' ))
		{
			$f->{ url } = $locat->getAttribute( 'xlink:href' );
		}
		push @files, $f;
	}

	return @files;
}

1;

__END__

=head1 NAME

HTTP::OAI::Metadata::METS - METS accessor utility

=head1 DESCRIPTION

=head1 SYNOPSIS

=head1 NOTE