| 1 | package XML::Filter::ExceptionLocator; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | our $VERSION = '1.01'; | |||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use base 'XML::SAX::Base'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # from XML::Filter::XInclude | ||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | sub set_document_locator { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_document_locator: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | my ($self, $locator) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | push @{$self->{locators} ||= []}, $locator; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"locators"} ||= []
MC/DC0%0/1
$self->{"locators"} ||= []
$self->{"locators"}
Truth table50%1/2
A
A= $self->{"locators"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | $self->SUPER::set_document_locator($locator); | |||||||||||||||||||||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # install handler for all SAX methods | ||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=8.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | for my $method (qw(start_document end_document start_element | |||||||||||||||||||||||||||||||||||||||||||||
| 20 | end_element processing_instruction comment | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | skipped_entity ignorable_whitespace end_entity | ||||||||||||||||||||||||||||||||||||||||||||||
| 22 | start_entity entity_reference | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | s tart_cdata end_cdata)) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 28 | my $super_meth = "SUPER::$method"; | |||||||||||||||||||||||||||||||||||||||||||||
| 26 | 28 | *{__PACKAGE__ . "::$method"} = | |||||||||||||||||||||||||||||||||||||||||||||
| 27 | 4 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=31.7
| |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # call method in expected context | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 4 | my $wantarray = wantarray; | |||||||||||||||||||||||||||||||||||||||||||||
| 32 | 4 | my (@ret, $ret); | |||||||||||||||||||||||||||||||||||||||||||||
| 33 | 4 | ▶ | if ($wantarray) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | eval { @ret = $self->$super_meth(@_); }; | |||||||||||||||||||||||||||||||||||||||||||||
| 35 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 4 | eval { $ret = $self->$super_meth(@_); }; | |||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | # handle errors | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 4 | my $err = $@; | |||||||||||||||||||||||||||||||||||||||||||||
| 41 | 4 | ▶ | if ($err and ref($err) and $err->isa('XML::SAX::Exception')) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%2/6
$err and ref $err and $err->isa("XML::SAX::Exception")
$err and ref $err
MC/DC0%0/3
$err and ref $err and $err->isa("XML::SAX::Exception")
$err
ref $err
$err->isa("XML::SAX::Exception")
Truth table25%1/4
A and B and C
A= $errB= ref $errC= $err->isa("XML::SAX::Exception")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | # it's showtime, add in Line/Col | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | if ($self->{locators} and @{$self->{locators}}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"locators"} and @{$self->{"locators"};}
MC/DC0%0/2
$self->{"locators"} and @{$self->{"locators"};}
$self->{"locators"}
@{$self->{"locators"};}
Truth table0%0/3
A and B
A= $self->{"locators"}B= @{$self->{"locators"};}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | $err->{LineNumber} = $self->{locators}[-1]->{LineNumber}; | |||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | $err->{ColumnNumber} = $self->{locators}[-1]->{ColumnNumber}; | |||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | die $err; | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | } elsif ($err) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | die $err; | |||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 4 | ▶ | return @ret if $wantarray; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 4 | return $ret; | |||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 28 | } | |||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 59 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||