File Coverage

blib/lib/XML/Liberal/Remedy/StandaloneAttribute.pm
Criterion Covered Total %
statement 11 11 100.0
branch 2 2 100.0
condition n/a
subroutine 3 3 100.0
pod 0 1 0.0
total 16 17 94.1


line stmt bran cond sub pod time code
1             package XML::Liberal::Remedy::StandaloneAttribute;
2 5     5   2083 use strict;
  5         8  
  5         124  
3              
4 5     5   26 use List::Util qw( min );
  5         8  
  5         675  
5              
6             sub apply {
7 86     86 0 120 my $class = shift;
8 86         144 my($driver, $error, $xml_ref) = @_;
9              
10 86 100       167 my ($attr) = $error->message =~
11             /^parser error : Specification mandates? value for attribute (\w+)/
12             or return 0;
13              
14             # In input like "
", the error location points to the slash
15             # -- the first non-whitespace character after the attribute name. We
16             # can just insert an attribute value at that point; no need to look
17             # backwards for where the attribute name starts or ends.
18 21         254 substr $$xml_ref, $error->location, 0, qq[="$attr" ];
19 21         217 return 1;
20             }
21              
22             1;