File Coverage

blib/lib/XML/Liberal/Remedy/StandaloneAttribute.pm
Criterion Covered Total %
statement 6 11 54.5
branch 0 2 0.0
condition n/a
subroutine 2 3 66.6
pod 0 1 0.0
total 8 17 47.0


line stmt bran cond sub pod time code
1             package XML::Liberal::Remedy::StandaloneAttribute;
2 2     2   1323 use strict;
  2         4  
  2         62  
3              
4 2     2   10 use List::Util qw( min );
  2         4  
  2         323  
5              
6             sub apply {
7 0     0 0   my $class = shift;
8 0           my($driver, $error, $xml_ref) = @_;
9              
10 0 0         my ($attr) = $error->message =~
11             /^parser error : Specification mandate 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 0           substr $$xml_ref, $error->location, 0, qq[="$attr" ];
19 0           return 1;
20             }
21              
22             1;