File Coverage

blib/lib/XML/Liberal/Remedy/TrailingElements.pm
Criterion Covered Total %
statement 12 13 92.3
branch 5 6 83.3
condition n/a
subroutine 2 2 100.0
pod 0 1 0.0
total 19 22 86.3


line stmt bran cond sub pod time code
1             package XML::Liberal::Remedy::TrailingElements;
2 5     5   2170 use strict;
  5         10  
  5         917  
3              
4             sub apply {
5 55     55 0 91 my $class = shift;
6 55         98 my($driver, $error, $xml_ref) = @_;
7              
8 55 100       107 return 0 if $error->message !~
9             /^parser error : Extra content at the end of the document/;
10              
11 10         91 my $pos = $error->location;
12 10         75 pos($$xml_ref) = $pos;
13 10 50       48 return 0 if $$xml_ref !~ /\G <[-:\w]+ (?:[>\s]|\z)/xms;
14              
15 10         26 while ($pos > 0) {
16 100         123 pos($$xml_ref) = $pos--;
17 100 100       251 return 1 if $$xml_ref =~ s{\G (/]+ \s*>) (.*)}{$2$1}xms;
18             }
19              
20 0           return 0;
21             }
22              
23             1;