| 1 | |||||||||||||||||||||||||||||||||||||||||||
| 2 | package XML::Pastor::Schema::Model; | ||||||||||||||||||||||||||||||||||||||||||
| 3 | 10 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 10 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 10 | ▶ | no warnings qw(uninitialized); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 10 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 10 | ▶ | use Class::Accessor; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 10 | ▶ | use XML::Pastor::Schema::Object; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 10 | ▶ | use XML::Pastor::Schema::NamespaceInfo; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 10 | ▶ | use XML::Pastor::Util qw(mergeHash); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 10 | our @ISA = qw(Class::Accessor); | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 10 | XML::Pastor::Schema::Model->mk_accessors( qw(type element group attribute attributeGroup defaultNamespace namespaces namespaceCounter)); | |||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 9 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=9 SCAR=23.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 9 | my $proto = shift; | |||||||||||||||||||||||||||||||||||||||||
| 22 | 9 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 9 | my $self = {@_}; | |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 9 | ▶ | unless ($self->{type}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 9 | $self->{type} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||
| 28 | 9 | ▶ | unless ($self->{element}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 9 | $self->{element} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 9 | ▶ | unless ($self->{group}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 9 | $self->{group} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 9 | ▶ | unless ($self->{attribute}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 9 | $self->{attribute} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 9 | ▶ | unless ($self->{attributeGroup}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 9 | $self->{attributeGroup} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 9 | ▶ | unless ($self->{namespaces}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 9 | $self->{namespaces} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 9 | ▶ | unless ($self->{namespaceCounter}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 9 | $self->{namespaceCounter} = 0 | |||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 9 | return bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | #------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 1 | ▶ | sub xml_item { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xml_item: called CC=9 SCAR=24.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | my $nsUri = shift; | |||||||||||||||||||||||||||||||||||||||||
| 60 | 1 | my $verbose = 0; | |||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | ▶ | if (!$nsUri && $self->defaultNamespace) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $nsUri and $self->defaultNamespace
MC/DC0%0/2
not $nsUri and $self->defaultNamespace
not $nsUri
$self->defaultNamespace
Truth table33%1/3
not(A) and B
A= not $nsUriB= $self->defaultNamespace
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 1 | $nsUri = $self->defaultNamespace()->uri(); | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 1 | ▶ | my $key = $nsUri ? "$name|$nsUri" : $name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 1 | ▶ | print STDERR "Model item: name = '$name', key = '$key'\n" if ($verbose >= 9); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 1 | my $item; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 1 | foreach my $hname (qw(element type group attribute attributeGroup)) { | |||||||||||||||||||||||||||||||||||||||||
| 71 | 1 | my $items = $self->{$hname}; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 1 | $item = $items->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | ▶ | last if defined($item); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | ▶ | print STDERR "Found item: name = '$name'\n" if (defined ($item) && ($verbose >= 9)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $item and $verbose >= 9
MC/DC0%0/2
defined $item and $verbose >= 9
defined $item
$verbose >= 9
Truth table33%1/3
A and B
A= defined $itemB= $verbose >= 9
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | return $item; | |||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | #------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 1 | ▶ | sub xml_item_class { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xml_item_class: called CC=4 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 85 | 1 | my $item = $self->xml_item(@_); | |||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | ▶ | return undef unless (defined($item)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 1 | ▶ | return $item->class || ($item->definition && $item->definition->class); | ||||||||||||||||||||||||||||||||||||||||
|
Condition16%1/6
$item->class || $item->definition && $item->definition->class
$item->definition and $item->definition->class
MC/DC0%0/3
$item->class || $item->definition && $item->definition->class
$item->class
$item->definition
$item->definition->class
Truth table25%1/4
A || B and C
A= $item->classB= $item->definitionC= $item->definition->class
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | #------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 151 | ▶ | sub add { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add: called CC=20 SCAR=39.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 151 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 94 | 151 | my $args = {@_}; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 151 | my $field; | |||||||||||||||||||||||||||||||||||||||||
| 96 | my $newItem; | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 151 | ▶ | unless (defined($field)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | 151 | ▶ | $newItem = $args->{object} || $args->{item} || $args->{node}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$args->{'object'} || $args->{'item'} || $args->{'node'}
$args->{"object"} or $args->{"item"}
MC/DC0%0/3
$args->{'object'} || $args->{'item'} || $args->{'node'}
$args->{"object"}
$args->{"item"}
$args->{'node'}
Truth table25%1/4
A or B || C
A= $args->{"object"}B= $args->{"item"}C= $args->{'node'}
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | SWITCH: { | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 151 | ▶ | UNIVERSAL::isa($newItem, "XML::Pastor::Schema::Type") and do {$field="type"; last SWITCH;}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 43 | ▶ | UNIVERSAL::isa($newItem, "XML::Pastor::Schema::Element") and do {$field="element"; last SWITCH;}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 2 | ▶ | UNIVERSAL::isa($newItem, "XML::Pastor::Schema::Group") and do {$field="group"; last SWITCH;}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | UNIVERSAL::isa($newItem, "XML::Pastor::Schema::Attribute") and do {$field="attribute"; last SWITCH;}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 1 | ▶ | UNIVERSAL::isa($newItem, "XML::Pastor::Schema::AttributeGroup") and do {$field="attributeGroup"; last SWITCH;}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 151 | ▶ | unless (defined($field)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | foreach my $arg (qw(type element group attribute attributeGroup)) { | |||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | if (defined ($args->{$arg})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $field = $arg; | |||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $newItem = $args->{$field}; | |||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 151 | ▶ | unless ( defined($field) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 151 | my $items = $self->{$field}; | |||||||||||||||||||||||||||||||||||||||||
| 126 | 151 | ▶ | my $key = UNIVERSAL::can($newItem, "key") ? $newItem->key() : (UNIVERSAL::can($newItem, "name") ? $newItem->name : '_anonymous_'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 151 | ▶ | if (defined(my $oldItem=$items->{$key})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | unless (UNIVERSAL::can($oldItem, 'isRedefinable') && $oldItem->isRedefinable() ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
UNIVERSAL::can($oldItem, "isRedefinable") and $oldItem->isRedefinable
MC/DC0%0/2
UNIVERSAL::can($oldItem, "isRedefinable") and $oldItem->isRedefinable
UNIVERSAL::can($oldItem, "isRedefinable")
$oldItem->isRedefinable
Truth table0%0/3
A and B
A= UNIVERSAL::can($oldItem, "isRedefinable")B= $oldItem->isRedefinable
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | die "Pastor : $field already defined : '$key'\\n"; | |||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||
| 132 | 151 | ▶ | $newItem->isRedefinable(1) if ($args->{operation} !~ /redefine/i) && UNIVERSAL::can($newItem, 'isRedefinable'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $args->{"operation"} =~ /redefine/i and UNIVERSAL::can($newItem, "isRedefinable")
MC/DC0%0/2
not $args->{"operation"} =~ /redefine/i and UNIVERSAL::can($newItem, "isRedefinable")
not $args->{"operation"} =~ /redefine/i
UNIVERSAL::can($newItem, "isRedefinable")
Truth table33%1/3
not(A) and B
A= not $args->{"operation"} =~ /redefine/iB= UNIVERSAL::can($newItem, "isRedefinable")
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 151 | $items->{$key} = $newItem; | |||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | #------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 24 | ▶ | sub addNamespaceUri { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
addNamespaceUri: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 24 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 140 | 24 | my $uri = shift; | |||||||||||||||||||||||||||||||||||||||||
| 141 | 24 | ▶ | my $verbose = $self->{verbose} || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'verbose'} || 0
MC/DC0%0/1
$self->{'verbose'} || 0
$self->{'verbose'}
Truth table50%1/2
A
A= $self->{'verbose'}
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | 24 | ▶ | return undef unless(defined($uri)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 24 | my $nsh = $self->namespaces(); | |||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 24 | ▶ | print STDERR "*** Adding Namespace URI to the schema model => '$uri'\n" if ($verbose >= 5); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | 24 | ▶ | if (exists ($nsh->{$uri})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | # URI is already in use | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 13 | my $ns = $nsh->{$uri}; | |||||||||||||||||||||||||||||||||||||||||
| 152 | 13 | $ns->usageCount($ns->usageCount+1); | |||||||||||||||||||||||||||||||||||||||||
| 153 | 13 | return $ns; | |||||||||||||||||||||||||||||||||||||||||
| 154 | }else { | ||||||||||||||||||||||||||||||||||||||||||
| 155 | # URI is not already there | ||||||||||||||||||||||||||||||||||||||||||
| 156 | 11 | my $nsPfx = undef; | |||||||||||||||||||||||||||||||||||||||||
| 157 | 11 | my $classPfx = undef; | |||||||||||||||||||||||||||||||||||||||||
| 158 | 11 | my $id = 0; | |||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | # The counter serves for id purposes. | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 11 | my $nsc = $self->namespaceCounter(); | |||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | 11 | ▶ | if ($nsc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | # There is at least one other target namespace alreday in there | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 2 | $id = $nsc+1; | |||||||||||||||||||||||||||||||||||||||||
| 166 | 2 | $nsPfx = "ns" . sprintf("%03d", $id); | |||||||||||||||||||||||||||||||||||||||||
| 167 | 2 | $classPfx = $nsPfx; | |||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | # Add the URI to the namspace hash | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 11 | my $ns = XML::Pastor::Schema::NamespaceInfo->new(uri=> $uri, id => $id, usageCount=>1, nsPrefix => $nsPfx, classPrefix => $classPfx); | |||||||||||||||||||||||||||||||||||||||||
| 173 | 11 | $nsh->{$uri} = $ns; | |||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | # This is the first namespace that is declared. Make it the default. | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 11 | ▶ | unless ($nsc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 9 | $self->defaultNamespace($ns); | |||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | # Increment the id counter | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 11 | $self->namespaceCounter( $self->namespaceCounter + 1); | |||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | 11 | return $ns; | |||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | #------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | sub getItem { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getItem: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | my $args = {@_}; | |||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | my $field; | |||||||||||||||||||||||||||||||||||||||||
| 194 | my $itemName; | ||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | unless (defined($field)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | foreach my $arg (qw(type element group attribute attributeGroup)) { | |||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | if (defined ($args->{$arg})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $field = $arg; | |||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | $itemName = $args->{$field}; | |||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | unless ( defined($field) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | my $items = $self->{$field}; | |||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | return $items->{$itemName}; | |||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | #------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | sub dump { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | my $d = Data::Dumper->new([$self]); | |||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | $d->Sortkeys(1); | |||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | # $d->Deepcopy(1); | ||||||||||||||||||||||||||||||||||||||||||
| 221 | # $d->Terse(1); | ||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | return $d->Dump(); | |||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | #------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 226 | 9 | ▶ | sub resolve { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resolve: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | 9 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 228 | 9 | my $opts = {@_}; | |||||||||||||||||||||||||||||||||||||||||
| 229 | 9 | ▶ | my $verbose = $opts->{verbose} || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts->{'verbose'} || 0
MC/DC0%0/1
$opts->{'verbose'} || 0
$opts->{'verbose'}
Truth table50%1/2
A
A= $opts->{'verbose'}
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | 9 | ▶ | print "\n==== Resolving schema model ... ====\n" if ($verbose >= 3); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | 9 | $self->_resolve($opts); | |||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | #------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 237 | 9 | ▶ | sub _resolve { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | 9 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 239 | 9 | my $opts = shift; | |||||||||||||||||||||||||||||||||||||||||
| 240 | 9 | my $hashList = [$self->group(), $self->attributeGroup, $self->type(), $self->element()]; | |||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 9 | foreach my $items (@$hashList) { | |||||||||||||||||||||||||||||||||||||||||
| 243 | 36 | foreach my $name (sort keys %$items) { | |||||||||||||||||||||||||||||||||||||||||
| 244 | 151 | $self->_resolveObject($items->{$name}, $opts); | |||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | #------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 397 | ▶ | sub _resolveObject { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolveObject: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | 397 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 253 | 397 | my $object = shift; | |||||||||||||||||||||||||||||||||||||||||
| 254 | 397 | my $opts = shift; | |||||||||||||||||||||||||||||||||||||||||
| 255 | 397 | ▶ | my $verbose = $opts->{verbose} || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts->{'verbose'} || 0
MC/DC0%0/1
$opts->{'verbose'} || 0
$opts->{'verbose'}
Truth table50%1/2
A
A= $opts->{'verbose'}
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | 397 | $self->_resolveObjectRef($object, $opts); | |||||||||||||||||||||||||||||||||||||||||
| 258 | 397 | ▶ | $self->_resolveObject($object->definition(), $opts) if ($object->definition()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | 397 | $self->_resolveObjectAttributes($object, $opts); | |||||||||||||||||||||||||||||||||||||||||
| 261 | 397 | $self->_resolveObjectElements($object, $opts); | |||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | 397 | $self->_resolveObjectClass($object, $opts); | |||||||||||||||||||||||||||||||||||||||||
| 264 | 397 | $self->_resolveObjectBase($object, $opts); | |||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | 397 | return $object; | |||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | #------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 270 | 397 | ▶ | sub _resolveObjectRef { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolveObjectRef: called CC=12 SCAR=26.2
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | 397 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 272 | 397 | my $object = shift; | |||||||||||||||||||||||||||||||||||||||||
| 273 | 397 | my $opts = shift; | |||||||||||||||||||||||||||||||||||||||||
| 274 | 397 | ▶ | my $verbose = $opts->{verbose} || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts->{'verbose'} || 0
MC/DC0%0/1
$opts->{'verbose'} || 0
$opts->{'verbose'}
Truth table50%1/2
A
A= $opts->{'verbose'}
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | 397 | ▶ | return $object unless ( UNIVERSAL::can($object, "ref") && $object->ref() ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
UNIVERSAL::can($object, "ref") and $object->ref
MC/DC50%1/2
UNIVERSAL::can($object, "ref") and $object->ref
UNIVERSAL::can($object, "ref")
$object->ref
Truth table66%2/3
A and B
A= UNIVERSAL::can($object, "ref")B= $object->ref
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | 40 | ▶ | print STDERR " Resolving REFERENCES for object '" . $object->name . "' ...\n" if ($verbose >= 6); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | 40 | my $field = undef; | |||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | SWITCH: { | ||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | UNIVERSAL::isa($object, "XML::Pastor::Schema::Type") and do {$field="type"; last SWITCH;}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 40 | ▶ | UNIVERSAL::isa($object, "XML::Pastor::Schema::Element") and do {$field="element"; last SWITCH;}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | 2 | ▶ | UNIVERSAL::isa($object, "XML::Pastor::Schema::Group") and do {$field="group"; last SWITCH;}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | UNIVERSAL::isa($object, "XML::Pastor::Schema::Attribute") and do {$field="attribute"; last SWITCH;}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | 1 | ▶ | UNIVERSAL::isa($object, "XML::Pastor::Schema::AttributeGroup") and do {$field="attributeGroup"; last SWITCH;}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | 40 | ▶ | print STDERR " Reference is $field\n" if ($verbose >=9); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | 40 | my $hash = $self->{$field}; | |||||||||||||||||||||||||||||||||||||||||
| 293 | 40 | my $refKey = $object->refKey; | |||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | 40 | ▶ | print STDERR " Resolving reference for '$refKey'\n" if ($verbose >=9); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | 40 | my $def = $hash->{$refKey}; | |||||||||||||||||||||||||||||||||||||||||
| 298 | 40 | $object->definition($def); | |||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | 40 | return $def; | |||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | #------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 305 | 397 | ▶ | sub _resolveObjectClass { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolveObjectClass: called CC=41 SCAR=42.6
| |||||||||||||||||||||||||||||||||||||||||||
| 306 | 397 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 307 | 397 | my $object = shift; | |||||||||||||||||||||||||||||||||||||||||
| 308 | 397 | my $opts = shift; | |||||||||||||||||||||||||||||||||||||||||
| 309 | 397 | ▶ | my $verbose = $opts->{verbose} || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts->{'verbose'} || 0
MC/DC0%0/1
$opts->{'verbose'} || 0
$opts->{'verbose'}
Truth table50%1/2
A
A= $opts->{'verbose'}
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | 397 | $opts->{object} = $object; | |||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | 397 | ▶ | my $class_prefix = $opts->{class_prefix} || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts->{'class_prefix'} || ''
MC/DC0%0/1
$opts->{'class_prefix'} || ''
$opts->{'class_prefix'}
Truth table50%1/2
A
A= $opts->{'class_prefix'}
| |||||||||||||||||||||||||||||||||||||||||||
| 313 | 397 | ▶ | while (($class_prefix) && ($class_prefix !~ /::$/)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$class_prefix and not $class_prefix =~ /::$/
MC/DC50%1/2
$class_prefix and not $class_prefix =~ /::$/
$class_prefix
not $class_prefix =~ /::$/
Truth table66%2/3
A and not(B)
A= $class_prefixB= not $class_prefix =~ /::$/
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | 666 | $class_prefix .= ':'; | |||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | 397 | ▶ | print STDERR " Resolving CLASS for object '" . $object->name . "' ... \n" if ($verbose >= 6); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | 397 | ▶ | if (UNIVERSAL::can($object, "metaClass")) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | 397 | $object->metaClass($class_prefix . "Pastor::Meta"); | |||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | 397 | ▶ | if (UNIVERSAL::isa($object, "XML::Pastor::Schema::Type")) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | 111 | ▶ | print " object '" . $object->name . "' is a Type. Resolving class...\n" if ($verbose >= 7); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 326 | 111 | $object->class($self->_typeToClass($object->name(), $opts)); | |||||||||||||||||||||||||||||||||||||||||
| 327 | ▶ | }elsif (UNIVERSAL::isa($object, "XML::Pastor::Schema::Element") && ($object->scope() =~ /global/)) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
UNIVERSAL::isa($object, "XML::Pastor::Schema::Element") and $object->scope =~ /global/
MC/DC100%2/2
UNIVERSAL::isa($object, "XML::Pastor::Schema::Element") and $object->scope =~ /global/
UNIVERSAL::isa($object, "XML::Pastor::Schema::Element")
$object->scope =~ /global/
Truth table100%3/3
A and B
A= UNIVERSAL::isa($object, "XML::Pastor::Schema::Element")B= $object->scope =~ /global/
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | 79 | ▶ | print " object '" . $object->name . "' is a global element. Resolving class...\n" if ($verbose >= 7); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | 79 | ▶ | my $uri = UNIVERSAL::can($object, 'targetNamespace') ? $object->targetNamespace : ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | 79 | ▶ | my $pfx = $uri ? $self->namespaceClassPrefix($uri) : ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | 79 | $object->class($class_prefix. $pfx . $object->name()); | |||||||||||||||||||||||||||||||||||||||||
| 332 | ▶ | }elsif(UNIVERSAL::can($object, "type") && UNIVERSAL::can($object, "class")) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
UNIVERSAL::can($object, "type") and UNIVERSAL::can($object, "class")
MC/DC0%0/2
UNIVERSAL::can($object, "type") and UNIVERSAL::can($object, "class")
UNIVERSAL::can($object, "type")
UNIVERSAL::can($object, "class")
Truth table33%1/3
A and B
A= UNIVERSAL::can($object, "type")B= UNIVERSAL::can($object, "class")
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | 207 | ▶ | print " object '" . ($object->name || ''). "' 'can' type() and class(). TYPE='". ($object->type() || '') . "' CLASS='" . ($object->class() || '') . "' Resolving class...\n" if ($verbose >= 7); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$object->name || ''
$object->type || ''
$object->class || ''
MC/DC0%0/1
$object->name || ''
$object->name
MC/DC0%0/1
$object->type || ''
$object->type
MC/DC0%0/1
$object->class || ''
$object->class
Truth table0%0/2
A
A= $object->name
Truth table0%0/2
A
A= $object->type
Truth table0%0/2
A
A= $object->class
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | 207 | $object->class($self->_typeToClass($object->type(), $opts)); | |||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | 397 | ▶ | if (UNIVERSAL::can($object, "itemType") && UNIVERSAL::can($object, "itemClass") && $object->itemType) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
UNIVERSAL::can($object, "itemType") and UNIVERSAL::can($object, "itemClass") and $object->itemType
UNIVERSAL::can($object, "itemType") and UNIVERSAL::can($object, "itemClass")
MC/DC66%2/3
UNIVERSAL::can($object, "itemType") and UNIVERSAL::can($object, "itemClass") and $object->itemType
UNIVERSAL::can($object, "itemType")
UNIVERSAL::can($object, "itemClass")
$object->itemType
Truth table75%3/4
A and B and C
A= UNIVERSAL::can($object, "itemType")B= UNIVERSAL::can($object, "itemClass")C= $object->itemType
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | 6 | ▶ | print " object '" . $object->name . "' 'can' itemType() and itemClass(). Resolving class...\n" if ($verbose >= 7); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 340 | 6 | $object->itemClass($self->_typeToClass($object->itemType, $opts)); | |||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | 397 | ▶ | if (UNIVERSAL::can($object, "memberTypes") && UNIVERSAL::can($object, "memberClasses") && $object->memberTypes) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
UNIVERSAL::can($object, "memberTypes") and UNIVERSAL::can($object, "memberClasses") and $object->memberTypes
UNIVERSAL::can($object, "memberTypes") and UNIVERSAL::can($object, "memberClasses")
MC/DC66%2/3
UNIVERSAL::can($object, "memberTypes") and UNIVERSAL::can($object, "memberClasses") and $object->memberTypes
UNIVERSAL::can($object, "memberTypes")
UNIVERSAL::can($object, "memberClasses")
$object->memberTypes
Truth table75%3/4
A and B and C
A= UNIVERSAL::can($object, "memberTypes")B= UNIVERSAL::can($object, "memberClasses")C= $object->memberTypes
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | 12 | ▶ | print " object '" . $object->name . "' 'can' memberTypes() and memberClasses(). Resolving class...\n" if ($verbose >= 7); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 345 | 12 | my @mbts = split ' ', $object->memberTypes; | |||||||||||||||||||||||||||||||||||||||||
| 346 | 12 | $object->memberClasses([map {$self->_typeToClass($_, $opts);} @mbts]); | |||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | 397 | ▶ | if (UNIVERSAL::can($object, "baseClasses")) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 351 | 289 | ▶ | print " object '" . $object->name . "' 'can' baseClasses(). Resolving class...\n" if ($verbose >= 7); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | 289 | ▶ | if (UNIVERSAL::can($object, "base") && $object->base()) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition100%3/3
UNIVERSAL::can($object, "base") and $object->base
MC/DC100%2/2
UNIVERSAL::can($object, "base") and $object->base
UNIVERSAL::can($object, "base")
$object->base
Truth table100%3/3
A and B
A= UNIVERSAL::can($object, "base")B= $object->base
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | 58 | $object->baseClasses([$self->_typeToClass($object->base(), $opts)]); | |||||||||||||||||||||||||||||||||||||||||
| 356 | ▶ | }elsif (UNIVERSAL::isa($object, "XML::Pastor::Schema::Element") | |||||||||||||||||||||||||||||||||||||||||
|
Condition83%5/6
UNIVERSAL::isa($object, "XML::Pastor::Schema::Element") and $object->type and $object->scope =~ /global/
UNIVERSAL::isa($object, "XML::Pastor::Schema::Element") and $object->type
MC/DC66%2/3
UNIVERSAL::isa($object, "XML::Pastor::Schema::Element") and $object->type and $object->scope =~ /global/
UNIVERSAL::isa($object, "XML::Pastor::Schema::Element")
$object->type
$object->scope =~ /global/
Truth table75%3/4
A and B and C
A= UNIVERSAL::isa($object, "XML::Pastor::Schema::Element")B= $object->typeC= $object->scope =~ /global/
| |||||||||||||||||||||||||||||||||||||||||||
| 357 | && $object->type() && ($object->scope() =~ /global/)){ | ||||||||||||||||||||||||||||||||||||||||||
| 358 | 79 | $object->baseClasses([$self->_typeToClass($object->type(), $opts), "XML::Pastor::Element"]); | |||||||||||||||||||||||||||||||||||||||||
| 359 | }elsif ( UNIVERSAL::isa($object, "XML::Pastor::Schema::SimpleType")) { | ||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | my $isa = $opts->{simple_isa}; | |||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | $isa = ( (ref($isa) =~ /ARRAY/) ? $isa : ($isa ? [$isa] : [])); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | $object->baseClasses([@$isa, "XML::Pastor::SimpleType"]); | |||||||||||||||||||||||||||||||||||||||||
| 363 | }elsif ( UNIVERSAL::isa($object, "XML::Pastor::Schema::ComplexType")) { | ||||||||||||||||||||||||||||||||||||||||||
| 364 | 53 | my $isa = $opts->{complex_isa}; | |||||||||||||||||||||||||||||||||||||||||
| 365 | 53 | ▶ | $isa = ( (ref($isa) =~ /ARRAY/) ? $isa : ($isa ? [$isa] : [])); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | 53 | $object->baseClasses([@$isa, "XML::Pastor::ComplexType"]); | |||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | 397 | return $object; | |||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | #------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 375 | 397 | ▶ | sub _resolveObjectAttributes { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolveObjectAttributes: called CC=10 SCAR=23.9
| |||||||||||||||||||||||||||||||||||||||||||
| 376 | 397 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 377 | 397 | my $object = shift; | |||||||||||||||||||||||||||||||||||||||||
| 378 | 397 | my $opts = shift; | |||||||||||||||||||||||||||||||||||||||||
| 379 | 397 | ▶ | my $verbose = $opts->{verbose} || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts->{'verbose'} || 0
MC/DC0%0/1
$opts->{'verbose'} || 0
$opts->{'verbose'}
Truth table50%1/2
A
A= $opts->{'verbose'}
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||
| 381 | 397 | ▶ | return undef unless (UNIVERSAL::can($object, "attributes")); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 382 | 64 | ▶ | print STDERR " Resolving ATTRIBUTES for object '" . $object->name . "' ...\n" if ($verbose >= 6); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | 64 | my $attributes = $object->attributes(); | |||||||||||||||||||||||||||||||||||||||||
| 385 | 64 | my $attribInfo = $object->attributeInfo(); | |||||||||||||||||||||||||||||||||||||||||
| 386 | 64 | my $newAttribs = []; | |||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | 64 | foreach my $attribName (@$attributes) { | |||||||||||||||||||||||||||||||||||||||||
| 389 | 103 | my $attrib = $attribInfo->{$attribName}; | |||||||||||||||||||||||||||||||||||||||||
| 390 | 103 | $self->_resolveObject($attrib, $opts); | |||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | 103 | ▶ | unless (UNIVERSAL::isa($attrib, "XML::Pastor::Schema::Attribute")) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | 1 | ▶ | my $a= (UNIVERSAL::can($attrib, "definition") && $attrib->definition()) || $attrib; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
UNIVERSAL::can($attrib, 'definition') && $attrib->definition || $attrib
UNIVERSAL::can($attrib, "definition") and $attrib->definition
MC/DC0%0/3
UNIVERSAL::can($attrib, 'definition') && $attrib->definition || $attrib
UNIVERSAL::can($attrib, "definition")
$attrib->definition
$attrib
Truth table20%1/5
A and B || C
A= UNIVERSAL::can($attrib, "definition")B= $attrib->definitionC= $attrib
| |||||||||||||||||||||||||||||||||||||||||||
| 394 | 1 | ▶ | push @$newAttribs, @{$a->attributes()} if UNIVERSAL::can($a, "attributes"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 395 | 1 | ▶ | mergeHash($attribInfo,$a->attributeInfo()) if UNIVERSAL::can($a, "attributeInfo"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 396 | }else { | ||||||||||||||||||||||||||||||||||||||||||
| 397 | 102 | push @$newAttribs, $attribName; | |||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | 64 | $object->attributes($newAttribs); | |||||||||||||||||||||||||||||||||||||||||
| 402 | 64 | return $object; | |||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | #------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 406 | 397 | ▶ | sub _resolveObjectElements { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolveObjectElements: called CC=10 SCAR=23.9
| |||||||||||||||||||||||||||||||||||||||||||
| 407 | 397 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 408 | 397 | my $object = shift; | |||||||||||||||||||||||||||||||||||||||||
| 409 | 397 | my $opts = shift; | |||||||||||||||||||||||||||||||||||||||||
| 410 | 397 | ▶ | my $verbose = $opts->{verbose} || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts->{'verbose'} || 0
MC/DC0%0/1
$opts->{'verbose'} || 0
$opts->{'verbose'}
Truth table50%1/2
A
A= $opts->{'verbose'}
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | 397 | ▶ | return undef unless (UNIVERSAL::can($object, "elements")); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||
| 414 | 64 | ▶ | print STDERR " Resolving ELEMENTS for object '" . $object->name . "' ...\n" if ($verbose >= 6); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||
| 416 | 64 | my $elements = $object->elements(); | |||||||||||||||||||||||||||||||||||||||||
| 417 | 64 | my $elemInfo = $object->elementInfo(); | |||||||||||||||||||||||||||||||||||||||||
| 418 | 64 | my $newElems = []; | |||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | 64 | foreach my $elemName (@$elements) { | |||||||||||||||||||||||||||||||||||||||||
| 421 | 100 | my $elem = $elemInfo->{$elemName}; | |||||||||||||||||||||||||||||||||||||||||
| 422 | 100 | $self->_resolveObject($elem, $opts); | |||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||
| 424 | 100 | ▶ | unless (UNIVERSAL::isa($elem, "XML::Pastor::Schema::Element")) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 425 | 1 | ▶ | my $e= (UNIVERSAL::can($elem, "definition") && $elem->definition()) || $elem; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
UNIVERSAL::can($elem, 'definition') && $elem->definition || $elem
UNIVERSAL::can($elem, "definition") and $elem->definition
MC/DC0%0/3
UNIVERSAL::can($elem, 'definition') && $elem->definition || $elem
UNIVERSAL::can($elem, "definition")
$elem->definition
$elem
Truth table20%1/5
A and B || C
A= UNIVERSAL::can($elem, "definition")B= $elem->definitionC= $elem
| |||||||||||||||||||||||||||||||||||||||||||
| 426 | 1 | ▶ | push @$newElems, @{$e->elements()} if UNIVERSAL::can($e, "elements"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 427 | 1 | ▶ | mergeHash($elemInfo,$e->elementInfo()) if UNIVERSAL::can($e, "elementInfo"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 428 | }else { | ||||||||||||||||||||||||||||||||||||||||||
| 429 | 99 | push @$newElems, $elemName; | |||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | 64 | $object->elements($newElems); | |||||||||||||||||||||||||||||||||||||||||
| 434 | 64 | return $object; | |||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | #------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 438 | 397 | ▶ | sub _resolveObjectBase { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolveObjectBase: called CC=13 SCAR=26.0
| |||||||||||||||||||||||||||||||||||||||||||
| 439 | 397 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 440 | 397 | my $object = shift; | |||||||||||||||||||||||||||||||||||||||||
| 441 | 397 | my $opts = shift; | |||||||||||||||||||||||||||||||||||||||||
| 442 | 397 | ▶ | my $verbose = $opts->{verbose} || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts->{'verbose'} || 0
MC/DC0%0/1
$opts->{'verbose'} || 0
$opts->{'verbose'}
Truth table50%1/2
A
A= $opts->{'verbose'}
| |||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||
| 444 | 397 | ▶ | return undef unless (UNIVERSAL::can($object, "base") && $object->base()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
UNIVERSAL::can($object, "base") and $object->base
MC/DC100%2/2
UNIVERSAL::can($object, "base") and $object->base
UNIVERSAL::can($object, "base")
$object->base
Truth table100%3/3
A and B
A= UNIVERSAL::can($object, "base")B= $object->base
| |||||||||||||||||||||||||||||||||||||||||||
| 445 | 58 | ▶ | print STDERR " Resolving BASE for object '" . $object->name . "' ...\n" if ($verbose >= 6); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||
| 448 | 58 | my $base = $object->base(); | |||||||||||||||||||||||||||||||||||||||||
| 449 | 58 | my $types = $self->type(); | |||||||||||||||||||||||||||||||||||||||||
| 450 | 58 | my $baseType = $types->{$base}; | |||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | 58 | ▶ | return undef unless ($baseType); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 454 | 3 | $self->_resolveObject($baseType, $opts); | |||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||
| 457 | 3 | ▶ | if (UNIVERSAL::can($object, "xAttributes")) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 458 | 3 | my $xattribs = []; | |||||||||||||||||||||||||||||||||||||||||
| 459 | 3 | my $xattribInfo = {}; | |||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||
| 461 | 3 | ▶ | if (UNIVERSAL::can($baseType, "effectiveAttributes")) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 462 | 3 | push @$xattribs, @{$baseType->effectiveAttributes()}; | |||||||||||||||||||||||||||||||||||||||||
| 463 | 3 | mergeHash ($xattribInfo, $baseType->effectiveAttributeInfo()); | |||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | 3 | push @$xattribs, @{$object->attributes()}; | |||||||||||||||||||||||||||||||||||||||||
| 467 | 3 | mergeHash ($xattribInfo, $object->attributeInfo()); | |||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||
| 469 | 3 | ▶ | print ' ' . scalar(@$xattribs) . ' attributes. ' if ($verbose >=5); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||
| 471 | 3 | ▶ | if (@$xattribs) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 472 | 3 | $object->xAttributes($xattribs); | |||||||||||||||||||||||||||||||||||||||||
| 473 | 3 | $object->xAttributeInfo($xattribInfo); | |||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | 3 | ▶ | if (UNIVERSAL::can($object, "xElements")) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 478 | 3 | my $xelems = []; | |||||||||||||||||||||||||||||||||||||||||
| 479 | 3 | my $xelemInfo = {}; | |||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||
| 481 | 3 | ▶ | if (UNIVERSAL::can($baseType, "effectiveElements")) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 482 | 3 | push @$xelems, @{$baseType->effectiveElements()}; | |||||||||||||||||||||||||||||||||||||||||
| 483 | 3 | mergeHash ($xelemInfo, $baseType->effectiveElementInfo()); | |||||||||||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||
| 486 | 3 | push @$xelems, @{$object->elements()}; | |||||||||||||||||||||||||||||||||||||||||
| 487 | 3 | mergeHash ($xelemInfo, $object->elementInfo()); | |||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | # print ' ' . scalar(@$xelems) . ' elements. '; | ||||||||||||||||||||||||||||||||||||||||||
| 490 | 3 | ▶ | if (@$xelems) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 491 | 3 | $object->xElements($xelems); | |||||||||||||||||||||||||||||||||||||||||
| 492 | 3 | $object->xElementInfo($xelemInfo); | |||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||
| 496 | 3 | return $object; | |||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | #------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 500 | 493 | ▶ | sub _typeToClass { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_typeToClass: called CC=15 SCAR=28.5
| |||||||||||||||||||||||||||||||||||||||||||
| 501 | 493 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 502 | 493 | my $type = shift; | |||||||||||||||||||||||||||||||||||||||||
| 503 | 493 | my $opts = shift; | |||||||||||||||||||||||||||||||||||||||||
| 504 | 493 | my $object = $opts->{object}; | |||||||||||||||||||||||||||||||||||||||||
| 505 | 493 | ▶ | my $isNonType = $opts->{isNonType} || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts->{'isNonType'} || 0
MC/DC0%0/1
$opts->{'isNonType'} || 0
$opts->{'isNonType'}
Truth table50%1/2
A
A= $opts->{'isNonType'}
| |||||||||||||||||||||||||||||||||||||||||||
| 506 | 493 | ▶ | my $typePfx = $isNonType ? "" : "Type::"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 507 | 493 | my $verbose = 0; | |||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||
| 509 | 493 | ▶ | return undef unless (defined($type)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||
| 511 | 487 | ▶ | my $class_prefix = $opts->{class_prefix} || ""; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts->{'class_prefix'} || ''
MC/DC0%0/1
$opts->{'class_prefix'} || ''
$opts->{'class_prefix'}
Truth table50%1/2
A
A= $opts->{'class_prefix'}
| |||||||||||||||||||||||||||||||||||||||||||
| 512 | 487 | ▶ | while (($class_prefix) && ($class_prefix !~ /::$/)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$class_prefix and not $class_prefix =~ /::$/
MC/DC50%1/2
$class_prefix and not $class_prefix =~ /::$/
$class_prefix
not $class_prefix =~ /::$/
Truth table66%2/3
A and not(B)
A= $class_prefixB= not $class_prefix =~ /::$/
| |||||||||||||||||||||||||||||||||||||||||||
| 513 | 846 | $class_prefix .= ':'; | |||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||
| 516 | 487 | my $builtin_prefix = "XML::Pastor::Builtin::"; | |||||||||||||||||||||||||||||||||||||||||
| 517 | 487 | ▶ | if (($type =~ /^Union$/i) || ($type =~ /^List$/i)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition33%1/3
$type =~ /^Union$/i or $type =~ /^List$/i
MC/DC0%0/2
$type =~ /^Union$/i or $type =~ /^List$/i
$type =~ /^Union$/i
$type =~ /^List$/i
Truth table33%1/3
A or B
A= $type =~ /^Union$/iB= $type =~ /^List$/i
| |||||||||||||||||||||||||||||||||||||||||||
| 518 | # This one is put by the parser. So we don't have a URI for it. | ||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | return $builtin_prefix . ucfirst($type); | |||||||||||||||||||||||||||||||||||||||||
| 520 | }elsif (!$type) { | ||||||||||||||||||||||||||||||||||||||||||
| 521 | # No type declaration, assume string | ||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | return $builtin_prefix . "string"; | |||||||||||||||||||||||||||||||||||||||||
| 523 | }elsif ($type =~ /www.w3.org\/.*\/XMLSchema$/) { | ||||||||||||||||||||||||||||||||||||||||||
| 524 | # Builtin type | ||||||||||||||||||||||||||||||||||||||||||
| 525 | 154 | my ($localType) = split /\|/, $type; | |||||||||||||||||||||||||||||||||||||||||
| 526 | 154 | return $builtin_prefix . $localType; | |||||||||||||||||||||||||||||||||||||||||
| 527 | }elsif ($type =~ /\|/) { | ||||||||||||||||||||||||||||||||||||||||||
| 528 | # Type with a namespace. | ||||||||||||||||||||||||||||||||||||||||||
| 529 | 90 | my ($localType, $uri) = split /\|/, $type; | |||||||||||||||||||||||||||||||||||||||||
| 530 | 90 | my $pfx = $self->namespaceClassPrefix($uri); | |||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||
| 532 | 90 | my $retval = $class_prefix . $pfx . $typePfx . $localType; ; | |||||||||||||||||||||||||||||||||||||||||
| 533 | 90 | ▶ | print STDERR "_typeToClass: from '$type' to '$retval'\n" if ($verbose >=9); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||
| 535 | 90 | return $retval; | |||||||||||||||||||||||||||||||||||||||||
| 536 | #die "Pastor: Namespaces not yet supported!\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 537 | }else { | ||||||||||||||||||||||||||||||||||||||||||
| 538 | # Regular type. | ||||||||||||||||||||||||||||||||||||||||||
| 539 | 243 | ▶ | my $uri = UNIVERSAL::can($object, 'targetNamespace') ? $object->targetNamespace : ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 540 | 243 | ▶ | my $pfx = $uri ? $self->namespaceClassPrefix($uri) : ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 541 | 243 | return $class_prefix . $pfx . $typePfx . $type; | |||||||||||||||||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||
| 546 | #------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 547 | 220 | ▶ | sub namespaceClassPrefix { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
namespaceClassPrefix: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 548 | 220 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 549 | 220 | my $uri = shift; | |||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||
| 551 | 220 | my $ns = $self->namespaces->{$uri}; | |||||||||||||||||||||||||||||||||||||||||
| 552 | 220 | ▶ | my $pfx = defined($ns) ? ($ns->classPrefix() || "") : ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$ns->classPrefix or ""
MC/DC100%1/1
$ns->classPrefix or ""
$ns->classPrefix
Truth table100%2/2
A
A= $ns->classPrefix
| |||||||||||||||||||||||||||||||||||||||||||
| 553 | 220 | ▶ | while (($pfx) && ($pfx !~ /::$/)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$pfx and not $pfx =~ /::$/
MC/DC100%2/2
$pfx and not $pfx =~ /::$/
$pfx
not $pfx =~ /::$/
Truth table100%3/3
A and not(B)
A= $pfxB= not $pfx =~ /::$/
| |||||||||||||||||||||||||||||||||||||||||||
| 554 | 40 | $pfx .= ':'; | |||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||
| 557 | 220 | return $pfx; | |||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||
| 560 | 10 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||
| 562 | __END__ | ||||||||||||||||||||||||||||||||||||||||||