Branch Coverage

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


line true false branch
38 0 6 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 41 20 if (&blessed($schema_file) and $schema_file->isa('URI'))
111 41 0 if (($schema_file->scheme || '') eq 'file') { }
117 61 0 if (-f $schema_file)
125 0 61 unless defined $schema_file
127 14 47 if ($cached and $schema_cache[-1] ne $schema_file)
138 0 24 if (@schema_cache > $MAX_SCHEMA_CACHE_SIZE)
142 0 0 if (exists &Treex::PML::Instance::Writer::forget_schema)
152 14 47 if ($cached and $handler_cache[-1][1] ne $subkey)
164 0 24 if (@handler_cache > $MAX_SCHEMA_CACHE_SIZE)
173 0 61 if (ref $opts ne 'HASH')
176 34 27 unless (ref $ctxt)
180 0 61 if ($config and ref(my $load_opts = $config->get_data('options/load')))
183 0 61 if not $Treex::PML::Instance::DEBUG and $config and defined $config->get_data('options/debug')
185 61 0 unless $opts->{'parser_options'}
187 61 0 if (exists $opts->{'filename'})
191 18 43 $opts->{'use_resources'} ? :
196 0 61 if (defined $opts->{'dom'}) { }
22 39 elsif (defined $opts->{'fh'}) { }
6 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 39 $config && $config->get_root ? :
241 0 61 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 &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 61 unless (ref $schema)
358 0 61 unless (length($schema->{'version'} || ''))
361 0 61 if (index(' 1.1 1.2 ', ' ' . $schema->{'version'} . ' ') < 0)
372 0 61 if defined $sel_knit and ref $sel_knit ne 'HASH'
374 0 61 if defined $sel_refs and ref $sel_refs ne 'HASH'
382 0 122 defined $sel ? :
384 0 0 ref $ids ? :
0 0 defined $ids ? :
394 0 61 $opts->{'no_trees'} ? :
395 0 61 $opts->{'no_references'} ? :
396 0 61 $opts->{'no_knit'} ? :
397 0 61 $opts->{'validate_cdata'} ? :
398 0 61 $opts->{'ignore_content_patterns'} ? :
402 0 61 if $opts->{'dump_handlers'} or $ENV{'PML_COMPILE_DUMP'}
405 0 0 if ($reader->nodeType == 7)
415 33 28 if defined $fh_to_close
416 0 61 if $@
444 0 122 if ($type == 3) { }
61 61 elsif ($type == 1) { }
447 61 0 if ($reader->localName eq 'head' and $reader->namespaceURI eq 'http://ufal.mff.cuni.cz/pdt/pml/') { }
456 0 61 unless ($found_head)
462 61 207 if $reader->depth <= 1
464 86 121 if ($type == 1 and $reader->namespaceURI eq 'http://ufal.mff.cuni.cz/pdt/pml/')
466 61 25 if ($name eq 'schema') { }
25 0 elsif ($name eq 'references') { }
467 0 61 if ($ctxt->{'_schema'})
469 0 0 unless $reader->nextSibling
473 0 61 unless readAttributes($reader)
475 61 0 if (defined $schema_file and length $schema_file) { }
481 24 37 unless ($ctxt->{'_schema'} = get_cached_schema($key))
491 24 0 if $CACHE_SCHEMAS
505 25 0 if ($reader->read)
507 30 55 if ($reader->localName eq 'reffile' and $reader->namespaceURI eq 'http://ufal.mff.cuni.cz/pdt/pml/')
509 0 30 unless readAttributes($reader)
511 30 0 if (defined $id and length $id and defined $href and length $href) { }
513 30 0 if (defined $name and length $name)
515 0 30 if (defined $prev_ids) { }
516 0 0 if (ref $prev_ids) { }
536 25 60 unless $reader->nextSibling
543 0 61 unless $ctxt->{'_schema'}
555 37 24 if ($cached) { }
559 24 0 if $CACHE_HANDLERS
565 0 0 unless -d $dir or mkdir $dir
569 0 0 unless open my $fh, '>:utf8', $dump_file
582 61 0 if $reader->nodeType == 15
583 0 61 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 152 0 if ($r->moveToFirstAttribute == 1)
649 151 61 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 475 644 if $path
815 237 506 if $decl_type == 11 or $decl_type == 12 or $decl_type == 1 or $decl_type == 13
819 24 482 if ($decl_type == 2) { }
88 394 elsif ($decl_type == 3) { }
35 359 elsif ($decl_type == 4) { }
35 324 elsif ($decl_type == 5) { }
45 279 elsif ($decl_type == 6) { }
8 271 elsif ($decl_type == 7) { }
213 58 elsif ($decl_type == 8) { }
56 2 elsif ($decl_type == 9) { }
2 0 elsif ($decl_type == 10) { }
837 0 24 if $@
849 0 88 if ($VALIDATE_CDATA) { }
881 85 249 if ($member->is_required) { }
2 247 elsif ($mdecl and $mdecl->get_decl_type == 10) { }
883 0 85 if ($mdecl and $mdecl->get_role eq '#TREES') { }
898 283 51 if ($KNIT and not $role)
900 9 274 if ($mdecl and $mdecl->get_decl_type == 6 and $mdecl->get_role eq '#KNIT')
923 9 0 if ($mname ne $knit_name)
934 35 290 if ($role eq '#ID') { }
3 287 elsif (not $trees_type and $role eq '#TREES' and $BUILD_TREES) { }
7 280 elsif ($role eq '#CHILDNODES') { }
1 279 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 81 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 35 53 if (defined $id)
1062 0 88 if $@
1068 35 0 if $cpath
1082 0 35 if ($VALIDATE_CDATA) { }
1096 35 0 if ($cdecl) { }
1105 16 26 if ($member->is_required)
1110 10 32 if ($member->get_role eq '#ID')
1114 17 18 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 25 if (defined $id)
1191 0 35 if $@
1208 1 34 if ($decl->is_mixed) { }
1226 9 26 if ($VALIDATE_SEQUENCES and $content_pattern)
1233 10 0 if (not $trees_type and $decl->get_role eq '#TREES' and $BUILD_TREES)
1242 9 26 if ($content_pattern) { }
1252 0 35 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 213 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 213 if $@
1423 56 0 unless ($value_hash)
1460 0 56 if $@
1496 0 2 if $@
1504 427 692 if ($decl_type == 11 or $decl_type == 12 or $decl_type == 13)
1510 427 0 if $path
1512 85 342 if ($decl_type == 12 and $decl->is_required)
1519 0 85 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 199 228 if (not exists $handlers{$path})
1539 199 0 if ($mpath)