| 1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | package PRANG::Graph::Meta::Element; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 9 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 9 | ▶ | use PRANG::Util qw(types_of); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 9 | ▶ | use MooseX::Method::Signatures; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 9 | has 'xmlns' => | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | isa => "Str", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | predicate => "has_xmlns", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 9 | has 'xmlns_attr' => | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | isa => "Str", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | predicate => "has_xmlns_attr", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 9 | has 'xml_nodeName' => | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | isa => "Str|HashRef", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | predicate => "has_xml_nodeName", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 9 | has 'xml_nodeName_prefix' => | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | isa => "HashRef[Str]", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | predicate => "has_xml_nodeName_prefix", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 9 | has 'xml_nodeName_attr' => | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | isa => "Str", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | predicate => "has_xml_nodeName_attr", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 9 | has 'xml_required' => | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | isa => "Bool", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | predicate => "has_xml_required", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 9 | has 'xml_min' => | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | isa => "Int", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | predicate => "has_xml_min", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 9 | has 'xml_max' => | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | isa => "Int", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | predicate => "has_xml_max", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | # FIXME: see commitlog, core Moose should get support for this again | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | # (perhaps) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | #has '+isa' => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | # required => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | # ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | has 'graph_node' => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | isa => "PRANG::Graph::Node", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | default => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 15 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 15 | $self->build_graph_node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 9 | ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 9 | use constant HIGHER_ORDER_TYPE => | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 9 | ▶ | "Moose::Meta::TypeConstraint::Parameterized"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 9 | ▶ | method _error(Str $message) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
Subroutine
__ANON__: not called CC=2 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | my $class = $self->associated_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | my $context = " (Element: "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | if ( $class ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | $context .= $class->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | $context .= "(unassociated)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | $context .= "/".$self->name.") "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | $message.$context; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 9 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 9 | ▶ | method error(Str $message) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
Subroutine
__ANON__: not called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | die $self->_error($message); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 9 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 9 | ▶ | method warn_of(Str $message) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
Subroutine
__ANON__: not called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | warn $self->_error($message)."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 9 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 9 | ▶ | method build_graph_node() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=109 SCAR=66.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 15 | my ($expect_one, $expect_many); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 15 | ▶ | if ( $self->has_xml_required ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 7 | $expect_one = $self->xml_required; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | ▶ | elsif ( $self->has_predicate or | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition83%5/6
$self->has_predicate or $self->has_xml_min and not $self->xml_min
$self->has_xml_min and not $self->xml_min
MC/DC66%2/3
$self->has_predicate or $self->has_xml_min and not $self->xml_min
$self->has_predicate
$self->has_xml_min
not $self->xml_min
Truth table75%3/4
A or B and not(C)
A= $self->has_predicateB= $self->has_xml_minC= not $self->xml_min
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | $self->has_xml_min and !$self->xml_min ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 4 | $expect_one = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 4 | $expect_one = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 15 | ▶ | my $t_c = $self->type_constraint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | or $self->error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | "No type constraint on attribute; did you specify 'isa'?", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | # check to see whether ArrayRef was specified | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 15 | ▶ | if ( $t_c->is_a_type_of("ArrayRef") ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 3 | my $is_paramd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 3 | ▶ | until ( $t_c->equals("ArrayRef") ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 3 | ▶ | if ( $t_c->isa(HIGHER_ORDER_TYPE) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 3 | $is_paramd = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 3 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | $t_c = $t_c->parent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 3 | ▶ | if (not $is_paramd) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | $self->error("ArrayRef, but not Parameterized"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 3 | $expect_many = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 3 | $t_c = $t_c->type_parameter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | ▶ | elsif ( $self->has_xml_max and $self->xml_max > 1 or | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition44%4/9
$self->has_xml_max and $self->xml_max > 1 or $self->has_xml_min and $self->xml_min > 1
$self->has_xml_max and $self->xml_max > 1
$self->has_xml_min and $self->xml_min > 1
MC/DC0%0/4
$self->has_xml_max and $self->xml_max > 1 or $self->has_xml_min and $self->xml_min > 1
$self->has_xml_max
$self->xml_max > 1
$self->has_xml_min
$self->xml_min > 1
Truth table28%2/7
A and B or C and D
A= $self->has_xml_maxB= $self->xml_max > 1C= $self->has_xml_minD= $self->xml_min > 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | $self->has_xml_min and $self->xml_min > 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | $self->error( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | "min/max specified as >1, but type constraint is not an ArrayRef", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | # ok. now let's walk the type constraint tree, and look for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | # types | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 15 | my ($expect_bool, $expect_simple, @expect_type, @expect_role); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 15 | my @st = $t_c; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 15 | my %t_c; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 15 | ▶ | while ( my $x = shift @st ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 21 | $t_c{$x} = $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 21 | ▶ | if ( $x->isa("Moose::Meta::TypeConstraint::Class") ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 7 | push @expect_type, $x->class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | elsif ( $x->isa("Moose::Meta::TypeConstraint::Union") ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 3 | push @st, @{ $x->parents }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | elsif ( $x->isa("Moose::Meta::TypeConstraint::Enum") ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 1 | push @st, $x->parent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | elsif ( $x->isa("Moose::Meta::TypeConstraint::Role") ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # likely to be a wildcard. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 1 | push @expect_role, $x->role; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | elsif ( ref $x eq "Moose::Meta::TypeConstraint" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 9 | ▶ | if ( $x->equals("Bool") ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | $expect_bool = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | elsif ( $x->equals("Value") ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 3 | $expect_simple = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 5 | push @st, $x->parent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | $self->error("Sorry, I don't know how to map a " | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | .ref($x)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 12 | my $node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 12 | ▶ | my $nodeName = $self->has_xml_nodeName ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | $self->xml_nodeName : $self->name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 12 | ▶ | my $nodeName_prefix = $self->has_xml_nodeName_prefix ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | $self->xml_nodeName_prefix : {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 12 | my $nodeName_r_prefix = { reverse %$nodeName_prefix }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 12 | ▶ | my $expect_concrete = ($expect_bool||0) + | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%4/4
$expect_bool || 0
$expect_simple || 0
MC/DC100%1/1
$expect_bool || 0
$expect_bool
MC/DC100%1/1
$expect_simple || 0
$expect_simple
Truth table100%2/2
A
A= $expect_bool
Truth table100%2/2
A
A= $expect_simple
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | ($expect_simple||0) + @expect_type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 12 | ▶ | if ( $expect_concrete > 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | # multiple or ambiguous types are specified; we *need* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | # to know | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | if ( ! ref $nodeName ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | $self->error( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | "type union specified, but no nodename map given" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | while ( my ($nodeName, $type) = each %$nodeName ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | if ( not exists $t_c{$type} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | $self->error( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | "nodeName to type map specifies $nodeName => '$type', but $type is not" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | ." an acceptable type", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 12 | my $prefix_xx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | # plug-in type classes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 12 | ▶ | if ( @expect_role ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 1 | my @users = map { $_->name } types_of(@expect_role); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 1 | ▶ | if ( $self->has_xml_nodeName and !ref $self->xml_nodeName ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->has_xml_nodeName and not ref $self->xml_nodeName
MC/DC0%0/2
$self->has_xml_nodeName and not ref $self->xml_nodeName
$self->has_xml_nodeName
not ref $self->xml_nodeName
Truth table33%1/3
A and not(B)
A= $self->has_xml_nodeNameB= not ref $self->xml_nodeName
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | $self->error( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | "Str value for xml_nodeName incompatible with specifying a role type " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | ."constraint" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 1 | ▶ | $nodeName = {} if !ref $nodeName; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 1 | for my $user ( @users ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 2 | ▶ | if ( $user->does("PRANG::Graph") ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 2 | my $plugin_nodeName = $user->root_element; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 2 | my $xmlns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 2 | ▶ | if ( $xmlns = eval { $user->xmlns }//"" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
eval { // ""
MC/DC0%0/1
eval {
do {
$user->xmlns
}
} // ""
eval {
do {
$user->xmlns
}
}
Truth table50%1/2
A
A= eval {
do {
$user->xmlns
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | if ( not exists $nodeName_r_prefix->{$xmlns} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | $prefix_xx ||= "a"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$prefix_xx ||= "a"
MC/DC0%0/1
$prefix_xx ||= "a"
$prefix_xx
Truth table0%0/2
A
A= $prefix_xx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | $prefix_xx++ while exists $nodeName_prefix->{$prefix_xx}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | $nodeName_prefix->{$prefix_xx} = $xmlns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | $nodeName_r_prefix->{$xmlns} = $prefix_xx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | $plugin_nodeName = "$nodeName_r_prefix->{$xmlns}:$plugin_nodeName"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 2 | ▶ | if ( exists $nodeName->{$plugin_nodeName} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | $self->error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | "Both '$user' and '$nodeName->{$plugin_nodeName}' plug-in type specify nodename $plugin_nodeName".($xmlns ? " (xmlns $xmlns)" : "").", conflict", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 2 | $nodeName->{$plugin_nodeName} = $user; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | $self->error( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | "Can't use one or more of role(s) @expect_role; ".$user->name." needs to consume role PRANG::Graph (hint: did you forget to \"with 'PRANG::Graph';\"?)", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 2 | push @expect_type, $user; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 2 | $expect_concrete++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 1 | $self->xml_nodeName({%$nodeName}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 1 | ▶ | if ( !$self->has_xml_nodeName_prefix and keys %$nodeName_prefix ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $self->has_xml_nodeName_prefix and keys %$nodeName_prefix
MC/DC0%0/2
not $self->has_xml_nodeName_prefix and keys %$nodeName_prefix
not $self->has_xml_nodeName_prefix
keys %$nodeName_prefix
Truth table33%1/3
not(A) and B
A= not $self->has_xml_nodeName_prefixB= keys %$nodeName_prefix
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | $self->xml_nodeName_prefix($nodeName_prefix); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 12 | ▶ | if (!$expect_concrete) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | $self->error( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | "no type(s) specified (or, role evaluated to nothing)", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 12 | ▶ | if ( !ref $nodeName ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 11 | ▶ | my $expected = $expect_bool ? "Bool" : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | $expect_simple ? "Str" : $expect_type[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 11 | $nodeName = { $nodeName => $expected }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 11 | $self->xml_nodeName($nodeName); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | # we will be using 'delete' with nodeName, so copy it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 12 | $nodeName = {%$nodeName}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | # figure out the XML namespace of this node and set it on the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | # attribute | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 12 | my %xmlns_opts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 12 | ▶ | if ( $self->has_xmlns ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 1 | $xmlns_opts{xmlns} = $self->xmlns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 11 | ▶ | my $xmlns = eval { $self->associated_class->name->xmlns } // ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
eval { // ""
MC/DC0%0/1
eval {
do {
$self->associated_class->name->xmlns
}
} // ""
eval {
do {
$self->associated_class->name->xmlns
}
}
Truth table50%1/2
A
A= eval {
do {
$self->associated_class->name->xmlns
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 11 | ▶ | $xmlns_opts{xmlns} = $xmlns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | if $xmlns; # FIXME - should *always* set it! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 12 | ▶ | if ( $self->has_xmlns_attr ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | $xmlns_opts{xmlns_attr} = $self->xmlns_attr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | my $prefix_xmlns = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 4 | ▶ | my $name = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=21.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 4 | ▶ | if ( $nodeName_prefix and $name =~ /^(\w+):(\w+)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$nodeName_prefix and $name =~ /^(\w+):(\w+)/
MC/DC0%0/2
$nodeName_prefix and $name =~ /^(\w+):(\w+)/
$nodeName_prefix
$name =~ /^(\w+):(\w+)/
Truth table33%1/3
A and B
A= $nodeName_prefixB= $name =~ /^(\w+):(\w+)/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | my %this_xmlns_opts = %xmlns_opts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | my $xmlns = $nodeName_prefix->{$1} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | or die "unknown prefix '$1' used on attribute ".$self->name." of ".eval{$self->associated_class->name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | $this_xmlns_opts{xmlns} = $xmlns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ($2, \%this_xmlns_opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 4 | ($name, \%xmlns_opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 12 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 12 | my @expect; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 12 | for my $class ( @expect_type ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 8 | my (@names) = grep { $nodeName->{$_} eq $class } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | keys %$nodeName; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | # auto-load the classes now... save problems later | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 8 | ▶ | if ( !eval{ $class->meta->can("marshall_in_element") } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 8 | ▶ | my $ok = eval "use $class; 1"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 8 | ▶ | if ( !$ok ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | die "problem auto-including class '$class'; (hint: did you expect '$class' to be a subtype, but forget to define it before it was used or not use BEGIN { } appropriately?); exception is: $@"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 8 | ▶ | if ( !eval{ $class->meta->can("marshall_in_element") } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 8 | die "'$class' can't marshall in; did you 'use PRANG::Graph'?"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | if ( !@names ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | die "type '$class' specified as allowed on '" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | .$self->name."' element of ".$self->associated_class->name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | .", but which node names indicate that type? You've defined: " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | .($self->has_xml_nodeName | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | ? ( ref $self->xml_nodeName | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ? join("; ", map { "$_ => ".$self->xml_nodeName->{$_} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | sort keys %{$self->xml_nodeName} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | : ("(all '".$self->xml_nodeName."')") ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | : "(nothing)" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | for my $name ( @names ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | my ($nn, $xmlns_args) = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | $prefix_xmlns->($name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | push @expect, PRANG::Graph::Element->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | %$xmlns_args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | attrName => $self->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | nodeClass => $class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | nodeName => $nn, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | delete $nodeName->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 4 | ▶ | if ( $expect_bool ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | my (@names) = grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 1 | !$t_c{$nodeName->{$_}}->is_a_type_of("Object") | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | } keys %$nodeName; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | # 'Bool' elements are a shorthand for the element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | # 'maybe' being there. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 1 | for my $name ( @names ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 1 | my ($nn, $xmlns_args) = $prefix_xmlns->($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 1 | push @expect, PRANG::Graph::Element->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | %$xmlns_args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | attrName => $self->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | attIsArray => $expect_many, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | nodeName => $nn, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 1 | delete $nodeName->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 4 | ▶ | if ( $expect_simple ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | my (@names) = grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 3 | my $t_c = $t_c{$nodeName->{$_}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 3 | ▶ | die "dang, ".$self->name." of ".$self->associated_class->name.", no type constraint called $nodeName->{$_} (element $_)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | if !$t_c; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 3 | !$t_c->is_a_type_of("Object") | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } keys %$nodeName; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 3 | for my $name ( @names ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | # 'Str', 'Int', etc element attributes: this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | # means an XML data type: <attr>value</attr> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 3 | ▶ | if ( !length($name) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | # this is for 'mixed' data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | push @expect, PRANG::Graph::Text->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | attrName => $self->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | # regular XML data style | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 3 | my ($nn, $xmlns_args) = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | $prefix_xmlns->($name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 3 | push @expect, PRANG::Graph::Element->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | %$xmlns_args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | attrName => $self->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | nodeName => $nn, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | contents => PRANG::Graph::Text->new, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 3 | delete $nodeName->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | # determine if we need explicit attributes to record the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | # nodename and/or XML namespace. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | # first rule. If multiple prefix:nodeName entries map to the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | # same type, then we would have an ambiguous type map, and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | # therefore need at least one of name_attr and xmlns_attr | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 4 | my $have_ambiguous; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 4 | my (%seen_types, %seen_xmlns, %seen_localname); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 4 | my $fixed_xmlns = $self->xmlns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 4 | my $use_prefixes = $self->has_xml_nodeName_prefix; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 4 | ▶ | if ( $fixed_xmlns and $use_prefixes ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$fixed_xmlns and $use_prefixes
MC/DC0%0/2
$fixed_xmlns and $use_prefixes
$fixed_xmlns
$use_prefixes
Truth table33%1/3
A and B
A= $fixed_xmlnsB= $use_prefixes
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | $self->error("specify only one of 'xmlns' / 'xml_nodeName_prefix' (note: latter may be implied by use of roles)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 4 | ▶ | while ( my ($element_fullname, $class) = each %{$self->xml_nodeName}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 4 | my ($xmlns, $localname); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 4 | ▶ | if ( $use_prefixes ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | (my $prefix, $localname) = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | ($element_fullname =~ /^(?:(\w+):)?(\w+|\*)/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | $prefix //= ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$prefix //= ""
MC/DC0%0/1
$prefix //= ""
$prefix
Truth table0%0/2
A
A= $prefix
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | ▶ | $xmlns = $nodeName_prefix->{$prefix}//""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$nodeName_prefix->{$prefix} // ""
MC/DC0%0/1
$nodeName_prefix->{$prefix} // ""
$nodeName_prefix->{$prefix}
Truth table0%0/2
A
A= $nodeName_prefix->{$prefix}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 4 | $localname = $element_fullname; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 4 | ▶ | $xmlns = $fixed_xmlns//""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$fixed_xmlns // ""
MC/DC0%0/1
$fixed_xmlns // ""
$fixed_xmlns
Truth table50%1/2
A
A= $fixed_xmlns
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 4 | ▶ | $localname //= ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$localname //= ""
MC/DC0%0/1
$localname //= ""
$localname
Truth table50%1/2
A
A= $localname
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 4 | $seen_localname{$localname}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 4 | $seen_xmlns{$xmlns}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 4 | ▶ | $have_ambiguous++ if $localname eq "*"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 4 | ▶ | $have_ambiguous++ if $xmlns eq "*"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 4 | my $ent = [ $xmlns, $localname ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 4 | ▶ | if ( my $aref = $seen_types{$class} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | $have_ambiguous++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | push @$aref, $ent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 4 | $seen_types{$class} = [ $ent ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | # if all nodes have the same localname, we can use just | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | # xmlns_attr. if all nodes have the same xmlns, we can use | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | # just name_attr | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 4 | my @name_attr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 4 | ▶ | if ( $have_ambiguous ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | if ( keys %seen_localname > 1 or $seen_localname{"*"} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
keys %seen_localname > 1 or $seen_localname{"*"}
MC/DC0%0/2
keys %seen_localname > 1 or $seen_localname{"*"}
keys %seen_localname > 1
$seen_localname{"*"}
Truth table0%0/3
A or B
A= keys %seen_localname > 1B= $seen_localname{"*"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | if ( !$self->has_xml_nodeName_attr ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | $self->error( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | "xml_nodeName map ambiguities or wildcarding imply need for " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | ."xml_nodeName_attr, but none given", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | my $attr = $self->xml_nodeName_attr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | push @name_attr, name_attr => $attr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | for my $x ( @expect ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | $x->nodeName_attr($attr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | push @name_attr, xml_nodeName => (keys %seen_localname)[0]//""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
(keys %seen_localname)[0] // ""
MC/DC0%0/1
(keys %seen_localname)[0] // ""
(keys %seen_localname)[0]
Truth table0%0/2
A
A= (keys %seen_localname)[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | if ( keys %seen_xmlns > 1 or $seen_xmlns{"*"} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
keys %seen_xmlns > 1 or $seen_xmlns{"*"}
MC/DC0%0/2
keys %seen_xmlns > 1 or $seen_xmlns{"*"}
keys %seen_xmlns > 1
$seen_xmlns{"*"}
Truth table0%0/3
A or B
A= keys %seen_xmlns > 1B= $seen_xmlns{"*"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | if ( !$self->has_xmlns_attr ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | $self->error( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | "xml_nodeName map ambiguities or wildcarding imply need for " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | ."xmlns_attr, but none given", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | my $attr = $self->xmlns_attr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | push @name_attr, xmlns_attr => $attr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | for my $x ( @expect ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | $x->xmlns_attr($attr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | ▶ | push @name_attr, xmlns => (keys %seen_xmlns)[0]//""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
(keys %seen_xmlns)[0] // ""
MC/DC0%0/1
(keys %seen_xmlns)[0] // ""
(keys %seen_xmlns)[0]
Truth table0%0/2
A
A= (keys %seen_xmlns)[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | ▶ | elsif ( $self->has_xmlns_attr or $self->has_xml_nodeName_attr ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->has_xmlns_attr or $self->has_xml_nodeName_attr
MC/DC0%0/2
$self->has_xmlns_attr or $self->has_xml_nodeName_attr
$self->has_xmlns_attr
$self->has_xml_nodeName_attr
Truth table33%1/3
A or B
A= $self->has_xmlns_attrB= $self->has_xml_nodeName_attr
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | $self->error("unnecessary use of xmlns_attr / xml_nodeName_attr"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | elsif ( $self->has_xml_nodeName ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 4 | push @name_attr, type_map => {%{$self->xml_nodeName}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 4 | ▶ | if ( $self->has_xml_nodeName_prefix ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | push @name_attr, type_map_prefix => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | {%{$self->xml_nodeName_prefix}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 4 | ▶ | if ( @expect > 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | $node = PRANG::Graph::Choice->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | choices => \@expect, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | attrName => $self->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | @name_attr, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 4 | $node = $expect[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 4 | ▶ | if ( $self->has_xml_nodeName_attr ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | $node->nodeName_attr($self->xml_nodeName_attr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 4 | ▶ | if ( $expect_bool ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 1 | $expect_one = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 4 | ▶ | if ( $expect_one and !$expect_simple and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition44%4/9
$expect_one and not $expect_simple and not $self->is_required and not $self->has_default
$expect_one and not $expect_simple and not $self->is_required
$expect_one and not $expect_simple
MC/DC0%0/4
$expect_one and not $expect_simple and not $self->is_required and not $self->has_default
$expect_one
not $expect_simple
not $self->is_required
not $self->has_default
Truth table40%2/5
A and not(B) and not(C) and not(D)
A= $expect_oneB= not $expect_simpleC= not $self->is_requiredD= not $self->has_default
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | !$self->is_required and !$self->has_default ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | $self->warn_of( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | "expected element is not required, this can cause errors on marshall out" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | # deal with limits | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 4 | ▶ | if ( !$expect_one or $expect_many) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $expect_one or $expect_many
MC/DC50%1/2
not $expect_one or $expect_many
not $expect_one
$expect_many
Truth table66%2/3
not(A) or B
A= not $expect_oneB= $expect_many
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 3 | my @min_max; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 3 | ▶ | if ( $expect_one and !$self->has_xml_min ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$expect_one and not $self->has_xml_min
MC/DC0%0/2
$expect_one and not $self->has_xml_min
$expect_one
not $self->has_xml_min
Truth table33%1/3
A and not(B)
A= $expect_oneB= not $self->has_xml_min
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | $self->xml_min(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 3 | ▶ | if ( $self->has_xml_min ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 1 | push @min_max, min => $self->xml_min; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 3 | ▶ | if ( !$expect_many and !$self->has_xml_max ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$expect_many or $self->has_xml_max
MC/DC0%0/2
$expect_many or $self->has_xml_max
$expect_many
$self->has_xml_max
Truth table33%1/3
A or B
A= $expect_manyB= $self->has_xml_max
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 3 | $self->xml_max(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 3 | ▶ | if ( $self->has_xml_max ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 3 | push @min_max, max => $self->xml_max; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 3 | ▶ | die "no node! fail! processing ".$self->associated_class->name.", element ".$self->name unless $node; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 3 | $node = PRANG::Graph::Quantity->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | @min_max, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | attrName => $self->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | child => $node, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 1 | $self->xml_min(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 1 | $self->xml_max(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 4 | return $node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 9 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | package Moose::Meta::Attribute::Custom::Trait::PRANG::Element; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | sub register_implementation { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 8 | ▶ | "PRANG::Graph::Meta::Element"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
register_implementation: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 9 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | PRANG::Graph::Meta::Element - metaclass metarole for XML elements | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | use PRANG::Graph; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | has_element 'somechild' => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | isa => "Some::Type", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | xml_required => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | # equivalent alternative - plays well with others! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | has 'somechild' => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | traits => [qw/PRANG::Element/], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | isa => "Some::Type", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | xml_required => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | The PRANG concept is that attributes in your classes are marked to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | correspond with attributes and elements in your XML. This class is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | for marking your class' attributes as XML I<elements>. For marking | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | them as XML I<attributes>, see L<PRANG::Graph::Meta::Attr>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | Non-trivial elements - and this means elements which contain more than | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | a single TextNode element within - are mapped to Moose classes. The | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | child elements that are allowed within that class correspond to the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | attributes marked with the C<PRANG::Element> trait, either via | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | C<has_element> or the Moose C<traits> keyword. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | Where it makes sense, as much as possible is set up from the regular | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | Moose definition of the attribute. This includes the XML node name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | the type constraint, and also the predicate. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | If you like, you can also set the C<xmlns> and C<xml_nodeName> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | attribute property, to override the default behaviour, which is to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | assume that the XML element name matches the Moose attribute name, and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | that the XML namespace of the element is that of the enclosing class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | (ie, C<$class-E<gt>xmlns>), if defined. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | The B<order> of declaring element attributes is important. They | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | implicitly define a "sequence". To specify a "choice", you must use a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | union sub-type - see below. Care must be taken with bundling element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | attributes into roles as ordering when composing is not defined. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | The B<predicate> property of the attribute is also important. If you | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | do not define C<predicate>, then the attribute is considered | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | I<required>. This can be overridden by specifying C<xml_required> (it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | must be defined to be effective). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | The B<isa> property (B<type constraint>) you set via 'isa' is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | I<required>. The behaviour for major types is described below. The | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | module knows about sub-typing, and so if you specify a sub-type of one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | of these types, then the behaviour will be as for the type on this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | list. Only a limited subset of higher-order/parametric/structured | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | types are permitted as described. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | =item B<Bool sub-type> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | If the attribute is a Bool sub-type (er, or just "Bool", then the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | element will marshall to the empty element if true, or no element if | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | false. The requirement that C<predicate> be defined is relaxed for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | C<Bool> sub-types. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | ie, C<Bool> will serialise to: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | <object> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | <somechild /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | </object> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | For true and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | <object> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | </object> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | For false. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | =item B<Scalar sub-type> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | If it is a Scalar subtype (eg, an enum, a Str or an Int), then the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | value of the Moose attribute is marshalled to the value of the element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | as a TextNode; eg | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | <somechild>somevalue</somechild> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | =item B<Object sub-type> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | If the attribute is an Object subtype (ie, a Class), then the element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | is serialised according to the definition of the Class defined. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | eg, with; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | package CD; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | use Moose; use PRANG::Graph; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | has_element 'author' => qw( is rw isa Person ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | has_attr 'name' => qw( is rw isa Str ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | package Person; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | use Moose; use PRANG::Graph; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | has_attr 'group' => qw( is rw isa Bool ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | has_attr 'name' => qw( is rw isa Str ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | has_element 'deceased' => qw( is rw isa Bool ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | Then the object; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | CD->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | name => "2Pacalypse Now", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | author => Person->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | group => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | name => "Tupac Shakur", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | deceased => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | Would serialise to (assuming that there is a L<PRANG::Graph> document | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | type with C<cd> as a root element): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | <cd name="2Pacalypse Now"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | <author group="0" name="Tupac Shakur> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | <deceased /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | </author> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | </cd> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | =item B<ArrayRef sub-type> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | An C<ArrayRef> sub-type indicates that the element may occur multiple | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | times at this point. Bounds may be specified directly - the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | C<xml_min> and C<xml_max> attribute properties. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | Higher-order types are supported; in fact, to not specify the type of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | the elements of the array is a big no-no. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | If C<xml_nodeName> is specified, it refers to the items; no array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | container node is expected. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | For example; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | has_attr 'name' => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | isa => "Str", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | has_attr 'releases' => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | isa => "ArrayRef[CD]", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | xml_min => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | xml_nodeName => "cd", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | Assuming that this property appeared in the definition for 'artist', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | and that CD C<has_attr 'title'...>, it would let you parse: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | <artist> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | <name>The Headless Chickens</name> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | <cd title="Stunt Clown">...<cd> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | <cd title="Body Blow">...<cd> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | <cd title="Greedy">...<cd> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | </artist> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | You cannot (currently) Union an ArrayRef type with other simple types. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | =item B<Union types> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | Union types are special; they indicate that any one of the types | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | indicated may be expected next. By default, the name of the element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | is still the name of the Moose attribute, and if the case is that a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | particular element may just be repeated any number of times, this is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | fine. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | However, this can be inconvenient in the typical case where the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | alternation is between a set of elements which are allowed in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | particular context, each corresponding to a particular Moose type. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | Another one is the case of mixed XML, where there may be text, then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | XML fragments, more text, more XML, etc. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | There are two relevant questions to answer. When marshalling OUT, we | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | want to know what element name to use for the attribute in the slot. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | When marshalling IN, we need to know what element names are allowable, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | and potentially which sub-type to expect for a particular element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | After applying much DWIMery, the following scenarios arise; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | =item B<1:1 mapping from Type to Element name> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | This is often the case for message containers that allow any number of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | a collection of classes inside. For this case, a map must be provided | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | to the C<xml_nodeName> function, which allows marshalling in and out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | to proceed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | has_element 'message' => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | isa => "my::unionType", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | xml_nodeName => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | "nodename" => "TypeA", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | "somenode" => "TypeB", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | It is an error if types are repeated in the map. The empty string can | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | be used as a node name for text nodes, otherwise they are not allowed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | This case is made of win because no extra attributes are required to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | help the marshaller; the type of the data is enough. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | An example of this in practice; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | subtype "My::XML::Language::choice0" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | => as join("|", map { "My::XML::Language::$_" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | qw( CD Store Person ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | has_element 'things' => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | isa => "ArrayRef[My::XML::Language::choice0]", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | xml_nodeName => +{ map {( lc($_) => $_ )} qw(CD Store Person) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | This would allow the enclosing class to have a 'things' property, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | which contains all of the elements at that point, which can be C<cd>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | C<store> or C<person> elements. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | In this case, it may be preferrable to pass a role name as the element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | type, and let this module evaluate construct the C<xml_nodeName> map | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | =item B<more types than element names> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | This happens when some of the types have different XML namespaces; the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | type of the node is indicated by the namespace prefix. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | In this case, you must supply a namespace map, too. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | has_element 'message' => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | isa => "my::unionType", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | xml_nodeName => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | "trumpery:nodename" => "TypeA", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | "rubble:nodename" => "TypeB", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | "claptrap:nodename" => "TypeC", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | xml_nodeName_prefix => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | "trumpery" => "uri:type:A", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | "rubble" => "uri:type:B", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | "claptrap" => "uri:type:C", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | B<FIXME:> this is currently unimplemented. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | =item B<more element names than types> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | This can happen for two reasons: one is that the schema that this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | element definition comes from is re-using types. Another is that you | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | are just accepting XML without validation (eg, XMLSchema's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | C<processContents="skip"> property). In this case, there needs to be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | another attribute which records the names of the node. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | has_element 'message' => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | isa => "my::unionType", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | xml_nodeName => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | "nodename" => "TypeA", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | "somenode" => "TypeB", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | "someother" => "TypeB", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | xml_nodeName_attr => "message_name", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | If any node name is allowed, then you can simply pass in C<*> as an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | C<xml_nodeName> value. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | =item B<more namespaces than types> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | The principle use of this is L<PRANG::XMLSchema::Whatever>, which | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | converts arbitrarily namespaced XML into objects. In this case, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | another attribute is needed, to record the XML namespaces of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | elements. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | has 'nodenames' => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | isa => "ArrayRef[Maybe[Str]]", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | has 'nodenames_xmlns' => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | isa => "ArrayRef[Maybe[Str]]", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | has_element 'contents' => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | isa => "ArrayRef[PRANG::XMLSchema::Whatever|Str]", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | xml_nodeName => { "" => "Str", "*" => "PRANG::XMLSchema::Whatever" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | xml_nodeName_attr => "nodenames", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | xmlns => "*", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | xmlns_attr => "nodenames_xmlns", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | B<FIXME:> this is currently unimplemented. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | =item B<unknown/extensible element names and types> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | These are indicated by specifying a role. At the time that the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | L<PRANG::Graph::Node> is built for the attribute, the currently | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | available implementors of these roles are checked, which must all | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | implement L<PRANG::Graph>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | They Treated as if there is an C<xml_nodeName> entry for the class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | from the C<root_element> value for the class to the type. This allows | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | writing extensible schemas. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | L<PRANG::Graph::Meta::Attr>, L<PRANG::Graph::Meta::Element>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | L<PRANG::Graph::Node> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | =head1 AUTHOR AND LICENCE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | Development commissioned by NZ Registry Services, and carried out by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | Catalyst IT - L<http://www.catalyst.net.nz/> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | Copyright 2009, 2010, NZ Registry Services. This module is licensed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | under the Artistic License v2.0, which permits relicensing under other | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | Free Software licenses. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||