| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package XML::Validate::Base; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
52
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
482
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
$VERSION = sprintf"%d.%03d", q$Revision: 1.9 $ =~ /: (\d+)\.(\d+)/; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
|
9
|
0
|
|
|
0
|
1
|
|
die "XML::Validate::Base::new must be overridden. (XML::Validate::Base is an abstract class.)"; |
|
10
|
|
|
|
|
|
|
} |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub validate { |
|
13
|
0
|
|
|
0
|
1
|
|
die "XML::Validate::Base::validate must be overridden. (XML::Validate::Base is an abstract class.)"; |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub options { |
|
17
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
18
|
0
|
|
|
|
|
|
return $self->{options}; |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub last_error { |
|
22
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
23
|
0
|
|
|
|
|
|
return $self->{error}; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub add_error { |
|
27
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
28
|
0
|
|
|
|
|
|
my ($error) = @_; |
|
29
|
0
|
|
|
|
|
|
$self->{error} = $error; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub clear_errors { |
|
33
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
34
|
0
|
|
|
|
|
|
$self->{error} = undef; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub set_options { |
|
38
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
39
|
0
|
|
|
|
|
|
my ($supplied_options,$valid_options) = @_; |
|
40
|
0
|
|
|
|
|
|
foreach my $option (keys %{$supplied_options}) { |
|
|
0
|
|
|
|
|
|
|
|
41
|
0
|
0
|
|
|
|
|
if (!_member($option,keys %{$valid_options})) { |
|
|
0
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
die "Unknown option: $option\n"; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
} |
|
45
|
0
|
|
|
|
|
|
$self->{options} = {%{$valid_options},%{$supplied_options}}; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _member { |
|
49
|
0
|
|
|
0
|
|
|
my ($search,@list) = @_; |
|
50
|
0
|
|
|
|
|
|
foreach my $item (@list) { |
|
51
|
0
|
0
|
|
|
|
|
return 1 if $search eq $item; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
0
|
|
|
|
|
|
return 0; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
|
|
0
|
0
|
|
sub TRACE {} |
|
57
|
0
|
|
|
0
|
0
|
|
sub DUMP {} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 NAME |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
XML::Validate::Base - Abstract base class to be used by XML::Validate modules |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
use XML::Validate::Base; |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub new { |
|
70
|
|
|
|
|
|
|
... override new ... |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub validate { |
|
74
|
|
|
|
|
|
|
... override validate ... |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
XML::Validate::Base provides a base class with helpful subs for real |
|
80
|
|
|
|
|
|
|
XML::Validate modules. |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 METHODS |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=over |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item new(%options) |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Constructs a new validator. This method must be overridden. |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item validate($xml) |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Parses and validates $xml. Returns a true value on success, undef on |
|
93
|
|
|
|
|
|
|
failure. This method must be overridden. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item options |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
An accessor for the options hashref. |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item set_options($supplied_options,$valid_options) |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Sets the options for the validator. $supplied_options and $valid_options are |
|
102
|
|
|
|
|
|
|
hash refs containing respectively the options supplied to the constructor and |
|
103
|
|
|
|
|
|
|
the valid options for validator along with their default values. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
If the supplied options hash ref contains an option not listed in valid |
|
106
|
|
|
|
|
|
|
options, this sub throws an exception. |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item last_error |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Returns the error from the last validate call. This is a hash ref with the |
|
111
|
|
|
|
|
|
|
following fields: |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=over |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item * |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
message |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item * |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
line |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item * |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
column |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=back |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Note that the error gets cleared at the beginning of each C call. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item add_error($error) |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Stores $error for retrieval by last_error. $error should be a hash ref. |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item clear_errors |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Clears any errors held by the validator. |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=back |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 VERSION |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
$Revision: 1.9 $ on $Date: 2005/09/06 11:05:08 $ by $Author: johna $ |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 AUTHOR |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Colin Robertson Ecpan _at_ bbc _dot_ co _dot_ ukE |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
(c) BBC 2005. This program is free software; you can redistribute it and/or modify it under the GNU GPL. |
|
152
|
|
|
|
|
|
|
See the file COPYING in this distribution, or http://www.gnu.org/licenses/gpl.txt |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |