PICA/Writer/PIXML.pm

filter: Statementstmt 36.3% 20 / 55 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 66.6% 6 / 9 Podpod 33.3% 1 / 3 totaltotal 35.5% 27 / 76 CC 10 SCAR 35.4
CC
10
Cov
32%
write_record
72.0
write_field
12.0
BEGIN
1.0
CRAP 34.4
« PICA/Writer/PPXML.pm ↑ Summary PICA/Writer/XML.pm »
1 package PICA::Writer::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 Scalar::Util qw(reftype);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 16 ▶use XML::LibXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 16 ▶use PICA::Path;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 16 ▶use PICA::Data;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 16 ▶use parent 'PICA::Writer::XML';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 16 our $PPN = PICA::Path->new('003@$0');
14  
15 0 ▶sub namespace { }
Subroutine namespace: not called CC=1 SCAR=0.0
Pod undocumented
16  
17 0 ▶sub write_field {
Subroutine write_field: not called CC=3 SCAR=24.8
Pod undocumented
18 0 my ($self, $field) = @_;
19  
20 0 my $writer = $self->{writer};
21  
22 0 my ($tag, $occurrence) = ($field->[0], $field->[1]);
23 0 my %attr = (tag => $tag, fulltag => $tag);
24 0 ▶ if ($occurrence > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($occurrence > 1) 0 0 0
25 0 $attr{fulltag} .= $occurrence;
26 0 $attr{occurrence} = $occurrence;
27 }
28 0 $writer->startTag('datafield', %attr);
29 0 ▶ for (my $i = 3; $i < scalar @$field; $i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @$field) 0 0 0
30 0 $writer->dataElement('subfield', $field->[$i],
31 code => $field->[$i - 1]);
32 }
33 0 $writer->endTag('datafield');
34 }
35  
36 0 ▶sub write_record {
Subroutine write_record: not called CC=8 SCAR=42.8
Pod documented
37 0 my ($self, $record) = @_;
38 0 ▶ $record = $record->{record} if reftype $record eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if builtin::reftype($record) eq "HASH" 0 0 0
39  
40 0 my $writer = $self->{writer};
41  
42 0 $writer->startTag('record');
43  
44 0 $writer->startTag('header', status => "upsert");
45  
46 0 $writer->dataElement('identifier',
47 PICA::Data::pica_value($record, '003@$0'));
48 0 $writer->endTag('header');
49  
50 0 $writer->startTag('metadata');
51  
52 0 $self->write_field($_) for grep {$_->[0] =~ /^0/} @$record;
53  
54 0 for my $holding (@{PICA::Data::pica_holdings($record)}) {
55 0 my @local = grep {$_->[0] =~ /^1/} @{$holding->{record}};
56 0 $self->write_field($_) for @local;
57  
58 0 for my $item (@{PICA::Data::pica_items($holding)}) {
59 0 ▶ $writer->startTag('item', epn => $item->{_id} // "",);
Condition0%0/2
$item->{"_id"} // ""
l!l
00
MC/DC0%0/1
$item->{"_id"} // ""
$item->{"_id"}
Truth table0%0/2
A
A= $item->{"_id"}
Aresult
11
00
60 0 $self->write_field($_) for @{$item->{record}};
61 0 $writer->endTag('item');
62 }
63 }
64  
65 0 $writer->endTag('metadata');
66 0 $writer->endTag('record');
67 }
68  
69 16 1;
70 __END__
« PICA/Writer/PPXML.pm ↑ Summary PICA/Writer/XML.pm »