Schema/Util.pm

filter: Statementstmt 100% 24 / 24 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 97.0% 33 / 34 CC 4 SCAR 8.5
CC
4
Cov
96%
_attr
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.3
« Schema.pm ↑ Summary Schema/Node.pm »
1 package XML::Validator::Schema::Util;
2 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
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 6 require Exporter;
16 6 our @ISA = qw(Exporter);
17 6 our @EXPORT_OK = qw(_attr _err XSD);
18 6 ▶use XML::SAX::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 # setup an exception class for validation errors
21 6 @XML::SAX::Exception::Validator::ISA = qw(XML::SAX::Exception);
22  
23 6 ▶use constant XSD => 'http://www.w3.org/2001/XMLSchema';
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 # get an attribute value by name, ignoring namespaces
26 1915 ▶sub _attr {
Subroutine _attr: called CC=4 SCAR=13.9
27 1915 my ($data, $name) = @_;
28 return $data->{Attributes}{'{}' . $name}{Value}
29 1915 ▶ if exists $data->{Attributes}{'{}' . $name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $data->{"Attributes"}{'{}' . $name} 760 1155 1915
30 1155 foreach my $attr (keys %{$data->{Attributes}}) {
31 1428 ▶ return $data->{$attr}->{Value} if $attr =~ /^\{.*?\}$name/;
Branch: 1 branch
BranchTrueFalseTotal
if $attr =~ /^\{.*?\}$name/ 0 1428 1428
32 }
33 1155 return;
34 }
35  
36 # throw a validator exception
37 91 ▶sub _err {
Subroutine _err: called CC=1 SCAR=0.0
38 91 XML::SAX::Exception::Validator->throw(Message => shift);
39 }
40  
41  
42  
43 6 1;
« Schema.pm ↑ Summary Schema/Node.pm »