lib/XML/Handler/Dtd2Html.pm

filter: Statementstmt 6.0% 62 / 1026 Branchbran 0.0% 0 / 376 Conditioncond 0.0% 0 / 88 MC/DCmcdc 0.0% 0 / 44 Subroutinesub 23.5% 20 / 85 Podpod 0.0% 0 / 11 totaltotal 5.0% 82 / 1630 CC 256 SCAR 59.8
CC
256
Cov
4%
GenerateHTML
2162.0
generateMain
380.0
_cross_ref
306.0
CRAP 395.1
↑ Summary script/dtd2html.pl »
1
2 package XML::Handler::Dtd2Html::Document;
3
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6
7 1 ▶use Parse::RecDescent;
Subroutine BEGIN: called CC=1 SCAR=0.0
8
9 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
10 0 my $proto = shift;
11 0 ▶ my $class = ref($proto) || $proto;
Condition0%0/3
ref $proto || $proto
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
12 0 my $self = {
13 xml_decl => undef,
14 dtd => undef,
15 root_name => undef,
16 list_decl => [],
17 hash_notation => {},
18 hash_entity => {},
19 hash_element => {},
20 hash_attr => {},
21 hlink => 1,
22 preformatted => "pre",
23 emphasis => "em",
24 width => 80,
25 };
26 0 bless($self, $class);
27 0 $self->{cm_parser} = Parse::RecDescent->new(<<'EndGrammar');
28 <autotree>
29
30 contentspec: 'EMPTY' | 'ANY' | Mixed | children
31
32 children: ( choice | seq ) ( '?' | '*' | '+' )(?)
33
34 cp: ( Name | choice | seq ) ( '?' | '*' | '+' )(?)
35
36 choice: '(' cp ( '|' cp )(s) ')'
37
38 seq: '(' cp ( ',' cp )(s?) ')'
39
40 Mixed: '(' '#PCDATA' ( '|' Name )(s?) ')*' | '(' '#PCDATA' ')'
41
42 Name: /[\w_:][\w\d\.\-_:]*/
43
44 EndGrammar
45 0 return $self;
46 }
47
48 ###############################################################################
49
50 package XML::Handler::Dtd2Html;
51
52 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
54
55 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
56
57 1 $VERSION="0.42";
58
59 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
60 0 my $proto = shift;
61 0 ▶ my $class = ref($proto) || $proto;
Condition0%0/3
ref $proto || $proto
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
62 0 my $self = {
63 doc => XML::Handler::Dtd2Html::Document->new(),
64 comments => []
65 };
66 0 bless($self, $class);
67 0 return $self;
68 }
69
70 # Content Events (Basic)
71
72 0 ▶sub start_document {
Subroutine start_document: not called CC=2 SCAR=17.9
Pod undocumented
73 0 my $self = shift;
74 0 my ($decl) = @_;
75 0 ▶ $self->{doc}->{xml_decl} = $decl if (%{$decl});
Branch: 1 branch
BranchTrueFalseTotal
if %{$decl;} 0 0 0
76 0 return;
77 }
78
79 0 ▶sub end_document {
Subroutine end_document: not called CC=1 SCAR=6.9
Pod undocumented
80 0 my $self = shift;
81 0 return $self->{doc};
82 }
83
84 # Declarations Events
85
86 0 ▶sub element_decl {
Subroutine element_decl: not called CC=2 SCAR=17.9
Pod undocumented
87 0 my $self = shift;
88 0 my ($decl) = @_;
89 0 ▶ if (scalar @{$self->{comments}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$self->{"comments"};}) 0 0 0
90 0 $decl->{comments} = [@{$self->{comments}}];
91 0 $self->{comments} = [];
92 }
93 0 $decl->{type} = "element";
94 0 $decl->{used_by} = {};
95 0 $decl->{uses} = {};
96 0 my $name = $decl->{Name};
97 0 $self->{doc}->{hash_element}->{$name} = $decl;
98 0 push @{$self->{doc}->{list_decl}}, $decl;
99 0 return;
100 }
101
102 0 ▶sub attribute_decl {
Subroutine attribute_decl: not called CC=3 SCAR=24.8
Pod undocumented
103 0 my $self = shift;
104 0 my ($decl) = @_;
105 0 ▶ if (scalar @{$self->{comments}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$self->{"comments"};}) 0 0 0
106 0 $decl->{comments} = [@{$self->{comments}}];
107 0 $self->{comments} = [];
108 }
109 0 my $elt_name = $decl->{eName};
110 $self->{doc}->{hash_attr}->{$elt_name} = []
111 0 ▶ unless (exists $self->{doc}->{hash_attr}->{$elt_name});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"doc"}{"hash_attr"}{$elt_name} 0 0 0
112 0 push @{$self->{doc}->{hash_attr}->{$elt_name}}, $decl;
113 0 return;
114 }
115
116 0 ▶sub internal_entity_decl {
Subroutine internal_entity_decl: not called CC=3 SCAR=24.8
Pod undocumented
117 0 my $self = shift;
118 0 my ($decl) = @_;
119 0 ▶ if (scalar @{$self->{comments}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$self->{"comments"};}) 0 0 0
120 0 $decl->{comments} = [@{$self->{comments}}];
121 0 $self->{comments} = [];
122 }
123 0 $decl->{type} = "internal_entity";
124 0 my $name = $decl->{Name};
125 0 ▶ unless ($name =~ /^%/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($name =~ /^%/) 0 0 0
126 0 $self->{doc}->{hash_entity}->{$name} = $decl;
127 0 push @{$self->{doc}->{list_decl}}, $decl;
128 }
129 0 return;
130 }
131
132 0 ▶sub external_entity_decl {
Subroutine external_entity_decl: not called CC=3 SCAR=24.8
Pod undocumented
133 0 my $self = shift;
134 0 my ($decl) = @_;
135 0 ▶ if (scalar @{$self->{comments}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$self->{"comments"};}) 0 0 0
136 0 $decl->{comments} = [@{$self->{comments}}];
137 0 $self->{comments} = [];
138 }
139 0 $decl->{type} = "external_entity";
140 0 my $name = $decl->{Name};
141 0 ▶ unless ($name =~ /^%/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($name =~ /^%/) 0 0 0
142 0 $self->{doc}->{hash_entity}->{$name} = $decl;
143 0 push @{$self->{doc}->{list_decl}}, $decl;
144 }
145 0 return;
146 }
147
148 # DTD Events
149
150 0 ▶sub notation_decl {
Subroutine notation_decl: not called CC=2 SCAR=17.9
Pod undocumented
151 0 my $self = shift;
152 0 my ($decl) = @_;
153 0 ▶ if (scalar @{$self->{comments}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$self->{"comments"};}) 0 0 0
154 0 $decl->{comments} = [@{$self->{comments}}];
155 0 $self->{comments} = [];
156 }
157 0 $decl->{type} = "notation";
158 0 my $name = $decl->{Name};
159 0 $self->{doc}->{hash_notation}->{$name} = $decl;
160 0 push @{$self->{doc}->{list_decl}}, $decl;
161 0 return;
162 }
163
164 0 ▶sub unparsed_entity_decl {
Subroutine unparsed_entity_decl: not called CC=1 SCAR=6.9
Pod undocumented
165 0 my $self = shift;
166 0 my ($decl) = @_;
167 0 $self->{comments} = [];
168 0 warn "unparsed entity $decl->{Name}.\n";
169 0 return;
170 }
171
172 # Lexical Events
173
174 0 ▶sub start_dtd {
Subroutine start_dtd: not called CC=2 SCAR=17.9
Pod undocumented
175 0 my $self = shift;
176 0 my ($dtd) = @_;
177 0 ▶ if (scalar @{$self->{comments}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$self->{"comments"};}) 0 0 0
178 0 $dtd->{comments} = [@{$self->{comments}}];
179 0 $self->{comments} = [];
180 }
181 0 $dtd->{type} = "doctype";
182 0 $self->{doc}->{dtd} = $dtd;
183 0 $self->{doc}->{root_name} = $dtd->{Name};
184 0 return;
185 }
186
187 0 ▶sub comment {
Subroutine comment: not called CC=1 SCAR=6.9
Pod undocumented
188 0 my $self = shift;
189 0 my ($comment) = @_;
190 0 push @{$self->{comments}}, $comment;
191 0 return;
192 }
193
194 # SAX1 Events
195
196 # deprecated in favour of start_document (see XML::SAX::Expat 0.36)
197 #sub xml_decl {
198 # my $self = shift;
199 # my ($decl) = @_;
200 # $self->{doc}->{xml_decl} = $decl;
201 #}
202
203 ###############################################################################
204
205 package XML::Handler::Dtd2Html::ContentModelVisitor;
206
207 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
208 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
209
210 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
211 0 my $proto = shift;
212 0 ▶ my $class = ref($proto) || $proto;
Condition0%0/3
ref $proto || $proto
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
213 0 my ($doc) = @_;
214 my $self = {
215 doc => $doc,
216 str => "",
217 raw => "",
218 tab => "",
219 max => $doc->{width},
220 0 need => 0,
221 };
222 0 bless($self, $class);
223 0 return $self;
224 }
225
226 0 ▶sub _inc_tab {
Subroutine _inc_tab: not called CC=1 SCAR=6.9
227 0 my $self = shift;
228 0 $self->{tab} .= " ";
229 0 return;
230 }
231
232 0 ▶sub _dec_tab {
Subroutine _dec_tab: not called CC=1 SCAR=6.9
233 0 my $self = shift;
234 0 $self->{tab} =~ s/ $//;
235 0 return;
236 }
237
238 0 ▶sub _add {
Subroutine _add: not called CC=2 SCAR=17.9
239 0 my $self = shift;
240 0 my ($raw, $str) = @_;
241 0 ▶ $str = $raw unless (defined $str);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $str 0 0 0
242 0 $self->{raw} .= $raw;
243 0 $self->{str} .= $str;
244 0 return;
245 }
246
247 0 ▶sub _add_name {
Subroutine _add_name: not called CC=3 SCAR=24.8
248 0 my $self = shift;
249 0 my ($raw, $str) = @_;
250 0 ▶ $str = $raw unless (defined $str);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $str 0 0 0
251 $self->_break()
252 0 ▶ if (length($self->{tab} . $self->{raw} . $raw) > $self->{max});
Branch: 1 branch
BranchTrueFalseTotal
if length $self->{"tab"} . $self->{"raw"} . $raw > $self->{"max"} 0 0 0
253 0 $self->{raw} .= $raw;
254 0 $self->{str} .= $str;
255 0 return;
256 }
257
258 0 ▶sub _break {
Subroutine _break: not called CC=2 SCAR=17.9
259 0 my $self = shift;
260 0 $self->{need} = 0;
261 0 ▶ if ($self->{raw} !~ /^\s*$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"raw"} =~ /^\s*$/) 0 0 0
262 0 $self->{raw} = "";
263 0 $self->{str} .= "\n" . $self->{tab};
264 }
265 0 return;
266 }
267
268 0 ▶sub _visit {
Subroutine _visit: not called CC=2 SCAR=17.9
269 0 my $self = shift;
270 0 my $node = shift;
271
272 0 my $func = "visit_" . ref $node;
273 0 ▶ if($self->can($func)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can($func)) { } 0 0 0
274 0 $self->$func($node, @_);
275 } else {
276 0 warn "Please implement a function '$func' in '",ref $self,"'.\n";
277 }
278 0 return;
279 }
280
281 # contentspec: 'EMPTY' | 'ANY' | Mixed | children
282 0 ▶sub visit_contentspec {
Subroutine visit_contentspec: not called CC=4 SCAR=30.0
283 0 my $self = shift;
284 0 my ($node) = @_;
285
286 0 ▶ if (exists $node->{__VALUE__}) {
Branch: 3 branches
BranchTrueFalseTotal
if (exists $node->{'__VALUE__'}) { } 0 0 0
elsif (exists $node->{'Mixed'}) { } 0 0 0
elsif (exists $node->{'children'}) { } 0 0 0
287 0 $self->{str} .= $self->{doc}->_mk_value($node->{__VALUE__});
288 } elsif (exists $node->{Mixed}) {
289 0 $self->_visit($node->{Mixed});
290 } elsif (exists $node->{children}) {
291 0 $self->_visit($node->{children});
292 }
293 0 return;
294 }
295
296 # children: ( choice | seq ) ( '?' | '*' | '+' )(?)
297 0 ▶sub visit_children {
Subroutine visit_children: not called CC=4 SCAR=30.0
298 0 my $self = shift;
299 0 my ($node) = @_;
300
301 0 my $altern1 = $node->{_alternation_1_of_production_1_of_rule_children};
302 0 ▶ if (exists $altern1->{choice}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $altern1->{'choice'}) { } 0 0 0
elsif (exists $altern1->{'seq'}) { } 0 0 0
303 0 $self->_visit($altern1->{choice});
304 } elsif (exists $altern1->{seq}) {
305 0 $self->_visit($altern1->{seq});
306 }
307 0 my $altern2 = shift @{$node->{'_alternation_2_of_production_1_of_rule_children(?)'}};
308 0 ▶ if (defined $altern2) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $altern2) 0 0 0
309 0 $self->_add($altern2->{__VALUE__}); # '?' or '*' or '+'
310 }
311 0 return;
312 }
313
314 # cp: ( Name | choice | seq ) ( '?' | '*' | '+' )(?)
315 0 ▶sub visit_cp {
Subroutine visit_cp: not called CC=8 SCAR=42.8
316 0 my $self = shift;
317 0 my ($node, $first) = @_;
318
319 0 my $altern1 = $node->{_alternation_1_of_production_1_of_rule_cp};
320 0 ▶ if (exists $altern1->{Name}) {
Branch: 3 branches
BranchTrueFalseTotal
if (exists $altern1->{'Name'}) { } 0 0 0
elsif (exists $altern1->{'choice'}) { } 0 0 0
elsif (exists $altern1->{'seq'}) { } 0 0 0
321 0 ▶ $self->_break() if ($self->{need});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"need"} 0 0 0
322 0 $self->_visit($altern1->{Name});
323 } elsif (exists $altern1->{choice}) {
324 0 ▶ $self->_break() unless ($first);
Branch: 1 branch
BranchTrueFalseTotal
unless $first 0 0 0
325 0 $self->_visit($altern1->{choice});
326 0 $self->{need} = 1;
327 } elsif (exists $altern1->{seq}) {
328 0 ▶ $self->_break() unless ($first);
Branch: 1 branch
BranchTrueFalseTotal
unless $first 0 0 0
329 0 $self->_visit($altern1->{seq});
330 0 $self->{need} = 1;
331 }
332 0 my $altern2 = shift @{$node->{'_alternation_2_of_production_1_of_rule_cp(?)'}};
333 0 ▶ if (defined $altern2) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $altern2) 0 0 0
334 0 $self->_add($altern2->{__VALUE__}); # '?' or '*' or '+'
335 }
336 0 return;
337 }
338
339 # choice: '(' cp ( '|' cp )(s) ')'
340 0 ▶sub visit_choice {
Subroutine visit_choice: not called CC=2 SCAR=17.9
341 0 my $self = shift;
342 0 my ($node) = @_;
343
344 0 $self->_add($node->{__STRING1__} . " "); # '('
345 0 $self->_inc_tab();
346 0 $self->_visit($node->{cp}, 1);
347 0 foreach (@{$node->{'_alternation_1_of_production_1_of_rule_choice(s)'}}) {
348 0 $self->_add(" " . $_->{__STRING1__} . " "); # '|'
349 0 $self->_visit($_->{cp}, 0);
350 }
351 0 $self->_dec_tab();
352 0 $self->_add(" " . $node->{__STRING2__}); # ')'
353 0 return;
354 }
355
356 # seq: '(' cp ( ',' cp )(s?) ')'
357 0 ▶sub visit_seq {
Subroutine visit_seq: not called CC=2 SCAR=17.9
358 0 my $self = shift;
359 0 my ($node) = @_;
360
361 0 $self->_add($node->{__STRING1__} . " "); # '('
362 0 $self->_inc_tab();
363 0 $self->_visit($node->{cp}, 1);
364 0 foreach (@{$node->{'_alternation_1_of_production_1_of_rule_seq(s?)'}}) {
365 0 $self->_add(" " . $_->{__STRING1__} . " "); # ','
366 0 $self->_visit($_->{cp}, 0);
367 }
368 0 $self->_dec_tab();
369 0 $self->_add(" " . $node->{__STRING2__}); # ')'
370 0 return;
371 }
372
373 # Mixed: '(' '#PCDATA' ( '|' Name )(s?) ')*' | '(' '#PCDATA' ')'
374 0 ▶sub visit_Mixed {
Subroutine visit_Mixed: not called CC=2 SCAR=17.9
375 0 my $self = shift;
376 0 my ($node) = @_;
377
378 0 $self->_add($node->{__STRING1__} . " "); # '('
379 0 my $value = $self->{doc}->_mk_value($node->{__STRING2__});
380 0 $self->_inc_tab();
381 0 $self->_add_name($node->{__STRING2__}, $value); # '#PCDATA'
382 0 foreach (@{$node->{'_alternation_1_of_production_1_of_rule_Mixed(s?)'}}) {
383 0 $self->_add(" " . $_->{__STRING1__} . " "); # '|'
384 0 $self->_visit($_->{Name});
385 }
386 0 $self->_dec_tab();
387 0 $self->_add(" " . $node->{__STRING3__}); # ')*' or ')'
388 0 return;
389 }
390
391 # Name: /[\w_:][\w\d\.\-_:]*/
392 0 ▶sub visit_Name {
Subroutine visit_Name: not called CC=1 SCAR=6.9
393 0 my $self = shift;
394 0 my ($node) = @_;
395
396 0 my $anchor = $self->{doc}->_mk_text_anchor("elt", $node->{__VALUE__});
397 0 $self->_add_name($node->{__VALUE__}, $anchor);
398 0 return;
399 }
400
401 ###############################################################################
402
403 package XML::Handler::Dtd2Html::Document;
404
405 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
406 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
407
408 1 ▶use HTML::Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
409 1 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
410
411 0 ▶sub _process_args {
Subroutine _process_args: not called CC=16 SCAR=56.1
412 0 my $self = shift;
413 0 my %hash = @_;
414
415 0 $self->{outfile} = $hash{outfile};
416
417 0 ▶ if (defined $hash{title}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $hash{'title'}) { } 0 0 0
418 0 $self->{title} = $hash{title};
419 } else {
420 0 foreach my $comment (@{$self->{dtd}->{comments}}) {
421 0 my ($doc, $r_tags) = $self->_extract_doc($comment);
422 0 foreach (@{$r_tags}) {
423 0 my ($href, $entry, $data) = @{$_};
424 0 ▶ if (uc($entry) eq "TITLE") {
Branch: 1 branch
BranchTrueFalseTotal
if (uc $entry eq "TITLE") 0 0 0
425 0 $self->{title} = $data;
426 }
427 }
428 }
429 $self->{title} = "DTD " . $self->{root_name}
430 0 ▶ unless ($self->{title});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"title"} 0 0 0
431 }
432
433 0 $self->{css} = $hash{css};
434 0 $self->{examples} = $hash{examples};
435 0 $self->{dirname} = dirname($hash{outfile});
436 0 $self->{basename} = basename($hash{outfile});
437 0 $self->{filebase} = $hash{outfile};
438 0 $self->{filebase} =~ s/^([^\/]+\/)+//;
439 0 $self->{flag_comment} = $hash{flag_comment};
440 0 $self->{flag_href} = $hash{flag_href};
441
442 0 ▶ $self->{now} = $hash{flag_date} ? localtime() : "";
Branch: 1 branch
BranchTrueFalseTotal
$hash{'flag_date'} ? : 0 0 0
443 0 $self->{generator} = "dtd2html " . $XML::Handler::Dtd2Html::VERSION . " (Perl " . $] . ")";
444
445 0 ▶ if (defined $hash{path_tmpl}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $hash{'path_tmpl'}) { } 0 0 0
446 0 $self->{path_tmpl} = [ $hash{path_tmpl} ];
447 } else {
448 0 ▶ my $language = $hash{language} || 'en';
Condition0%0/2
$hash{'language'} || 'en'
l!l
00
MC/DC0%0/1
$hash{'language'} || 'en'
$hash{'language'}
Truth table0%0/2
A
A= $hash{'language'}
Aresult
11
00
449 0 my $path = $INC{'XML/Handler/Dtd2Html.pm'};
450 0 $path =~ s/\.pm$//i;
451 0 $self->{path_tmpl} = [ $path . '/' . $language, $path ];
452 }
453
454 0 $self->_cross_ref($hash{flag_zombi});
455
456 0 ▶ if ($hash{flag_multi}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hash{"flag_multi"}) 0 0 0
457 0 foreach my $decl (@{$self->{list_decl}}) {
458 0 my $type = $decl->{type};
459 0 my $name = $decl->{Name};
460 0 ▶ if (exists $decl->{comments}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $decl->{"comments"}) 0 0 0
461 0 $decl->{comments} = [ ${$decl->{comments}}[-1] ];
462 }
463 0 ▶ if ($type eq "element" and exists $self->{hash_attr}->{$name}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "element" and exists $self->{"hash_attr"}{$name}) 0 0 0
Condition0%0/3
$type eq "element" and exists $self->{"hash_attr"}{$name}
!ll&&!rl&&r
000
MC/DC0%0/2
$type eq "element" and exists $self->{"hash_attr"}{$name}
$type eq "element" exists $self->{"hash_attr"}{$name}
Truth table0%0/3
A and B
A= $type eq "element"B= exists $self->{"hash_attr"}{$name}
ABresult
0X0
100
111
464 0 foreach my $attr (@{$self->{hash_attr}->{$name}}) {
465 0 ▶ if (exists $attr->{comments}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $attr->{"comments"}) 0 0 0
466 0 $attr->{comments} = [ ${$attr->{comments}}[-1] ];
467 }
468 }
469 }
470 }
471 }
472 0 return;
473 }
474
475 0 ▶sub _cross_ref {
Subroutine _cross_ref: not called CC=17 SCAR=57.2
476 0 my $self = shift;
477 0 my($flag_zombi) = @_;
478
479 0 ▶ while (my($name, $decl) = each %{$self->{hash_element}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$$self{"hash_element"};}) 0 0 0
480 0 my $model = $decl->{Model};
481 0 ▶ while ($model) {
Branch: 1 branch
BranchTrueFalseTotal
if ($model) 0 0 0
482 0 for ($model) {
483 0 s/^[ \n\r\t\f\013]+//; # whitespaces
484
485 0 ▶ s/^[\?\*\+\(\),\|]//
Branch: 1 branch
BranchTrueFalseTotal
s/^[\?\*\+\(\),\|]// and last 0 0 0
486 and last;
487 0 ▶ s/^EMPTY//
Branch: 1 branch
BranchTrueFalseTotal
s/^EMPTY// and last 0 0 0
488 and last;
489 0 ▶ s/^ANY//
Branch: 1 branch
BranchTrueFalseTotal
s/^ANY// and last 0 0 0
490 and last;
491 0 ▶ s/^#PCDATA//
Branch: 1 branch
BranchTrueFalseTotal
s/^#PCDATA// and last 0 0 0
492 and last;
493 s/^([A-Za-z_:][0-9A-Za-z\.\-_:]*)//
494 and $self->{hash_element}->{$name}->{uses}->{$1} = 1,
495 0 ▶ and $self->{hash_element}->{$1}->{used_by}->{$name} = 1,
Branch: 1 branch
BranchTrueFalseTotal
s/^([A-Za-z_:][0-9A-Za-z\.\-_:]*)// and $self->{"hash_element"}{$name}{"uses"}{$1} = 1 and $self->{"hash_element"}{$1}{"used_by"}{$name} = 1, last 0 0 0
Condition0%0/2
s/^([A-Za-z_:][0-9A-Za-z\.\-_:]*)// and $self->{"hash_element"}{$name}{"uses"}{$1} = 1
!ll
00
MC/DC0%0/1
s/^([A-Za-z_:][0-9A-Za-z\.\-_:]*)// and $self->{"hash_element"}{$name}{"uses"}{$1} = 1
s/^([A-Za-z_:][0-9A-Za-z\.\-_:]*)//
Truth table0%0/2
A
A= s/^([A-Za-z_:][0-9A-Za-z\.\-_:]*)//
Aresult
00
11
496 last;
497 0 ▶ s/^([\S]+)//
Branch: 1 branch
BranchTrueFalseTotal
s/^([\S]+)// and warn __PACKAGE__, ":_cross_ref INTERNAL_ERROR $1\n", last 0 0 0
498 and warn __PACKAGE__,":_cross_ref INTERNAL_ERROR $1\n",
499 last;
500 }
501 }
502 }
503
504 0 ▶ if ($flag_zombi) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flag_zombi) 0 0 0
505 0 my $one_more_time = 1;
506 0 ▶ while ($one_more_time) {
Branch: 1 branch
BranchTrueFalseTotal
if ($one_more_time) 0 0 0
507 0 $one_more_time = 0;
508 0 ▶ while (my($elt_name, $elt_decl) = each %{$self->{hash_element}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$$self{"hash_element"};}) 0 0 0
509 0 ▶ next if ($elt_name eq $self->{root_name});
Branch: 1 branch
BranchTrueFalseTotal
if $elt_name eq $self->{"root_name"} 0 0 0
510 0 ▶ unless (scalar keys %{$elt_decl->{used_by}}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (scalar keys %{$$elt_decl{"used_by"};}) 0 0 0
511 0 delete $self->{hash_element}->{$elt_name};
512 0 foreach my $child (keys %{$elt_decl->{uses}}) {
513 0 my $decl = $self->{hash_element}->{$child};
514 0 delete $decl->{used_by}->{$elt_name};
515 0 $one_more_time = 1;
516 }
517 }
518 }
519 }
520 }
521 0 return;
522 }
523
524 0 ▶sub _format_content_model {
Subroutine _format_content_model: not called CC=1 SCAR=6.9
525 0 my $self = shift;
526 0 my ($model) = @_;
527 0 my $visitor = XML::Handler::Dtd2Html::ContentModelVisitor->new($self);
528 0 $visitor->_visit($self->{cm_parser}->contentspec($model));
529 0 my $str = $visitor->{str};
530 0 return $str;
531 }
532
533 0 ▶sub _include_doc {
Subroutine _include_doc: not called CC=3 SCAR=24.8
534 0 my $self = shift;
535 0 my($filename) = @_;
536 0 my $doc = "";
537
538 0 ▶ open my $IN, '<', $filename
Branch: 1 branch
BranchTrueFalseTotal
open my $IN, "<", $filename or warn "can't open $filename ($!).\n", (return $doc) 0 0 0
539 or warn "can't open $filename ($!).\n",
540 return $doc;
541
542 0 ▶ while (<$IN>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $IN)) 0 0 0
543 0 $doc .= $_;
544 }
545 0 close $IN;
546 0 return $doc;
547 }
548
549 0 ▶sub _extract_doc {
Subroutine _extract_doc: not called CC=6 SCAR=37.4
550 0 my $self = shift;
551 0 my($comment) = @_;
552 0 my $doc = undef;
553 0 my @tags = ();
554 0 my @lines = split /\n/, $comment->{Data};
555 0 foreach (@lines) {
556 0 ▶ if (/^\s*@(@?)\s*([\s0-9A-Z_a-z]+):\s*(.*)/) {
Branch: 2 branches
BranchTrueFalseTotal
if (/^\s*@(\@?)\s*([\s0-9A-Z_a-z]+):\s*(.*)/) { } 0 0 0
elsif (/^\s*@(\@?)\s*([A-Z_a-z][0-9A-Z_a-z]*)\s+(.*)/) { } 0 0 0
557 0 my $href = $1;
558 0 my $tag = $2;
559 0 my $value = $3;
560 0 $tag =~ s/\s*$//;
561 0 ▶ if (uc($tag) eq "INCLUDE") {
Branch: 1 branch
BranchTrueFalseTotal
if (uc $tag eq 'INCLUDE') { } 0 0 0
562 0 $doc .= $self->_include_doc($value);
563 } else {
564 0 push @tags, [$href, $tag, $value];
565 }
566 } elsif (/^\s*@(@?)\s*([A-Z_a-z][0-9A-Z_a-z]*)\s+(.*)/) {
567 0 my $href = $1;
568 0 my $tag = $2;
569 0 my $value = $3;
570 0 ▶ if (uc($tag) eq "INCLUDE") {
Branch: 1 branch
BranchTrueFalseTotal
if (uc $tag eq 'INCLUDE') { } 0 0 0
571 0 $doc .= $self->_include_doc($value);
572 } else {
573 0 push @tags, [$href, $tag, $value];
574 }
575 } else {
576 0 $doc .= $_;
577 0 $doc .= "\n";
578 }
579 }
580 0 return ($doc, \@tags);
581 }
582
583 0 ▶sub _process_text {
Subroutine _process_text: not called CC=16 SCAR=56.1
584 0 my $self = shift;
585 0 my($text, $current, $href) = @_;
586
587 # keep track of leading and trailing white-space
588 0 ▶ my $lead = ($text =~ s/\A(\s+)//s ? $1 : "");
Branch: 1 branch
BranchTrueFalseTotal
$text =~ s/\A(\s+)//s ? : 0 0 0
589 0 ▶ my $trail = ($text =~ s/(\s+)\Z//s ? $1 : "");
Branch: 1 branch
BranchTrueFalseTotal
$text =~ s/(\s+)\Z//s ? : 0 0 0
590
591 # split at space/non-space boundaries
592 0 my @words = split( /(?<=\s)(?=\S)|(?<=\S)(?=\s)/, $text );
593
594 # process each word individually
595 0 foreach my $word (@words) {
596 # skip space runs
597 0 ▶ next if ($word =~ /^\s*$/);
Branch: 1 branch
BranchTrueFalseTotal
if $word =~ /^\s*$/ 0 0 0
598 0 ▶ next if ($word eq $current);
Branch: 1 branch
BranchTrueFalseTotal
if $word eq $current 0 0 0
599 0 ▶ if ($word =~ /^[A-Za-z_:][0-9A-Za-z\.\-_:]*$/) {
Branch: 3 branches
BranchTrueFalseTotal
if ($word =~ /^[A-Za-z_:][0-9A-Za-z\.\-_:]*$/) { } 0 0 0
elsif ($word =~ m[^\w+://\w]) { } 0 0 0
elsif ($word =~ /^[\w.-]+\@[\w.-]+/) { } 0 0 0
600 0 ▶ next if ($self->{flag_href} and !$href);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"flag_href"} and not $href 0 0 0
Condition0%0/3
$self->{"flag_href"} and not $href
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"flag_href"} and not $href
$self->{"flag_href"} not $href
Truth table0%0/3
A and not(B)
A= $self->{"flag_href"}B= not $href
ABresult
0X0
100
111
601 # looks like a DTD name
602 0 ▶ if (exists $self->{hash_notation}->{$word}) {
Branch: 3 branches
BranchTrueFalseTotal
if (exists $self->{'hash_notation'}{$word}) { } 0 0 0
elsif (exists $self->{'hash_entity'}{$word}) { } 0 0 0
elsif (exists $self->{'hash_element'}{$word}) { } 0 0 0
603 0 $word = $self->_mk_text_anchor("not", $word);
604 }
605 elsif (exists $self->{hash_entity}->{$word}) {
606 0 $word = $self->_mk_text_anchor("ent", $word);
607 }
608 elsif (exists $self->{hash_element}->{$word}) {
609 0 $word = $self->_mk_text_anchor("elt", $word);
610 }
611 } elsif ($word =~ /^\w+:\/\/\w/) {
612 # looks like a URL
613 # Don't relativize it: leave it as the author intended
614 $word = "<a href='" . $word . "'>" . $word . "</a>"
615 0 ▶ if ($self->{hlink});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"hlink"} 0 0 0
616 } elsif ($word =~ /^[\w.-]+\@[\w.-]+/) {
617 # looks like an e-mail address
618 $word = "<a href='mailto:" . $word . "'>" . $word . "</a>"
619 0 ▶ if ($self->{hlink});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"hlink"} 0 0 0
620 }
621 }
622
623 # put everything back together
624 0 return $lead . join('', @words) . $trail;
625 }
626
627 0 ▶sub _mk_value {
Subroutine _mk_value: not called CC=1 SCAR=6.9
628 0 my $self = shift;
629 0 my($value) = @_;
630
631 0 return "<span class='keyword1'>" . $value . "</span> ";
632 }
633
634 0 ▶sub _mk_index_anchor {
Subroutine _mk_index_anchor: not called CC=1 SCAR=6.9
635 0 my $self = shift;
636 0 my($type, $name) = @_;
637
638 0 my $href = $self->_mk_index_href($type, $name);
639 0 return "<a class='index' href='" . $href . "'>" . $name ."</a>";
640 }
641
642 0 ▶sub _mk_text_anchor {
Subroutine _mk_text_anchor: not called CC=1 SCAR=6.9
643 0 my $self = shift;
644 0 my($type, $name) = @_;
645
646 0 my $href = $self->_mk_index_href($type, $name);
647 0 return "<a href='" . $href . "'>" . $name . "</a>";
648 }
649
650 0 ▶sub _mk_index_href {
Subroutine _mk_index_href: not called CC=1 SCAR=6.9
651 0 my $self = shift;
652 0 my($type, $name) = @_;
653
654 0 return "#" . $type . "_" . $name;
655 }
656
657 0 ▶sub generateAlphaElement {
Subroutine generateAlphaElement: not called CC=5 SCAR=34.0
658 0 my $self = shift;
659 0 my ($nb, $a_link, $flg_brief) = @_;
660
661 0 ▶ $nb = 'nb_element' unless (defined $nb);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $nb 0 0 0
662 0 ▶ $a_link = 'a_elements' unless (defined $a_link);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $a_link 0 0 0
663
664 0 my @elements = sort keys %{$self->{hash_element}};
665 0 my @a_link = ();
666 0 foreach (@elements) {
667 0 my $a = $self->_mk_index_anchor("elt", $_);
668 0 ▶ if ($flg_brief) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flg_brief) { } 0 0 0
669 0 my $brief = $self->_get_brief($self->{hash_element}->{$_});
670 push @a_link, {
671 a => $a,
672 brief => $brief,
673 0 root => ($_ eq $self->{root_name}),
674 };
675 } else {
676 0 push @a_link, {
677 a => $a,
678 };
679 }
680 }
681 $self->{template}->param(
682 0 $nb => scalar @elements,
683 $a_link => \@a_link,
684 );
685 0 return;
686 }
687
688 0 ▶sub generateAlphaEntity {
Subroutine generateAlphaEntity: not called CC=5 SCAR=34.0
689 0 my $self = shift;
690 0 my ($nb, $a_link, $flg_brief) = @_;
691
692 0 ▶ $nb = 'nb_entity' unless (defined $nb);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $nb 0 0 0
693 0 ▶ $a_link = 'a_entities' unless (defined $a_link);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $a_link 0 0 0
694
695 0 my @entities = sort keys %{$self->{hash_entity}};
696 0 my @a_link = ();
697 0 foreach (@entities) {
698 0 my $a = $self->_mk_index_anchor("ent", $_);
699 0 ▶ if ($flg_brief) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flg_brief) { } 0 0 0
700 0 my $brief = $self->_get_brief($self->{hash_element}->{$_});
701 0 push @a_link, {
702 a => $a,
703 brief => $brief,
704 root => undef,
705 };
706 } else {
707 0 push @a_link, {
708 a => $a,
709 };
710 }
711 }
712 $self->{template}->param(
713 0 $nb => scalar @entities,
714 $a_link => \@a_link,
715 );
716 0 return;
717 }
718
719 0 ▶sub generateAlphaNotation {
Subroutine generateAlphaNotation: not called CC=5 SCAR=34.0
720 0 my $self = shift;
721 0 my ($nb, $a_link, $flg_brief) = @_;
722
723 0 ▶ $nb = 'nb_notation' unless (defined $nb);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $nb 0 0 0
724 0 ▶ $a_link = 'a_notations' unless (defined $a_link);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $a_link 0 0 0
725
726 0 my @notations = sort keys %{$self->{hash_notation}};
727 0 my @a_link = ();
728 0 foreach (@notations) {
729 0 my $a = $self->_mk_index_anchor("not", $_);
730 0 ▶ if ($flg_brief) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flg_brief) { } 0 0 0
731 0 my $brief = $self->_get_brief($self->{hash_element}->{$_});
732 0 push @a_link, {
733 a => $a,
734 brief => $brief,
735 root => undef,
736 };
737 } else {
738 0 push @a_link, {
739 a => $a,
740 };
741 }
742 }
743 $self->{template}->param(
744 0 $nb => scalar @notations,
745 $a_link => \@a_link,
746 );
747 0 return;
748 }
749
750 0 ▶sub generateExampleIndex {
Subroutine generateExampleIndex: not called CC=4 SCAR=30.0
751 0 my $self = shift;
752 0 my ($nb, $a_link) = @_;
753
754 0 ▶ $nb = 'nb_example' unless (defined $nb);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $nb 0 0 0
755 0 ▶ $a_link = 'a_examples' unless (defined $a_link);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $a_link 0 0 0
756
757 0 my @examples = @{$self->{examples}};
758 0 my @a_link = ();
759 0 foreach (@examples) {
760 0 my $a = $self->_mk_index_anchor("ex", $_);
761 0 push @a_link, {
762 a => $a,
763 };
764 }
765 $self->{template}->param(
766 0 $nb => scalar @examples,
767 $a_link => \@a_link,
768 );
769 0 return;
770 }
771
772 0 ▶sub _mk_tree {
Subroutine _mk_tree: not called CC=8 SCAR=42.8
773 0 my $self = shift;
774 0 my ($name, $depth) = @_;
775
776 0 ▶ return if ($self->{hash_element}->{$name}->{done});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"hash_element"}{$name}{"done"} 0 0 0
777 0 $self->{hash_element}->{$name}->{done} = 1;
778 die __PACKAGE__,"_mk_tree: INTERNAL ERROR ($name).\n"
779 0 ▶ unless (defined $self->{hash_element}->{$name}->{uses});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"hash_element"}{$name}{"uses"} 0 0 0
780 0 ▶ return unless (scalar keys %{$self->{hash_element}->{$name}->{uses}});
Branch: 1 branch
BranchTrueFalseTotal
unless scalar keys %{$$self{"hash_element"}{$name}{"uses"};} 0 0 0
781
782 0 my %done = ();
783 0 ▶ $self->{_tree_depth} = $depth if ($depth > $self->{_tree_depth});
Branch: 1 branch
BranchTrueFalseTotal
if $depth > $self->{"_tree_depth"} 0 0 0
784 0 $self->{_tree} .= "<ul class='tree'>\n";
785 0 foreach (keys %{$self->{hash_element}->{$name}->{uses}}) {
786 0 ▶ next if ($_ eq $name);
Branch: 1 branch
BranchTrueFalseTotal
if $_ eq $name 0 0 0
787 0 ▶ next if (exists $done{$_});
Branch: 1 branch
BranchTrueFalseTotal
if exists $done{$_} 0 0 0
788 0 $done{$_} = 1;
789 0 $self->{_tree} .= " <li class='tree'>" . $self->_mk_index_anchor("elt", $_) . "\n";
790 0 $self->_mk_tree($_, $depth+1);
791 0 $self->{_tree} .= " </li>\n";
792 }
793 0 $self->{_tree} .= "</ul>\n";
794 0 return;
795 }
796
797 0 ▶sub generateTree {
Subroutine generateTree: not called CC=3 SCAR=24.8
798 0 my $self = shift;
799
800 0 $self->{_tree_depth} = 1;
801 0 $self->{_tree} = "<ul class='tree'>\n";
802 0 $self->{_tree} .= " <li class='tree'>" . $self->_mk_index_anchor("elt", $self->{root_name}) . "\n";
803 0 ▶ if (exists $self->{hash_element}->{$self->{root_name}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{'hash_element'}{$self->{'root_name'}}) { } 0 0 0
804 0 $self->_mk_tree($self->{root_name}, $self->{_tree_depth});
805 } else {
806 0 warn "$self->{root_name} declared in DOCTYPE is an unknown element.\n";
807 }
808 0 $self->{_tree} .= " </li>\n";
809 0 $self->{_tree} .= "</ul>\n";
810 0 ▶ $self->{_tree} = "" if ($self->{_tree_depth} > 7);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_tree_depth"} > 7 0 0 0
811 $self->{template}->param(
812 tree => $self->{_tree},
813 0 );
814 0 delete $self->{_tree};
815 0 return;
816 }
817
818 0 ▶sub _get_doc {
Subroutine _get_doc: not called CC=11 SCAR=48.8
819 0 my $self = shift;
820 0 my ($decl) = @_;
821
822 0 my $name = $decl->{Name};
823 0 my @doc = ();
824 0 my @tag = ();
825 0 ▶ if ($self->{flag_comment} and exists $decl->{comments}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"flag_comment"} and exists $decl->{"comments"}) 0 0 0
Condition0%0/3
$self->{"flag_comment"} and exists $decl->{"comments"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"flag_comment"} and exists $decl->{"comments"}
$self->{"flag_comment"} exists $decl->{"comments"}
Truth table0%0/3
A and B
A= $self->{"flag_comment"}B= exists $decl->{"comments"}
ABresult
0X0
100
111
826 0 foreach my $comment (@{$decl->{comments}}) {
827 0 my ($doc, $r_tags) = $self->_extract_doc($comment);
828 0 ▶ if (defined $doc) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $doc) 0 0 0
829 0 my $data = $self->_process_text($doc, $name);
830 0 push @doc, { data => $data };
831 }
832 0 foreach (@{$r_tags}) {
833 0 my ($href, $entry, $data) = @{$_};
834 0 ▶ unless ( uc($entry) eq "BRIEF"
Branch: 1 branch
BranchTrueFalseTotal
unless (uc $entry eq "BRIEF" or uc $entry eq "HIDDEN" or uc $entry eq "TITLE" and $decl->{"type"} eq "doctype") 0 0 0
Condition0%0/9
uc $entry eq "BRIEF" or uc $entry eq "HIDDEN" or uc $entry eq "TITLE" and $decl->{"type"} eq "doctype"
l!l&&r!l&&!r
000
uc $entry eq "BRIEF" or uc $entry eq "HIDDEN"
l!l&&r!l&&!r
000
uc $entry eq "TITLE" and $decl->{"type"} eq "doctype"
!ll&&!rl&&r
000
MC/DC0%0/4
uc $entry eq "BRIEF" or uc $entry eq "HIDDEN" or uc $entry eq "TITLE" and $decl->{"type"} eq "doctype"
uc $entry eq "BRIEF" uc $entry eq "HIDDEN" uc $entry eq "TITLE" $decl->{"type"} eq "doctype"
Truth table0%0/5
A or B or C and D
A= uc $entry eq "BRIEF"B= uc $entry eq "HIDDEN"C= uc $entry eq "TITLE"D= $decl->{"type"} eq "doctype"
ABCDresult
1XXX1
01XX1
00111
000X0
00100
835 or uc($entry) eq "HIDDEN"
836 or (uc($entry) eq "TITLE" and $decl->{type} eq "doctype") ) {
837 0 ▶ if ($entry =~ /^SAMPLE($|\s)/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($entry =~ /^SAMPLE($|\s)/i) { } 0 0 0
838 0 $entry =~ s/^SAMPLE\s*//i;
839 0 $data = "<$self->{preformatted}>" . $self->_mk_example($data) . "</$self->{preformatted}>";
840 0 push @tag, {
841 entry => $entry,
842 data => $data,
843 };
844 } else {
845 0 $data = $self->_process_text($data, $name, $href);
846 0 push @tag, {
847 entry => $entry,
848 data => $data,
849 };
850 }
851 }
852 }
853 }
854 }
855
856 0 return (\@doc, \@tag);
857 }
858
859 0 ▶sub _get_doc_attrs {
Subroutine _get_doc_attrs: not called CC=11 SCAR=48.8
860 0 my $self = shift;
861 0 my ($name) = @_;
862
863 0 my @doc_attrs = ();
864 0 ▶ if ($self->{flag_comment} and exists $self->{hash_attr}->{$name}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"flag_comment"} and exists $self->{"hash_attr"}{$name}) 0 0 0
Condition0%0/3
$self->{"flag_comment"} and exists $self->{"hash_attr"}{$name}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"flag_comment"} and exists $self->{"hash_attr"}{$name}
$self->{"flag_comment"} exists $self->{"hash_attr"}{$name}
Truth table0%0/3
A and B
A= $self->{"flag_comment"}B= exists $self->{"hash_attr"}{$name}
ABresult
0X0
100
111
865 0 foreach my $attr (@{$self->{hash_attr}->{$name}}) {
866 0 ▶ if (exists $attr->{comments}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $attr->{"comments"}) 0 0 0
867 0 my @doc = ();
868 0 my @tag = ();
869 0 foreach my $comment (@{$attr->{comments}}) {
870 0 my ($doc, $r_tags) = $self->_extract_doc($comment);
871 0 ▶ if (defined $doc) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $doc) 0 0 0
872 0 my $data = $self->_process_text($doc, $name);
873 0 push @doc, { data => $data };
874 }
875 0 foreach (@{$r_tags}) {
876 0 my ($href, $entry, $data) = @{$_};
877 0 ▶ unless ( uc($entry) eq "BRIEF"
Branch: 1 branch
BranchTrueFalseTotal
unless (uc $entry eq "BRIEF" or uc $entry eq "HIDDEN") 0 0 0
Condition0%0/3
uc $entry eq "BRIEF" or uc $entry eq "HIDDEN"
l!l&&r!l&&!r
000
MC/DC0%0/2
uc $entry eq "BRIEF" or uc $entry eq "HIDDEN"
uc $entry eq "BRIEF" uc $entry eq "HIDDEN"
Truth table0%0/3
A or B
A= uc $entry eq "BRIEF"B= uc $entry eq "HIDDEN"
ABresult
1X1
011
000
878 or uc($entry) eq "HIDDEN" ) {
879 0 ▶ if ($entry =~ /^SAMPLE($|\s)/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($entry =~ /^SAMPLE($|\s)/i) { } 0 0 0
880 0 $entry =~ s/^SAMPLE\s*//i;
881 0 $data = "<$self->{preformatted}>" . $self->_mk_example($data) . "</$self->{preformatted}>";
882 0 push @tag, {
883 entry => $entry,
884 data => $data,
885 };
886 } else {
887 0 $data = $self->_process_text($data, $name, $href);
888 0 push @tag, {
889 entry => $entry,
890 data => $data,
891 };
892 }
893 }
894 }
895 }
896 push @doc_attrs, {
897 name => $attr->{aName},
898 0 doc => [ @doc ],
899 tag => [ @tag ],
900 }
901 }
902 }
903 }
904
905 0 return \@doc_attrs;
906 }
907
908 0 ▶sub _get_style {
Subroutine _get_style: not called CC=3 SCAR=24.8
909 0 my $self = shift;
910 0 my ($name) = @_;
911
912 0 my $style = "";
913 0 my $path = ${$self->{path_tmpl}}[-1];
914 0 ▶ open my $IN, '<', "$path/$name"
Branch: 1 branch
BranchTrueFalseTotal
open my $IN, "<", "$path/$name" or warn "can't open $path/$name ($!)", (return $style) 0 0 0
915 or warn "can't open $path/$name ($!)",
916 return $style;
917
918 0 ▶ while (<$IN>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $IN)) 0 0 0
919 0 $style .= $_;
920 }
921 0 close $IN;
922 0 return $style;
923 }
924
925 0 ▶sub generateMain {
Subroutine generateMain: not called CC=19 SCAR=59.4
926 0 my $self = shift;
927
928 0 my $standalone = "";
929 0 my $version;
930 my $encoding;
931 0 ▶ if (defined $self->{xml_decl}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"xml_decl"}) 0 0 0
932 0 $standalone = $self->{xml_decl}->{Standalone};
933 0 $version = $self->{xml_decl}->{Version};
934 0 $encoding = $self->{xml_decl}->{Encoding};
935 }
936 0 my $decl = $self->{dtd};
937 0 my $name = $decl->{Name};
938 0 my ($r_doc, $r_tag) = $self->_get_doc($decl);
939 $self->{template}->param(
940 dtd => "<a href='#elt_" . $name . "'>" . $name . "</a>",
941 standalone => ($standalone eq "yes"),
942 version => $version,
943 encoding => $encoding,
944 publicId => $decl->{PublicId},
945 systemId => $decl->{SystemId},
946 0 doc => $r_doc,
947 tag => $r_tag,
948 );
949
950 0 my @decls = ();
951 0 foreach my $decl (@{$self->{list_decl}}) {
952 0 my $type = $decl->{type};
953 0 my $name = $decl->{Name};
954 0 ($r_doc, $r_tag) = $self->_get_doc($decl);
955 0 ▶ if ($type eq "notation") {
Branch: 4 branches
BranchTrueFalseTotal
if ($type eq 'notation') { } 0 0 0
elsif ($type eq 'internal_entity') { } 0 0 0
elsif ($type eq 'external_entity') { } 0 0 0
elsif ($type eq 'element') { } 0 0 0
956 push @decls, {
957 is_notation => 1,
958 is_internal_entity => 0,
959 is_external_entity => 0,
960 is_element => 0,
961 name => $name,
962 a => "<a id='not_" . $name . "' name='not_" . $name . "'/>",
963 publicId => $decl->{PublicId},
964 systemId => $decl->{SystemId},
965 0 ▶ both_id => defined($decl->{PublicId}) && defined($decl->{SystemId}),
Condition0%0/3
defined $decl->{'PublicId'} && defined $decl->{'SystemId'}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $decl->{'PublicId'} && defined $decl->{'SystemId'}
defined $decl->{'PublicId'} defined $decl->{'SystemId'}
Truth table0%0/3
A && B
A= defined $decl->{'PublicId'}B= defined $decl->{'SystemId'}
ABresult
0X0
100
111
966 doc => $r_doc,
967 tag => $r_tag,
968 };
969 } elsif ($type eq "internal_entity") {
970 push @decls, {
971 is_notation => 0,
972 is_internal_entity => 1,
973 is_external_entity => 0,
974 is_element => 0,
975 name => $name,
976 a => "<a id='ent_" . $name . "' name='ent_" . $name . "'/>",
977 0 value => "&amp;#" . ord $decl->{Value} . ";",
978 doc => $r_doc,
979 tag => $r_tag,
980 };
981 } elsif ($type eq "external_entity") {
982 push @decls, {
983 is_notation => 0,
984 is_internal_entity => 0,
985 is_external_entity => 1,
986 is_element => 0,
987 name => $name,
988 a => "<a id='ent_" . $name . "' name='ent_" . $name . "'/>",
989 publicId => $decl->{PublicId},
990 systemId => $decl->{SystemId},
991 0 doc => $r_doc,
992 tag => $r_tag,
993 };
994 } elsif ($type eq "element") {
995 0 my $model = $decl->{Model};
996 0 my @attrs = ();
997 0 ▶ if (exists $self->{hash_attr}->{$name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"hash_attr"}{$name}) 0 0 0
998 0 foreach my $attr (@{$self->{hash_attr}->{$name}}) {
999 0 my $type = $attr->{Type};
1000 0 ▶ my $tokenized_type = $type eq "CDATA"
Condition0%0/21
$type eq 'CDATA' || $type eq 'ID' || $type eq 'IDREF' || $type eq 'IDREFS' || $type eq 'ENTITY' || $type eq 'ENTITIES' || $type eq 'NMTOKEN' || $type eq 'NMTOKENS'
l!l&&r!l&&!r
000
$type eq "CDATA" or $type eq "ID" or $type eq "IDREF" or $type eq "IDREFS" or $type eq "ENTITY" or $type eq "ENTITIES" or $type eq "NMTOKEN"
l!l&&r!l&&!r
000
$type eq "CDATA" or $type eq "ID" or $type eq "IDREF" or $type eq "IDREFS" or $type eq "ENTITY" or $type eq "ENTITIES"
l!l&&r!l&&!r
000
$type eq "CDATA" or $type eq "ID" or $type eq "IDREF" or $type eq "IDREFS" or $type eq "ENTITY"
l!l&&r!l&&!r
000
$type eq "CDATA" or $type eq "ID" or $type eq "IDREF" or $type eq "IDREFS"
l!l&&r!l&&!r
000
$type eq "CDATA" or $type eq "ID" or $type eq "IDREF"
l!l&&r!l&&!r
000
$type eq "CDATA" or $type eq "ID"
l!l&&r!l&&!r
000
MC/DC0%0/8
$type eq 'CDATA' || $type eq 'ID' || $type eq 'IDREF' || $type eq 'IDREFS' || $type eq 'ENTITY' || $type eq 'ENTITIES' || $type eq 'NMTOKEN' || $type eq 'NMTOKENS'
$type eq "CDATA" $type eq "ID" $type eq "IDREF" $type eq "IDREFS" $type eq "ENTITY" $type eq "ENTITIES" $type eq "NMTOKEN" $type eq 'NMTOKENS'
Truth table0%0/9
A or B or C or D or E or F or G || H
A= $type eq "CDATA"B= $type eq "ID"C= $type eq "IDREF"D= $type eq "IDREFS"E= $type eq "ENTITY"F= $type eq "ENTITIES"G= $type eq "NMTOKEN"H= $type eq 'NMTOKENS'
ABCDEFGHresult
1XXXXXXX1
01XXXXXX1
001XXXXX1
0001XXXX1
00001XXX1
000001XX1
0000001X1
000000011
000000000
1001 || $type eq "ID"
1002 || $type eq "IDREF"
1003 || $type eq "IDREFS"
1004 || $type eq "ENTITY"
1005 || $type eq "ENTITIES"
1006 || $type eq "NMTOKEN"
1007 || $type eq "NMTOKENS";
1008 0 ▶ unless ($tokenized_type) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($tokenized_type) 0 0 0
1009 0 $type =~ s/\(/\( /;
1010 0 $type =~ s/\)/ \)/;
1011 0 $type =~ s/\|/ \| /g;
1012 }
1013 0 my $value = $attr->{Value};
1014 0 ▶ $value = "\"$attr->{Value}\"" if ($value);
Branch: 1 branch
BranchTrueFalseTotal
if $value 0 0 0
1015 push @attrs, {
1016 name => $name,
1017 attr_name => $attr->{aName},
1018 type => $type,
1019 tokenized_type => $tokenized_type,
1020 value_default => $attr->{ValueDefault},
1021 0 value => $value,
1022 };
1023 }
1024 }
1025 0 push @decls, {
1026 is_notation => 0,
1027 is_internal_entity => 0,
1028 is_external_entity => 0,
1029 is_element => 1,
1030 name => $name,
1031 a => "<a id='elt_" . $name . "' name='elt_" . $name . "'/>",
1032 model => $self->_format_content_model($model),
1033 attrs => \@attrs,
1034 doc => $r_doc,
1035 tag => $r_tag,
1036 doc_attrs => $self->_get_doc_attrs($name),
1037 };
1038 } else {
1039 0 warn __PACKAGE__,":generateMain INTERNAL_ERROR (type:$type)\n";
1040 }
1041 }
1042 $self->{template}->param(
1043 0 decls => \@decls,
1044 );
1045 0 return;
1046 }
1047
1048 0 ▶sub _process_example {
Subroutine _process_example: not called CC=12 SCAR=50.5
1049 0 my $self = shift;
1050 0 my($text) = @_;
1051
1052 # keep track of leading and trailing white-space
1053 0 ▶ my $lead = ($text =~ s/\A(\s+)//s ? $1 : "");
Branch: 1 branch
BranchTrueFalseTotal
$text =~ s/\A(\s+)//s ? : 0 0 0
1054 0 ▶ my $trail = ($text =~ s/(\s+)\Z//s ? $1 : "");
Branch: 1 branch
BranchTrueFalseTotal
$text =~ s/(\s+)\Z//s ? : 0 0 0
1055
1056 # split at space/non-space boundaries
1057 0 my @words = split( /(?<=\s)(?=\S)|(?<=\S)(?=\s)/, $text );
1058
1059 # process each word individually
1060 0 foreach my $word (@words) {
1061 # skip space runs
1062 0 ▶ next if $word =~ /^\s*$/;
Branch: 1 branch
BranchTrueFalseTotal
if $word =~ /^\s*$/ 0 0 0
1063 0 ▶ if ($word =~ /^&lt;([A-Za-z_:][0-9A-Za-z\.\-_:]*)(&gt;[\S]*)?$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($word =~ /^&lt;([A-Za-z_:][0-9A-Za-z\.\-_:]*)(&gt;[\S]*)?$/) 0 0 0
1064 # looks like a DTD name, in example file
1065 0 ▶ if (exists $self->{hash_notation}->{$1}) {
Branch: 3 branches
BranchTrueFalseTotal
if (exists $self->{'hash_notation'}{$1}) { } 0 0 0
elsif (exists $self->{'hash_entity'}{$1}) { } 0 0 0
elsif (exists $self->{'hash_element'}{$1}) { } 0 0 0
1066 0 $word = "&lt;" . $self->_mk_text_anchor("not", $1);
1067 0 ▶ $word .= $2 if (defined $2);
Branch: 1 branch
BranchTrueFalseTotal
if defined $2 0 0 0
1068 }
1069 elsif (exists $self->{hash_entity}->{$1}) {
1070 0 $word = "&lt;" . $self->_mk_text_anchor("ent", $1);
1071 0 ▶ $word .= $2 if (defined $2);
Branch: 1 branch
BranchTrueFalseTotal
if defined $2 0 0 0
1072 }
1073 elsif (exists $self->{hash_element}->{$1}) {
1074 0 $word = "&lt;" . $self->_mk_text_anchor("elt", $1);
1075 0 ▶ $word .= $2 if (defined $2);
Branch: 1 branch
BranchTrueFalseTotal
if defined $2 0 0 0
1076 }
1077 }
1078 }
1079
1080 # put everything back together
1081 0 return $lead . join('', @words) . $trail;
1082 }
1083
1084 0 ▶sub _mk_example {
Subroutine _mk_example: not called CC=3 SCAR=24.8
1085 0 my $self = shift;
1086 0 my ($example, $emphasis) = @_;
1087
1088 0 ▶ open my $IN, '<', $example
Branch: 1 branch
BranchTrueFalseTotal
open my $IN, "<", $example or warn "can't open $example ($!)", next 0 0 0
1089 or warn "can't open $example ($!)",
1090 next;
1091 0 my $data;
1092 0 ▶ while (<$IN>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $IN)) 0 0 0
1093 0 s/&/&amp;/g;
1094 0 s/</&lt;/g;
1095 0 s/>/&gt;/g;
1096 0 s/'/&apos;/g;
1097 0 s/\"/&quot;/g;
1098 0 s/&lt;!--/<$self->{emphasis}>&lt;!--/g;
1099 0 s/--&gt;/--&gt;<\/$self->{emphasis}>/g;
1100 0 $data .= $self->_process_example($_);
1101 }
1102 0 close $IN;
1103
1104 0 return $data;
1105 }
1106
1107 0 ▶sub generateExample {
Subroutine generateExample: not called CC=2 SCAR=17.9
1108 0 my $self = shift;
1109
1110 0 my @examples = ();
1111 0 foreach my $ex (@{$self->{examples}}) {
1112 0 push @examples, {
1113 filename => $ex,
1114 a => "<a id='ex_" . $ex . "' name='ex_" . $ex . "'/>",
1115 text => $self->_mk_example($ex),
1116 };
1117 }
1118 $self->{template}->param(
1119 0 nb_example => scalar @{$self->{examples}},
1120 examples => \@examples,
1121 );
1122 0 return;
1123 }
1124
1125 0 ▶sub generateCSS {
Subroutine generateCSS: not called CC=3 SCAR=24.8
1126 0 my $self = shift;
1127 0 my ($style) = @_;
1128
1129 0 my $outfile = $self->{dirname} . "/" . $self->{css} . ".css";
1130
1131 0 ▶ unless ( -e $outfile) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $outfile) 0 0 0
1132 0 ▶ open my $OUT, '>', $outfile
Branch: 1 branch
BranchTrueFalseTotal
open my $OUT, ">", $outfile or die "can't open $outfile ($!)\n" 0 0 0
1133 or die "can't open $outfile ($!)\n";
1134 0 print $OUT $style;
1135 0 close $OUT;
1136 }
1137 0 return;
1138 }
1139
1140 0 ▶sub GenerateHTML {
Subroutine GenerateHTML: not called CC=5 SCAR=34.0
1141 0 my $self = shift;
1142
1143 warn "No element declaration captured.\n"
1144 0 ▶ unless (scalar keys %{$self->{hash_element}});
Branch: 1 branch
BranchTrueFalseTotal
unless scalar keys %{$$self{"hash_element"};} 0 0 0
1145
1146 0 $self->_process_args(@_);
1147
1148 0 my $style = $self->_get_style("simple.css");
1149
1150 0 ▶ $self->generateCSS($style) if ($self->{css});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"css"} 0 0 0
1151
1152 0 my $template = "simple.tmpl";
1153 $self->{template} = HTML::Template->new(
1154 filename => $template,
1155 path => $self->{path_tmpl},
1156 0 );
1157 die "can't create template with $template ($!).\n"
1158 0 ▶ unless (defined $self->{template});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"template"} 0 0 0
1159
1160 $self->{template}->param(
1161 generator => $self->{generator},
1162 date => $self->{now},
1163 title => $self->{title},
1164 0 );
1165 0 $self->generateAlphaElement();
1166 0 $self->generateAlphaEntity();
1167 0 $self->generateAlphaNotation();
1168 0 $self->generateExampleIndex();
1169 0 $self->generateTree();
1170 0 $self->generateMain();
1171 0 $self->generateExample();
1172
1173 0 my $filename = $self->{outfile} . ".html";
1174 0 ▶ open my $OUT, '>', $filename
Branch: 1 branch
BranchTrueFalseTotal
open my $OUT, ">", $filename or die "can't open $filename ($!)\n" 0 0 0
1175 or die "can't open $filename ($!)\n";
1176 0 print $OUT $self->{template}->output();
1177 0 close $OUT;
1178 0 return;
1179 }
1180
1181 ###############################################################################
1182
1183 package XML::Handler::Dtd2Html::DocumentFrame;
1184
1185 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
1186 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
1187
1188 1 ▶use base qw(XML::Handler::Dtd2Html::Document);
Subroutine BEGIN: called CC=1 SCAR=0.0
1189
1190 0 ▶sub _mk_index_href {
Subroutine _mk_index_href: not called CC=1 SCAR=6.9
1191 0 my $self = shift;
1192 0 my($type, $name) = @_;
1193
1194 0 return $self->{filebase} . ".main.html#" . $type . "_" . $name;
1195 }
1196
1197 0 ▶sub GenerateHTML {
Subroutine GenerateHTML: not called CC=11 SCAR=48.8
1198 0 my $self = shift;
1199
1200 warn "No element declaration captured.\n"
1201 0 ▶ unless (scalar keys %{$self->{hash_element}});
Branch: 1 branch
BranchTrueFalseTotal
unless scalar keys %{$$self{"hash_element"};} 0 0 0
1202
1203 0 $self->_process_args(@_);
1204
1205 0 my $style = $self->_get_style("frame.css");
1206
1207 0 ▶ $self->generateCSS($style) if ($self->{css});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"css"} 0 0 0
1208
1209 0 my $template = "frame.tmpl";
1210 $self->{template} = HTML::Template->new(
1211 filename => $template,
1212 path => $self->{path_tmpl},
1213 0 );
1214 die "can't create template with $template ($!).\n"
1215 0 ▶ unless (defined $self->{template});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"template"} 0 0 0
1216
1217 $self->{template}->param(
1218 generator => $self->{generator},
1219 date => $self->{now},
1220 title => $self->{title},
1221 file => $self->{filebase},
1222 0 );
1223
1224 0 my $filename = $self->{outfile} . ".html";
1225 0 ▶ open my $OUT, '>', $filename
Branch: 1 branch
BranchTrueFalseTotal
open my $OUT, ">", $filename or die "can't open $filename ($!)\n" 0 0 0
1226 or die "can't open $filename ($!)\n";
1227 0 print $OUT $self->{template}->output();
1228 0 close $OUT;
1229
1230 0 $template = "alpha.tmpl";
1231 $self->{template} = HTML::Template->new(
1232 filename => $template,
1233 path => $self->{path_tmpl},
1234 0 );
1235 die "can't create template with $template ($!).\n"
1236 0 ▶ unless (defined $self->{template});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"template"} 0 0 0
1237
1238 $self->{template}->param(
1239 generator => $self->{generator},
1240 date => $self->{now},
1241 css => $self->{css},
1242 0 title_page => $self->{title} . " (Alpha)",
1243 );
1244 0 $self->generateAlphaElement();
1245 0 $self->generateAlphaEntity();
1246 0 $self->generateAlphaNotation();
1247 0 $self->generateExampleIndex();
1248
1249 0 $filename = $self->{outfile} . ".alpha.html";
1250 0 ▶ open $OUT, '>', $filename
Branch: 1 branch
BranchTrueFalseTotal
open $OUT, ">", $filename or die "can't open $filename ($!)\n" 0 0 0
1251 or die "can't open $filename ($!)\n";
1252 0 print $OUT $self->{template}->output();
1253 0 close $OUT;
1254
1255 0 $template = "tree.tmpl";
1256 $self->{template} = HTML::Template->new(
1257 filename => $template,
1258 path => $self->{path_tmpl},
1259 0 );
1260 die "can't create template with $template ($!).\n"
1261 0 ▶ unless (defined $self->{template});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"template"} 0 0 0
1262
1263 $self->{template}->param(
1264 generator => $self->{generator},
1265 date => $self->{now},
1266 css => $self->{css},
1267 0 title_page => $self->{title} . " (Tree)",
1268 );
1269 0 $self->generateTree();
1270
1271 0 $filename = $self->{outfile} . ".tree.html";
1272 0 ▶ open $OUT, '>', $filename
Branch: 1 branch
BranchTrueFalseTotal
open $OUT, ">", $filename or die "can't open $filename ($!)\n" 0 0 0
1273 or die "can't open $filename ($!)\n";
1274 0 print $OUT $self->{template}->output();
1275 0 close $OUT;
1276
1277 0 $template = "main.tmpl";
1278 $self->{template} = HTML::Template->new(
1279 filename => $template,
1280 path => $self->{path_tmpl},
1281 0 );
1282 die "can't create template with $template ($!).\n"
1283 0 ▶ unless (defined $self->{template});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"template"} 0 0 0
1284
1285 $self->{template}->param(
1286 generator => $self->{generator},
1287 date => $self->{now},
1288 css => $self->{css},
1289 title => $self->{title},
1290 0 title_page => $self->{title} . " (Main)",
1291 );
1292 0 $self->generateMain();
1293 0 $self->generateExample();
1294
1295 0 $filename = $self->{outfile} . ".main.html";
1296 0 ▶ open $OUT, '>', $filename
Branch: 1 branch
BranchTrueFalseTotal
open $OUT, ">", $filename or die "can't open $filename ($!)\n" 0 0 0
1297 or die "can't open $filename ($!)\n";
1298 0 print $OUT $self->{template}->output();
1299 0 close $OUT;
1300 0 return;
1301 }
1302
1303 ###############################################################################
1304
1305 package XML::Handler::Dtd2Html::DocumentBook;
1306
1307 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
1308 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
1309
1310 1 ▶use base qw(XML::Handler::Dtd2Html::Document);
Subroutine BEGIN: called CC=1 SCAR=0.0
1311
1312 0 ▶sub _get_brief {
Subroutine _get_brief: not called CC=6 SCAR=37.4
1313 0 my $self = shift;
1314 0 my ($decl) = @_;
1315
1316 0 ▶ if ($self->{flag_comment} and exists $decl->{comments}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"flag_comment"} and exists $decl->{"comments"}) 0 0 0
Condition0%0/3
$self->{"flag_comment"} and exists $decl->{"comments"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"flag_comment"} and exists $decl->{"comments"}
$self->{"flag_comment"} exists $decl->{"comments"}
Truth table0%0/3
A and B
A= $self->{"flag_comment"}B= exists $decl->{"comments"}
ABresult
0X0
100
111
1317 0 foreach my $comment (@{$decl->{comments}}) {
1318 0 my ($doc, $r_tags) = $self->_extract_doc($comment);
1319 0 foreach my $tag (@{$r_tags}) {
1320 0 my $entry = ${$tag}[1];
1321 0 my $data = ${$tag}[2];
1322 0 ▶ if (uc($entry) eq "BRIEF") {
Branch: 1 branch
BranchTrueFalseTotal
if (uc $entry eq "BRIEF") 0 0 0
1323 0 return $data;
1324 }
1325 }
1326 }
1327 }
1328 0 return undef;
1329 }
1330
1331 0 ▶sub _get_parents {
Subroutine _get_parents: not called CC=2 SCAR=17.9
1332 0 my $self = shift;
1333 0 my ($decl) = @_;
1334
1335 0 my @parents = ();
1336 0 foreach (sort keys %{$decl->{used_by}}) {
1337 0 push @parents, { a => $self->_mk_text_anchor("elt", $_) };
1338 }
1339
1340 0 return \@parents;
1341 }
1342
1343 0 ▶sub _get_childs {
Subroutine _get_childs: not called CC=2 SCAR=17.9
1344 0 my $self = shift;
1345 0 my ($decl) = @_;
1346
1347 0 my @childs = ();
1348 0 foreach (sort keys %{$decl->{uses}}) {
1349 0 push @childs, { a => $self->_mk_text_anchor("elt", $_) };
1350 }
1351
1352 0 return \@childs;
1353 }
1354
1355 0 ▶sub _get_attributes {
Subroutine _get_attributes: not called CC=16 SCAR=56.1
1356 0 my $self = shift;
1357 0 my ($name) = @_;
1358
1359 0 my @attrs = ();
1360 0 ▶ if (exists $self->{hash_attr}->{$name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"hash_attr"}{$name}) 0 0 0
1361 0 foreach my $attr (@{$self->{hash_attr}->{$name}}) {
1362 0 my @enum = ();
1363 0 my $is_enum;
1364 my $is_notation;
1365 0 my $type = $attr->{Type};
1366 0 ▶ if ( $type ne "CDATA"
Branch: 1 branch
BranchTrueFalseTotal
if ($type ne "CDATA" and $type ne "ID" and $type ne "IDREF" and $type ne "IDREFS" and $type ne "ENTITY" and $type ne "ENTITIES" and $type ne "NMTOKEN" and $type ne "NMTOKENS") 0 0 0
Condition0%0/21
$type ne "CDATA" and $type ne "ID" and $type ne "IDREF" and $type ne "IDREFS" and $type ne "ENTITY" and $type ne "ENTITIES" and $type ne "NMTOKEN" and $type ne "NMTOKENS"
!ll&&!rl&&r
000
$type ne "CDATA" and $type ne "ID" and $type ne "IDREF" and $type ne "IDREFS" and $type ne "ENTITY" and $type ne "ENTITIES" and $type ne "NMTOKEN"
!ll&&!rl&&r
000
$type ne "CDATA" and $type ne "ID" and $type ne "IDREF" and $type ne "IDREFS" and $type ne "ENTITY" and $type ne "ENTITIES"
!ll&&!rl&&r
000
$type ne "CDATA" and $type ne "ID" and $type ne "IDREF" and $type ne "IDREFS" and $type ne "ENTITY"
!ll&&!rl&&r
000
$type ne "CDATA" and $type ne "ID" and $type ne "IDREF" and $type ne "IDREFS"
!ll&&!rl&&r
000
$type ne "CDATA" and $type ne "ID" and $type ne "IDREF"
!ll&&!rl&&r
000
$type ne "CDATA" and $type ne "ID"
!ll&&!rl&&r
000
MC/DC0%0/8
$type ne "CDATA" and $type ne "ID" and $type ne "IDREF" and $type ne "IDREFS" and $type ne "ENTITY" and $type ne "ENTITIES" and $type ne "NMTOKEN" and $type ne "NMTOKENS"
$type ne "CDATA" $type ne "ID" $type ne "IDREF" $type ne "IDREFS" $type ne "ENTITY" $type ne "ENTITIES" $type ne "NMTOKEN" $type ne "NMTOKENS"
Truth table0%0/9
A and B and C and D and E and F and G and H
A= $type ne "CDATA"B= $type ne "ID"C= $type ne "IDREF"D= $type ne "IDREFS"E= $type ne "ENTITY"F= $type ne "ENTITIES"G= $type ne "NMTOKEN"H= $type ne "NMTOKENS"
ABCDEFGHresult
0XXXXXXX0
10XXXXXX0
110XXXXX0
1110XXXX0
11110XXX0
111110XX0
1111110X0
111111100
111111111
1367 and $type ne "ID"
1368 and $type ne "IDREF"
1369 and $type ne "IDREFS"
1370 and $type ne "ENTITY"
1371 and $type ne "ENTITIES"
1372 and $type ne "NMTOKEN"
1373 and $type ne "NMTOKENS" ) {
1374 0 ▶ if ($type =~ /^NOTATION/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type =~ /^NOTATION/) { } 0 0 0
1375 0 $is_notation = 1;
1376 0 $type =~ s/^NOTATION\s*\(//;
1377 0 $type =~ s/\)$//;
1378 0 foreach (split /\|/, $type) {
1379 0 push @enum, {
1380 val => $_,
1381 };
1382 }
1383 } else {
1384 0 $is_enum = 1;
1385 0 $type =~ s/^\(//;
1386 0 $type =~ s/\)$//;
1387 0 foreach (split /\|/, $type) {
1388 0 push @enum, {
1389 val => $_,
1390 };
1391 }
1392 }
1393 }
1394 0 my $value_default = $attr->{ValueDefault};
1395 0 my $value = $attr->{Value};
1396 0 ▶ if ($value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value) 0 0 0
1397 0 $value_default .= " \"" . $value . "\"";
1398 }
1399 0 ▶ $value_default = "&#160;" unless ($value_default);
Branch: 1 branch
BranchTrueFalseTotal
unless $value_default 0 0 0
1400 push @attrs, {
1401 attr_name => $attr->{aName},
1402 0 is_enum => $is_enum,
1403 is_notation => $is_notation,
1404 enum => \@enum,
1405 type => $type,
1406 value_default => $value_default,
1407 };
1408 }
1409 }
1410
1411 0 return \@attrs;
1412 }
1413
1414 0 ▶sub _mk_value {
Subroutine _mk_value: not called CC=1 SCAR=6.9
1415 0 my $self = shift;
1416 0 my($value) = @_;
1417
1418 0 return $value;
1419 }
1420
1421 0 ▶sub _mk_index_href {
Subroutine _mk_index_href: not called CC=1 SCAR=6.9
1422 0 my $self = shift;
1423 0 my($type, $name) = @_;
1424
1425 0 my $uri_name = $name;
1426 0 $uri_name =~ s/[ :]/_/g;
1427 0 $uri_name = $self->_mk_filename($uri_name);
1428
1429 0 return $self->{filebase} . "." . $type . "." . $uri_name . ".html";
1430 }
1431
1432 0 ▶sub _mk_nav_href {
Subroutine _mk_nav_href: not called CC=2 SCAR=17.9
1433 0 my $self = shift;
1434 0 my($type, $name) = @_;
1435
1436 0 ▶ return undef unless ($name);
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 0 0
1437
1438 0 return $self->_mk_index_href($type, $name);
1439 }
1440
1441 0 ▶sub _mk_outfile {
Subroutine _mk_outfile: not called CC=1 SCAR=6.9
1442 0 my $self = shift;
1443 0 my($type, $name) = @_;
1444
1445 0 my $uri_name = $name;
1446 0 $uri_name =~ s/[ :]/_/g;
1447 0 $uri_name = $self->_mk_filename($uri_name);
1448
1449 0 return $self->{outfile} . "." . $type . "." . $uri_name . ".html";
1450 }
1451
1452 0 ▶sub _test_sensitive {
Subroutine _test_sensitive: not called CC=3 SCAR=20.3
1453 0 my $self = shift;
1454 1 ▶ use File::Temp qw(tempfile);
Subroutine BEGIN: called CC=1 SCAR=0.0
1455
1456 0 my ($fh, $filename) = tempfile("caseXXXX");
1457 0 close $fh;
1458 0 ▶ if (-e $filename and -e uc $filename) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $filename and -e uc $filename) 0 0 0
Condition0%0/3
-e $filename and -e uc $filename
!ll&&!rl&&r
000
MC/DC0%0/2
-e $filename and -e uc $filename
-e $filename -e uc $filename
Truth table0%0/3
A and B
A= -e $filenameB= -e uc $filename
ABresult
0X0
100
111
1459 0 $self->{not_sensitive} = 1;
1460 }
1461 0 unlink $filename;
1462 0 return;
1463 }
1464
1465 0 ▶sub _mk_filename {
Subroutine _mk_filename: not called CC=2 SCAR=17.9
1466 0 my $self = shift;
1467 0 my ($name) = @_;
1468 0 ▶ return $name unless (exists $self->{not_sensitive});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"not_sensitive"} 0 0 0
1469 0 $name =~ s/([A-Z])/$1_/g;
1470 0 $name =~ s/([a-z])/_$1/g;
1471 0 return $name;
1472 }
1473
1474 0 ▶sub copyPNG {
Subroutine copyPNG: not called CC=4 SCAR=26.3
1475 0 my $self = shift;
1476 1 ▶ use File::Copy;
Subroutine BEGIN: called CC=1 SCAR=0.0
1477
1478 0 my $path = ${$self->{path_tmpl}}[-1];
1479 0 foreach my $img (qw(next up home prev)) {
1480 0 my $infile = $path . "/" . $img .".png";
1481 0 my $outfile = $self->{dirname} . "/" . $img . ".png";
1482 0 ▶ unless ( -e $infile) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $infile) 0 0 0
1483 0 warn "can't find $infile.\n";
1484 0 next;
1485 }
1486 0 copy($infile, $outfile);
1487 0 ▶ unless ( -e $outfile) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $outfile) 0 0 0
1488 0 warn "$outfile is not copied.\n";
1489 }
1490 }
1491 0 return;
1492 }
1493
1494 0 ▶sub GenerateHTML {
Subroutine GenerateHTML: not called CC=46 SCAR=76.8
1495 0 my $self = shift;
1496
1497 warn "No element declaration captured.\n"
1498 0 ▶ unless (scalar keys %{$self->{hash_element}});
Branch: 1 branch
BranchTrueFalseTotal
unless scalar keys %{$$self{"hash_element"};} 0 0 0
1499
1500 0 $self->_process_args(@_);
1501
1502 0 $self->_test_sensitive();
1503
1504 0 my $style = $self->_get_style("book.css");
1505
1506 0 ▶ $self->generateCSS($style) if ($self->{css});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"css"} 0 0 0
1507 0 $self->copyPNG();
1508
1509 0 my $template = "book.tmpl";
1510 $self->{template} = HTML::Template->new(
1511 filename => $template,
1512 path => $self->{path_tmpl},
1513 0 );
1514 die "can't create template with $template ($!).\n"
1515 0 ▶ unless (defined $self->{template});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"template"} 0 0 0
1516
1517 $self->{template}->param(
1518 generator => $self->{generator},
1519 date => $self->{now},
1520 css => $self->{css},
1521 book_title => $self->{title},
1522 0 );
1523 $self->{template}->param(
1524 page_title => $self->{title},
1525 0 href_next => $self->_mk_nav_href("", ""),
1526 href_prev => $self->_mk_nav_href("", ""),
1527 href_home => $self->_mk_nav_href("book", "home"),
1528 href_up => $self->_mk_nav_href("", ""),
1529 lbl_next => "&nbsp;",
1530 lbl_prev => "&nbsp;",
1531 );
1532 $self->{template}->param(
1533 href_prolog => $self->{filebase} . ".book." . $self->_mk_filename("prolog") . ".html",
1534 href_elt => $self->{filebase} . ".book." . $self->_mk_filename("elements_index") . ".html",
1535 href_ent => $self->{filebase} . ".book." . $self->_mk_filename("entities_index") . ".html",
1536 href_not => $self->{filebase} . ".book." . $self->_mk_filename("notations_index") . ".html",
1537 0 href_ex => $self->{filebase} . ".book." . $self->_mk_filename("examples_list") . ".html",
1538 );
1539 0 $self->generateTree();
1540
1541 0 my $filename = $self->_mk_outfile("book", "home");
1542 0 ▶ open my $OUT, '>', $filename
Branch: 1 branch
BranchTrueFalseTotal
open my $OUT, ">", $filename or die "can't open $filename ($!)\n" 0 0 0
1543 or die "can't open $filename ($!)\n";
1544 0 print $OUT $self->{template}->output();
1545 0 close $OUT;
1546
1547 0 $template = "prolog.tmpl";
1548 $self->{template} = HTML::Template->new(
1549 filename => $template,
1550 path => $self->{path_tmpl},
1551 0 );
1552 die "can't create template with $template ($!).\n"
1553 0 ▶ unless (defined $self->{template});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"template"} 0 0 0
1554
1555 $self->{template}->param(
1556 generator => $self->{generator},
1557 date => $self->{now},
1558 css => $self->{css},
1559 book_title => $self->{title},
1560 0 );
1561 $self->{template}->param(
1562 page_title => $self->{title},
1563 0 href_next => $self->_mk_nav_href("book", "elements index"),
1564 href_prev => $self->_mk_nav_href("book", "home"),
1565 href_home => $self->_mk_nav_href("book", "home"),
1566 href_up => $self->_mk_nav_href("book", "home"),
1567 lbl_next => "elements index",
1568 lbl_prev => "home",
1569 );
1570 0 my ($r_doc, $r_tag) = $self->_get_doc($self->{dtd});
1571 $self->{template}->param(
1572 name => $self->{dtd}->{Name},
1573 brief => $self->_get_brief($self->{dtd}),
1574 publicId => $self->{dtd}->{PublicId},
1575 systemId => $self->{dtd}->{SystemId},
1576 0 doc => $r_doc,
1577 tag => $r_tag,
1578 );
1579
1580 0 $filename = $self->_mk_outfile("book", "prolog");
1581 0 ▶ open $OUT, '>', $filename
Branch: 1 branch
BranchTrueFalseTotal
open $OUT, ">", $filename or die "can't open $filename ($!)\n" 0 0 0
1582 or die "can't open $filename ($!)\n";
1583 0 print $OUT $self->{template}->output();
1584 0 close $OUT;
1585
1586 0 $template = "index.tmpl";
1587 $self->{template} = HTML::Template->new(
1588 filename => $template,
1589 path => $self->{path_tmpl},
1590 0 );
1591 die "can't create template with $template ($!).\n"
1592 0 ▶ unless (defined $self->{template});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"template"} 0 0 0
1593
1594 $self->{template}->param(
1595 generator => $self->{generator},
1596 date => $self->{now},
1597 css => $self->{css},
1598 book_title => $self->{title},
1599 0 );
1600 $self->{template}->param(
1601 0 page_title => "Elements Index.",
1602 href_next => $self->_mk_nav_href("book", "entities index"),
1603 href_prev => $self->_mk_nav_href("book", "prolog"),
1604 href_home => $self->_mk_nav_href("book", "home"),
1605 href_up => $self->_mk_nav_href("book", "home"),
1606 lbl_next => "entities index",
1607 lbl_prev => "prolog",
1608 );
1609 $self->{template}->param(
1610 0 idx_elt => 1,
1611 idx_ent => 0,
1612 idx_not => 0,
1613 lst_ex => 0,
1614 );
1615 0 $self->generateAlphaElement("nb", "a_link", 1);
1616 0 my @elements = sort keys %{$self->{hash_element}};
1617
1618 0 $filename = $self->_mk_outfile("book", "elements_index");
1619 0 ▶ open $OUT, '>', $filename
Branch: 1 branch
BranchTrueFalseTotal
open $OUT, ">", $filename or die "can't open $filename ($!)\n" 0 0 0
1620 or die "can't open $filename ($!)\n";
1621 0 print $OUT $self->{template}->output();
1622 0 close $OUT;
1623
1624 0 ▶ if (scalar @elements) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @elements) 0 0 0
1625 0 $template = "element.tmpl";
1626 $self->{template} = HTML::Template->new(
1627 filename => $template,
1628 path => $self->{path_tmpl},
1629 0 loop_context_vars => 1,
1630 );
1631 die "can't create template with $template ($!).\n"
1632 0 ▶ unless (defined $self->{template});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"template"} 0 0 0
1633
1634 $self->{template}->param(
1635 generator => $self->{generator},
1636 date => $self->{now},
1637 css => $self->{css},
1638 book_title => $self->{title},
1639 0 );
1640
1641 0 my @prevs = @elements;
1642 0 my @nexts = @elements;
1643 0 pop @prevs;
1644 0 unshift @prevs, "elements index";
1645 0 shift @nexts;
1646 0 push @nexts, "";
1647 0 my $first = 1;
1648 0 foreach my $name (@elements) {
1649 0 my $decl = $self->{hash_element}->{$name};
1650 0 ▶ my $type_p = $first ? "book" : "elt";
Branch: 1 branch
BranchTrueFalseTotal
$first ? : 0 0 0
1651 0 my $type_n = "elt";
1652 0 my $prev = shift @prevs;
1653 0 my $next = shift @nexts;
1654
1655 $self->{template}->param(
1656 0 ▶ page_title => "Element " . $name,
Branch: 2 branches
BranchTrueFalseTotal
$next ? : 0 0 0
$prev ? : 0 0 0
1657 href_next => $self->_mk_nav_href($type_n, $next),
1658 href_prev => $self->_mk_nav_href($type_p, $prev),
1659 href_home => $self->_mk_nav_href("book", "home"),
1660 href_up => $self->_mk_nav_href("book", "elements index"),
1661 lbl_next => ($next ? $next : "&nbsp;"),
1662 lbl_prev => ($prev ? $prev : "&nbsp;"),
1663 );
1664 0 my $model = $decl->{Model};
1665 0 ($r_doc, $r_tag) = $self->_get_doc($decl);
1666 $self->{template}->param(
1667 0 ▶ name => $name,
Branch: 2 branches
BranchTrueFalseTotal
$model =~ /#PCDATA/ ? : 0 0 0
!($model =~ /(ANY|EMPTY)/) ? : 0 0 0
1668 brief => $self->_get_brief($decl),
1669 f_model => $self->_format_content_model($model),
1670 attrs => $self->_get_attributes($name),
1671 parents => $self->_get_parents($decl),
1672 childs => $self->_get_childs($decl),
1673 doc => $r_doc,
1674 tag => $r_tag,
1675 doc_attrs => $self->_get_doc_attrs($name),
1676 is_mixed => ($model =~ /#PCDATA/) ? 1 : 0,
1677 is_element => ($model !~ /(ANY|EMPTY)/) ? 1 : 0,
1678 );
1679
1680 0 $filename = $self->_mk_outfile($type_n, $name);
1681 0 ▶ open $OUT, '>', $filename
Branch: 1 branch
BranchTrueFalseTotal
open $OUT, ">", $filename or die "can't open $filename ($!)\n" 0 0 0
1682 or die "can't open $filename ($!)\n";
1683 0 print $OUT $self->{template}->output();
1684 0 close $OUT;
1685 0 $first = 0;
1686 }
1687 }
1688
1689 0 $template = "index.tmpl";
1690 $self->{template} = HTML::Template->new(
1691 filename => $template,
1692 path => $self->{path_tmpl},
1693 0 );
1694 die "can't create template with $template ($!).\n"
1695 0 ▶ unless (defined $self->{template});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"template"} 0 0 0
1696
1697 $self->{template}->param(
1698 generator => $self->{generator},
1699 date => $self->{now},
1700 css => $self->{css},
1701 book_title => $self->{title},
1702 0 );
1703 $self->{template}->param(
1704 0 page_title => "Entities Index.",
1705 href_next => $self->_mk_nav_href("book", "notations index"),
1706 href_prev => $self->_mk_nav_href("book", "elements index"),
1707 href_home => $self->_mk_nav_href("book", "home"),
1708 href_up => $self->_mk_nav_href("book", "home"),
1709 lbl_next => "notations index",
1710 lbl_prev => "elements index",
1711 );
1712 $self->{template}->param(
1713 0 idx_elt => 0,
1714 idx_ent => 1,
1715 idx_not => 0,
1716 lst_ex => 0,
1717 );
1718 0 my @entities = sort keys %{$self->{hash_entity}};
1719 0 $self->generateAlphaEntity("nb", "a_link", 1);
1720
1721 0 $filename = $self->_mk_outfile("book","entities_index");
1722 0 ▶ open $OUT, '>', $filename
Branch: 1 branch
BranchTrueFalseTotal
open $OUT, ">", $filename or die "can't open $filename ($!)\n" 0 0 0
1723 or die "can't open $filename ($!)\n";
1724 0 print $OUT $self->{template}->output();
1725 0 close $OUT;
1726
1727 0 ▶ if (scalar @entities) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @entities) 0 0 0
1728 0 $template = "entity.tmpl";
1729 $self->{template} = HTML::Template->new(
1730 filename => $template,
1731 path => $self->{path_tmpl},
1732 0 );
1733 die "can't create template with $template ($!).\n"
1734 0 ▶ unless (defined $self->{template});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"template"} 0 0 0
1735
1736 $self->{template}->param(
1737 generator => $self->{generator},
1738 date => $self->{now},
1739 css => $self->{css},
1740 book_title => $self->{title},
1741 0 );
1742
1743 0 my @prevs = @entities;
1744 0 my @nexts = @entities;
1745 0 pop @prevs;
1746 0 unshift @prevs, "entities index";
1747 0 shift @nexts;
1748 0 push @nexts, "";
1749 0 my $first = 1;
1750 0 foreach (@entities) {
1751 0 my $decl = $self->{hash_entity}->{$_};
1752 0 ▶ my $type_p = $first ? "book" : "ent";
Branch: 1 branch
BranchTrueFalseTotal
$first ? : 0 0 0
1753 0 my $type_n = "ent";
1754 0 my $prev = shift @prevs;
1755 0 my $next = shift @nexts;
1756
1757 $self->{template}->param(
1758 0 ▶ page_title => "Entity " . $_,
Branch: 2 branches
BranchTrueFalseTotal
$next ? : 0 0 0
$prev ? : 0 0 0
1759 href_next => $self->_mk_nav_href($type_n, $next),
1760 href_prev => $self->_mk_nav_href($type_p, $prev),
1761 href_home => $self->_mk_nav_href("book", "home"),
1762 href_up => $self->_mk_nav_href("book", "entities index"),
1763 lbl_next => ($next ? $next : "&nbsp;"),
1764 lbl_prev => ($prev ? $prev : "&nbsp;"),
1765 );
1766 0 ($r_doc, $r_tag) = $self->_get_doc($decl);
1767 $self->{template}->param(
1768 name => $_,
1769 brief => $self->_get_brief($decl),
1770 value => (exists $decl->{Value}) ? ord($decl->{Value}) : undef,
1771 publicId => $decl->{PublicId},
1772 systemId => $decl->{SystemId},
1773 0 ▶ doc => $r_doc,
Branch: 1 branch
BranchTrueFalseTotal
exists $decl->{'Value'} ? : 0 0 0
1774 tag => $r_tag,
1775 );
1776
1777 0 $filename = $self->_mk_outfile($type_n, $_);
1778 0 ▶ open $OUT, '>', $filename
Branch: 1 branch
BranchTrueFalseTotal
open $OUT, ">", $filename or die "can't open $filename ($!)\n" 0 0 0
1779 or die "can't open $filename ($!)\n";
1780 0 print $OUT $self->{template}->output();
1781 0 close $OUT;
1782 0 $first = 0;
1783 }
1784 }
1785
1786 0 $template = "index.tmpl";
1787 $self->{template} = HTML::Template->new(
1788 filename => $template,
1789 path => $self->{path_tmpl},
1790 0 );
1791 die "can't create template with $template ($!).\n"
1792 0 ▶ unless (defined $self->{template});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"template"} 0 0 0
1793
1794 $self->{template}->param(
1795 generator => $self->{generator},
1796 date => $self->{now},
1797 css => $self->{css},
1798 book_title => $self->{title},
1799 0 );
1800 $self->{template}->param(
1801 0 page_title => "Notations Index.",
1802 href_next => $self->_mk_nav_href("book", "examples list"),
1803 href_prev => $self->_mk_nav_href("book", "entities index"),
1804 href_home => $self->_mk_nav_href("book", "home"),
1805 href_up => $self->_mk_nav_href("book", "home"),
1806 lbl_next => "examples list",
1807 lbl_prev => "entities index",
1808 );
1809 $self->{template}->param(
1810 0 idx_elt => 0,
1811 idx_ent => 0,
1812 idx_not => 1,
1813 lst_ex => 0,
1814 );
1815 0 my @notations = sort keys %{$self->{hash_notation}};
1816 0 $self->generateAlphaNotation("nb", "a_link", 1);
1817
1818 0 $filename = $self->_mk_outfile("book", "notations_index");
1819 0 ▶ open $OUT, '>', $filename
Branch: 1 branch
BranchTrueFalseTotal
open $OUT, ">", $filename or die "can't open $filename ($!)\n" 0 0 0
1820 or die "can't open $filename ($!)\n";
1821 0 print $OUT $self->{template}->output();
1822 0 close $OUT;
1823
1824 0 ▶ if (scalar @notations) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @notations) 0 0 0
1825 0 $template = "notation.tmpl";
1826 $self->{template} = HTML::Template->new(
1827 filename => $template,
1828 path => $self->{path_tmpl},
1829 0 );
1830 die "can't create template with $template ($!).\n"
1831 0 ▶ unless (defined $self->{template});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"template"} 0 0 0
1832
1833 $self->{template}->param(
1834 generator => $self->{generator},
1835 date => $self->{now},
1836 css => $self->{css},
1837 book_title => $self->{title},
1838 0 );
1839
1840 0 my @prevs = @notations;
1841 0 my @nexts = @notations;
1842 0 pop @prevs;
1843 0 unshift @prevs, "notations_index";
1844 0 shift @nexts;
1845 0 push @nexts, "";
1846 0 my $first = 1;
1847 0 foreach (@notations) {
1848 0 my $decl = $self->{hash_notation}->{$_};
1849 0 ▶ my $type_p = $first ? "book" : "not";
Branch: 1 branch
BranchTrueFalseTotal
$first ? : 0 0 0
1850 0 my $type_n = "not";
1851 0 my $prev = shift @prevs;
1852 0 my $next = shift @nexts;
1853
1854 $self->{template}->param(
1855 0 ▶ page_title => "Notation " . $_,
Branch: 2 branches
BranchTrueFalseTotal
$next ? : 0 0 0
$prev ? : 0 0 0
1856 href_next => $self->_mk_nav_href($type_n, $next),
1857 href_prev => $self->_mk_nav_href($type_p, $prev),
1858 href_home => $self->_mk_nav_href("book", "home"),
1859 href_up => $self->_mk_nav_href("book", "notations index"),
1860 lbl_next => ($next ? $next : "&nbsp;"),
1861 lbl_prev => ($prev ? $prev : "&nbsp;"),
1862 );
1863 0 ($r_doc, $r_tag) = $self->_get_doc($decl);
1864 $self->{template}->param(
1865 name => $_,
1866 brief => $self->_get_brief($decl),
1867 publicId => $decl->{PublicId},
1868 systemId => $decl->{SystemId},
1869 0 doc => $r_doc,
1870 tag => $r_tag,
1871 );
1872
1873 0 $filename = $self->_mk_outfile($type_n, $_);
1874 0 ▶ open $OUT, '>', $filename
Branch: 1 branch
BranchTrueFalseTotal
open $OUT, ">", $filename or die "can't open $filename ($!)\n" 0 0 0
1875 or die "can't open $filename ($!)\n";
1876 0 print $OUT $self->{template}->output();
1877 0 close $OUT;
1878 0 $first = 0;
1879 }
1880 }
1881
1882 0 $template = "index.tmpl";
1883 $self->{template} = HTML::Template->new(
1884 filename => $template,
1885 path => $self->{path_tmpl},
1886 0 );
1887 die "can't create template with $template ($!).\n"
1888 0 ▶ unless (defined $self->{template});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"template"} 0 0 0
1889
1890 $self->{template}->param(
1891 generator => $self->{generator},
1892 date => $self->{now},
1893 css => $self->{css},
1894 book_title => $self->{title},
1895 0 );
1896 $self->{template}->param(
1897 0 page_title => "Examples List.",
1898 href_next => $self->_mk_nav_href("", ""),
1899 href_prev => $self->_mk_nav_href("book", "notations index"),
1900 href_home => $self->_mk_nav_href("book", "home"),
1901 href_up => $self->_mk_nav_href("book", "home"),
1902 lbl_next => "&nbsp;",
1903 lbl_prev => "notations index",
1904 );
1905 $self->{template}->param(
1906 0 idx_elt => 0,
1907 idx_ent => 0,
1908 idx_not => 0,
1909 lst_ex => 1,
1910 );
1911 0 my @examples = @{$self->{examples}};
1912 0 $self->generateExampleIndex("nb", "a_link");
1913
1914 0 $filename = $self->_mk_outfile("book", "examples_list");
1915 0 ▶ open $OUT, '>', $filename
Branch: 1 branch
BranchTrueFalseTotal
open $OUT, ">", $filename or die "can't open $filename ($!)\n" 0 0 0
1916 or die "can't open $filename ($!)\n";
1917 0 print $OUT $self->{template}->output();
1918 0 close $OUT;
1919
1920 0 ▶ if (scalar @examples) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @examples) 0 0 0
1921 0 $template = "example.tmpl";
1922 $self->{template} = HTML::Template->new(
1923 filename => $template,
1924 path => $self->{path_tmpl},
1925 0 );
1926 die "can't create template with $template ($!).\n"
1927 0 ▶ unless (defined $self->{template});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"template"} 0 0 0
1928
1929 $self->{template}->param(
1930 generator => $self->{generator},
1931 date => $self->{now},
1932 css => $self->{css},
1933 book_title => $self->{title},
1934 0 );
1935
1936 0 my @prevs = @examples;
1937 0 my @nexts = @examples;
1938 0 pop @prevs;
1939 0 unshift @prevs, "examples list";
1940 0 shift @nexts;
1941 0 push @nexts, "";
1942 0 my $first = 1;
1943 0 foreach my $example (@examples) {
1944 0 ▶ my $type_p = $first ? "book" : "ex";
Branch: 1 branch
BranchTrueFalseTotal
$first ? : 0 0 0
1945 0 my $type_n = "ex";
1946 0 my $prev = shift @prevs;
1947 0 my $next = shift @nexts;
1948
1949 $self->{template}->param(
1950 0 ▶ page_title => "Example " . $example,
Branch: 2 branches
BranchTrueFalseTotal
$next ? : 0 0 0
$prev ? : 0 0 0
1951 href_next => $self->_mk_nav_href($type_n, $next),
1952 href_prev => $self->_mk_nav_href($type_p, $prev),
1953 href_home => $self->_mk_nav_href("book", "home"),
1954 href_up => $self->_mk_nav_href("book", "examples list"),
1955 lbl_next => ($next ? $next : "&nbsp;"),
1956 lbl_prev => ($prev ? $prev : "&nbsp;"),
1957 );
1958 $self->{template}->param(
1959 0 example => $self->_mk_example($example),
1960 );
1961
1962 0 $filename = $self->_mk_outfile($type_n, $example);
1963 0 ▶ open $OUT, '>', $filename
Branch: 1 branch
BranchTrueFalseTotal
open $OUT, ">", $filename or die "can't open $filename ($!)\n" 0 0 0
1964 or die "can't open $filename ($!)\n";
1965 0 print $OUT $self->{template}->output();
1966 0 close $OUT;
1967 0 $first = 0;
1968 }
1969 }
1970 0 return;
1971 }
1972
1973 1 1;
1974
1975 __END__
↑ Summary script/dtd2html.pl »