| 1 | # Copyright (c) 2004-2005 Timothy Appnel | ||||||||||||||||||||||||||||
| 2 | # http://www.timaoutloud.org/ | ||||||||||||||||||||||||||||
| 3 | # This code is released under the Artistic License. | ||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||
| 5 | # XML::Parser::Style::Elemental - A flexible and extensible object | ||||||||||||||||||||||||||||
| 6 | # tree style for XML::Parser. DEPRECATED. | ||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | package XML::Parser::Style::Elemental; | ||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 1 | $VERSION = '0.72'; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 0 | ▶ | sub Init { | ||||||||||||||||||||||||||
|
Subroutine
Init: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 17 | 0 | my $xp = shift; | |||||||||||||||||||||||||||
| 18 | 0 | ▶ | $xp->{Elemental} ||= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$xp->{"Elemental"} ||= {}
MC/DC0%0/1
$xp->{"Elemental"} ||= {}
$xp->{"Elemental"}
Truth table0%0/2
A
A= $xp->{"Elemental"}
| |||||||||||||||||||||||||||||
| 19 | 0 | my $e = $xp->{Elemental}; | |||||||||||||||||||||||||||
| 20 | 0 | ▶ | if ($xp->{Pkg} eq 'main' || !defined $xp->{Pkg}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$xp->{"Pkg"} eq "main" or not defined $xp->{"Pkg"}
MC/DC0%0/2
$xp->{"Pkg"} eq "main" or not defined $xp->{"Pkg"}
$xp->{"Pkg"} eq "main"
not defined $xp->{"Pkg"}
Truth table0%0/3
A or not(B)
A= $xp->{"Pkg"} eq "main"B= not defined $xp->{"Pkg"}
| |||||||||||||||||||||||||||||
| 21 | 0 | ▶ | $e->{Document} ||= 'XML::Elemental::Document'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$e->{"Document"} ||= "XML::Elemental::Document"
MC/DC0%0/1
$e->{"Document"} ||= "XML::Elemental::Document"
$e->{"Document"}
Truth table0%0/2
A
A= $e->{"Document"}
| |||||||||||||||||||||||||||||
| 22 | 0 | ▶ | $e->{Element} ||= 'XML::Elemental::Element'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$e->{"Element"} ||= "XML::Elemental::Element"
MC/DC0%0/1
$e->{"Element"} ||= "XML::Elemental::Element"
$e->{"Element"}
Truth table0%0/2
A
A= $e->{"Element"}
| |||||||||||||||||||||||||||||
| 23 | 0 | ▶ | $e->{Characters} ||= 'XML::Elemental::Characters'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$e->{"Characters"} ||= "XML::Elemental::Characters"
MC/DC0%0/1
$e->{"Characters"} ||= "XML::Elemental::Characters"
$e->{"Characters"}
Truth table0%0/2
A
A= $e->{"Characters"}
| |||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | 0 | map { eval "use $e->{$_}" } qw( Document Element Characters); | |||||||||||||||||||||||||||
| 26 | 0 | $xp->{__doc} = $e->{Document}->new; | |||||||||||||||||||||||||||
| 27 | 0 | push(@{$xp->{__stack}}, $xp->{__doc}); | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 0 | ▶ | sub Start { | ||||||||||||||||||||||||||
|
Subroutine
Start: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 31 | 0 | my $xp = shift; | |||||||||||||||||||||||||||
| 32 | 0 | my $tag = shift; | |||||||||||||||||||||||||||
| 33 | 0 | my $node = $xp->{Elemental}->{Element}->new(); | |||||||||||||||||||||||||||
| 34 | 0 | $node->name(ns_qualify($xp, $tag)); | |||||||||||||||||||||||||||
| 35 | 0 | $node->parent($xp->{__stack}->[-1]); | |||||||||||||||||||||||||||
| 36 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 0 | $node->attributes({}); | |||||||||||||||||||||||||||
| 38 | 0 | ▶ | while (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | 0 | my ($key, $value) = (shift @_, shift @_); | |||||||||||||||||||||||||||
| 40 | 0 | $node->attributes->{ns_qualify($xp, $key, $tag)} = $value; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | 0 | ▶ | $node->parent->contents([]) unless $node->parent->contents; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 0 | push(@{$node->parent->contents}, $node); | |||||||||||||||||||||||||||
| 45 | 0 | push(@{$xp->{__stack}}, $node); | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | ▶ | sub Char { | ||||||||||||||||||||||||||
|
Subroutine
Char: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 49 | 0 | my ($xp, $data) = @_; | |||||||||||||||||||||||||||
| 50 | 0 | my $parent = $xp->{__stack}->[-1]; | |||||||||||||||||||||||||||
| 51 | 0 | ▶ | $parent->contents([]) unless $parent->contents; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 0 | my $contents = $parent->contents(); | |||||||||||||||||||||||||||
| 53 | 0 | my $class = $xp->{Elemental}->{Characters}; | |||||||||||||||||||||||||||
| 54 | 0 | ▶ | unless ($contents && ref($contents->[-1]) eq $class) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$contents and ref $contents->[-1] eq $class
MC/DC0%0/2
$contents and ref $contents->[-1] eq $class
$contents
ref $contents->[-1] eq $class
Truth table0%0/3
A and B
A= $contentsB= ref $contents->[-1] eq $class
| |||||||||||||||||||||||||||||
| 55 | 0 | ▶ | return if ($xp->{Elemental}->{No_Whitespace} && $data !~ /\S/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$xp->{"Elemental"}{"No_Whitespace"} and not $data =~ /\S/
MC/DC0%0/2
$xp->{"Elemental"}{"No_Whitespace"} and not $data =~ /\S/
$xp->{"Elemental"}{"No_Whitespace"}
not $data =~ /\S/
Truth table0%0/3
A and not(B)
A= $xp->{"Elemental"}{"No_Whitespace"}B= not $data =~ /\S/
| |||||||||||||||||||||||||||||
| 56 | 0 | my $node = $class->new(); | |||||||||||||||||||||||||||
| 57 | 0 | $node->parent($parent); | |||||||||||||||||||||||||||
| 58 | 0 | $node->data($data); | |||||||||||||||||||||||||||
| 59 | 0 | push(@{$contents}, $node); | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | else { | ||||||||||||||||||||||||||||
| 62 | 0 | ▶ | my $d = $contents->[-1]->data() || ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
$contents->[-1]->data || ''
MC/DC0%0/1
$contents->[-1]->data || ''
$contents->[-1]->data
Truth table0%0/2
A
A= $contents->[-1]->data
| |||||||||||||||||||||||||||||
| 63 | 0 | ▶ | return if ($xp->{Elemental}->{No_Whitespace} && $d !~ /\S/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$xp->{"Elemental"}{"No_Whitespace"} and not $d =~ /\S/
MC/DC0%0/2
$xp->{"Elemental"}{"No_Whitespace"} and not $d =~ /\S/
$xp->{"Elemental"}{"No_Whitespace"}
not $d =~ /\S/
Truth table0%0/3
A and not(B)
A= $xp->{"Elemental"}{"No_Whitespace"}B= not $d =~ /\S/
| |||||||||||||||||||||||||||||
| 64 | 0 | $contents->[-1]->data("$d$data"); | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | ▶ | sub End { pop(@{$_[0]->{__stack}}) } | ||||||||||||||||||||||||||
|
Subroutine
End: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | ▶ | sub Final { | ||||||||||||||||||||||||||
|
Subroutine
Final: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 71 | 0 | delete $_[0]->{__stack}; | |||||||||||||||||||||||||||
| 72 | 0 | $_[0]->{__doc}; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | ▶ | sub ns_qualify { | ||||||||||||||||||||||||||
|
Subroutine
ns_qualify: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 76 | 0 | ▶ | return $_[1] unless $_[0]->{Namespaces}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | 0 | ▶ | my $ns = $_[0]->namespace($_[1]) || $_[0]->namespace($_[2]); | ||||||||||||||||||||||||||
|
Condition0%0/3
$_[0]->namespace($_[1]) || $_[0]->namespace($_[2])
MC/DC0%0/2
$_[0]->namespace($_[1]) || $_[0]->namespace($_[2])
$_[0]->namespace($_[1])
$_[0]->namespace($_[2])
Truth table0%0/3
A || B
A= $_[0]->namespace($_[1])B= $_[0]->namespace($_[2])
| |||||||||||||||||||||||||||||
| 78 | 0 | ▶ | return $_[1] unless $ns; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | 0 | ▶ | $ns =~ m!(/|#)$! ? "$ns$_[1]" : "$ns/$_[1]"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 1 | 1; | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | __END__ | ||||||||||||||||||||||||||||