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   256435 use 5.010;
  2         15  
4 2     2   18 use strict;
  2         8  
  2         39  
5 2     2   10 use warnings;
  2         7  
  2         64  
6            
7 2     2   11 use Exporter 'import';
  2         5  
  2         66  
8            
9 2     2   738 use XML::LibXML;
  2         52323  
  2         11  
10            
11             our $VERSION = '0.02';
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         281 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   481 };
  2         12  
35            
36            
37            
38             1; # End of XML::XPath::Helper::Const
39            
40             __END__