| 1 | package XML::Validator::Schema::Library; | ||||||||||||
| 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 | 6 | ▶ | use XML::Validator::Schema::Util qw(XSD _err); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 6 | ▶ | use Carp qw(croak); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | |||||||||||||
| 8 | =head1 NAME | ||||||||||||
| 9 | |||||||||||||
| 10 | XML::Validator::Schema::TypeLibrary | ||||||||||||
| 11 | |||||||||||||
| 12 | =head1 DESCRIPTION | ||||||||||||
| 13 | |||||||||||||
| 14 | Internal base class used to implement a libraries of named items. | ||||||||||||
| 15 | |||||||||||||
| 16 | =cut | ||||||||||||
| 17 | |||||||||||||
| 18 | 154 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||
| 19 | 154 | my $pkg = shift; | |||||||||||
| 20 | 154 | my $self = bless({@_}, $pkg); | |||||||||||
| 21 | |||||||||||||
| 22 | croak("Missing required 'what' parameter.") | ||||||||||||
| 23 | 154 | ▶ | unless $self->{what}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 24 | |||||||||||||
| 25 | # initialize stacks | ||||||||||||
| 26 | 154 | $self->{stacks} = {}; | |||||||||||
| 27 | |||||||||||||
| 28 | 154 | return $self; | |||||||||||
| 29 | } | ||||||||||||
| 30 | |||||||||||||
| 31 | 0 | ▶ | sub find_all { | ||||||||||
|
Subroutine
find_all: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||
| 32 | 0 | my $self = shift; | |||||||||||
| 33 | 0 | my @ret; | |||||||||||
| 34 | 0 | foreach my $ns (keys %{$self->{stacks}}) { | |||||||||||
| 35 | 0 | foreach my $name (keys %{$self->{$ns}}) { | |||||||||||
| 36 | 0 | push @ret, $self->{stacks}{$ns}{$name}; | |||||||||||
| 37 | } | ||||||||||||
| 38 | } | ||||||||||||
| 39 | 0 | return @ret; | |||||||||||
| 40 | } | ||||||||||||
| 41 | |||||||||||||
| 42 | 485 | ▶ | sub find { | ||||||||||
|
Subroutine
find: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||
| 43 | 485 | my ($self, %arg) = @_; | |||||||||||
| 44 | 485 | ▶ | croak("Missing required name parameter.") unless $arg{name}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 45 | |||||||||||||
| 46 | # HACK: fix when QName resolution works | ||||||||||||
| 47 | 485 | $arg{name} =~ s!^[^:]*:!!; | |||||||||||
| 48 | 485 | ▶ | $arg{ns} ||= XSD; | ||||||||||
|
Condition50%1/2
$arg{"ns"} ||= "http://www.w3.org/2001/XMLSchema"
MC/DC0%0/1
$arg{"ns"} ||= "http://www.w3.org/2001/XMLSchema"
$arg{"ns"}
Truth table50%1/2
A
A= $arg{"ns"}
| |||||||||||||
| 49 | |||||||||||||
| 50 | 485 | return $self->{stacks}{$arg{ns}}{$arg{name}}; | |||||||||||
| 51 | } | ||||||||||||
| 52 | |||||||||||||
| 53 | 107 | ▶ | sub add { | ||||||||||
|
Subroutine
add: called CC=5 SCAR=17.0
Pod
undocumented
| |||||||||||||
| 54 | 107 | my ($self, %arg) = @_; | |||||||||||
| 55 | 107 | ▶ | croak("Missing required name parameter.") unless $arg{name}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 56 | 107 | ▶ | croak("Missing required obj parameter.") unless $arg{obj}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 57 | |||||||||||||
| 58 | # HACK: fix when QName resolution works | ||||||||||||
| 59 | 107 | $arg{name} =~ s!^\w+:!!; | |||||||||||
| 60 | 107 | ▶ | $arg{ns} ||= XSD; | ||||||||||
|
Condition50%1/2
$arg{"ns"} ||= "http://www.w3.org/2001/XMLSchema"
MC/DC0%0/1
$arg{"ns"} ||= "http://www.w3.org/2001/XMLSchema"
$arg{"ns"}
Truth table50%1/2
A
A= $arg{"ns"}
| |||||||||||||
| 61 | |||||||||||||
| 62 | _err("Illegal attempt to redefine $self->{what} '$arg{name}' ". | ||||||||||||
| 63 | "in namespace '$arg{ns}'") | ||||||||||||
| 64 | 107 | ▶ | if exists $self->{stacks}{$arg{ns}}{$arg{name}}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 65 | 107 | $self->{stacks}{$arg{ns}}{$arg{name}} = $arg{obj}; | |||||||||||
| 66 | } | ||||||||||||
| 67 | |||||||||||||
| 68 | 6 | 1; | |||||||||||