line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XML::ExtOn::Context; |
2
|
10
|
|
|
10
|
|
48614
|
use strict; |
|
10
|
|
|
|
|
24
|
|
|
10
|
|
|
|
|
329
|
|
3
|
10
|
|
|
10
|
|
46
|
use warnings; |
|
10
|
|
|
|
|
18
|
|
|
10
|
|
|
|
|
263
|
|
4
|
10
|
|
|
10
|
|
47
|
use Data::Dumper; |
|
10
|
|
|
|
|
17
|
|
|
10
|
|
|
|
|
434
|
|
5
|
10
|
|
|
10
|
|
2240
|
use Tie::UnionHash; |
|
10
|
|
|
|
|
5521
|
|
|
10
|
|
|
|
|
365
|
|
6
|
|
|
|
|
|
|
### install get/set accessors for this object. |
7
|
|
|
|
|
|
|
for my $key ( qw/ __changes_hash __context_map _parent/ ) { |
8
|
10
|
|
|
10
|
|
51
|
no strict 'refs'; |
|
10
|
|
|
|
|
29
|
|
|
10
|
|
|
|
|
5429
|
|
9
|
|
|
|
|
|
|
*{ __PACKAGE__ . "::$key" } = sub { |
10
|
48
|
|
|
48
|
|
60
|
my $self = shift; |
11
|
48
|
100
|
|
|
|
154
|
$self->{$key} = $_[0] if @_; |
12
|
48
|
|
|
|
|
117
|
return $self->{$key}; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
sub new { |
16
|
7
|
|
|
7
|
0
|
91
|
my $class = shift; |
17
|
7
|
50
|
|
|
|
27
|
$class = ref $class if ref $class; |
18
|
7
|
|
|
|
|
20
|
my $self = bless( {}, $class ); |
19
|
7
|
|
|
|
|
19
|
my %args = @_; |
20
|
7
|
|
100
|
|
|
42
|
my $map = $args{parent_map} || {xmlns=>'http://www.w3.org/2000/xmlns/'}; |
21
|
7
|
|
|
|
|
14
|
my %changes = (); |
22
|
7
|
|
|
|
|
26
|
$self->__changes_hash(\%changes); |
23
|
7
|
|
|
|
|
10
|
my %new_map = (); |
24
|
7
|
|
|
|
|
55
|
tie %new_map, 'Tie::UnionHash', $map, \%changes; |
25
|
7
|
|
|
|
|
325
|
$self->__context_map(\%new_map); |
26
|
|
|
|
|
|
|
#save parent |
27
|
7
|
|
|
|
|
37
|
$self->_parent( $args{parent}); |
28
|
7
|
|
|
|
|
26
|
return $self; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
=head2 sub_context |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
create sub_context |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
sub sub_context { |
36
|
2
|
|
|
2
|
0
|
7
|
my $self = shift; |
37
|
2
|
|
|
|
|
5
|
return __PACKAGE__->new( parent_map=>$self->get_map, parent=>$self ) |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
sub parent { |
41
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
42
|
0
|
|
0
|
|
|
0
|
return $self->_parent || $self; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
=head2 get_changes |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Get changed items hash |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub get_changes { |
51
|
1
|
|
|
1
|
0
|
1440
|
my $self = shift; |
52
|
1
|
|
|
|
|
3
|
return $self->__changes_hash; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub get_map { |
56
|
26
|
|
|
26
|
0
|
40
|
my $self = shift; |
57
|
26
|
|
|
|
|
50
|
return $self->__context_map; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub get_uri { |
61
|
11
|
|
|
11
|
0
|
26
|
my $self = shift; |
62
|
11
|
|
100
|
|
|
47
|
my $prefix = shift||''; |
63
|
11
|
|
|
|
|
36
|
my $map = $self->get_map; |
64
|
11
|
100
|
|
|
|
34
|
unless ( $prefix) { |
65
|
9
|
|
66
|
|
|
52
|
return $map->{$prefix} || $map->{xmlns} |
66
|
|
|
|
|
|
|
} |
67
|
2
|
|
|
|
|
8
|
return $map->{$prefix}; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub get_prefix { |
71
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
72
|
1
|
|
|
|
|
1
|
my $uri = shift; |
73
|
1
|
|
|
|
|
1
|
return { reverse %{ $self->get_map } }->{$uri}; |
|
1
|
|
|
|
|
3
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
sub declare_prefix { |
77
|
8
|
|
|
8
|
0
|
988
|
my $self = shift; |
78
|
8
|
|
|
|
|
23
|
my %map = @_; |
79
|
8
|
|
|
|
|
24
|
my $current_map = $self->get_map; |
80
|
8
|
|
|
|
|
36
|
while (my ( $prefix, $uri) = each %map ) { |
81
|
8
|
|
|
|
|
41
|
$current_map->{$prefix} = $uri; |
82
|
|
|
|
|
|
|
} |
83
|
8
|
|
|
|
|
195
|
$current_map; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |