| 1 | package Net::OAI::Record::OAI_DC; | ||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||
| 3 | 17 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 4 | 17 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 5 | 17 | ▶ | use base qw( XML::SAX::Base ); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 6 | 17 | ▶ | use Carp qw( carp ); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 7 | 17 | our $VERSION = "1.16_12"; | |||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||
| 9 | use constant { | ||||||||||||||||||||||||||||||||||||||||
| 10 | 17 | XMLNS_DC => 'http://purl.org/dc/elements/1.1/', | |||||||||||||||||||||||||||||||||||||||
| 11 | XMLNS_OAIDC => 'http://www.openarchives.org/OAI/2.0/oai_dc/', | ||||||||||||||||||||||||||||||||||||||||
| 12 | 17 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||
| 14 | 17 | our @OAI_DC_ELEMENTS = qw( | |||||||||||||||||||||||||||||||||||||||
| 15 | title | ||||||||||||||||||||||||||||||||||||||||
| 16 | creator | ||||||||||||||||||||||||||||||||||||||||
| 17 | subject | ||||||||||||||||||||||||||||||||||||||||
| 18 | description | ||||||||||||||||||||||||||||||||||||||||
| 19 | publisher | ||||||||||||||||||||||||||||||||||||||||
| 20 | contributor | ||||||||||||||||||||||||||||||||||||||||
| 21 | date | ||||||||||||||||||||||||||||||||||||||||
| 22 | type | ||||||||||||||||||||||||||||||||||||||||
| 23 | format | ||||||||||||||||||||||||||||||||||||||||
| 24 | identifier | ||||||||||||||||||||||||||||||||||||||||
| 25 | source | ||||||||||||||||||||||||||||||||||||||||
| 26 | language | ||||||||||||||||||||||||||||||||||||||||
| 27 | relation | ||||||||||||||||||||||||||||||||||||||||
| 28 | coverage | ||||||||||||||||||||||||||||||||||||||||
| 29 | rights | ||||||||||||||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||
| 32 | 17 | our $AUTOLOAD; | |||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||
| 34 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||
| 36 | Net::OAI::Record::OAI_DC - class for baseline Dublin Core support | ||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||
| 38 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||
| 40 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||
| 42 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||
| 44 | The accessor methods are aware of their calling context (list,scalar) and | ||||||||||||||||||||||||||||||||||||||||
| 45 | will respond appropriately. For example an item may have multiple creators, | ||||||||||||||||||||||||||||||||||||||||
| 46 | so a call to creator() in a scalar context returns only the first creator; | ||||||||||||||||||||||||||||||||||||||||
| 47 | and in a list context all creators are returned. | ||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||
| 49 | # scalar context | ||||||||||||||||||||||||||||||||||||||||
| 50 | my $creator = $metadata->creator(); | ||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||
| 52 | # list context | ||||||||||||||||||||||||||||||||||||||||
| 53 | my @creators = $metadata->creator(); | ||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||
| 55 | =head2 new() | ||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||
| 57 | =cut | ||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||
| 59 | sub new { | ||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | my ( $class, %opts ) = @_; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | my $self = bless \%opts, ref( $class ) || $class; | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table0%0/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | foreach ( @OAI_DC_ELEMENTS ) { $self->{ $_ } = []; } | |||||||||||||||||||||||||||||||||||||||
| 63 | 0 | return( $self ); | |||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||
| 66 | =head2 title() | ||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||
| 68 | =head2 creator() | ||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||
| 70 | =head2 subject() | ||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||
| 72 | =head2 description() | ||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||
| 74 | =head2 publisher() | ||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||
| 76 | =head2 contributor() | ||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||
| 78 | =head2 date() | ||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||
| 80 | =head2 type() | ||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||
| 82 | =head2 format() | ||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||
| 84 | =head2 identifier() | ||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||
| 86 | =head2 source() | ||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||
| 88 | =head2 language() | ||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||
| 90 | =head2 relation() | ||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||
| 92 | =head2 coverage() | ||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||
| 94 | =head2 rights() | ||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||
| 96 | =cut | ||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||
| 98 | ## rather than right all the accessors we use AUTOLOAD to catch calls | ||||||||||||||||||||||||||||||||||||||||
| 99 | ## valid element names as methods, and return appropriately as a list | ||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||
| 101 | sub AUTOLOAD { | ||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | my $sub = lc( $AUTOLOAD ); | |||||||||||||||||||||||||||||||||||||||
| 104 | 0 | $sub =~ s/.*:://; | |||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | if ( grep /$sub/, @OAI_DC_ELEMENTS ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | if ( wantarray() ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | return( @{ $self->{ $sub } } ); | |||||||||||||||||||||||||||||||||||||||
| 108 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | return( $self->{ $sub }[0] ); | |||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||
| 114 | ## generic output method | ||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||
| 116 | sub asString { | ||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
asString: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | my @result; | |||||||||||||||||||||||||||||||||||||||
| 119 | 0 | foreach my $element ( @OAI_DC_ELEMENTS ) { | |||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | next unless $self->{ $element }; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | foreach ( @{ $self->{ $element } } ) { | |||||||||||||||||||||||||||||||||||||||
| 122 | 0 | push(@result, "$element => $_"); | |||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | return join("\n", @result); | |||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||
| 128 | ## SAX handlers | ||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||
| 130 | sub start_element { | ||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | my ( $self, $element ) = @_; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
start_element: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | my $elname = $element->{ LocalName }; | |||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | if ( ($element->{ NamespaceURI } eq XMLNS_OAIDC) and ($elname eq "dc") ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
$element->{"NamespaceURI"} eq "http://www.openarchives.org/OAI/2.0/oai_dc/" and $elname eq "dc"
MC/DC0%0/2
$element->{"NamespaceURI"} eq "http://www.openarchives.org/OAI/2.0/oai_dc/" and $elname eq "dc"
$element->{"NamespaceURI"} eq "http://www.openarchives.org/OAI/2.0/oai_dc/"
$elname eq "dc"
Truth table0%0/3
A and B
A= $element->{"NamespaceURI"} eq "http://www.openarchives.org/OAI/2.0/oai_dc/"B= $elname eq "dc"
| |||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | $self->{ _insideRecord } = 1} | |||||||||||||||||||||||||||||||||||||||
| 135 | elsif ( $element->{ NamespaceURI } ne XMLNS_DC ) { | ||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | carp "what is ".$element->{ Name }."?"; | |||||||||||||||||||||||||||||||||||||||
| 137 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||
| 139 | elsif ( grep /$elname/, @OAI_DC_ELEMENTS ) { | ||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $self->{ chars } = ""} | |||||||||||||||||||||||||||||||||||||||
| 141 | else { | ||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | carp "what is $elname?"} | |||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||
| 145 | sub end_element { | ||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | my ( $self, $element ) = @_; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
end_element: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | my $elname = $element->{ LocalName }; | |||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | if ( ($element->{ NamespaceURI } eq XMLNS_OAIDC) and ($elname eq "dc") ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition0%0/3
$element->{"NamespaceURI"} eq "http://www.openarchives.org/OAI/2.0/oai_dc/" and $elname eq "dc"
MC/DC0%0/2
$element->{"NamespaceURI"} eq "http://www.openarchives.org/OAI/2.0/oai_dc/" and $elname eq "dc"
$element->{"NamespaceURI"} eq "http://www.openarchives.org/OAI/2.0/oai_dc/"
$elname eq "dc"
Truth table0%0/3
A and B
A= $element->{"NamespaceURI"} eq "http://www.openarchives.org/OAI/2.0/oai_dc/"B= $elname eq "dc"
| |||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | $self->{ _insideRecord } = 0} | |||||||||||||||||||||||||||||||||||||||
| 151 | elsif ( $element->{ NamespaceURI } ne XMLNS_DC ) { | ||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | return undef} | |||||||||||||||||||||||||||||||||||||||
| 153 | elsif ( grep /$elname/, @OAI_DC_ELEMENTS ) { # o.k. | ||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | push( @{ $self->{ $elname } }, $self->{ chars } ); | |||||||||||||||||||||||||||||||||||||||
| 155 | 0 | $self->{ chars } = undef; | |||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||
| 157 | elsif ( $self->{ chars } =~ /\S/ ) { | ||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | carp "unassigned content: ".$self->{ chars }; | |||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||
| 162 | sub characters { | ||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | my ( $self, $characters ) = @_; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
characters: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | $self->{ chars } .= $characters->{ Data } if $self->{ _insideRecord }; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||
| 167 | 17 | 1; | |||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||