| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package XML::ExtOn::SAX12ExtOn; |
|
2
|
|
|
|
|
|
|
#$Id: SAX12ExtOn.pm 385 2008-12-30 15:46:21Z zag $ |
|
3
|
|
|
|
|
|
|
|
|
4
|
6
|
|
|
6
|
|
31
|
use XML::Filter::SAX1toSAX2; |
|
|
6
|
|
|
|
|
10
|
|
|
|
6
|
|
|
|
|
154
|
|
|
5
|
6
|
|
|
6
|
|
30
|
use XML::ExtOn; |
|
|
6
|
|
|
|
|
11
|
|
|
|
6
|
|
|
|
|
141
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#use base qw/ XML::ExtOn XML::Filter::SAX1toSAX2/; |
|
8
|
6
|
|
|
6
|
|
29
|
use base qw/ XML::ExtOn/; |
|
|
6
|
|
|
|
|
10
|
|
|
|
6
|
|
|
|
|
588
|
|
|
9
|
6
|
|
|
6
|
|
33
|
use strict; |
|
|
6
|
|
|
|
|
17
|
|
|
|
6
|
|
|
|
|
200
|
|
|
10
|
6
|
|
|
6
|
|
29
|
use warnings; |
|
|
6
|
|
|
|
|
12
|
|
|
|
6
|
|
|
|
|
163
|
|
|
11
|
6
|
|
|
6
|
|
31
|
use Data::Dumper; |
|
|
6
|
|
|
|
|
14
|
|
|
|
6
|
|
|
|
|
2776
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub _scan_namespaces { |
|
14
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
15
|
0
|
|
|
|
|
|
my ( $elem, $attributes ) = @_; |
|
16
|
0
|
|
|
|
|
|
while ( my ( $attr_name, $value ) = each %$attributes ) { |
|
17
|
0
|
0
|
|
|
|
|
if ( $attr_name =~ /^xmlns(:(.*))?$/ ) { |
|
18
|
0
|
|
0
|
|
|
|
my $prefix = $2 || ''; |
|
19
|
0
|
|
|
|
|
|
$elem->ns->declare_prefix( $prefix, $value ); |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub process_a_name { |
|
25
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
26
|
0
|
|
|
|
|
|
my $elem = shift; |
|
27
|
0
|
|
|
|
|
|
my $key = shift; |
|
28
|
0
|
|
|
|
|
|
my ( $lname, $prefix ) = reverse split( /:/, $key ); |
|
29
|
0
|
|
|
|
|
|
my $ns = $elem->ns->get_uri($prefix); |
|
30
|
|
|
|
|
|
|
# warn "key: $key prefix: $prefix ns_iri: $ns "; |
|
31
|
0
|
0
|
|
|
|
|
unless ( defined $ns ) { |
|
32
|
0
|
|
|
|
|
|
$prefix = undef; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
#for attributes ! |
|
35
|
0
|
0
|
|
|
|
|
$ns = undef unless defined $prefix; |
|
36
|
0
|
|
|
|
|
|
return ( $lname, $ns, $prefix ); |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub start_element { |
|
40
|
0
|
|
|
0
|
0
|
|
my ( $self, $element ) = @_; |
|
41
|
0
|
|
|
|
|
|
my $elem = $self->mk_element( $element->{Name} ); |
|
42
|
0
|
|
|
|
|
|
my $attr = $element->{Attributes}; |
|
43
|
0
|
|
|
|
|
|
my %by_name = (); |
|
44
|
0
|
|
|
|
|
|
$self->_scan_namespaces( $elem, $attr ); |
|
45
|
0
|
|
|
|
|
|
while ( my ( $key, $val ) = each %$attr ) { |
|
46
|
0
|
|
|
|
|
|
my ( $lname, $uri, $prefix, ) = $self->process_a_name( $elem, $key ); |
|
47
|
|
|
|
|
|
|
# delete attribute if unknown prefix |
|
48
|
0
|
0
|
0
|
|
|
|
if ( ! defined $prefix and $key =~/:/) { |
|
49
|
|
|
|
|
|
|
next |
|
50
|
0
|
|
|
|
|
|
} |
|
51
|
0
|
0
|
|
|
|
|
unless ( defined $prefix ) { |
|
52
|
0
|
|
|
|
|
|
$elem->attrs_by_name->{$lname} = $val; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
else { |
|
55
|
0
|
|
|
|
|
|
$elem->attrs_by_ns_uri($uri)->{$lname} = $val; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
} |
|
58
|
0
|
|
|
|
|
|
return $self->SUPER::start_element($elem); |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
1; |