line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XML::Validator::Schema::Attribute; |
2
|
5
|
|
|
5
|
|
24
|
use strict; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
170
|
|
3
|
5
|
|
|
5
|
|
23
|
use warnings; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
166
|
|
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
|
|
|
5
|
|
26
|
use XML::Validator::Schema::Util qw(_attr _err); |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
1494
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new { |
19
|
0
|
|
|
0
|
0
|
|
my ($pkg, %arg) = @_; |
20
|
0
|
|
|
|
|
|
my $self = bless \%arg, $pkg; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# create an attribute based on the contents of an element hash |
24
|
|
|
|
|
|
|
sub parse { |
25
|
0
|
|
|
0
|
0
|
|
my ($pkg, $data) = @_; |
26
|
0
|
|
|
|
|
|
my $self = $pkg->new(); |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my $name = _attr($data, 'name'); |
29
|
0
|
0
|
|
|
|
|
$self->{name} = $name if $name; |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
my $ref = _attr($data, 'ref'); |
32
|
0
|
0
|
|
|
|
|
if ($ref) { |
33
|
0
|
0
|
|
|
|
|
_err("Illegal combination of 'ref' and 'name' in .") |
34
|
|
|
|
|
|
|
if $name; |
35
|
0
|
|
|
|
|
|
$self->{unresolved_ref} = 1; |
36
|
0
|
|
|
|
|
|
$self->{name} = $ref; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
0
|
0
|
0
|
|
|
|
_err("Found with neither 'name' nor 'ref'.") |
40
|
|
|
|
|
|
|
unless $name or $ref; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
my $type_name = _attr($data, 'type'); |
43
|
0
|
0
|
|
|
|
|
if ($type_name) { |
44
|
0
|
|
|
|
|
|
$self->{unresolved_type} = 1; |
45
|
0
|
|
|
|
|
|
$self->{type_name} = $type_name; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# load use, defaults to optional |
49
|
0
|
|
0
|
|
|
|
my $use = _attr($data, 'use') || 'optional'; |
50
|
0
|
0
|
0
|
|
|
|
_err("Invalid 'use' value in : '$use'.") |
51
|
|
|
|
|
|
|
unless $use eq 'optional' or $use eq 'required'; |
52
|
0
|
0
|
|
|
|
|
$self->{required} = $use eq 'required' ? 1 : 0; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
return $self; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|