| 1 | package XML::Validator::Schema::Attribute; | ||||||||||||||||||||||||||||
| 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 | =head1 NAME | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | XML::Validator::Schema::Attribute - an attribute node in a schema object | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | This is an internal module used by XML::Validator::Schema to represent | ||||||||||||||||||||||||||||
| 12 | attributes derived from XML Schema documents. | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | =cut | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 5 | ▶ | use XML::Validator::Schema::Util qw(_attr _err); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 27 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 19 | 27 | my ($pkg, %arg) = @_; | |||||||||||||||||||||||||||
| 20 | 27 | my $self = bless \%arg, $pkg; | |||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | # create an attribute based on the contents of an element hash | ||||||||||||||||||||||||||||
| 24 | 27 | ▶ | sub parse { | ||||||||||||||||||||||||||
|
Subroutine
parse: called CC=11 SCAR=24.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 25 | 27 | my ($pkg, $data) = @_; | |||||||||||||||||||||||||||
| 26 | 27 | my $self = $pkg->new(); | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 27 | my $name = _attr($data, 'name'); | |||||||||||||||||||||||||||
| 29 | 27 | ▶ | $self->{name} = $name if $name; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 27 | my $ref = _attr($data, 'ref'); | |||||||||||||||||||||||||||
| 32 | 27 | ▶ | if ($ref) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | 1 | ▶ | _err("Illegal combination of 'ref' and 'name' in <attribute>.") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | if $name; | ||||||||||||||||||||||||||||
| 35 | 1 | $self->{unresolved_ref} = 1; | |||||||||||||||||||||||||||
| 36 | 1 | $self->{name} = $ref; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 27 | ▶ | _err("Found <attribute> with neither 'name' nor 'ref'.") | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$name or $ref
MC/DC0%0/2
$name or $ref
$name
$ref
Truth table66%2/3
A or B
A= $nameB= $ref
| |||||||||||||||||||||||||||||
| 40 | unless $name or $ref; | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 27 | my $type_name = _attr($data, 'type'); | |||||||||||||||||||||||||||
| 43 | 27 | ▶ | if ($type_name) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 21 | $self->{unresolved_type} = 1; | |||||||||||||||||||||||||||
| 45 | 21 | $self->{type_name} = $type_name; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | # load use, defaults to optional | ||||||||||||||||||||||||||||
| 49 | 27 | ▶ | my $use = _attr($data, 'use') || 'optional'; | ||||||||||||||||||||||||||
|
Condition100%2/2
_attr($data, 'use') || 'optional'
MC/DC100%1/1
_attr($data, 'use') || 'optional'
_attr($data, 'use')
Truth table100%2/2
A
A= _attr($data, 'use')
| |||||||||||||||||||||||||||||
| 50 | 27 | ▶ | _err("Invalid 'use' value in <attribute name='$name'>: '$use'.") | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$use eq "optional" or $use eq "required"
MC/DC0%0/2
$use eq "optional" or $use eq "required"
$use eq "optional"
$use eq "required"
Truth table66%2/3
A or B
A= $use eq "optional"B= $use eq "required"
| |||||||||||||||||||||||||||||
| 51 | unless $use eq 'optional' or $use eq 'required'; | ||||||||||||||||||||||||||||
| 52 | 27 | ▶ | $self->{required} = $use eq 'required' ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 27 | return $self; | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 5 | 1; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||