File Coverage

blib/lib/XML/Atom.pm
Criterion Covered Total %
statement 10 26 38.4
branch 1 8 12.5
condition n/a
subroutine 3 3 100.0
pod n/a
total 14 37 37.8


line stmt bran cond sub pod time code
1             # $Id$
2              
3             package XML::Atom;
4 21     21   5558 use strict;
  21         43  
  21         680  
5              
6 21     21   546 use 5.008_001;
  21         104  
  21         7117  
7             our $VERSION = '0.41';
8              
9             BEGIN {
10 21     21   78 @XML::Atom::EXPORT = qw( LIBXML DATETIME);
11 21 50       55 if (eval { require XML::LibXML }) {
  21         12109  
12 0         0 *{XML::Atom::LIBXML} = sub() {1};
13             } else {
14 21         44903 require XML::XPath;
15 0           *{XML::Atom::LIBXML} = sub() {0};
16             }
17 0 0         if (eval { require DateTime::Format::Atom }) {
  0            
18 0           *{XML::Atom::DATETIME} = sub() {1};
19             } else {
20 0           *{XML::Atom::DATETIME} = sub() {0};
21             }
22            
23 0           local $^W = 0;
24             *XML::XPath::Function::namespace_uri = sub {
25 0           my $self = shift;
26 0           my($node, @params) = @_;
27 0           my $ns = $node->getNamespace($node->getPrefix);
28 0 0         if (!$ns) {
29 0           $ns = ($node->getNamespaces)[0];
30             }
31 0 0         XML::XPath::Literal->new($ns ? $ns->getExpanded : '');
32 0           };
33              
34 0           $XML::Atom::ForceUnicode = 0;
35 0           $XML::Atom::DefaultVersion = 0.3;
36             }
37              
38             sub libxml_parser {
39             ## uses old XML::LibXML < 1.70 interface for compat reasons
40             return XML::LibXML->new(
41             #no_network => 1, # v1.63+
42             expand_xinclude => 0,
43             expand_entities => 1,
44             load_ext_dtd => 0,
45             ext_ent_handler => sub { warn "External entities disabled."; '' },
46             );
47             }
48              
49             sub expat_parser {
50             return XML::Parser->new(
51             Handlers => {
52             ExternEnt => sub { warn "External Entities disabled."; '' },
53             ExternEntFin => sub {},
54             },
55             );
56             }
57              
58             use base qw( XML::Atom::ErrorHandler Exporter );
59              
60             package XML::Atom::Namespace;
61             use strict;
62              
63             sub new {
64             my $class = shift;
65             my($prefix, $uri) = @_;
66             bless { prefix => $prefix, uri => $uri }, $class;
67             }
68              
69             sub DESTROY { }
70              
71             use vars qw( $AUTOLOAD );
72             sub AUTOLOAD {
73             (my $var = $AUTOLOAD) =~ s!.+::!!;
74             no strict 'refs';
75             ($_[0], $var);
76             }
77              
78             1;
79             __END__