File Coverage

blib/lib/XML/Bare/SAX/Parser.pm
Criterion Covered Total %
statement 9 40 22.5
branch 0 2 0.0
condition n/a
subroutine 3 8 37.5
pod 1 5 20.0
total 13 55 23.6


line stmt bran cond sub pod time code
1             package XML::Bare::SAX::Parser;
2              
3             $VERSION = "0.01";
4              
5 1     1   814 use base qw(DynaLoader);
  1         1  
  1         101  
6              
7             bootstrap XML::Bare::SAX::Parser $VERSION;
8              
9 1     1   5 use vars qw ($VERSION);
  1         2  
  1         50  
10 1     1   14 use strict;
  1         2  
  1         345  
11              
12             sub new {
13 0     0 1   my $class = shift;
14 0 0         unshift @_, 'Handler' unless @_ != 1;
15 0           my %p = @_;
16 0           return bless \%p, $class;
17             }
18              
19             #sub DESTROY {
20             # my $self = shift;
21             # XML::Bare::SAX::Parser::free_tree();
22             #}
23              
24             sub supported_features {
25 0     0 0   my $self = shift;
26             # Only namespaces are required by all parsers
27             return (
28 0           'http://xml.org/sax/features/namespaces',
29             );
30             }
31              
32             sub parse_string {
33 0     0 0   my $self = shift;
34 0           my $string = shift;
35 0           my $handler = $self->{Handler};
36 0           my $document = { Parent => undef };
37            
38 0           $handler->start_document($document);
39             #my $node = { Name => 'xml' };
40             #$handler->start_element($node);
41 0           XML::Bare::SAX::Parser::parse( $handler, $string );
42             #$handler->end_element($node);
43 0           $handler->end_document($document);
44             }
45              
46             sub parse_file {
47 0     0 0   my $self = shift;
48 0           my $file = shift;
49 0           open( FILE, $file );
50 0           $self->parse_uri( $file );
51 0           close( FILE );
52             }
53              
54             sub parse_uri {
55 0     0 0   my $self = shift;
56 0           my $file = shift;
57            
58 0           open( FILE, $file );
59 0           my $string; { local $/ = undef; $string = <$file>; }
  0            
  0            
  0            
60 0           close( FILE );
61 0           my $handler = $self->{Handler};
62 0           my $document = { Parent => undef };
63            
64 0           $handler->start_document($document);
65             #my $node = { Name => 'xml' };
66             #$handler->start_element($node);
67            
68 0           XML::Bare::SAX::Parser::parse( $handler, $string );
69             #$handler->end_element($node);
70 0           $handler->end_document($document);
71             }
72              
73             1;
74              
75             __END__