| 1 | package XML::Struct; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use XML::LibXML::Reader; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use XML::Struct::Reader; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use XML::Struct::Writer; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use XML::Struct::Simple; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 5 | our $VERSION = '0.25'; | |||||||||||||||||||||||||||
| 10 | 5 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||
| 11 | 5 | our @EXPORT_OK = qw(readXML writeXML simpleXML removeXMLAttr textValues); | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | sub readXML { # ( [$from], %options ) | ||||||||||||||||||||||||||||
| 14 | 30 | ▶ | my (%options) = @_ % 2 ? (from => @_) : @_; | ||||||||||||||||||||||||||
|
Subroutine
readXML: called CC=5 SCAR=17.8
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | my %reader_options = ( | ||||||||||||||||||||||||||||
| 17 | 50 | map { $_ => delete $options{$_} } | |||||||||||||||||||||||||||
| 18 | 30 | grep { exists $options{$_} } | |||||||||||||||||||||||||||
| 19 | qw(attributes whitespace path stream simple micro root ns depth content deep) | ||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||
| 21 | 30 | ▶ | if (%options) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | 30 | ▶ | if (exists $options{from} and keys %options == 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $options{"from"} and keys %options == 1
MC/DC0%0/2
exists $options{"from"} and keys %options == 1
exists $options{"from"}
keys %options == 1
Truth table33%1/3
A and B
A= exists $options{"from"}B= keys %options == 1
| |||||||||||||||||||||||||||||
| 23 | 30 | $reader_options{from} = $options{from}; | |||||||||||||||||||||||||||
| 24 | } else { | ||||||||||||||||||||||||||||
| 25 | 0 | $reader_options{from} = \%options; | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 30 | XML::Struct::Reader->new( %reader_options )->readDocument; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | sub writeXML { | ||||||||||||||||||||||||||||
| 33 | 1 | ▶ | my ($xml, %options) = @_; | ||||||||||||||||||||||||||
|
Subroutine
writeXML: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 34 | 1 | XML::Struct::Writer->new(%options)->write($xml); | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | sub simpleXML { | ||||||||||||||||||||||||||||
| 38 | 1 | ▶ | my ($element, %options) = @_; | ||||||||||||||||||||||||||
|
Subroutine
simpleXML: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 39 | 1 | XML::Struct::Simple->new(%options)->transform($element); | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 5 | *removeXMLAttr = *XML::Struct::Simple::removeXMLAttr; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | # TODO: document (better name?) | ||||||||||||||||||||||||||||
| 45 | sub textValues { | ||||||||||||||||||||||||||||
| 46 | 0 | ▶ | my ($element, $options) = @_; | ||||||||||||||||||||||||||
|
Subroutine
textValues: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 47 | # TODO: %options (e.g. join => " ") | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | my $children = $element->[2]; | |||||||||||||||||||||||||||
| 50 | 0 | ▶ | return "" if !$children; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 0 | return join "", grep { $_ ne "" } map { | |||||||||||||||||||||||||||
| 53 | 0 | ▶ | ref $_ ? textValues($_, $options) : $_ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | } @$children; | ||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 5 | 1; | |||||||||||||||||||||||||||
| 58 | __END__ | ||||||||||||||||||||||||||||