line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XML::Validator::Schema::Util; |
2
|
6
|
|
|
6
|
|
31
|
use strict; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
258
|
|
3
|
6
|
|
|
6
|
|
32
|
use warnings; |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
390
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
XML::Validator::Schema::Util |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 DESCRIPTION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
This is an internal module containing a few commonly used functions. |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=cut |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
require Exporter; |
16
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
17
|
|
|
|
|
|
|
our @EXPORT_OK = qw(_attr _err XSD); |
18
|
6
|
|
|
6
|
|
1154
|
use XML::SAX::Exception; |
|
6
|
|
|
|
|
3888
|
|
|
6
|
|
|
|
|
268
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# setup an exception class for validation errors |
21
|
|
|
|
|
|
|
@XML::SAX::Exception::Validator::ISA = qw(XML::SAX::Exception); |
22
|
|
|
|
|
|
|
|
23
|
6
|
|
|
6
|
|
36
|
use constant XSD => 'http://www.w3.org/2001/XMLSchema'; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
1286
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# get an attribute value by name, ignoring namespaces |
26
|
|
|
|
|
|
|
sub _attr { |
27
|
30
|
|
|
30
|
|
44
|
my ($data, $name) = @_; |
28
|
30
|
100
|
|
|
|
107
|
return $data->{Attributes}{'{}' . $name}{Value} |
29
|
|
|
|
|
|
|
if exists $data->{Attributes}{'{}' . $name}; |
30
|
25
|
|
|
|
|
25
|
foreach my $attr (keys %{$data->{Attributes}}) { |
|
25
|
|
|
|
|
74
|
|
31
|
15
|
50
|
|
|
|
227
|
return $data->{$attr}->{Value} if $attr =~ /^\{.*?\}$name/; |
32
|
|
|
|
|
|
|
} |
33
|
25
|
|
|
|
|
72
|
return; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# throw a validator exception |
37
|
|
|
|
|
|
|
sub _err { |
38
|
8
|
|
|
8
|
|
64
|
XML::SAX::Exception::Validator->throw(Message => shift); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |