line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XML::LibXML::Debugging; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
41096
|
use 5.008; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
48
|
|
4
|
1
|
|
|
1
|
|
1357
|
use parent qw(XML::LibXML); |
|
1
|
|
|
|
|
452
|
|
|
1
|
|
|
|
|
5
|
|
5
|
|
|
|
|
|
|
use strict; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use HTML::HTML5::Entities qw(encode_entities_numeric); |
8
|
|
|
|
|
|
|
use XML::LibXML qw(:all); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
BEGIN { |
11
|
|
|
|
|
|
|
$XML::LibXML::Debugging::AUTHORITY = 'cpan:TOBYINK'; |
12
|
|
|
|
|
|
|
$XML::LibXML::Debugging::VERSION = '0.103'; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub XML::LibXML::Document::toDebuggingHash |
16
|
|
|
|
|
|
|
{ |
17
|
|
|
|
|
|
|
my $n = shift; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
return { |
20
|
|
|
|
|
|
|
'type' => 'Document', |
21
|
|
|
|
|
|
|
'root' => $n->documentElement->toDebuggingHash, |
22
|
|
|
|
|
|
|
}; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub XML::LibXML::Document::toClarkML |
26
|
|
|
|
|
|
|
{ |
27
|
|
|
|
|
|
|
my $n = shift; |
28
|
|
|
|
|
|
|
$n->documentElement->toClarkML; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub XML::LibXML::Element::toDebuggingHash |
32
|
|
|
|
|
|
|
{ |
33
|
|
|
|
|
|
|
my $n = shift; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $rv = { |
36
|
|
|
|
|
|
|
'type' => 'Element', |
37
|
|
|
|
|
|
|
'qname' => $n->nodeName, |
38
|
|
|
|
|
|
|
'prefix' => $n->prefix, |
39
|
|
|
|
|
|
|
'suffix' => $n->localname, |
40
|
|
|
|
|
|
|
'nsuri' => $n->namespaceURI, |
41
|
|
|
|
|
|
|
'attributes' => [], |
42
|
|
|
|
|
|
|
'children' => [], |
43
|
|
|
|
|
|
|
}; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
foreach my $attr ($n->attributes) |
46
|
|
|
|
|
|
|
{ |
47
|
|
|
|
|
|
|
my $x = $attr->toDebuggingHash; |
48
|
|
|
|
|
|
|
push @{ $rv->{'attributes'} }, $x if $x; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
foreach my $kid ($n->childNodes) |
52
|
|
|
|
|
|
|
{ |
53
|
|
|
|
|
|
|
if ($kid->nodeType == XML_TEXT_NODE |
54
|
|
|
|
|
|
|
|| $kid->nodeType == XML_CDATA_SECTION_NODE) |
55
|
|
|
|
|
|
|
{ |
56
|
|
|
|
|
|
|
push @{ $rv->{'children'} }, $kid->nodeValue; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
elsif ($kid->nodeType == XML_COMMENT_NODE) |
59
|
|
|
|
|
|
|
{ |
60
|
|
|
|
|
|
|
push @{ $rv->{'children'} }, $kid->toDebuggingHash; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
elsif ($kid->nodeType == XML_ELEMENT_NODE) |
63
|
|
|
|
|
|
|
{ |
64
|
|
|
|
|
|
|
push @{ $rv->{'children'} }, $kid->toDebuggingHash; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
return $rv; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub XML::LibXML::Element::toClarkML |
72
|
|
|
|
|
|
|
{ |
73
|
|
|
|
|
|
|
my $n = shift; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
my $rv; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
if (defined $n->namespaceURI) |
78
|
|
|
|
|
|
|
{ |
79
|
|
|
|
|
|
|
$rv = sprintf("<{%s}%s", $n->namespaceURI, $n->localname); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
else |
82
|
|
|
|
|
|
|
{ |
83
|
|
|
|
|
|
|
$rv = sprintf("<%s", $n->localname); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
foreach my $attr ($n->attributes) |
87
|
|
|
|
|
|
|
{ |
88
|
|
|
|
|
|
|
my $x = $attr->toClarkML; |
89
|
|
|
|
|
|
|
$rv .= " $x" if $x; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
if (! $n->childNodes) |
93
|
|
|
|
|
|
|
{ |
94
|
|
|
|
|
|
|
return $rv . "/>"; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
$rv .= ">"; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
foreach my $kid ($n->childNodes) |
100
|
|
|
|
|
|
|
{ |
101
|
|
|
|
|
|
|
if ($kid->nodeType == XML_TEXT_NODE |
102
|
|
|
|
|
|
|
|| $kid->nodeType == XML_CDATA_SECTION_NODE) |
103
|
|
|
|
|
|
|
{ |
104
|
|
|
|
|
|
|
$rv .= encode_entities_numeric($kid->nodeValue); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
elsif ($kid->nodeType == XML_COMMENT_NODE) |
107
|
|
|
|
|
|
|
{ |
108
|
|
|
|
|
|
|
$rv .= ""; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
elsif ($kid->nodeType == XML_ELEMENT_NODE) |
111
|
|
|
|
|
|
|
{ |
112
|
|
|
|
|
|
|
$rv .= $kid->toClarkML; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
if (defined $n->namespaceURI) |
117
|
|
|
|
|
|
|
{ |
118
|
|
|
|
|
|
|
$rv .= sprintf("{%s}%s>", $n->namespaceURI, $n->localname); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
else |
121
|
|
|
|
|
|
|
{ |
122
|
|
|
|
|
|
|
$rv .= sprintf("%s>", $n->localname); |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
return $rv; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub XML::LibXML::Comment::toDebuggingHash |
129
|
|
|
|
|
|
|
{ |
130
|
|
|
|
|
|
|
my $n = shift; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
return { |
133
|
|
|
|
|
|
|
'type' => 'Comment', |
134
|
|
|
|
|
|
|
'comment' => $n->nodeValue, |
135
|
|
|
|
|
|
|
}; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub XML::LibXML::Comment::toClarkML |
139
|
|
|
|
|
|
|
{ |
140
|
|
|
|
|
|
|
my $n = shift; |
141
|
|
|
|
|
|
|
return ""; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub XML::LibXML::Attr::toDebuggingHash |
145
|
|
|
|
|
|
|
{ |
146
|
|
|
|
|
|
|
my $n = shift; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
if ($n->nodeType == XML_NAMESPACE_DECL) |
149
|
|
|
|
|
|
|
{ |
150
|
|
|
|
|
|
|
return { |
151
|
|
|
|
|
|
|
'type' => 'Namespace Declaration', |
152
|
|
|
|
|
|
|
'qname' => $n->nodeName, |
153
|
|
|
|
|
|
|
'prefix' => $n->prefix, |
154
|
|
|
|
|
|
|
'suffix' => $n->getLocalName, |
155
|
|
|
|
|
|
|
'nsuri' => $n->getNamespaceURI, |
156
|
|
|
|
|
|
|
'value' => $n->getData, |
157
|
|
|
|
|
|
|
}; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
return { |
161
|
|
|
|
|
|
|
'type' => 'Attribute', |
162
|
|
|
|
|
|
|
'qname' => $n->nodeName, |
163
|
|
|
|
|
|
|
'prefix' => $n->prefix, |
164
|
|
|
|
|
|
|
'suffix' => $n->localname, |
165
|
|
|
|
|
|
|
'nsuri' => $n->namespaceURI, |
166
|
|
|
|
|
|
|
'value' => $n->nodeValue, |
167
|
|
|
|
|
|
|
}; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub XML::LibXML::Attr::toClarkML |
171
|
|
|
|
|
|
|
{ |
172
|
|
|
|
|
|
|
my $n = shift; |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
if ($n->nodeType == XML_NAMESPACE_DECL) |
175
|
|
|
|
|
|
|
{ |
176
|
|
|
|
|
|
|
if (defined $n->getLocalName) |
177
|
|
|
|
|
|
|
{ |
178
|
|
|
|
|
|
|
return sprintf("{%s}%s=\"%s\"", |
179
|
|
|
|
|
|
|
$n->getNamespaceURI, $n->getLocalName, $n->getData); |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
return sprintf("{%s}xmlns=\"%s\"", |
182
|
|
|
|
|
|
|
$n->getNamespaceURI, $n->getData); |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
if (defined $n->namespaceURI) |
186
|
|
|
|
|
|
|
{ |
187
|
|
|
|
|
|
|
return sprintf("{%s}%s=\"%s\"", |
188
|
|
|
|
|
|
|
$n->namespaceURI, $n->localname, $n->nodeValue); |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
else |
191
|
|
|
|
|
|
|
{ |
192
|
|
|
|
|
|
|
return sprintf("%s=\"%s\"", |
193
|
|
|
|
|
|
|
$n->localname, $n->nodeValue); |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
sub XML::LibXML::Node::toClarkML |
198
|
|
|
|
|
|
|
{ |
199
|
|
|
|
|
|
|
return ''; |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
sub XML::LibXML::Node::toDebuggingHash |
203
|
|
|
|
|
|
|
{ |
204
|
|
|
|
|
|
|
return {type=>'Node'}; |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
sub XML::LibXML::Namespace::toClarkML |
208
|
|
|
|
|
|
|
{ |
209
|
|
|
|
|
|
|
return XML::LibXML::Attr::toClarkML(@_); |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
sub XML::LibXML::Namespace::toDebuggingHash |
213
|
|
|
|
|
|
|
{ |
214
|
|
|
|
|
|
|
return XML::LibXML::Attr::toDebuggingHash(@_); |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
1; |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
__END__ |