File Coverage

blib/lib/XML/XPath/Helper/Const.pm
Criterion Covered Total %
statement 17 17 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 23 23 100.0


line stmt bran cond sub pod time code
1             package XML::XPath::Helper::Const;
2            
3 2     2   269170 use 5.010;
  2         20  
4 2     2   13 use strict;
  2         4  
  2         38  
5 2     2   10 use warnings;
  2         4  
  2         80  
6            
7 2     2   11 use Exporter 'import';
  2         3  
  2         76  
8            
9 2     2   773 use XML::LibXML;
  2         55088  
  2         21  
10            
11             our $VERSION = '0.04';
12            
13             our @EXPORT_OK = qw(XPATH_SIMPLE_LIST
14             XPATH_SIMPLE_TAGS
15             XPATH_NESTED_TAGS);
16            
17             our %EXPORT_TAGS = (all => \@EXPORT_OK);
18            
19             use constant
20             {
21             # The following is taken from:
22             # https://stackoverflow.com/questions/75059177/is-it-possible-to-find-nodes-containing-a-simple-list-using-xpath-1-0/75061420#75061420
23 2         301 XPATH_SIMPLE_LIST => XML::LibXML::XPathExpression->new(<<"EOT"),
24             ./*[
25             *[not(*)]
26             and
27             not(*[position()>1
28             and
29             name(.) != name(preceding-sibling::*[1])])
30             ]
31             EOT
32             XPATH_SIMPLE_TAGS => XML::LibXML::XPathExpression->new("*[count(*) = 0]"),
33             XPATH_NESTED_TAGS => XML::LibXML::XPathExpression->new("*[count(*) > 0]"),
34 2     2   488 };
  2         20  
35            
36            
37            
38             1; # End of XML::XPath::Helper::Const
39            
40             __END__