Branch Coverage

blib/lib/Treex/PML/Instance/Reader.pm
Criterion Covered Total %
branch 197 384 51.3


line true false branch
38 0 8 if (not $ENV{'PML_COMPILE_NO_XS'} and eval { do { require XML::CompactTree::XS; 'XML::CompactTree::XS'->import; $Treex::PML::Instance::Reader::HAVE_XS = 1; 1 } }) { }
110 64 0 if (builtin::blessed($schema_file) and $schema_file->isa("URI"))
111 64 0 if (($schema_file->scheme || '') eq 'file') { }
117 64 0 if (-f $schema_file)
125 0 64 unless defined $schema_file
127 14 50 if ($cached and $schema_cache[-1] ne $schema_file)
138 0 27 if (@schema_cache > $MAX_SCHEMA_CACHE_SIZE)
142 0 0 if (exists &Treex::PML::Instance::Writer::forget_schema)
152 14 50 if ($cached and $handler_cache[-1][1] ne $subkey)
164 0 27 if (@handler_cache > $MAX_SCHEMA_CACHE_SIZE)
173 0 64 if (ref $opts ne "HASH")
176 36 28 unless (ref $ctxt)
180 0 64 if ($config and ref(my $load_opts = $config->get_data("options/load")))
183 0 64 if not $Treex::PML::Instance::DEBUG and $config and defined $config->get_data("options/debug")
185 64 0 unless $opts->{'parser_options'}
187 64 0 if (exists $opts->{'filename'})
191 19 45 $opts->{'use_resources'} ? :
196 1 63 if (defined $opts->{'dom'}) { }
22 41 elsif (defined $opts->{'fh'}) { }
8 33 elsif (defined $opts->{'string'}) { }
33 0 elsif (defined $ctxt->{'_filename'}) { }
209 0 33 if ($ctxt->{'_filename'} eq '-') { }
229 0 0 if (defined $id and length $id) { }
238 22 42 $config && $config->get_root ? :
241 0 64 if ($root_ns ne "http://ufal.mff.cuni.cz/pdt/pml/" or grep {($_->{'root'} || '') eq $root_element if ($_->{'ns'} || '') eq "http://ufal.mff.cuni.cz/pdt/pml/";} @transform_map)
242 0 0 if ($_->{'ns'} || '') eq "http://ufal.mff.cuni.cz/pdt/pml/"
243 0 0 if ($config and $config->get_root)
252 0 0 unless $type and $type =~ /^(?:xslt|perl|pipe|shell)$/
255 0 0 if ($test || $transform->{'ns'} || $transform->{'root'} and !$transform->{'ns'} || $transform->{'ns'} eq $root_ns and !$transform->{'root'} || $transform->{'root'} eq $root_element and not $test or eval { do { $dom->find($test) } }) { }
259 0 0 if ($type eq 'xslt') { }
0 0 elsif ($type eq 'perl') { }
0 0 elsif ($type eq 'pipe' or $type eq 'shell') { }
260 0 0 if XSLT_BUG()
261 0 0 if (eval { do { require XML::LibXSLT; 1 } }) { }
263 0 0 unless $in_xsl_href
268 0 0 if $params
274 0 0 if $dom and $dom->can("setBaseURI")
275 0 0 if $dom and $dom->can("setURI")
284 0 0 unless $code
289 0 0 if $params
291 0 0 if $@
292 0 0 unless builtin::blessed($dom) and $dom->isa("XML::LibXML::Document")
294 0 0 if $dom and $dom->can("setBaseURI")
295 0 0 if $dom and $dom->can("setURI")
301 0 0 unless $code
306 0 0 if defined $_
0 0 if $params
308 0 0 if ($type eq 'pipe') { }
322 0 0 if ($type eq 'pipe') { }
330 0 0 if $tmp_file_in
335 0 0 unless open my $fh, "<", $tmp_file_out
336 0 0 if $tmp_file_out
347 0 0 if (($reader->namespaceURI || '') ne "http://ufal.mff.cuni.cz/pdt/pml/")
355 0 64 unless (ref $schema)
358 0 64 unless (length($schema->{'version'} || ''))
361 0 64 if (index(" 1.1 1.2 ", ' ' . $schema->{'version'} . ' ') == -1)
372 0 64 if defined $sel_knit and ref $sel_knit ne "HASH"
374 0 64 if defined $sel_refs and ref $sel_refs ne "HASH"
382 0 128 defined $sel ? :
384 0 0 ref $ids ? :
0 0 defined $ids ? :
394 0 64 $opts->{'no_trees'} ? :
395 0 64 $opts->{'no_references'} ? :
396 0 64 $opts->{'no_knit'} ? :
397 0 64 $opts->{'validate_cdata'} ? :
398 0 64 $opts->{'ignore_content_patterns'} ? :
402 0 64 if $opts->{'dump_handlers'} or $ENV{'PML_COMPILE_DUMP'}
405 0 0 if ($reader->nodeType == 7)
415 33 31 if defined $fh_to_close
416 0 64 if $@
444 0 93 if ($type == 3) { }
64 29 elsif ($type == 1) { }
447 64 0 if ($reader->localName eq 'head' and $reader->namespaceURI eq 'http://ufal.mff.cuni.cz/pdt/pml/') { }
456 0 64 unless ($found_head)
462 64 124 if $reader->depth <= 1
464 90 34 if ($type == 1 and $reader->namespaceURI eq "http://ufal.mff.cuni.cz/pdt/pml/")
466 64 26 if ($name eq 'schema') { }
26 0 elsif ($name eq 'references') { }
467 0 64 if ($ctxt->{'_schema'})
469 0 0 unless $reader->nextSibling
473 0 64 unless readAttributes($reader)
475 64 0 if (defined $schema_file and length $schema_file) { }
481 27 37 unless ($ctxt->{'_schema'} = get_cached_schema($key))
491 27 0 if $CACHE_SCHEMAS
505 26 0 if ($reader->read)
507 33 8 if ($reader->localName eq "reffile" and $reader->namespaceURI eq "http://ufal.mff.cuni.cz/pdt/pml/")
509 0 33 unless readAttributes($reader)
511 33 0 if (defined $id and length $id and defined $href and length $href) { }
513 33 0 if (defined $name and length $name)
515 0 33 if (defined $prev_ids) { }
516 0 0 if (ref $prev_ids) { }
536 26 15 unless $reader->nextSibling
543 0 64 unless $ctxt->{'_schema'}
555 37 27 if ($cached) { }
559 27 0 if $CACHE_HANDLERS
565 0 0 unless -d $dir or mkdir $dir
569 0 0 unless open my $fh, ">:utf8", $dump_file
582 64 0 if $reader->nodeType == 15
583 0 64 if ($Treex::PML::Instance::Reader::HAVE_XS) { }
618 476 19 if (UNIVERSAL::DOES::does($val, 'Treex::PML::Node')) { }
619 30 446 if ($phase == 0)
622 476 0 if ($phase == 1) { }
629 0 19 if ($phase == 1)
632 19 0 if ($phase == 0) { }
645 161 0 if ($r->moveToFirstAttribute == 1)
649 163 64 unless $prefix and $prefix eq "xmlns" or not $prefix and $name eq "xmlns"
692 0 24 unless $decl
694 24 0 if ($idM)
697 6 18 if ($cdecl and $cdecl->get_decl_type == 8 and $cdecl->get_format eq 'ID') { }
18 0 elsif ($cdecl = $idM->get_content_decl) { }
700 0 18 if ($cdecl and $cdecl->get_decl_type == 8 and $cdecl->get_format eq "ID")
727 10 0 if ($decl) { }
731 0 10 $Treex::PML::Instance::Reader::HAVE_XS ? :
748 10 0 if ($idM)
782 0 0 if ($STRICT) { }
814 520 724 if $path
815 262 555 if $decl_type == 11 or $decl_type == 12 or $decl_type == 1 or $decl_type == 13
819 27 528 if ($decl_type == 2) { }
100 428 elsif ($decl_type == 3) { }
39 389 elsif ($decl_type == 4) { }
39 350 elsif ($decl_type == 5) { }
45 305 elsif ($decl_type == 6) { }
8 297 elsif ($decl_type == 7) { }
235 62 elsif ($decl_type == 8) { }
60 2 elsif ($decl_type == 9) { }
2 0 elsif ($decl_type == 10) { }
837 0 27 if $@
849 0 100 if ($VALIDATE_CDATA) { }
881 87 290 if ($member->is_required) { }
2 288 elsif ($mdecl and $mdecl->get_decl_type == 10) { }
883 0 87 if ($mdecl and $mdecl->get_role eq '#TREES') { }
898 324 53 if ($KNIT and not $role)
900 9 315 if ($mdecl and $mdecl->get_decl_type == 6 and $mdecl->get_role eq "#KNIT")
923 9 0 if ($mname ne $knit_name)
934 37 331 if ($role eq '#ID') { }
3 328 elsif (not $trees_type and $role eq '#TREES' and $BUILD_TREES) { }
7 321 elsif ($role eq '#CHILDNODES') { }
1 320 elsif ($role eq '#KNIT' and $KNIT) { }
939 3 0 if ($mtype == 6) { }
0 0 elsif ($mtype == 5) { }
943 0 3 unless ($cmdecl and ($cmdecl->get_role || '') eq "#NODE" and $cmdecl_type == 3 || $cmdecl_type == 4)
967 0 7 if ($children_member) { }
975 1 0 $mname ne $knit_name ? :
986 7 93 if ($decl->get_role eq '#NODE' and $BUILD_TREES) { }
991 7 0 if ($children_member)
994 7 0 if ($ctype == 6) { }
0 0 elsif ($ctype == 5) { }
997 0 7 unless ($cmdecl->get_role eq "#NODE" and $cmdecl_type == 3 || $cmdecl_type == 4)
1020 0 0 unless ($cmdecl->get_role eq "#NODE" and $cmdecl_type == 3 || $cmdecl_type == 4)
1054 37 63 if (defined $id)
1062 0 100 if $@
1068 39 0 if $cpath
1082 0 39 if ($VALIDATE_CDATA) { }
1096 39 0 if ($cdecl) { }
1105 18 32 if ($member->is_required)
1110 10 40 if ($member->get_role eq "#ID")
1114 17 22 if ($decl->get_role eq '#NODE' and $BUILD_TREES) { }
1119 10 7 if ($cdecl and ($cdecl->get_role || '') eq '#CHILDNODES') { }
7 0 elsif ($cdecl) { }
1121 2 8 if ($ctype == 6) { }
8 0 elsif ($ctype == 5) { }
1124 0 2 unless ($cmdecl->get_role eq "#NODE" and $cmdecl_type == 3 || $cmdecl_type == 4)
1144 0 12 unless my $cmdecl = $edecl->get_content_decl
1147 0 12 unless ($cmdecl->get_role eq "#NODE" and $cmdecl_type == 3 || $cmdecl_type == 4)
1183 10 29 if (defined $id)
1191 0 39 if $@
1208 1 38 if ($decl->is_mixed) { }
1226 9 30 if ($VALIDATE_SEQUENCES and $content_pattern)
1233 10 0 if (not $trees_type and $decl->get_role eq "#TREES" and $BUILD_TREES)
1242 9 30 if ($content_pattern) { }
1252 0 39 if $@
1255 0 45 unless my $cdecl = $decl->get_content_decl
1291 0 0 if (not $trees_type and $decl->get_role eq "#TREES" and $BUILD_TREES)
1293 0 0 unless ($cdecl and ($cdecl->get_role || '') eq "#NODE" and $cdecl_type == 3 || $cdecl_type == 4)
1313 0 45 if $@
1358 0 8 if $@
1388 0 235 if ($VALIDATE_CDATA and $decl->get_format ne 'any') { }
1394 0 0 if (defined $format_checker)
1395 0 0 if (ref $format_checker eq 'CODE') { }
1419 0 235 if $@
1423 60 0 unless ($value_hash)
1460 0 60 if $@
1496 0 2 if $@
1504 482 762 if ($decl_type == 11 or $decl_type == 12 or $decl_type == 13)
1510 482 0 if $path
1512 87 395 if ($decl_type == 12 and $decl->is_required)
1519 0 87 if ($mdecl->get_role eq "#TREES" and $mdecl == $trees_type)
1521 0 0 if $mpath
1524 0 0 if (not $have_trees and $BUILD_TREES) { }
1526 0 0 if $have_trees and not defined $ret
1536 234 248 if (not exists $handlers{$path})
1539 234 0 if ($mpath)