| 1 | ## This is a simple XML backend for TEI files -*-cperl-*- | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ## author: Petr Pajas | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # $Id: TEIXML.pm 2762 2006-07-28 13:57:23Z pajas $ ' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | ############################################################# | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | package Treex::PML::Backend::TEIXML; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Treex::PML; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use XML::LibXML; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use XML::LibXML::SAX::Parser; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Treex::PML::IO qw(close_backend); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | $VERSION='2.29'; # version template | |||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | sub open_backend { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
open_backend: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | my ($uri,$rw,$encoding)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # discard encoding and pass the rest to the Treex::PML::IO | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | Treex::PML::IO::open_backend($uri,$rw,($rw eq 'w' ? $encoding : undef)); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | sub test { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
test: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | # should be replaced with some better magic-test for TEI XML | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | my ($f)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | if (ref($f)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | my $line1=$f->getline(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | my $line2=$f->getline(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | return ($line1 =~ /^\s*<\?xml / and ($line2 =~ /^\s*<p[\s>]/ | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
$line1 =~ /^\s*<\?xml / && ($line2 =~ /^\s*<p[\s>]/ || $line2 =~ /^\s*<text>/ || $line2 =~ /^<!DOCTYPE text /)
$line2 =~ /^\s*<p[\s>]/ or $line2 =~ /^\s*<text>/ or $line2 =~ /^<!DOCTYPE text /
$line2 =~ /^\s*<p[\s>]/ or $line2 =~ /^\s*<text>/
MC/DC0%0/4
$line1 =~ /^\s*<\?xml / && ($line2 =~ /^\s*<p[\s>]/ || $line2 =~ /^\s*<text>/ || $line2 =~ /^<!DOCTYPE text /)
$line1 =~ /^\s*<\?xml /
$line2 =~ /^\s*<p[\s>]/
$line2 =~ /^\s*<text>/
$line2 =~ /^<!DOCTYPE text /
Truth table0%0/5
A && B or C or D
A= $line1 =~ /^\s*<\?xml /B= $line2 =~ /^\s*<p[\s>]/C= $line2 =~ /^\s*<text>/D= $line2 =~ /^<!DOCTYPE text /
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | or $line2 =~ /^\s*<text>/ or $line2 =~/^<!DOCTYPE text /)); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | my $fh = Treex::PML::IO::open_backend($f,"r"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | my $test = $fh && test($fh); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$fh && test($fh)
MC/DC0%0/2
$fh && test($fh)
$fh
test($fh)
Truth table0%0/3
A && B
A= $fhB= test($fh)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | Treex::PML::IO::close_backend($fh); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | return $test; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | sub read { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | my ($input,$target_doc) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | my $handler = Treex::PML::Backend::TEIXML::SAXHandler->new(TargetDocument => $target_doc); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my $p = XML::LibXML::SAX::Parser->new(Handler => $handler); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | if (ref($input)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | $p->parse(Source => { ByteStream => $input }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | $p->parse_uri($input); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub xml_quote { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xml_quote: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | local $_=$_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | s/&/&/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | s/\'/'/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | s/\"/"/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | s/>/>/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | s/</</g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | return $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | sub xml_quote_pcdata { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xml_quote_pcdata: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | local $_=$_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | s/&/&/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | s/>/>/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | s/</</g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | return $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | sub write { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write: not called CC=34 SCAR=70.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | my ($output, $src_doc) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | die "Require GLOB reference\n" unless ref($output); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my $rootdep=''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | if ($src_doc->FS->exists('dep') && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$src_doc->FS->exists("dep") and $src_doc->FS->isList("dep")
MC/DC0%0/2
$src_doc->FS->exists("dep") and $src_doc->FS->isList("dep")
$src_doc->FS->exists("dep")
$src_doc->FS->isList("dep")
Truth table0%0/3
A and B
A= $src_doc->FS->exists("dep")B= $src_doc->FS->isList("dep")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | $src_doc->FS->isList('dep')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ($rootdep)=$src_doc->FS->listValues('dep'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | # xml_decl | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | print $output "<?xml"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | if ($src_doc->metaData('xmldecl_version') ne "") { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | print $output " version=\"".$src_doc->metaData('xmldecl_version')."\""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | print $output " version=\"1.0\""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | if ($src_doc->encoding() ne "") { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | print $output " encoding=\"".$src_doc->encoding()."\""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | if ($src_doc->metaData('xmldecl_standalone') ne "") { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | print $output " standalone=\"".$src_doc->metaData('xmldecl_standalone')."\""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | print $output "?>\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | if ($src_doc->metaData('xml_doctype')) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | my $properties=$src_doc->metaData('xml_doctype'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | unless ($properties->{'Name'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | my $output = "DOCTYPE ".$properties->{'Name'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | $output .= ' SYSTEM "'.$properties->{'SystemId'}.'"' if $properties->{'SystemId'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | $output .= ' PUBLIC "'.$properties->{'PublicId'}.'"' if $properties->{'PublicId'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | $output .= ' '.$properties->{'Internal'} if $properties->{'Internal'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | print $output "<!",$output,">"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | print $output "<text>\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | # declare all list attributes as fLib. If fLib info exists, use it | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | # to get value identifiers | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | foreach my $attr (grep { $src_doc->FS->isList($_) } $src_doc->FS->attributes) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my %valids; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if (ref($src_doc->metaData('fLib'))) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my $flib=$src_doc->metaData('fLib'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | if (exists($flib->{$attr})) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | foreach (@{$flib->{$attr}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | $valids{$_->[1]} = $_->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | print $output "<fLib>\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | foreach ($src_doc->FS->listValues($attr)) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | print $output "<f"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | print $output " id=\"$valids{$_}\"" if (exists($valids{$_}) and $valids{$_} ne ""); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $valids{$_} and $valids{$_} ne ""
MC/DC0%0/2
exists $valids{$_} and $valids{$_} ne ""
exists $valids{$_}
$valids{$_} ne ""
Truth table0%0/3
A and B
A= exists $valids{$_}B= $valids{$_} ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | print $output " name=\"$attr\">", | |||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | "<sym value=\"$_\"/></f>\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | print $output "</fLib>\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | print $output "<body>\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | print $output "<p"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | if ($src_doc->tree(0)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my $tree0=$src_doc->tree(0); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | foreach ($src_doc->FS->attributes()) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | print $output " $1=\"".xml_quote($tree0->{$_})."\"" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | if (/^p_(.*)$/ and $tree0->{$_} ne ""); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
/^p_(.*)$/ and $tree0->{$_} ne ""
MC/DC0%0/2
/^p_(.*)$/ and $tree0->{$_} ne ""
/^p_(.*)$/
$tree0->{$_} ne ""
Truth table0%0/3
A and B
A= /^p_(.*)$/B= $tree0->{$_} ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | print $output ">\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | foreach my $tree ($src_doc->trees) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | print $output "<s"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | foreach ($src_doc->FS->attributes()) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | print $output " $1=\"".xml_quote($tree->{$_})."\"" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | if (/^s_(.*)/ and $tree->{$_} ne ""); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
/^s_(.*)/ and $tree->{$_} ne ""
MC/DC0%0/2
/^s_(.*)/ and $tree->{$_} ne ""
/^s_(.*)/
$tree->{$_} ne ""
Truth table0%0/3
A and B
A= /^s_(.*)/B= $tree->{$_} ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | print $output ">\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | foreach my $node (sort { $a->{ord} <=> $b->{ord} } $tree->descendants) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | my $type=$node->{tei_type} || "w"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$node->{'tei_type'} || 'w'
MC/DC0%0/1
$node->{'tei_type'} || 'w'
$node->{'tei_type'}
Truth table0%0/2
A
A= $node->{'tei_type'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | print $output "<$type"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | foreach (grep { exists($node->{$_}) and | |||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | defined($node->{$_}) and | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
exists $node->{$_} && defined $node->{$_} && !/^[sp]_|^(?:form|type|ord|dep)$/
exists $node->{$_} and defined $node->{$_}
MC/DC0%0/3
exists $node->{$_} && defined $node->{$_} && !/^[sp]_|^(?:form|type|ord|dep)$/
exists $node->{$_}
defined $node->{$_}
!/^[sp]_|^(?:form|type|ord|dep)$/
Truth table0%0/4
A and B && not(C)
A= exists $node->{$_}B= defined $node->{$_}C= !/^[sp]_|^(?:form|type|ord|dep)$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | !/^[sp]_|^(?:form|type|ord|dep)$/ } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | $src_doc->FS->attributes()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | print $output " $_=\"".xml_quote($node->{$_})."\""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | print $output " dep=\"". | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | xml_quote($node->parent->parent ? ($node->parent->{id} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | || $node->parent->{AID} #grrrrrrrr! | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | ) : $rootdep )."\""; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$node->parent->{"id"} or $node->parent->{"AID"}
MC/DC0%0/2
$node->parent->{"id"} or $node->parent->{"AID"}
$node->parent->{"id"}
$node->parent->{"AID"}
Truth table0%0/3
A or B
A= $node->parent->{"id"}B= $node->parent->{"AID"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | print $output ">"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | print $output xml_quote_pcdata($node->{form}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | print $output "</$type>\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | print $output "</s>\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | print $output "</p>\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | print $output "</body>\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | print $output "</text>\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | # SAX TEI-XML to Treex::PML::Document transducer | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | package Treex::PML::Backend::TEIXML::SAXHandler; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 1 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 1 | $VERSION='2.29'; # version template | |||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 1 | ▶ | use Treex::PML; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | my ($class, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | bless \%args, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | sub start_document { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
start_document: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | my ($self,$hash) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | $self->{TargetDocument} ||= Treex::PML::Factory->createDocument(); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"TargetDocument"} ||= "Treex::PML::Factory"->createDocument
MC/DC0%0/2
$self->{"TargetDocument"} ||= "Treex::PML::Factory"->createDocument
$self->{"TargetDocument"}
"Treex::PML::Factory"->createDocument
Truth table0%0/3
A ||= B
A= $self->{"TargetDocument"}B= "Treex::PML::Factory"->createDocument
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | sub end_document { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
end_document: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | my @header = ('@V form','@V form','@N ord'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | foreach my $attr (keys(%{$self->{FSAttrs}})) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | push @header, '@P '.$attr; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | if (exists($self->{FSAttrSyms}->{$attr}) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $self->{"FSAttrSyms"}{$attr} and ref $self->{"FSAttrSyms"}{$attr}
MC/DC0%0/2
exists $self->{"FSAttrSyms"}{$attr} and ref $self->{"FSAttrSyms"}{$attr}
exists $self->{"FSAttrSyms"}{$attr}
ref $self->{"FSAttrSyms"}{$attr}
Truth table0%0/3
A and B
A= exists $self->{"FSAttrSyms"}{$attr}B= ref $self->{"FSAttrSyms"}{$attr}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | and ref($self->{FSAttrSyms}->{$attr})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | my ($list); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | foreach (@{$self->{FSAttrSyms}->{$attr}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | $list.="|$_->[1]"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | push @header, '@L '.$attr.$list; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | $self->{TargetDocument}->changeFS(Treex::PML::Factory->createFSFormat(\@header)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | $self->{TargetDocument}->changeMetaData('fLib' => $self->{FSAttrSyms}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | $self->{TargetDocument}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | sub xml_decl { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xml_decl: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | my ($self,$data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | $self->{TargetDocument}->changeEncoding($data->{Encoding} || 'iso-8859-2'); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$data->{'Encoding'} || 'iso-8859-2'
MC/DC0%0/1
$data->{'Encoding'} || 'iso-8859-2'
$data->{'Encoding'}
Truth table0%0/2
A
A= $data->{'Encoding'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | $self->{TargetDocument}->changeMetaData('xmldecl_version' => $data->{Version}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | $self->{TargetDocument}->changeMetaData('xmldecl_standalone' => $data->{Standalone}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | sub characters { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
characters: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | my ($self,$hash) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | return unless $self->{Node}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | if (($self->{Node}{tei_type} eq 'w') or | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"Node"}{"tei_type"} eq "w" or $self->{"Node"}{"tei_type"} eq "c"
MC/DC0%0/2
$self->{"Node"}{"tei_type"} eq "w" or $self->{"Node"}{"tei_type"} eq "c"
$self->{"Node"}{"tei_type"} eq "w"
$self->{"Node"}{"tei_type"} eq "c"
Truth table0%0/3
A or B
A= $self->{"Node"}{"tei_type"} eq "w"B= $self->{"Node"}{"tei_type"} eq "c"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | ($self->{Node}{tei_type} eq 'c')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | my $str = $hash->{Data}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | if ($]>=5.008) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | # leave data in the UTF-8 encoding | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | $self->{Node}->{form}.=$str; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | $self->{Node}->{form}=$self->{Node}->{form}. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | XML::LibXML::decodeFromUTF8($self->{TargetDocument}->encoding(),$str); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | sub start_element { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
start_element: not called CC=21 SCAR=61.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | my ($self, $hash) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | my $elem = $hash->{Name}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | my $attr = $hash->{Attributes}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | my $target_doc = $self->{TargetDocument}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | if ($elem eq 'p') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | $self->{DocAttributes}=$attr; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } elsif ($elem eq 'f') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | $self->{CurrentFSAttr}=$attr->{"{}name"}->{Value}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | $self->{CurrentFSAttrID}=$attr->{"{}id"}->{Value}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | $self->{FSAttrs}->{$attr->{"{}name"}->{Value}}=1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } elsif ($elem eq 'sym') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | push @{$self->{FSAttrSyms}->{$self->{CurrentFSAttr}}}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | [$self->{CurrentFSAttrID},$attr->{"{}value"}->{Value}]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } elsif ($elem eq 's') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | my $node = $self->{Node} = $self->{Tree} = $target_doc->new_tree($target_doc->lastTreeNo+1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | $node->{ord} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | $self->{LastOrd} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | $node->{tei_type}=$elem; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | $node->{form}='#'.($target_doc->lastTreeNo+1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | if (ref($attr)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | foreach (values %$attr) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | $node->{'s_'.$_->{Name}} = ($]>=5.008) ? $_->{Value} : | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | XML::LibXML::decodeFromUTF8($target_doc->encoding(),$_->{Value}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | $self->{FSAttrs}->{'s_'.$_->{Name}}=1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | $self->{IDs}->{$node->{id}}=$node | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | if ($node->{id} ne ''); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | $self->{IDs}->{$node->{AID}}=$node | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | if ($node->{AID} ne ''); #grrrrrrrr! | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | if ($target_doc->lastTreeNo == 0 and ref($self->{DocAttributes})) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$target_doc->lastTreeNo == 0 and ref $self->{"DocAttributes"}
MC/DC0%0/2
$target_doc->lastTreeNo == 0 and ref $self->{"DocAttributes"}
$target_doc->lastTreeNo == 0
ref $self->{"DocAttributes"}
Truth table0%0/3
A and B
A= $target_doc->lastTreeNo == 0B= ref $self->{"DocAttributes"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | foreach (values %{$self->{DocAttributes}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | # leave data in the UTF-8 encoding in Perl 5.8 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | $node->{'p_'.$_->{Name}} = ($]>=5.008) ? $_->{Value} : | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | XML::LibXML::decodeFromUTF8($target_doc->encoding(),$_->{Value}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | $self->{FSAttrs}->{"p_".$_->{Name}}=1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | ▶ | } elsif ($elem eq 'w' or $elem eq 'c') { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$elem eq "w" or $elem eq "c"
MC/DC0%0/2
$elem eq "w" or $elem eq "c"
$elem eq "w"
$elem eq "c"
Truth table0%0/3
A or B
A= $elem eq "w"B= $elem eq "c"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | my $node = $self->{Node} = Treex::PML::Factory->createNode(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | $node->{tei_type}=$elem; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | $node->{ord} = ++($self->{LastOrd}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | $node->paste_on($self->{Tree},'ord'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | if (ref($attr)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | foreach (values %$attr) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | $node->{$_->{Name}} = ($]>=5.008) ? $_->{Value} : | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | XML::LibXML::decodeFromUTF8($target_doc->encoding(),$_->{Value}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | $self->{FSAttrs}->{$_->{Name}}=1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | $self->{IDs}->{$node->{id}}=$node | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | if ($node->{id} ne ''); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | $self->{IDs}->{$node->{AID}}=$node | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | if ($node->{AID} ne ''); #grrrrrrrr! | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | sub end_element { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
end_element: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | if ($self->{Node} and $self->{Node}->{tei_type} eq 's') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"Node"} and $self->{"Node"}{"tei_type"} eq "s"
MC/DC0%0/2
$self->{"Node"} and $self->{"Node"}{"tei_type"} eq "s"
$self->{"Node"}
$self->{"Node"}{"tei_type"} eq "s"
Truth table0%0/3
A and B
A= $self->{"Node"}B= $self->{"Node"}{"tei_type"} eq "s"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | # build the tree (no consistency checks at all) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | my @nodes=$self->{Tree}->descendants; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | foreach my $node (@nodes) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | my $dep=$node->{dep}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | if ($dep ne '' and | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$dep ne "" and ref $self->{"IDs"}{$dep}
MC/DC0%0/2
$dep ne "" and ref $self->{"IDs"}{$dep}
$dep ne ""
ref $self->{"IDs"}{$dep}
Truth table0%0/3
A and B
A= $dep ne ""B= ref $self->{"IDs"}{$dep}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | ref($self->{IDs}{$dep})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | $node->cut()->paste_on($self->{IDs}{$dep}, 'ord'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | $self->{Node} = $self->{Node}->parent if ($self->{Node}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | sub start_entity { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
start_entity: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | # just hoping some parser would support these | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | print "START ENTITY: @{$_[1]}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | sub end_entity { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
end_entity: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | print "END ENTITY: @{$_[1]}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | sub entity_reference { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
entity_reference: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | my $self = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | my $name = $_[1]->{Name}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | if ($self->{Node}->{tei_type} eq 'w' or | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"Node"}{"tei_type"} eq "w" or $self->{"Node"}{"tei_type"} eq "c"
MC/DC0%0/2
$self->{"Node"}{"tei_type"} eq "w" or $self->{"Node"}{"tei_type"} eq "c"
$self->{"Node"}{"tei_type"} eq "w"
$self->{"Node"}{"tei_type"} eq "c"
Truth table0%0/3
A or B
A= $self->{"Node"}{"tei_type"} eq "w"B= $self->{"Node"}{"tei_type"} eq "c"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | $self->{Node}->{tei_type} eq 'c') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | $self->{Node}->{form}.='&'.$name.';'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | sub start_cdata { # not much use for this | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
start_cdata: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | $self->{InCDATA} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | sub end_cdata { # not much use for this | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
end_cdata: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | $self->{InCDATA} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | sub comment { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
comment: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | my $self = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | my $data = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | if ($self->{Node}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | $self->{Node}->{xml_comment}.='<!--'.$data.'-->'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | sub doctype_decl { # unfortunatelly, not called by the parser, so far | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
doctype_decl: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | my ($self,$hash) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | $self->{TargetDocument}->changeMetaData("xml_doctype" => $hash); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | # hack to fix LibXML | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | sub XML::LibXML::Dtd::type { return $_[0]->nodeType } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
type: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||