| 1 | package PICA::Parser::PIXML; | ||||||||||
| 2 | 16 | ▶ | use v5.14.1; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | 16 | our $VERSION = '2.12'; | |||||||||
| 5 | |||||||||||
| 6 | 16 | ▶ | use parent 'PICA::Parser::XML'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 5 | ▶ | sub _next_record { | ||||||||
|
Subroutine
_next_record: called CC=5 SCAR=16.1
| |||||||||||
| 9 | 5 | my ($self) = @_; | |||||||||
| 10 | |||||||||||
| 11 | 5 | my $reader = $self->{xml_reader}; | |||||||||
| 12 | 5 | ▶ | return unless $reader->nextElement('metadata'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 13 | |||||||||||
| 14 | 4 | my @record; | |||||||||
| 15 | |||||||||||
| 16 | # get all field from PICA record; | ||||||||||
| 17 | 4 | for my $datafield ( | |||||||||
| 18 | $reader->copyCurrentNode(1)->getElementsByLocalName('datafield')) | ||||||||||
| 19 | { | ||||||||||
| 20 | 55 | my @field; | |||||||||
| 21 | |||||||||||
| 22 | # get field tag number | ||||||||||
| 23 | 55 | my $tag = $datafield->getAttribute('tag'); | |||||||||
| 24 | 55 | my $occ = $datafield->getAttribute('occurrence'); | |||||||||
| 25 | 55 | ▶ | $occ = $occ > 0 ? sprintf('%02d', $occ) : ''; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 55 | push(@field, ($tag, $occ)); | |||||||||
| 27 | |||||||||||
| 28 | # get all subfields | ||||||||||
| 29 | 55 | foreach my $subfield ($datafield->getElementsByLocalName('subfield')) | |||||||||
| 30 | { | ||||||||||
| 31 | 118 | my $subfield_code = $subfield->getAttribute('code'); | |||||||||
| 32 | 118 | my $subfield_data = $subfield->textContent; | |||||||||
| 33 | 118 | push(@field, ($subfield_code, $subfield_data)); | |||||||||
| 34 | } | ||||||||||
| 35 | 55 | push(@record, [@field]); | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 4 | return \@record; | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 16 | 1; | |||||||||
| 42 | __END__ | ||||||||||