| 1 | package Treex::PML::Instance::Writer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 9 | ▶ | use 5.008; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 9 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 9 | ▶ | no warnings qw(recursion); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 9 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 9 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 9 | ▶ | use UNIVERSAL::DOES; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 9 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 9 | our $VERSION = '2.29'; # version template | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 9 | ▶ | use List::Util qw(first); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 9 | ▶ | use Treex::PML::Instance::Common qw(:diagnostics :constants); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 9 | ▶ | use Treex::PML::Schema; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 9 | ▶ | use Treex::PML::IO qw(open_backend close_backend rename_uri); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 9 | ▶ | use Encode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | my ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 9 | %handlers, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | %src, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | %handler_cache, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | @handler_cache, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # TODO: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # - test inline schemas | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | # - content_pattern and cdata validation on save | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # - mixed content | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # - decorate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 9 | our $CACHE_HANDLERS=1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 9 | our $MAX_SCHEMA_CACHE_SIZE=50; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 9 | our $VALIDATE_CDATA=0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 9 | our $SAVE_REFFILES = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 9 | our $WITH_TREES = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 9 | our $KEEP_KNIT = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 9 | our $WRITE_SINGLE_LM = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 9 | our $WRITE_SINGLE_CHILDREN_LM = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 9 | our $INDENT = 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 9 | require Treex::PML; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 20 | ▶ | sub _get_handlers_cache_key { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_handlers_cache_key: called CC=8 SCAR=24.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 20 | my ($schema)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 20 | my $key="$schema"; $key=~s/.*=//; # strip class | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 20 | ▶ | $key, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%7/14
$Treex::PML::Instance::Writer::INDENT || 0
$Treex::PML::Instance::Writer::VALIDATE_CDATA || 0
$Treex::PML::Instance::Writer::SAVE_REFFILES || 0
$Treex::PML::Instance::Writer::WITH_TREES || 0
$Treex::PML::Instance::Writer::WRITE_SINGLE_LM || 0
$Treex::PML::Instance::Writer::KEEP_KNIT || 0
$Treex::PML::Instance::Writer::WRITE_SINGLE_CHILDREN_LM || 0
MC/DC0%0/1
$Treex::PML::Instance::Writer::INDENT || 0
$Treex::PML::Instance::Writer::INDENT
MC/DC0%0/1
$Treex::PML::Instance::Writer::VALIDATE_CDATA || 0
$Treex::PML::Instance::Writer::VALIDATE_CDATA
MC/DC0%0/1
$Treex::PML::Instance::Writer::SAVE_REFFILES || 0
$Treex::PML::Instance::Writer::SAVE_REFFILES
MC/DC0%0/1
$Treex::PML::Instance::Writer::WITH_TREES || 0
$Treex::PML::Instance::Writer::WITH_TREES
MC/DC0%0/1
$Treex::PML::Instance::Writer::WRITE_SINGLE_LM || 0
$Treex::PML::Instance::Writer::WRITE_SINGLE_LM
MC/DC0%0/1
$Treex::PML::Instance::Writer::KEEP_KNIT || 0
$Treex::PML::Instance::Writer::KEEP_KNIT
MC/DC0%0/1
$Treex::PML::Instance::Writer::WRITE_SINGLE_CHILDREN_LM || 0
$Treex::PML::Instance::Writer::WRITE_SINGLE_CHILDREN_LM
Truth table50%1/2
A
A= $Treex::PML::Instance::Writer::INDENT
Truth table50%1/2
A
A= $Treex::PML::Instance::Writer::VALIDATE_CDATA
Truth table50%1/2
A
A= $Treex::PML::Instance::Writer::SAVE_REFFILES
Truth table50%1/2
A
A= $Treex::PML::Instance::Writer::WITH_TREES
Truth table50%1/2
A
A= $Treex::PML::Instance::Writer::WRITE_SINGLE_LM
Truth table50%1/2
A
A= $Treex::PML::Instance::Writer::KEEP_KNIT
Truth table50%1/2
A
A= $Treex::PML::Instance::Writer::WRITE_SINGLE_CHILDREN_LM
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | join ',', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | $key, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | $INDENT || 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | $VALIDATE_CDATA || 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | $SAVE_REFFILES || 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | $WITH_TREES || 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | $WRITE_SINGLE_LM || 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | $KEEP_KNIT || 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | $WRITE_SINGLE_CHILDREN_LM || 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 20 | ▶ | sub get_cached_handlers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_cached_handlers: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 20 | my ($key)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 20 | my $subkey = $key->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 20 | my $cached = $handler_cache{ $key->[0] }{ $subkey }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 20 | ▶ | if ($cached and $handler_cache[-1][1] ne $subkey) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$cached and $handler_cache[-1][1] ne $subkey
MC/DC50%1/2
$cached and $handler_cache[-1][1] ne $subkey
$cached
$handler_cache[-1][1] ne $subkey
Truth table66%2/3
A and B
A= $cachedB= $handler_cache[-1][1] ne $subkey
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | # move the last retrieved schema to the end of the queue | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 5 | @handler_cache = ((grep { $_->[1] ne $subkey } @handler_cache),$key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 20 | return $cached; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 15 | ▶ | sub cache_handlers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cache_handlers: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 15 | my ($key,$handlers)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 15 | my $subkey = $key->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 15 | push @handler_cache,$key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 15 | $handler_cache{$key->[0]}{$subkey} = $handlers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 15 | ▶ | if (@handler_cache > $MAX_SCHEMA_CACHE_SIZE) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | my $del = shift @handler_cache; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | delete $handler_cache{ $del->[0] }{ $del->[1] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | sub forget_schema { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
forget_schema: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | my ($schema)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | delete $handler_cache{ $schema }; # delete also from the handler cache | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | @handler_cache = grep { $_->[0] ne $schema } @handler_cache; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 542 | ▶ | sub _indent { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_indent: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 542 | ▶ | if ($INDENT>=0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 539 | return q{"\n".('}.(' ' x $INDENT).q{' x $indent_level).} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 3 | return q() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 119 | ▶ | sub _indent_inc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_indent_inc: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 119 | ▶ | if ($INDENT>0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 118 | return q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | $indent_level++;`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 1 | return q() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 119 | ▶ | sub _indent_dec { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_indent_dec: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 119 | ▶ | if ($INDENT>0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 118 | return q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | $indent_level--;`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | return q() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 21 | ▶ | sub save { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
save: called CC=67 SCAR=65.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 21 | my ($ctxt,$opts)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 21 | my $fh = $opts->{fh}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | local $VALIDATE_CDATA=$opts->{validate_cdata} if | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 21 | ▶ | exists $opts->{validate_cdata}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 21 | ▶ | $ctxt->set_filename($opts->{filename}) if $opts->{filename}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 21 | my $href = $ctxt->{'_filename'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 21 | ▶ | $fh=\*STDOUT if ($href eq '-' and !$fh); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$href eq "-" and not $fh
MC/DC0%0/2
$href eq "-" and not $fh
$href eq "-"
not $fh
Truth table33%1/3
A and not(B)
A= $href eq "-"B= not $fh
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 21 | my $config = $opts->{config}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 21 | ▶ | if ($config and ref(my $load_opts = $config->get_data('options/save'))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$config and ref(my $load_opts = $config->get_data("options/save"))
MC/DC0%0/2
$config and ref(my $load_opts = $config->get_data("options/save"))
$config
ref(my $load_opts = $config->get_data("options/save"))
Truth table66%2/3
A and B
A= $configB= ref(my $load_opts = $config->get_data("options/save"))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | $opts = {%$load_opts, %$opts}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 21 | ▶ | local $KEEP_KNIT = 1 if $opts->{keep_knit}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 21 | ▶ | local $WRITE_SINGLE_LM = 1 if $opts->{write_single_LM}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 21 | ▶ | local $WRITE_SINGLE_CHILDREN_LM = 1 if $opts->{write_single_children_LM}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 21 | ▶ | local $INDENT = $opts->{indent} if defined $opts->{indent}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 21 | ▶ | unless ($fh) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 1 | ▶ | if (defined($href) and length($href)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $href and length $href
MC/DC0%0/2
defined $href and length $href
defined $href
length $href
Truth table33%1/3
A and B
A= defined $hrefB= length $href
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 1 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 1 | ▶ | rename_uri($href,$href."~") unless $href=~/^ntred:/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 1 | my $ok = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 1 | my $res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 1 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 1 | ▶ | $fh = open_backend($href,'w') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
open_backend($href, 'w') || die("Cannot open $href for writing: $!")
MC/DC0%0/1
open_backend($href, 'w') || die("Cannot open $href for writing: $!")
open_backend($href, 'w')
Truth table50%1/2
A
A= open_backend($href, 'w')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | || die "Cannot open $href for writing: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 1 | ▶ | if ($fh) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 1 | binmode $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | $res = $ctxt->save({%$opts, fh=> $fh}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 1 | close_backend($fh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 1 | $ok = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 1 | ▶ | unless ($ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my $err = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | rename_uri($href."~",$href) unless $href=~/^ntred:/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | die($err."$@\n") if $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 1 | return $res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | die("Usage: $ctxt->save({filename=>...,[fh => ...]})"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 20 | ▶ | $ctxt->{'_refs_save'} ||= $opts->{'refs_save'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$ctxt->{"_refs_save"} ||= $opts->{"refs_save"}
MC/DC0%0/2
$ctxt->{"_refs_save"} ||= $opts->{"refs_save"}
$ctxt->{"_refs_save"}
$opts->{"refs_save"}
Truth table33%1/3
A ||= B
A= $ctxt->{"_refs_save"}B= $opts->{"refs_save"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 20 | ▶ | binmode $fh if $fh; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 20 | my $transform_id = $ctxt->{'_transform_id'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 20 | my ($out_xsl_href,$out_xsl,$orig_fh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 20 | my $xsl_source=''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 20 | ▶ | if ($config and defined $transform_id and length $transform_id) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$config and defined $transform_id and length $transform_id
$config and defined $transform_id
MC/DC0%0/3
$config and defined $transform_id and length $transform_id
$config
defined $transform_id
length $transform_id
Truth table50%2/4
A and B and C
A= $configB= defined $transform_idC= length $transform_id
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | my $transform = $config->lookup_id( $transform_id ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | if ($transform) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ($out_xsl) = $transform->{'out'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | if ($out_xsl->{'type'} ne 'xslt') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | die(__PACKAGE__.": unsupported output transformation $transform_id (only type='xslt') transformations are supported)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | $out_xsl_href = URI->new(Encode::encode_utf8($out_xsl->get_member('href'))); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | $out_xsl_href = Treex::PML::ResolvePath($config->{_filename}, $out_xsl_href, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | unless (defined $out_xsl_href and length $out_xsl_href) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $out_xsl_href and length $out_xsl_href
MC/DC0%0/2
defined $out_xsl_href and length $out_xsl_href
defined $out_xsl_href
length $out_xsl_href
Truth table0%0/3
A and B
A= defined $out_xsl_hrefB= length $out_xsl_href
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | die(__PACKAGE__.": no output transformation defined for $transform_id"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $orig_fh = $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | open(my $pml_fh, '>', \$xsl_source) or die "Cannot open scalar for writing!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | $fh=$pml_fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | die(__PACKAGE__.": Couldn't find PML transform with ID $transform_id"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | # dump embedded DOM documents | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 20 | my $refs_to_save = $ctxt->{'_refs_save'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | # save_reffiles must be a id=>href hash reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 20 | ▶ | my @refs_to_save = grep { ($_->{readas}||'') eq 'dom' or ($_->{readas}||'') eq 'pml' } $ctxt->get_reffiles(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition28%2/7
($_->{'readas'} || '') eq 'dom' || ($_->{'readas'} || '') eq 'pml'
$_->{'readas'} || ''
$_->{'readas'} || ''
MC/DC0%0/2
($_->{'readas'} || '') eq 'dom' || ($_->{'readas'} || '') eq 'pml'
$_->{'readas'}
$_->{'readas'}
Truth table33%1/3
A || B
A= $_->{'readas'}B= $_->{'readas'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 20 | ▶ | if (ref($refs_to_save)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | @refs_to_save = grep { exists $refs_to_save->{$_->{id}} } @refs_to_save; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | for (@refs_to_save) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | unless (defined $refs_to_save->{$_->{id}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $refs_to_save->{$_->{id}}=$_->{href}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 20 | $refs_to_save = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 20 | my $references = $ctxt->{'_references'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | # update all DOM trees to be saved | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 20 | ▶ | $ctxt->{'_parser'} ||= $ctxt->_xml_parser(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$ctxt->{"_parser"} ||= $ctxt->_xml_parser
MC/DC0%0/2
$ctxt->{"_parser"} ||= $ctxt->_xml_parser
$ctxt->{"_parser"}
$ctxt->_xml_parser
Truth table33%1/3
A ||= B
A= $ctxt->{"_parser"}B= $ctxt->_xml_parser
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 20 | foreach my $ref (@refs_to_save) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 12 | ▶ | if ($ref->{readas} eq 'dom') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 12 | $ctxt->readas_dom($ref->{id},$ref->{href}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # NOTE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | # if ($refs_to_save->{$ref->{id}} ne $ref->{href}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | # then the ref-file is going to be renamed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | # Although we don't parse it as PML, it can be a PML file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | # If it is, we might try to update it's references too, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | # but the snag here is, that we don't know if the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | # resources it references aren't moved along with it by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | # other means (e.g. by user making the copy). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 20 | ▶ | binmode $fh,":utf8" if $fh; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 20 | ▶ | local $WITH_TREES = $ctxt->{'_no_read_trees'} ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 20 | prepare_handlers($ctxt); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 20 | ▶ | dump_handlers($ctxt) if $opts->{dump_handlers} or $ENV{PML_COMPILE_DUMP};; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$opts->{"dump_handlers"} or $ENV{"PML_COMPILE_DUMP"}
MC/DC0%0/2
$opts->{"dump_handlers"} or $ENV{"PML_COMPILE_DUMP"}
$opts->{"dump_handlers"}
$ENV{"PML_COMPILE_DUMP"}
Truth table33%1/3
A or B
A= $opts->{"dump_handlers"}B= $ENV{"PML_COMPILE_DUMP"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 20 | $handlers{'#initialize'}->($ctxt,$refs_to_save,$fh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 20 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 20 | $handlers{'#root'}->($ctxt->{_root}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 20 | ▶ | if ($ctxt->{'_pi'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 10 | my ($n,$v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 10 | for my $pi (@{$ctxt->{'_pi'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | # ($n,$v)=@$pi; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | # for ($n,$v) { s/&/&/g; s/</</g; } # no no, _pi's are already quoted | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | print $fh qq(<?@$pi?>\n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 20 | ▶ | ($handlers{'#cleanup'}||sub{})->(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
Condition33%1/3
$handlers{'#cleanup'} || sub {
}
MC/DC0%0/2
$handlers{'#cleanup'} || sub {
}
$handlers{'#cleanup'}
sub {
}
Truth table33%1/3
A || B
A= $handlers{'#cleanup'}B= sub {
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 20 | %handlers=(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | # close_uri($fh); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 20 | ▶ | $fh = $orig_fh if defined $orig_fh; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 20 | ▶ | die $@ if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 20 | ▶ | if ($xsl_source and $out_xsl_href) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$xsl_source and $out_xsl_href
MC/DC0%0/2
$xsl_source and $out_xsl_href
$xsl_source
$out_xsl_href
Truth table33%1/3
A and B
A= $xsl_sourceB= $out_xsl_href
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | die "Buggy libxslt version 10127\n" if XSLT_BUG; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | my $xslt = XML::LibXSLT->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | my $params = $out_xsl->content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | my %params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | %params = map { $_->{'name'} => $_->value } $params->values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | if $params; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | my $out_xsl_parsed = $xslt->parse_stylesheet_file($out_xsl_href); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | my $dom = XML::LibXML->new()->parse_string($xsl_source); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | my $result = $out_xsl_parsed->transform($dom,%params); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | if (UNIVERSAL::can($result,'toFH')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | $result->toFH($fh,1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | $out_xsl_parsed->output_fh($result,$fh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | # dump DOM trees to save | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 20 | ▶ | if (ref($ctxt->{'_ref'})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 13 | foreach my $ref (@refs_to_save) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 12 | ▶ | if ($ref->{readas} eq 'dom') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 12 | my $dom = $ctxt->{'_ref'}->{$ref->{id}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 12 | my $href; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 12 | ▶ | if (defined($refs_to_save->{$ref->{id}})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | $href = $refs_to_save->{$ref->{id}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | $href = $ref->{href} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 12 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 12 | ▶ | if (ref($dom)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 12 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 12 | ▶ | rename_uri($href,$href."~") unless $href=~/^ntred:/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 12 | my $ok = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 12 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 12 | my $ref_fh = open_backend($href,"w"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 12 | ▶ | if ($ref_fh) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 12 | binmode $ref_fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 12 | $dom->toFH($ref_fh,1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 12 | close_backend($ref_fh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 12 | $ok = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 12 | ▶ | unless ($ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | my $err = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | rename_uri($href."~",$href) unless $href=~/^ntred:/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | _die($err."$@") if $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } elsif ($ref->{readas} eq 'pml') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | my $ref_id = $ref->{id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | my $pml = $ctxt->{'_ref'}->{$ref_id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | if ($pml) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | my $href; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | if (exists($refs_to_save->{$ref_id})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | $href = $refs_to_save->{$ref_id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | $href = $ref->{href} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | $pml->save({ %$opts, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | refs_save=>{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | map { my $k=$_; $k=~s%^\Q$ref_id\E/%% ? ($k=>$refs_to_save->{$_}) : () } keys %$refs_to_save | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | filename => $href, fh=>undef }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 20 | return $ctxt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | ###################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 20 | ▶ | sub prepare_handlers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepare_handlers: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 20 | my ($ctxt)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 20 | %handlers=(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 20 | my $schema = $ctxt->{'_schema'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 20 | my $key=_get_handlers_cache_key($schema); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 20 | my $cached = get_cached_handlers($key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 20 | ▶ | if ($cached) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 5 | %handlers= @$cached; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 15 | compile_schema($schema); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 15 | ▶ | cache_handlers($key,[%handlers]) if $CACHE_HANDLERS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | sub dump_handlers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump_handlers: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | my $dir = '.pml_compile.d'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | (-d $dir) || mkdir($dir) || die "Can't dump to $dir: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-d $dir or mkdir $dir
MC/DC0%0/2
-d $dir or mkdir $dir
-d $dir
mkdir $dir
Truth table0%0/3
A or B
A= -d $dirB= mkdir $dir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | # print "created $dir\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | for my $f (keys %src) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | my $dump_file = File::Spec->catfile($dir,$f); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | open (my $fh, '>:utf8', $dump_file) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | || die "Can't write to $dump_file: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | my $sub = $src{$f}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | $sub=~s/^\s*#line[^\n]*\n//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | print $fh ($sub); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 36 | ▶ | sub _write_seq { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_write_seq: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 36 | my ($decl,$path,$seq)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 36 | my $sub=''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 36 | ▶ | local $INDENT=-1 if $decl->is_mixed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 36 | $sub .= q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | for my $el (`.$seq.q`->elements) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | ($k,$v)=@$el; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | if (defined $v and (ref $v or length $v)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | $handlers{ '`.$path.'/'.q`'.$k }->($k,$v); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | print $out `._indent().q`"<$k/>"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 36 | return $sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 9 | ▶ | sub _write_trees_seq { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_write_trees_seq: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 9 | my ($decl)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 9 | my $path = $decl->get_decl_path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 9 | ▶ | $path =~ s/^!// if $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 9 | return q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | my $prolog = $ctxt->{'_pml_prolog'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | if ($prolog) {`._write_seq($decl,$path,'$prolog').q` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | for $v (@{$ctxt->{'_trees'}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | if (ref $v) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | $k=$v->{'#name'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | $handlers{ '`.$path.'/'.q`'.$k }->($k,$v); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | my $epilog = $ctxt->{'_pml_epilog'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | if ($epilog) {`._write_seq($decl,$path,'$epilog').q` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 1 | ▶ | sub _write_trees_list { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_write_trees_list: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 1 | my ($decl)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 1 | my $path = $decl->get_content_decl->get_decl_path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 1 | ▶ | $path =~ s/^!// if $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 1 | return q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | for $v (@{$ctxt->{'_trees'}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | $handlers{ '`.$path.q`' }->('LM',$v); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 7 | ▶ | sub _write_children_seq { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_write_children_seq: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 7 | my ($tag,$decl)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 7 | my $path = $decl->get_decl_path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 7 | ▶ | $path =~ s/^!// if $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 7 | my $sub = q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | if ($v = $data->firstson) {`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 7 | ▶ | $sub .= q` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | print $out `._indent().q`"<`.$tag.q`>";` if defined $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 7 | $sub .= _indent_inc().q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | my $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | while ($v) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | $name = $v->{'#name'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | $handlers{ '`.$path.'/'.q`'.$name }->($name,$v); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | $v = $v->rbrother; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | }`._indent_dec(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 7 | ▶ | $sub .= q` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | print $out `._indent().q`"</`.$tag.q`>";` if defined $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 7 | $sub.=q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 7 | return $sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 5 | ▶ | sub _write_children_list { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_write_children_list: called CC=8 SCAR=21.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 5 | my ($tag,$decl)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 5 | $decl = $decl->get_content_decl; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 5 | my $path = $decl->get_decl_path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 5 | ▶ | $path =~ s/^!// if $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 5 | my $sub = q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | if ($v = $data->firstson) {`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 5 | ▶ | if (defined $tag) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 3 | ▶ | if (!$WRITE_SINGLE_LM and !$WRITE_SINGLE_CHILDREN_LM) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$Treex::PML::Instance::Writer::WRITE_SINGLE_LM or $Treex::PML::Instance::Writer::WRITE_SINGLE_CHILDREN_LM
MC/DC0%0/2
$Treex::PML::Instance::Writer::WRITE_SINGLE_LM or $Treex::PML::Instance::Writer::WRITE_SINGLE_CHILDREN_LM
$Treex::PML::Instance::Writer::WRITE_SINGLE_LM
$Treex::PML::Instance::Writer::WRITE_SINGLE_CHILDREN_LM
Truth table33%1/3
A or B
A= $Treex::PML::Instance::Writer::WRITE_SINGLE_LMB= $Treex::PML::Instance::Writer::WRITE_SINGLE_CHILDREN_LM
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 3 | $sub .= q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | if ($v && !$v->rbrother && keys(%$v)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | $handlers{ '`.$path.q`' }->('`.$tag.q`',$v); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | } else {`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 3 | $sub .= q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | print $out `._indent().q`"<`.$tag.q`>";` ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 5 | $sub.=_indent_inc().q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | while ($v) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | $handlers{ '`.$path.q`' }->('LM',$v); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | $v = $v->rbrother; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | }`._indent_dec(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 5 | ▶ | if (defined $tag) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 3 | $sub .= q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | print $out `._indent().q`"</`.$tag.q`>";`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 3 | ▶ | $sub .= q` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$Treex::PML::Instance::Writer::WRITE_SINGLE_LM or $Treex::PML::Instance::Writer::WRITE_SINGLE_CHILDREN_LM
MC/DC0%0/2
$Treex::PML::Instance::Writer::WRITE_SINGLE_LM or $Treex::PML::Instance::Writer::WRITE_SINGLE_CHILDREN_LM
$Treex::PML::Instance::Writer::WRITE_SINGLE_LM
$Treex::PML::Instance::Writer::WRITE_SINGLE_CHILDREN_LM
Truth table33%1/3
A or B
A= $Treex::PML::Instance::Writer::WRITE_SINGLE_LMB= $Treex::PML::Instance::Writer::WRITE_SINGLE_CHILDREN_LM
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | }` if !$WRITE_SINGLE_LM and !$WRITE_SINGLE_CHILDREN_LM; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 5 | $sub.=q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 5 | return $sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 14 | ▶ | sub _knit_code { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_knit_code: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 14 | my ($knit_decl,$knit_decl_path,$name)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 14 | my $idM = Treex::PML::Instance::Reader::_fix_id_member($knit_decl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 14 | ▶ | if ($idM) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 14 | my $idM_name=$idM->get_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 14 | return q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | my $knit_id = $v->{'`.$idM_name.q`'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | my $prefix; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | unless (defined $knit_id) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | warn "Cannot KNIT back: `.$idM_name.q` not defined on object `.$knit_decl_path.q`!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | } elsif ($knit_id =~ s/^(.*?)#//) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | $prefix=$1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | $prefix = $v->{'#knit_prefix'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | print $out `._indent().q`'<`.$name.q`>'.($prefix ? $prefix.'#'.$knit_id : $knit_id).'</`.$name.q`>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | if ($prefix and !UNIVERSAL::DOES::does($ctxt->{'_ref'}{$prefix},'Treex::PML::Instance')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | # DOM KNIT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | my $rf_href = $refs_to_save->{$prefix}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | if ( $rf_href ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | my $indeces = $ctxt->{'_ref-index'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | if ($indeces and $indeces->{$prefix}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | my $knit = $indeces->{$prefix}{$knit_id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | if ($knit) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | my $save_out = $out; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | my $xml=''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | open my $new_out, '>:utf8', \$xml; # perl 5.8.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | $out = $new_out; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | local $INDENT=-1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | $handlers{'`.$knit_decl_path.q`' }->($knit->nodeName,$v); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | close $new_out; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | $out = $save_out; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | $xml='<x xmlns="`.PML_NS.q`">'.$xml.'</x>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | my $new = $ctxt->{'_parser'}->parse_string($xml)->documentElement->firstChild; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | $new->setAttribute('`.$idM_name.q`',$knit_id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | $knit->ownerDocument->adoptNode( $new ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | $knit->parentNode->insertAfter($new,$knit); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | $knit->unbindNode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | $indeces->{$prefix}{$knit_id}=$new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | _warn("Didn't find ID '$knit_id' in '$rf_href' ('$prefix') - cannot knit back!\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | _warn("Knit-file '$rf_href' ('$prefix') has no index - cannot knit back!\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | warn("Cannot KNIT ".$knit_decl_path." if there is no member/attribute with role='#ID'!"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 20 | ▶ | sub simplify { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
simplify: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 20 | my $filename = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 20 | my $up = File::Spec->updir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 20 | my $sep = File::Spec->catfile(q(), q()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 20 | ▶ | while($filename =~ /\Q$sep$up$sep/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | $filename =~ s/\Q$sep\E?[^$sep]*\Q$sep$up$sep/$sep/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 20 | return $filename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 15 | ▶ | sub compile_schema { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compile_schema: called CC=1 SCAR=0.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 15 | my ($schema)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 15 | my ($ctxt,$refs_to_save,$out,$pml_trees_type,$have_trees,$indent_level); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 15 | my $schema_name = $schema->get_root_decl->get_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 20 | ▶ | $handlers{'#cleanup'}= sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 20 | undef $_ for ($ctxt,$refs_to_save,$out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 15 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 20 | ▶ | $handlers{'#initialize'}= sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 20 | my ($instance,$refs_save,$fh)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 20 | $ctxt = $instance; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 20 | $refs_to_save = $refs_save; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 20 | $out = $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 20 | $have_trees = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 20 | $pml_trees_type = $ctxt->{'_pml_trees_type'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 20 | $indent_level=0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 15 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 466 | ▶ | $schema->for_each_decl(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=86 SCAR=53.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 466 | my ($decl)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | # no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 466 | my $decl_type=$decl->get_decl_type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 466 | my $path = $decl->get_decl_path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 466 | ▶ | $path =~ s/^!// if $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 466 | ▶ | return if $decl_type == PML_ATTRIBUTE_DECL || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
$decl_type == 11 or $decl_type == 12 or $decl_type == 1 or $decl_type == 13
$decl_type == 11 or $decl_type == 12 or $decl_type == 1
$decl_type == 11 or $decl_type == 12
MC/DC100%4/4
$decl_type == 11 or $decl_type == 12 or $decl_type == 1 or $decl_type == 13
$decl_type == 11
$decl_type == 12
$decl_type == 1
$decl_type == 13
Truth table100%5/5
A or B or C or D
A= $decl_type == 11B= $decl_type == 12C= $decl_type == 1D= $decl_type == 13
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | $decl_type == PML_MEMBER_DECL || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | $decl_type == PML_TYPE_DECL || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | $decl_type == PML_ELEMENT_DECL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 238 | ▶ | if ($decl_type == PML_ROOT_DECL) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 9 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 15 | my $name = $decl->get_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 15 | my $cdecl = $decl->get_content_decl; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 15 | my $cdecl_type = $cdecl->get_decl_type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 15 | my $cpath = $cdecl->get_decl_path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 15 | $cpath =~ s/^!//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 15 | my $src = $schema_name.'__generated_write_root'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 15 | my $sub = q`#line 1 ".pml_compile.d/`.$src.q`" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | my ($data)=@_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | my $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | print $out '<?xml version="1.0" encoding="UTF-8"?>'."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | print $out '<`.$decl->get_name.q` xmlns="`.PML_NS.q`"';`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | # we need to know attributes now | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 15 | ▶ | if ($cdecl_type == PML_CONSTANT_DECL || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$cdecl_type == 10 or $cdecl_type == 3
MC/DC50%1/2
$cdecl_type == 10 or $cdecl_type == 3
$cdecl_type == 10
$cdecl_type == 3
Truth table66%2/3
A or B
A= $cdecl_type == 10B= $cdecl_type == 3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | $cdecl_type == PML_STRUCTURE_DECL) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 5 | for my $attr ($cdecl->get_attributes) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | ▶ | if ($attr->is_required) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | $sub.=q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | $v = $data->{'`.$attr->get_name.q`'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | $v = '' unless defined $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | $v =~ s/&/&/g; $v=~s/</</g; $v=~s/"/"/g; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | print $out ' `.$attr->get_name.q`="'.$v.'"'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | `; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | $sub.=q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | $v = $data->{'`.$attr->get_name.q`'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | if (defined($v) && length($v)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | $v=~s/&/&/g; $v=~s/</</g; $v=~s/"/"/g; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | print $out ' `.$attr->get_name.q`="'.$v.'"'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | `; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | # NOTE: using _^_ as indentation replacement! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 15 | ▶ | my $no_end_indent = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$cdecl_type == 5 && $cdecl->is_mixed
MC/DC100%2/2
$cdecl_type == 5 && $cdecl->is_mixed
$cdecl_type == 5
$cdecl->is_mixed
Truth table100%3/3
A && B
A= $cdecl_type == 5B= $cdecl->is_mixed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | ($cdecl_type == PML_SEQUENCE_DECL and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | $cdecl->is_mixed); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 15 | ▶ | my $psub = q` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | print $out ">\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | "_^_<head>\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | my $inline = $ctxt->{'_schema-inline'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | # remove /../ from filename, URI::rel gives strange results for base containing them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | my $filename = $ctxt->{_filename}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | $filename = $filename->path if ref $filename and index($filename,'file:/') == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | $filename = simplify($filename) if -e $filename; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | if (defined $inline and length $inline) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | print $out qq(_^__^_<schema>\n),$inline,qq( </schema>\n); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | $v = $ctxt->{'_schema-url'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | if (defined $v and length $v) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | $v=Treex::PML::IO::make_relative_URI($ctxt->{'_schema-url'},$filename); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | $v=~s/&/&/g; $v=~s/</</g; $v=~s/"/"/g; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | print $out qq(_^__^_<schema href="$v" />\n); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | print $out qq(_^__^_<schema>\n); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | $ctxt->{'_schema'}->write({fh=>$out}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | print $out qq(_^__^_</schema>\n); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | my $references = $ctxt->{'_references'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | if (ref($references) and keys(%$references)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | my $named = $ctxt->{'_refnames'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | my %names = $named ? (map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | my $name = $_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | map { $_ => $name } (ref($named->{$_}) ? @{$named->{$_}} : $named->{$_}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | } keys %$named) : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | print $out qq(_^__^_<references>\n); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | foreach my $id (sort keys %$references) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | my $href; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | if (exists($refs_to_save->{$id})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | # effectively rename the file reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | $href = $references->{$id} = $refs_to_save->{$id} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | $href = $references->{$id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | if (ref $href && $href->isa('Treex::PML::Resource::URI')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | $href = Treex::PML::IO::make_relative_URI($href,$href); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | $href = Treex::PML::IO::make_relative_URI($href,$filename); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | my $name = $names{$id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | for ($id,$href, (defined $name ? $name : ())) { s/&/&/g; s/</</g; s/"/"/g; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | print $out qq(_^__^__^_<reffile id="${id}").(defined $name ? qq( name="${name}") : ()).qq( href="${href}" />\n); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | print $out qq(_^__^_</references>\n); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | print $out "_^_</head>"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | $handlers{ '`.$cpath.q`' }->(undef,$data); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | print $out `.($no_end_indent ? '' : _indent()).q`'</`.$decl->get_name.q`>'."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 15 | ▶ | my $indent = $INDENT>0 ? ' ' x $INDENT : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 15 | $psub=~s/_\^_/$indent/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 15 | $sub.=$psub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 15 | $src{$src}=$sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 15 | ▶ | $handlers{'#root'}=eval $sub; die _nl($sub)."\n".$@.' ' if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | } elsif ($decl_type == PML_STRUCTURE_DECL) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | # print $path,"\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 38 | my $src = $schema_name.'__generated_write_structure@'.$path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 38 | $src=~y{/}{@}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 38 | my $sub = q`#line 1 ".pml_compile.d/`.$src.q`" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | my ($tag,$data)=@_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | my ($v,$k); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | unless (defined $data) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | print $out defined $tag ? '/>' : '>' if !$tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | my $close; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | if (defined $tag) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | $close = '/>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | print $out `._indent().q`'<'.$tag if length $tag;`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 38 | for my $attr ($decl->get_attributes) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 24 | my $name = $attr->get_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 24 | ▶ | if ($attr->is_required) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 22 | $sub.=q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | $v = $data->{'`.$name.q`'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | $v='' unless defined $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | $v=~s/&/&/g; $v=~s/</</g; $v=~s/"/"/g; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | print $out ' `.$name.q`'.'="'.$v.'"'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | `; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 2 | $sub.=q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | $v = $data->{'`.$name.q`'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | if (defined($v) && length($v)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | $v=~s/&/&/g; $v=~s/</</g; $v=~s/"/"/g; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | print $out ' `.$name.q`'.'="'.$v.'"'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | `; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 38 | $sub .= q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | }`._indent_inc(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 38 | my $this_trees_type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 38 | for my $m ($decl->get_members) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 115 | ▶ | next if $m->is_attribute; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 91 | my $name = $m->get_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 91 | my $mdecl = $m->get_content_decl; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 91 | my $mdecl_type = $mdecl->get_decl_type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 91 | $sub.=q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | $v = $data->{'`.$name.q`'};`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 91 | my $close_brace=0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 91 | my $ignore_required=0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 91 | ▶ | if ($WITH_TREES and $decl->get_role eq '#NODE' and $m->get_role eq '#CHILDNODES') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition83%5/6
$Treex::PML::Instance::Writer::WITH_TREES and $decl->get_role eq "#NODE" and $m->get_role eq "#CHILDNODES"
$Treex::PML::Instance::Writer::WITH_TREES and $decl->get_role eq "#NODE"
MC/DC66%2/3
$Treex::PML::Instance::Writer::WITH_TREES and $decl->get_role eq "#NODE" and $m->get_role eq "#CHILDNODES"
$Treex::PML::Instance::Writer::WITH_TREES
$decl->get_role eq "#NODE"
$m->get_role eq "#CHILDNODES"
Truth table75%3/4
A and B and C
A= $Treex::PML::Instance::Writer::WITH_TREESB= $decl->get_role eq "#NODE"C= $m->get_role eq "#CHILDNODES"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 3 | $close_brace=1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 3 | $sub.=q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | if (UNIVERSAL::DOES::does($data,'Treex::PML::Node')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | if (defined $close) { undef $close; print $out '>'; }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 3 | ▶ | if ($mdecl_type == PML_SEQUENCE_DECL) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | $sub .= _write_children_seq($name,$mdecl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | } elsif ($mdecl_type == PML_LIST_DECL) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 3 | $sub .= _write_children_list($name,$mdecl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 3 | $sub.=q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | } else { `; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | ▶ | } elsif ($WITH_TREES and ($m->get_role eq '#TREES' or $mdecl->get_role eq '#TREES')) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%4/6
$Treex::PML::Instance::Writer::WITH_TREES and $m->get_role eq "#TREES" || $mdecl->get_role eq "#TREES"
$m->get_role eq "#TREES" or $mdecl->get_role eq "#TREES"
MC/DC33%1/3
$Treex::PML::Instance::Writer::WITH_TREES and $m->get_role eq "#TREES" || $mdecl->get_role eq "#TREES"
$Treex::PML::Instance::Writer::WITH_TREES
$m->get_role eq "#TREES"
$mdecl->get_role eq "#TREES"
Truth table50%2/4
A and B or C
A= $Treex::PML::Instance::Writer::WITH_TREESB= $m->get_role eq "#TREES"C= $mdecl->get_role eq "#TREES"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 1 | $close_brace=1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 1 | $this_trees_type = $mdecl; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 1 | $ignore_required=1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 1 | $sub.=q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | if (!$have_trees and !defined $v and (!defined($pml_trees_type) or $pml_trees_type==$this_trees_type)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | $have_trees=1;`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 1 | ▶ | if ($m->is_required) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 1 | $sub.=q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | warn "Member '`.$path.'/'.$name.q`' with role #TREES is required but there are no trees, writing empty tag!\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | if !$ctxt->{_trees} and @{$ctxt->{_trees}};`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 1 | $sub.=q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | if (defined $close) { undef $close; print $out '>'; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | print $out `._indent().q`'<`.$name.q`>';`._indent_inc(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 1 | ▶ | if ($mdecl_type == PML_SEQUENCE_DECL) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | $sub .= _write_trees_seq($mdecl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | } elsif ($mdecl_type == PML_LIST_DECL) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 1 | $sub .= _write_trees_list($mdecl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 1 | $sub.=_indent_dec().q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | if (defined $close) { undef $close; print $out '>'; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | print $out `._indent().q`'</`.$name.q`>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | } else { `; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 91 | ▶ | if ($mdecl_type == PML_CONSTANT_DECL and !$m->is_required) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition33%1/3
$mdecl_type == 10 and not $m->is_required
MC/DC0%0/2
$mdecl_type == 10 and not $m->is_required
$mdecl_type == 10
not $m->is_required
Truth table33%1/3
A and not(B)
A= $mdecl_type == 10B= not $m->is_required
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | # do not write | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | $sub.=q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | if (defined $v and (ref($v) or length $v and $v ne "`.quotemeta($mdecl->get_value).q`")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | warn "Disregarding invalid constant value in member '`.$name.q`': '$v'!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | } elsif ($m->get_role eq '#KNIT') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | my $knit_name = $m->get_knit_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 0 | my $knit_decl = $m->get_knit_content_decl(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | my $knit_decl_path = $knit_decl->get_decl_path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | $knit_decl_path=~s/^!//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | $sub.=q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | if (defined $v and !ref $v and length $v) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | if (defined $close) { undef $close; print $out '>'; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | $handlers{'`.$path.'/'.$name.q`' }->('`.$name.q`',$v); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | } else {`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | ▶ | unless ($name eq $knit_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | $sub .= q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | $v = $data->{'`.$knit_name.q`'};`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | $sub .= q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | if (defined $close) { undef $close; print $out '>'; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | if (ref $v) {`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | ▶ | if ($KEEP_KNIT) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | $sub .= q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | $handlers{'`.$knit_decl_path.q`' }->('`.$name.q`',$v);`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | $sub.=_knit_code($knit_decl,$knit_decl_path,$name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | $sub .= q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | ▶ | if ($m->is_required) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | $sub.=q` else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | warn "Required member '`.$path.'/'.$knit_name.q`' missing, writing empty tag!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | print $out `._indent().q`'<`.$knit_name.q`/>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | $sub.= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 0 | ▶ | $sub .= q` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | }` if $close_brace; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | ▶ | } elsif ($mdecl_type == PML_LIST_DECL and $mdecl->get_role eq '#KNIT') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$mdecl_type == 6 and $mdecl->get_role eq "#KNIT"
MC/DC100%2/2
$mdecl_type == 6 and $mdecl->get_role eq "#KNIT"
$mdecl_type == 6
$mdecl->get_role eq "#KNIT"
Truth table100%3/3
A and B
A= $mdecl_type == 6B= $mdecl->get_role eq "#KNIT"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 7 | my $knit_name = $m->get_knit_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 7 | my $knit_decl = $mdecl->get_knit_content_decl(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 7 | my $knit_decl_path = $knit_decl->get_decl_path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 7 | $knit_decl_path=~s/^!//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 7 | ▶ | if ($name ne $knit_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 7 | $sub.=q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | if (ref $v) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | if (defined $close) { undef $close; print $out '>'; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | $handlers{'`.$path.'/'.$name.q`' }->('`.$name.q`',$v); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | $v = $data->{'`.$knit_name.q`'};`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 7 | ▶ | if ($m->is_required) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 0 | $sub.=q` if (!ref $v) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | warn "Required member '`.$path.'/'.$knit_name.q`' missing, writing empty tag!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | if (defined $close) { undef $close; print $out '>'; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | print $out `._indent().q`'<`.$knit_name.q`/>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | } else {`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 7 | $sub .= q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | if (ref $v) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | if (defined $close) { undef $close; print $out '>'; }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 7 | ▶ | if ($KEEP_KNIT) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | ▶ | if (!$WRITE_SINGLE_LM) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 0 | $sub .= q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | if (@$v==1 and defined($v->[0]) and !(UNIVERSAL::isa($v->[0],'HASH') and keys(%{$v->[0]})==0)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | $handlers{'`.$knit_decl_path.q`' }->('`.$name.q`',$v->[0]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | } else {`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 0 | $sub .= q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | print $out `._indent().q`'<`.$name.q`>';`._indent_inc().q` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | $handlers{'`.$knit_decl_path.q`' }->('LM',$_) for @$v;`._indent_dec().q` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | print $out `._indent().q`'</`.$name.q`>';`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 0 | ▶ | $sub .= q` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | }` if !$WRITE_SINGLE_LM; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 7 | ▶ | if (!$WRITE_SINGLE_LM) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 7 | $sub .= q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | if (@$v==1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | if (defined $close) { undef $close; print $out '>'; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | $v=$v->[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | `._knit_code($knit_decl,$knit_decl_path,$name).q` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | } else {`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 7 | $sub .= q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | if (defined $close) { undef $close; print $out '>'; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | print $out `._indent().q`'<`.$name.q`>';`._indent_inc().q` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | my $l = $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | for $v (@$l) {`._knit_code($knit_decl,$knit_decl_path,'LM').q` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | }`._indent_dec().q` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | print $out `._indent().q`'</`.$name.q`>';`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 7 | ▶ | $sub .= q` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | }` if !$WRITE_SINGLE_LM; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 7 | $sub.= | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | q` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 7 | ▶ | if ($name ne $knit_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 7 | $sub.=q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 7 | ▶ | $sub .= q` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | }` if $close_brace; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | # if ($mdecl->get_role eq '#TREES') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | # $sub.=q` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | # $handlers{'`.$path.'/'.$name.q`' }->('`.$name.q`',$v);`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | # } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 84 | $sub.=q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | if (defined $v and (ref $v or length $v)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | if (defined $close) { undef $close; print $out '>'; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | $handlers{'`.$path.'/'.$name.q`' }->('`.$name.q`',$v); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 84 | ▶ | if ($m->is_required and !$ignore_required ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$m->is_required and not $ignore_required
MC/DC100%2/2
$m->is_required and not $ignore_required
$m->is_required
not $ignore_required
Truth table100%3/3
A and not(B)
A= $m->is_requiredB= not $ignore_required
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 25 | $sub.=q` else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | warn "Required member '`.$path.'/'.$name.q`' missing, writing empty tag!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | if (defined $close) { undef $close; print $out '>'; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | print $out `._indent().q`'<`.$name.q`/>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 91 | ▶ | $sub .= q` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | }` if $close_brace; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 38 | $sub .= _indent_dec().q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | if (defined $tag and length $tag) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | print $out (defined($close) ? $close : `._indent().q`"</$tag>"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | # print $sub; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 38 | $src{$src}=$sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 38 | ▶ | $handlers{$path} = eval($sub); die _nl($sub)."\n".$@.' ' if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | } elsif ($decl_type == PML_CONTAINER_DECL) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 18 | my $src = $schema_name.'__generated_write_container@'.$path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 18 | $src=~y{/}{@}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 18 | my $sub = q`#line 1 ".pml_compile.d/`.$src.q`" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | my ($tag,$data)=@_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | my $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | unless (defined $data) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | print $out defined $tag ? '/>' : '>' if !$tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | my $close; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | my $ctag=$tag;`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 18 | my @attributes = $decl->get_attributes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 18 | ▶ | if (@attributes) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 12 | $sub.=q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | if (defined $tag) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | print $out `._indent().q`'<'.$tag ; $close = '>'; $ctag='';`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 12 | for my $attr (@attributes) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 13 | my $name = $attr->get_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 13 | ▶ | if ($attr->is_required) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 8 | $sub.=q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | $v = $data->{'`.$name.q`'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | $v='' unless defined $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | $v=~s/&/&/g; $v=~s/</</g; $v=~s/"/"/g; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | print $out ' `.$name.q`'.'="'.$v.'"'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | `; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 5 | $sub.=q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | $v = $data->{'`.$name.q`'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | if (defined($v) && length($v)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | $v=~s/&/&/g; $v=~s/</</g; $v=~s/"/"/g; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | print $out ' `.$name.q`'.'="'.$v.'"'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | `; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 12 | $sub .= q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 6 | $sub .= q`undef $tag;`; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 18 | my $cdecl = $decl->get_content_decl; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | # TODO: #TREES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 18 | ▶ | if ($cdecl) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 18 | my $cdecl_type = $cdecl->get_decl_type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 18 | my $cpath = $cdecl->get_decl_path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 18 | $cpath =~ s/^!//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 18 | my $close_brace=0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 18 | ▶ | if ($WITH_TREES and $decl->get_role eq '#NODE' and $cdecl->get_role eq '#CHILDNODES') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$Treex::PML::Instance::Writer::WITH_TREES and $decl->get_role eq "#NODE" and $cdecl->get_role eq "#CHILDNODES"
$Treex::PML::Instance::Writer::WITH_TREES and $decl->get_role eq "#NODE"
MC/DC66%2/3
$Treex::PML::Instance::Writer::WITH_TREES and $decl->get_role eq "#NODE" and $cdecl->get_role eq "#CHILDNODES"
$Treex::PML::Instance::Writer::WITH_TREES
$decl->get_role eq "#NODE"
$cdecl->get_role eq "#CHILDNODES"
Truth table75%3/4
A and B and C
A= $Treex::PML::Instance::Writer::WITH_TREESB= $decl->get_role eq "#NODE"C= $cdecl->get_role eq "#CHILDNODES"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 9 | $close_brace=1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 9 | $sub.=q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | if (UNIVERSAL::DOES::does($data,'Treex::PML::Node')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | undef $close; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | if (defined($ctag)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | if (!length($ctag)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | print $out '>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | } elsif ($data->firstson) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | print $out `._indent().q`qq{<$ctag>}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | print $out `._indent().q`qq{<$ctag/>}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 9 | ▶ | if ($cdecl_type == PML_SEQUENCE_DECL) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 7 | $sub .= _write_children_seq(undef,$cdecl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | } elsif ($cdecl_type == PML_LIST_DECL) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 2 | $sub .= _write_children_list(undef,$cdecl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 9 | $sub.=q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | if ($data->firstson) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | if (defined($ctag) and length($ctag)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | print $out `._indent().q`qq{</$ctag>}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | print $out `._indent().q`''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | } else { `; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 18 | $sub.=q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | $v = $data->{'#content'};`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 18 | ▶ | $sub.=q` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | undef $close; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | if (defined $v and (ref $v or length $v)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | $handlers{'`.$cpath.q`' }->($ctag,$v); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | my $ref = ref($v); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | print $out `._indent().q`'' if !$ctag and $ref and !((UNIVERSAL::DOES::does($v,'Treex::PML::Alt')`.($WRITE_SINGLE_LM ? '' : q` or UNIVERSAL::DOES::does($v,'Treex::PML::List')`) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | .q`) and @$v==1 and defined($v->[0]) and !(UNIVERSAL::isa($v->[0],'HASH') and keys(%{$v->[0]})==0)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | if (defined($ctag) and length($ctag)) { print $out `._indent().q`qq{<$ctag/>} } else { $close='/>'; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 18 | ▶ | $sub .= q` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | }` if $close_brace; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 0 | $sub .= q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | if (defined($ctag) and length($ctag)) { print $out `._indent().q`qq{<$ctag/>} } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | $close='/>'; }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 18 | $sub .= q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | if (defined $tag and length $tag) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | print $out (defined($close) ? $close : "</$tag>"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 18 | $src{$src}=$sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 18 | ▶ | $handlers{$path} = eval($sub); die _nl($sub)."\n".$@.' ' if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | } elsif ($decl_type == PML_SEQUENCE_DECL) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | # print $path,"\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 18 | my $src = $schema_name.'__generated_write_sequence@'.$path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 18 | $src=~y{/}{@}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | # TODO: check it's a Seq, warn about on undefined element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 18 | ▶ | local $INDENT=-1 if $decl->is_mixed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 18 | my $sub = q`#line 1 ".pml_compile.d/`.$src.q`" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | my ($tag,$data)=@_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | my ($k,$v); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | unless (defined $data) {`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 18 | ▶ | if ($WITH_TREES and $decl->get_role eq '#TREES') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$Treex::PML::Instance::Writer::WITH_TREES and $decl->get_role eq "#TREES"
MC/DC50%1/2
$Treex::PML::Instance::Writer::WITH_TREES and $decl->get_role eq "#TREES"
$Treex::PML::Instance::Writer::WITH_TREES
$decl->get_role eq "#TREES"
Truth table66%2/3
A and B
A= $Treex::PML::Instance::Writer::WITH_TREESB= $decl->get_role eq "#TREES"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 9 | $sub .= q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | if (!$have_trees and (!defined($pml_trees_type) or $pml_trees_type==$decl)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | print $out (length($tag) ? `._indent().q`"<$tag>" : '>') if defined $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | $have_trees=1;`._indent_inc()._write_trees_seq($decl)._indent_dec().q` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | print $out (length($tag) ? `._indent().q`"</$tag>" : '>') if defined $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | print $out defined $tag ? '/>' : '>' if !$tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 9 | $sub .= q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | print $out defined $tag ? '/>' : '>' if !$tag;`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 18 | $sub .= q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | print $out (length($tag) ? `._indent().q`"<$tag>" : '>') if defined $tag;` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | ._indent_inc()._write_seq($decl,$path,'$data')._indent_dec(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 18 | $sub.=q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | if (defined $tag and length $tag) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | print $out `._indent().q`"</$tag>"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 18 | $src{$src}=$sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | 18 | ▶ | $handlers{$path} = eval($sub); die _nl($sub)."\n".$@.' ' if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 18 | ▶ | $handlers{$path.'/#TEXT'} = eval q`sub { print $out ($_[1]); }` if $decl->is_mixed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | } elsif ($decl_type == PML_LIST_DECL) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | 29 | my $cdecl = $decl->get_content_decl; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 29 | my $cpath = $cdecl->get_decl_path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 29 | $cpath=~s/^!//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 29 | my $src = $schema_name.'__generated_write_list@'.$path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 29 | $src=~y{/}{@}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | # TODO: check it's a List | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | 29 | my $sub = q`#line 1 ".pml_compile.d/`.$src.q`" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | my ($tag,$data)=@_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | my ($v); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | if (!defined $data or !@$data) {`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 29 | ▶ | if ($WITH_TREES and $decl->get_role eq '#TREES') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$Treex::PML::Instance::Writer::WITH_TREES and $decl->get_role eq "#TREES"
MC/DC0%0/2
$Treex::PML::Instance::Writer::WITH_TREES and $decl->get_role eq "#TREES"
$Treex::PML::Instance::Writer::WITH_TREES
$decl->get_role eq "#TREES"
Truth table33%1/3
A and B
A= $Treex::PML::Instance::Writer::WITH_TREESB= $decl->get_role eq "#TREES"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 0 | $sub .= q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | if (!$have_trees and (!defined($pml_trees_type) or $pml_trees_type==$decl)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | print $out (length($tag) ? `._indent().q`"<$tag>" : '>') if defined $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | $have_trees=1;`._indent_inc()._write_trees_list($decl)._indent_dec().q` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | print $out `._indent().q`"</$tag>" if defined $tag and length $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | print $out defined $tag ? '/>' : '>' if !$tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | } `; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | 29 | $sub .= q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | print $out defined $tag ? '/>' : '>' if !$tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | return;`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | 29 | ▶ | if (!$WRITE_SINGLE_LM) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | 29 | $sub .= q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | } elsif (@$data==1 and defined($data->[0]) and !(UNIVERSAL::isa($data->[0],'HASH') and keys(%{$data->[0]})==0)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | print $out '>' if defined $tag and !length $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | $handlers{ '`.$cpath.q`' }->($tag || 'LM',$data->[0]);`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | 29 | $sub .= q` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | print $out (length($tag) ? `._indent().q`"<$tag>" : '>') if defined $tag;`._indent_inc().q` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | for $v (@$data) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | if (defined $v and (ref $v or length $v)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | $handlers{ '`.$cpath.q`' }->('LM',$v); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | print $out `._indent().q`"<LM/>"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | }`._indent_dec().q` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | print $out `._indent().q`"</$tag>" if defined $tag and length $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 29 | $src{$src}=$sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 29 | ▶ | $handlers{$path} = eval($sub); die _nl($sub)."\n".$@.' ' if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | } elsif ($decl_type == PML_ALT_DECL) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 5 | my $cdecl = $decl->get_content_decl; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | 5 | my $cpath = $cdecl->get_decl_path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | 5 | $cpath=~s/^!//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 5 | my $src = $schema_name.'__generated_write_alt@'.$path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 5 | $src=~y{/}{@}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | # TODO: check it's an Alt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | 5 | my $sub = q`#line 1 ".pml_compile.d/`.$src.q`" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | my ($tag,$data)=@_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | unless (defined $data) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | print $out defined $tag ? '/>' : '>' if !$tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | if (!UNIVERSAL::DOES::does($data, 'Treex::PML::Alt')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | print $out '>' if defined $tag and !length $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | $handlers{ '`.$cpath.q`' }->($tag || 'AM',$data); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | } elsif (@$data==1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | print $out '>' if defined $tag and !length $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | $handlers{ '`.$cpath.q`' }->($tag || 'AM',$data->[0]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | } elsif (@$data==0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | print $out defined $tag ? '/>' : '>' if !$tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | my $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | print $out (length($tag) ? `._indent().q`"<$tag>" : '>') if defined $tag;`._indent_inc().q` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | for $v (@$data) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | if (defined $v and (ref $v or length $v)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | $handlers{ '`.$cpath.q`' }->('AM',$v); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | print $out `._indent().q`"<AM/>"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | }`._indent_dec().q` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | print $out `._indent().q`"</$tag>" if defined $tag and length $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | 5 | $src{$src}=$sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | 5 | ▶ | $handlers{$path} = eval($sub); die _nl($sub)."\n".$@.' ' if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | } elsif ($decl_type == PML_CDATA_DECL) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | # TODO: CDATA FORMAT VALIDATION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | 101 | my $src = $schema_name.'__generated_write_cdata@'.$path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | 101 | $src=~y{/}{@}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | 101 | my $sub = q`#line 1 ".pml_compile.d/`.$src.q`" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | my ($tag,$data)=@_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | print $out (length($tag) ? `._indent().q`"<$tag>" : '>') if defined $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | if (defined $data and length $data) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | $data=~s/&/&/g;$data=~s/</</g;$data=~s/\]\]>/]]>/g; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | print $out $data; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | print $out "</$tag>" if defined $tag and length $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 101 | $src{$src}=$sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | 101 | ▶ | $handlers{$path} = eval($sub); die _nl($sub)."\n".$@.' ' if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | } elsif ($decl_type == PML_CHOICE_DECL) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | 14 | my $value_hash = $decl->{value_hash}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | 14 | ▶ | unless ($value_hash) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | 0 | $value_hash={}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | 0 | @{$value_hash}{@{$decl->{values}}}=(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | 0 | $decl->{value_hash}=$value_hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | 14 | my $src = $schema_name.'__generated_write_choice@'.$path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | 14 | $src=~y{/}{@}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 14 | my $sub = q`#line 1 ".pml_compile.d/`.$src.q`" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | my ($tag,$data)=@_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | print $out (length($tag) ? `._indent().q`"<$tag>" : '>') if defined $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | if (defined $data and length $data) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | warn("Value: '$data' not allowed for choice type '`.$path.q`'; writing anyway!") if !exists $value_hash->{$data}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | $data=~s/&/&/g;$data=~s/</</g; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | print $out $data; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | print $out "</$tag>" if defined $tag and length $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | 14 | $src{$src}=$sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | 14 | ▶ | $handlers{$path} = eval($sub); die _nl($sub)."\n".$@.' ' if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | } elsif ($decl_type == PML_CONSTANT_DECL) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | 0 | my $value = quotemeta($decl->{value}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 0 | my $src = $schema_name.'__generated_write_choice@'.$path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | 0 | $src=~y{/}{@}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | 0 | my $sub = q`#line 1 ".pml_compile.d/`.$src.q`" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | my ($tag,$data)=@_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | print $out (length($tag) ? `._indent().q`"<$tag>" : '>') if defined $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | if (defined $data and length $data) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | warn("Invalid value '$data' in a constant type '`.$path.q`', should be '`.$value.q`'; writing anyway!") if $data ne "`.$value.q`"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | $data=~s/&/&/g;$data=~s/</</g; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | print $out $data; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | print $out "</$tag>" if defined $tag and length $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | }`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | 0 | $src{$src}=$sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | 0 | ▶ | $handlers{$path} = eval($sub); die _nl($sub)."\n".$@.' ' if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | # print "@_\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | 15 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | $schema->for_each_decl( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | 466 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=21.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 466 | my ($decl)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | 466 | my $decl_type=$decl->get_decl_type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | 466 | ▶ | if ($decl_type == PML_ATTRIBUTE_DECL || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$decl_type == 11 or $decl_type == 12 or $decl_type == 13
$decl_type == 11 or $decl_type == 12
MC/DC100%3/3
$decl_type == 11 or $decl_type == 12 or $decl_type == 13
$decl_type == 11
$decl_type == 12
$decl_type == 13
Truth table100%4/4
A or B or C
A= $decl_type == 11B= $decl_type == 12C= $decl_type == 13
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | $decl_type == PML_MEMBER_DECL || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | $decl_type == PML_ELEMENT_DECL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | 159 | my $parent = $decl->get_parent_decl; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 159 | my $path = $parent->get_decl_path . '/'. $decl->get_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 159 | ▶ | $path =~ s/^!// if $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 159 | my $mdecl; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | 159 | ▶ | if (!exists($handlers{$path})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | 47 | ▶ | $mdecl ||= $decl->get_content_decl; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$mdecl ||= $decl->get_content_decl
MC/DC0%0/2
$mdecl ||= $decl->get_content_decl
$mdecl
$decl->get_content_decl
Truth table33%1/3
A ||= B
A= $mdeclB= $decl->get_content_decl
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | 47 | my $mpath = $mdecl->get_decl_path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | 47 | ▶ | $mpath =~ s/^!// if $mpath; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | # print "mapping $path -> $mpath ... $handlers{$mpath}\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | 47 | $handlers{$path} = $handlers{$mpath}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | 15 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | 9 | ▶ | sub _nl { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_nl: not called CC=1 SCAR=3.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | 0 | my ($str)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | 0 | my $i=0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | 0 | return join "\n", map sprintf("%4d\t",$i++).$_, split /\n/, $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 9 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||