| 1 | package PICA::Writer::PPXML; | ||||||||||||||||||||||||||||
| 2 | 8 | ▶ | use v5.14.1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 8 | our $VERSION = '1.18'; | |||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 8 | ▶ | use Scalar::Util qw(reftype); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 8 | ▶ | use XML::LibXML; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 8 | ▶ | use PICA::Path; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 8 | ▶ | use parent 'PICA::Writer::XML'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 8 | our $ILN = PICA::Path->new('101@$a'); | |||||||||||||||||||||||||||
| 13 | 8 | our $EPN = PICA::Path->new('203@$0'); | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | sub namespace { | ||||||||||||||||||||||||||||
| 16 | 0 | ▶ | 'http://www.oclcpica.org/xmlns/ppxml-1.0'; | ||||||||||||||||||||||||||
|
Subroutine
namespace: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | sub write_field { | ||||||||||||||||||||||||||||
| 20 | 0 | ▶ | my ($self, $field) = @_; | ||||||||||||||||||||||||||
|
Subroutine
write_field: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 0 | my $writer = $self->{writer}; | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 0 | ▶ | $writer->startTag('tag', id => $field->[0], occ => 1 * $field->[1] || ""); | ||||||||||||||||||||||||||
|
Condition0%0/2
1 * $field->[1] || ''
MC/DC0%0/1
1 * $field->[1] || ''
1 * $field->[1]
Truth table0%0/2
A
A= 1 * $field->[1]
| |||||||||||||||||||||||||||||
| 25 | 0 | ▶ | for (my $i = 3; $i < scalar @$field; $i += 2) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 0 | $writer->dataElement('subf', $field->[$i], id => $field->[$i - 1]); | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | 0 | $writer->endTag('tag'); | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | sub write_record { | ||||||||||||||||||||||||||||
| 32 | 0 | ▶ | my ($self, $record) = @_; | ||||||||||||||||||||||||||
|
Subroutine
write_record: not called CC=13 SCAR=52.0
Pod
documented
| |||||||||||||||||||||||||||||
| 33 | 0 | ▶ | $record = $record->{record} if reftype $record eq 'HASH'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | my $writer = $self->{writer}; | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | $writer->startTag('record'); | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | $writer->startTag('global', opacflag => "", status => ""); | |||||||||||||||||||||||||||
| 40 | 0 | $self->write_field($_) for grep {$_->[0] =~ /^0/} @$record; | |||||||||||||||||||||||||||
| 41 | 0 | $writer->endTag('global'); | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 0 | my @fields = grep {$_->[0] =~ /^[12]/} @$record; | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 0 | ▶ | while (@fields) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | 0 | my $iln; | |||||||||||||||||||||||||||
| 47 | my @local; | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | # collect level 1 fields up to the first level 2 field or the next 101@ | ||||||||||||||||||||||||||||
| 50 | 0 | ▶ | while (@fields and $fields[0][0] =~ /^1/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@fields and $fields[0][0] =~ /^1/u
MC/DC0%0/2
@fields and $fields[0][0] =~ /^1/u
@fields
$fields[0][0] =~ /^1/u
Truth table0%0/3
A and B
A= @fieldsB= $fields[0][0] =~ /^1/u
| |||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if ($fields[0][0] eq '101@') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 0 | ▶ | last if defined $iln; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | 0 | ($iln) = $ILN->match_subfields($fields[0]); | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | 0 | push @local, shift(@fields); | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 0 | my %copy; | |||||||||||||||||||||||||||
| 59 | 0 | ▶ | while (@fields && $fields[0][0] =~ /^2/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@fields and $fields[0][0] =~ /^2/u
MC/DC0%0/2
@fields and $fields[0][0] =~ /^2/u
@fields
$fields[0][0] =~ /^2/u
Truth table0%0/3
A and B
A= @fieldsB= $fields[0][0] =~ /^2/u
| |||||||||||||||||||||||||||||
| 60 | 0 | ▶ | my $occ = 1 * $fields[0][1] // ""; | ||||||||||||||||||||||||||
|
Condition0%0/2
1 * $fields[0][1] // ""
MC/DC0%0/1
1 * $fields[0][1] // ""
1 * $fields[0][1]
Truth table0%0/2
A
A= 1 * $fields[0][1]
| |||||||||||||||||||||||||||||
| 61 | 0 | push @{$copy{$occ}}, shift @fields; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 0 | ▶ | if (%copy) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 0 | for my $occ (sort keys %copy) { | |||||||||||||||||||||||||||
| 66 | 0 | $self->write_owner($iln, \@local, $copy{$occ}); | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | else { | ||||||||||||||||||||||||||||
| 70 | 0 | $self->write_owner($iln, \@local); | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | $writer->endTag('record'); | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | sub write_owner { | ||||||||||||||||||||||||||||
| 78 | 0 | ▶ | my ($self, $iln, $local, $copy) = @_; | ||||||||||||||||||||||||||
|
Subroutine
write_owner: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 0 | my $writer = $self->{writer}; | |||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 0 | ▶ | $writer->startTag('owner', iln => $iln // ""); | ||||||||||||||||||||||||||
|
Condition0%0/2
$iln // ""
MC/DC0%0/1
$iln // ""
$iln
Truth table0%0/2
A
A= $iln
| |||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 0 | ▶ | if (@$local) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | 0 | $writer->startTag('local'); | |||||||||||||||||||||||||||
| 86 | 0 | $self->write_field($_) for @$local; | |||||||||||||||||||||||||||
| 87 | 0 | $writer->endTag('local'); | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 0 | ▶ | if ($copy) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | 0 | ▶ | my $occ = 1 * $copy->[0][1] // ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
1 * $copy->[0][1] // ""
MC/DC0%0/1
1 * $copy->[0][1] // ""
1 * $copy->[0][1]
Truth table0%0/2
A
A= 1 * $copy->[0][1]
| |||||||||||||||||||||||||||||
| 92 | my ($epn) | ||||||||||||||||||||||||||||
| 93 | 0 | = map {$EPN->match_subfields($_)} grep {$_->[0] eq '203@'} @$copy; | |||||||||||||||||||||||||||
| 94 | 0 | $writer->startTag( | |||||||||||||||||||||||||||
| 95 | 'copy', | ||||||||||||||||||||||||||||
| 96 | occ => $occ, | ||||||||||||||||||||||||||||
| 97 | epn => $epn, | ||||||||||||||||||||||||||||
| 98 | opacflag => "", | ||||||||||||||||||||||||||||
| 99 | status => "" | ||||||||||||||||||||||||||||
| 100 | ); | ||||||||||||||||||||||||||||
| 101 | 0 | $self->write_field($_) for @$copy; | |||||||||||||||||||||||||||
| 102 | 0 | $writer->endTag('copy'); | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 0 | $writer->endTag('owner'); | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 8 | 1; | |||||||||||||||||||||||||||
| 109 | __END__ | ||||||||||||||||||||||||||||