| 1 | package PICA::Parser::PPXML; | ||||||||||
| 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 | return | ||||||||||
| 13 | 5 | ▶ | unless $reader->nextElement('record', | ||||||||
|
Branch: 1 branch
| |||||||||||
| 14 | 'http://www.oclcpica.org/xmlns/ppxml-1.0'); | ||||||||||
| 15 | |||||||||||
| 16 | 4 | my @record; | |||||||||
| 17 | |||||||||||
| 18 | # get all field from PICA record; | ||||||||||
| 19 | 4 | foreach | |||||||||
| 20 | my $field ($reader->copyCurrentNode(1)->getElementsByLocalName('tag')) | ||||||||||
| 21 | { | ||||||||||
| 22 | 55 | my @field; | |||||||||
| 23 | |||||||||||
| 24 | # get field tag number | ||||||||||
| 25 | 55 | my $tag = $field->getAttribute('id'); | |||||||||
| 26 | 55 | my $occ = $field->getAttribute('occ'); | |||||||||
| 27 | 55 | ▶ | $occ = $occ > 0 ? sprintf('%02d', $occ) : ''; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | 55 | push(@field, ($tag, $occ)); | |||||||||
| 29 | |||||||||||
| 30 | # get all subfields | ||||||||||
| 31 | 55 | foreach my $subfield ($field->getElementsByLocalName('subf')) { | |||||||||
| 32 | 118 | my $subfield_code = $subfield->getAttribute('id'); | |||||||||
| 33 | 118 | my $subfield_data = $subfield->textContent; | |||||||||
| 34 | 118 | push(@field, ($subfield_code, $subfield_data)); | |||||||||
| 35 | } | ||||||||||
| 36 | 55 | push(@record, [@field]); | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 4 | return \@record; | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | 16 | 1; | |||||||||
| 43 | __END__ | ||||||||||