| 1 | package XML::Validator::Schema::ElementRefNode; | ||||||||||||||||||||||||||||
| 2 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use base 'XML::Validator::Schema::ElementNode'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use XML::Validator::Schema::Util qw(_err _attr); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 5 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | =head1 NAME | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | XML::Validator::Schema::ElementRefNode - an element reference node | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | This is an internal module used by XML::Validator::Schema to represent | ||||||||||||||||||||||||||||
| 17 | an element reference node. | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =cut | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 43 | ▶ | sub parse { | ||||||||||||||||||||||||||
|
Subroutine
parse: called CC=9 SCAR=22.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 22 | 43 | my ($pkg, $data) = @_; | |||||||||||||||||||||||||||
| 23 | 43 | my $self = $pkg->new(); | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 43 | my $ref = _attr($data, 'ref'); | |||||||||||||||||||||||||||
| 26 | 43 | ▶ | croak("Why did you create an ElementRefNode if you didn't have a ref?") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | unless $ref; | ||||||||||||||||||||||||||||
| 28 | 43 | $self->{unresolved_ref} = 1; | |||||||||||||||||||||||||||
| 29 | 43 | $self->name($ref); | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 43 | my $name = _attr($data, 'name'); | |||||||||||||||||||||||||||
| 32 | 43 | ▶ | _err("Found <element> with illegal combination of 'ref' and 'name' ". | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | "attributes.") | ||||||||||||||||||||||||||||
| 34 | if $name; | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 43 | my $type_name = _attr($data, 'type'); | |||||||||||||||||||||||||||
| 37 | 43 | ▶ | _err("Found <element> with illegal combination of 'ref' and 'type' ". | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | "attributes.") | ||||||||||||||||||||||||||||
| 39 | if $type_name; | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 43 | my $min = _attr($data, 'minOccurs'); | |||||||||||||||||||||||||||
| 43 | 43 | ▶ | $min = 1 unless defined $min; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 43 | ▶ | _err("Invalid value for minOccurs '$min' found in <element>.") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | unless $min =~ /^\d+$/; | ||||||||||||||||||||||||||||
| 46 | 43 | $self->{min} = $min; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 43 | my $max = _attr($data, 'maxOccurs'); | |||||||||||||||||||||||||||
| 49 | 43 | ▶ | $max = 1 unless defined $max; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | 43 | ▶ | _err("Invalid value for maxOccurs '$max' found in <element>.") | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$max =~ /^\d+$/ or $max eq "unbounded"
MC/DC0%0/2
$max =~ /^\d+$/ or $max eq "unbounded"
$max =~ /^\d+$/
$max eq "unbounded"
Truth table66%2/3
A or B
A= $max =~ /^\d+$/B= $max eq "unbounded"
| |||||||||||||||||||||||||||||
| 51 | unless $max =~ /^\d+$/ or $max eq 'unbounded'; | ||||||||||||||||||||||||||||
| 52 | 43 | $self->{max} = $max; | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 43 | return $self; | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 5 | 1; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||