| 1 | # Copyrights 2006-2024 by [Mark Overmeer <markov@cpan.org>]. | ||||||||||||||||||||||||||||
| 2 | # For other contributors see ChangeLog. | ||||||||||||||||||||||||||||
| 3 | # See the manual pages for details on the licensing terms. | ||||||||||||||||||||||||||||
| 4 | # Pod stripped from pm file by OODoc 2.03. | ||||||||||||||||||||||||||||
| 5 | # This code is part of distribution XML-Compile. Meta-POD processed with | ||||||||||||||||||||||||||||
| 6 | # OODoc into POD and HTML manual-pages. See README.md | ||||||||||||||||||||||||||||
| 7 | # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | package XML::Compile::Schema::Instance;{ | ||||||||||||||||||||||||||||
| 10 | 50 | our $VERSION = '1.64'; | |||||||||||||||||||||||||||
| 11 | } | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 50 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 50 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 50 | ▶ | use Log::Report 'xml-compile'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 50 | ▶ | use XML::Compile::Schema::Specs; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 50 | ▶ | use XML::Compile::Util qw/pack_type unpack_type/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 50 | ▶ | use Scalar::Util qw/weaken/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 50 | my @defkinds = qw/element attribute simpleType complexType | |||||||||||||||||||||||||||
| 23 | attributeGroup group/; | ||||||||||||||||||||||||||||
| 24 | 50 | my %defkinds = map +($_ => 1), @defkinds; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | sub new($@) | ||||||||||||||||||||||||||||
| 28 | 58 | ▶ | { my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 29 | 58 | (bless {}, $class)->init( {top => @_} ); | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | sub init($) | ||||||||||||||||||||||||||||
| 33 | 58 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=4 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 34 | 58 | my $top = $args->{top}; | |||||||||||||||||||||||||||
| 35 | 58 | ▶ | defined $top && $top->isa('XML::LibXML::Node') | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $top and $top->isa("XML::LibXML::Node")
MC/DC0%0/2
defined $top and $top->isa("XML::LibXML::Node")
defined $top
$top->isa("XML::LibXML::Node")
Truth table33%1/3
A and B
A= defined $topB= $top->isa("XML::LibXML::Node")
| |||||||||||||||||||||||||||||
| 36 | or panic "instance is based on XML node"; | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 58 | $self->{filename} = $args->{filename}; | |||||||||||||||||||||||||||
| 39 | 58 | $self->{source} = $args->{source}; | |||||||||||||||||||||||||||
| 40 | 58 | $self->{$_} = {} for @defkinds, 'sgs', 'import'; | |||||||||||||||||||||||||||
| 41 | 58 | $self->{include} = []; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 58 | $self->_collectTypes($top, $args); | |||||||||||||||||||||||||||
| 44 | 58 | $self; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 1 | ▶ | sub targetNamespace { shift->{tns} } | ||||||||||||||||||||||||||
|
Subroutine
targetNamespace: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 49 | 0 | ▶ | sub schemaNamespace { shift->{xsd} } | ||||||||||||||||||||||||||
|
Subroutine
schemaNamespace: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | sub schemaInstance { shift->{xsi} } | ||||||||||||||||||||||||||
|
Subroutine
schemaInstance: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 51 | 1 | ▶ | sub source { shift->{source} } | ||||||||||||||||||||||||||
|
Subroutine
source: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 52 | 1 | ▶ | sub filename { shift->{filename} } | ||||||||||||||||||||||||||
|
Subroutine
filename: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 53 | 0 | ▶ | sub schema { shift->{schema} } | ||||||||||||||||||||||||||
|
Subroutine
schema: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 58 | ▶ | sub tnses() {keys %{shift->{tnses}}} | ||||||||||||||||||||||||||
|
Subroutine
tnses: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 63 | ▶ | sub sgs() { shift->{sgs} } | ||||||||||||||||||||||||||
|
Subroutine
sgs: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 0 | ▶ | sub type($) { $_[0]->{types}{$_[1]} } | ||||||||||||||||||||||||||
|
Subroutine
type: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | ▶ | sub element($) { $_[0]->{element}{$_[1]} } | ||||||||||||||||||||||||||
|
Subroutine
element: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 5 | ▶ | sub elements() { keys %{shift->{element}} } | ||||||||||||||||||||||||||
|
Subroutine
elements: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 69 | 1 | ▶ | sub attributes() { keys %{shift->{attributes}} } | ||||||||||||||||||||||||||
|
Subroutine
attributes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 70 | 1 | ▶ | sub attributeGroups() { keys %{shift->{attributeGroup}} } | ||||||||||||||||||||||||||
|
Subroutine
attributeGroups: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 71 | 1 | ▶ | sub groups() { keys %{shift->{group}} } | ||||||||||||||||||||||||||
|
Subroutine
groups: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 72 | 5 | ▶ | sub simpleTypes() { keys %{shift->{simpleType}} } | ||||||||||||||||||||||||||
|
Subroutine
simpleTypes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 73 | 7 | ▶ | sub complexTypes() { keys %{shift->{complexType}} } | ||||||||||||||||||||||||||
|
Subroutine
complexTypes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 4 | ▶ | sub types() { ($_[0]->simpleTypes, $_[0]->complexTypes) } | ||||||||||||||||||||||||||
|
Subroutine
types: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 50 | my %skip_toplevel = map +($_ => 1), qw/annotation notation redefine/; | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | sub _collectTypes($$) | ||||||||||||||||||||||||||||
| 82 | 58 | ▶ | { my ($self, $schema, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_collectTypes: called CC=27 SCAR=36.2
| |||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 58 | ▶ | $schema->localName eq 'schema' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | or panic "requires schema element"; | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 58 | ▶ | my $xsd = $self->{xsd} = $schema->namespaceURI || '<none>'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$schema->namespaceURI || '<none>'
MC/DC0%0/1
$schema->namespaceURI || '<none>'
$schema->namespaceURI
Truth table50%1/2
A
A= $schema->namespaceURI
| |||||||||||||||||||||||||||||
| 88 | 58 | ▶ | if(length $xsd) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | { my $def = $self->{def} | ||||||||||||||||||||||||||||
| 90 | 58 | ▶ | = XML::Compile::Schema::Specs->predefinedSchema($xsd) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | or error __x"schema namespace `{namespace}' not (yet) supported" | ||||||||||||||||||||||||||||
| 92 | , namespace => $xsd; | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 58 | $self->{xsi} = $def->{uri_xsi}; | |||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 58 | my $tns; | |||||||||||||||||||||||||||
| 98 | 58 | ▶ | if($tns = $args->{target_namespace}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | 1 | { $schema->removeAttribute('targetNamespace'); | |||||||||||||||||||||||||||
| 100 | 1 | $schema->setAttribute(targetNamespace => $tns); | |||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | else | ||||||||||||||||||||||||||||
| 103 | 57 | ▶ | { $tns = $schema->getAttribute('targetNamespace') || ''; | ||||||||||||||||||||||||||
|
Condition100%2/2
$schema->getAttribute('targetNamespace') || ''
MC/DC100%1/1
$schema->getAttribute('targetNamespace') || ''
$schema->getAttribute('targetNamespace')
Truth table100%2/2
A
A= $schema->getAttribute('targetNamespace')
| |||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | 58 | $self->{tns} = $tns; | |||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | $self->{efd} = $args->{element_form_default} | ||||||||||||||||||||||||||||
| 108 | 58 | ▶ | || $schema->getAttribute('elementFormDefault') | ||||||||||||||||||||||||||
|
Condition100%5/5
$args->{'element_form_default'} || $schema->getAttribute('elementFormDefault') || 'unqualified'
$args->{"element_form_default"} or $schema->getAttribute("elementFormDefault")
MC/DC100%2/2
$args->{'element_form_default'} || $schema->getAttribute('elementFormDefault') || 'unqualified'
$args->{"element_form_default"}
$schema->getAttribute("elementFormDefault")
Truth table100%3/3
A or B
A= $args->{"element_form_default"}B= $schema->getAttribute("elementFormDefault")
| |||||||||||||||||||||||||||||
| 109 | || 'unqualified'; | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | $self->{afd} = $args->{attribute_form_default} | ||||||||||||||||||||||||||||
| 112 | 58 | ▶ | || $schema->getAttribute('attributeFormDefault') | ||||||||||||||||||||||||||
|
Condition80%4/5
$args->{'attribute_form_default'} || $schema->getAttribute('attributeFormDefault') || 'unqualified'
$args->{"attribute_form_default"} or $schema->getAttribute("attributeFormDefault")
MC/DC50%1/2
$args->{'attribute_form_default'} || $schema->getAttribute('attributeFormDefault') || 'unqualified'
$args->{"attribute_form_default"}
$schema->getAttribute("attributeFormDefault")
Truth table66%2/3
A or B
A= $args->{"attribute_form_default"}B= $schema->getAttribute("attributeFormDefault")
| |||||||||||||||||||||||||||||
| 113 | || 'unqualified'; | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 58 | $self->{tnses} = {}; # added when used | |||||||||||||||||||||||||||
| 116 | 58 | $self->{types} = {}; | |||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 58 | $self->{schema} = $schema; | |||||||||||||||||||||||||||
| 119 | 58 | weaken($self->{schema}); | |||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | NODE: | ||||||||||||||||||||||||||||
| 122 | 58 | foreach my $node ($schema->childNodes) | |||||||||||||||||||||||||||
| 123 | 1020 | ▶ | { next unless $node->isa('XML::LibXML::Element'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 124 | 448 | my $local = $node->localName; | |||||||||||||||||||||||||||
| 125 | 448 | ▶ | my $myns = $node->namespaceURI || ''; | ||||||||||||||||||||||||||
|
Condition50%1/2
$node->namespaceURI || ''
MC/DC0%0/1
$node->namespaceURI || ''
$node->namespaceURI
Truth table50%1/2
A
A= $node->namespaceURI
| |||||||||||||||||||||||||||||
| 126 | 448 | ▶ | $myns eq $xsd | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$myns || '<none>'
MC/DC0%0/1
$myns || '<none>'
$myns
Truth table0%0/2
A
A= $myns
| |||||||||||||||||||||||||||||
| 127 | or error __x"schema element `{name}' not in schema namespace {ns} but {other}" | ||||||||||||||||||||||||||||
| 128 | , name => $local, ns => $xsd, other => ($myns || '<none>'); | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | next | ||||||||||||||||||||||||||||
| 131 | 448 | ▶ | if $skip_toplevel{$local}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 438 | ▶ | if($local eq 'import') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 134 | 1 | ▶ | { my $namespace = $node->getAttribute('namespace') || $tns; | ||||||||||||||||||||||||||
|
Condition33%1/3
$node->getAttribute('namespace') || $tns
MC/DC0%0/2
$node->getAttribute('namespace') || $tns
$node->getAttribute('namespace')
$tns
Truth table33%1/3
A || B
A= $node->getAttribute('namespace')B= $tns
| |||||||||||||||||||||||||||||
| 135 | 1 | ▶ | my $location = $node->getAttribute('schemaLocation') || ''; | ||||||||||||||||||||||||||
|
Condition50%1/2
$node->getAttribute('schemaLocation') || ''
MC/DC0%0/1
$node->getAttribute('schemaLocation') || ''
$node->getAttribute('schemaLocation')
Truth table50%1/2
A
A= $node->getAttribute('schemaLocation')
| |||||||||||||||||||||||||||||
| 136 | 1 | push @{$self->{import}{$namespace}}, $location; | |||||||||||||||||||||||||||
| 137 | 1 | next NODE; | |||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | 437 | ▶ | if($local eq 'include') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 141 | 0 | ▶ | { my $location = $node->getAttribute('schemaLocation') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | or error __x"include requires schemaLocation attribute at line {linenr}" | ||||||||||||||||||||||||||||
| 143 | , linenr => $node->line_number; | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | 0 | push @{$self->{include}}, $location; | |||||||||||||||||||||||||||
| 146 | 0 | next NODE; | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 437 | ▶ | unless($defkinds{$local}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 150 | 0 | { mistake __x"ignoring unknown definition class {class}" | |||||||||||||||||||||||||||
| 151 | , class => $local; | ||||||||||||||||||||||||||||
| 152 | 0 | next; | |||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | 437 | ▶ | my $name = $node->getAttribute('name') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 156 | or error __x"schema component {local} without name at line {linenr}" | ||||||||||||||||||||||||||||
| 157 | , local => $local, linenr => $node->line_number; | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | 437 | ▶ | my $tns = $node->getAttribute('targetNamespace') || $tns; | ||||||||||||||||||||||||||
|
Condition66%2/3
$node->getAttribute('targetNamespace') || $tns
MC/DC50%1/2
$node->getAttribute('targetNamespace') || $tns
$node->getAttribute('targetNamespace')
$tns
Truth table66%2/3
A || B
A= $node->getAttribute('targetNamespace')B= $tns
| |||||||||||||||||||||||||||||
| 160 | 437 | my $type = pack_type $tns, $name; | |||||||||||||||||||||||||||
| 161 | 437 | $self->{tnses}{$tns}++; | |||||||||||||||||||||||||||
| 162 | 437 | $self->{$local}{$type} = $node; | |||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 437 | ▶ | if(my $sg = $node->getAttribute('substitutionGroup')) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 165 | 5 | ▶ | { my ($prefix, $l) = $sg =~ m/:/ ? split(/:/, $sg, 2) : ('',$sg); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 166 | 5 | my $base = pack_type $node->lookupNamespaceURI($prefix), $l; | |||||||||||||||||||||||||||
| 167 | 5 | push @{$self->{sgs}{$base}}, $type; | |||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 58 | $self; | |||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 0 | ▶ | sub includeLocations() { @{shift->{include}} } | ||||||||||||||||||||||||||
|
Subroutine
includeLocations: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 0 | ▶ | sub imports() { keys %{shift->{import}} } | ||||||||||||||||||||||||||
|
Subroutine
imports: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | sub importLocations($) | ||||||||||||||||||||||||||||
| 182 | 0 | ▶ | { my $locs = $_[0]->{import}{$_[1]}; | ||||||||||||||||||||||||||
|
Subroutine
importLocations: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 183 | 0 | ▶ | $locs ? @$locs : (); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | sub printIndex(;$) | ||||||||||||||||||||||||||||
| 188 | 1 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
printIndex: called CC=15 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 189 | 1 | ▶ | my $fh = @_ % 2 ? shift : select; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 190 | 1 | my %args = @_; | |||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | 1 | $fh->print("namespace: ", $self->targetNamespace, "\n"); | |||||||||||||||||||||||||||
| 193 | 1 | ▶ | if(defined(my $filename = $self->filename)) | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 194 | 0 | { $fh->print(" filename: $filename\n"); | |||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | elsif(defined(my $source = $self->source)) | ||||||||||||||||||||||||||||
| 197 | 1 | { $fh->print(" source: $source\n"); | |||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | my @kinds | ||||||||||||||||||||||||||||
| 201 | = ! defined $args{kinds} ? @defkinds | ||||||||||||||||||||||||||||
| 202 | 0 | : ref $args{kinds} eq 'ARRAY' ? @{$args{kinds}} | |||||||||||||||||||||||||||
| 203 | 1 | ▶ | : $args{kinds}; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | my $list_abstract | ||||||||||||||||||||||||||||
| 206 | 1 | ▶ | = exists $args{list_abstract} ? $args{list_abstract} : 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 1 | foreach my $kind (@kinds) | |||||||||||||||||||||||||||
| 209 | 6 | { my $table = $self->{$kind}; | |||||||||||||||||||||||||||
| 210 | 6 | ▶ | keys %$table or next; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 211 | 5 | ▶ | $fh->print(" definitions of ${kind}s:\n") if @kinds > 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | 5 | foreach (sort keys %$table) | |||||||||||||||||||||||||||
| 214 | 145 | { my $info = $self->find($kind, $_); | |||||||||||||||||||||||||||
| 215 | 145 | my ($ns, $name) = unpack_type $_; | |||||||||||||||||||||||||||
| 216 | 145 | ▶ | next if $info->{abstract} && ! $list_abstract; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$info->{"abstract"} and not $list_abstract
MC/DC0%0/2
$info->{"abstract"} and not $list_abstract
$info->{"abstract"}
not $list_abstract
Truth table66%2/3
A and not(B)
A= $info->{"abstract"}B= not $list_abstract
| |||||||||||||||||||||||||||||
| 217 | 145 | ▶ | my $abstract = $info->{abstract} ? ' [abstract]' : ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 218 | 145 | ▶ | my $final = $info->{final} ? ' [final]' : ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 219 | 145 | $fh->print(" $name$abstract$final\n"); | |||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | sub find($$) | ||||||||||||||||||||||||||||
| 226 | 2737 | ▶ | { my ($self, $kind, $full) = @_; | ||||||||||||||||||||||||||
|
Subroutine
find: called CC=11 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 227 | 2737 | ▶ | my $node = $self->{$kind}{$full} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 228 | or return; | ||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | 2466 | ▶ | return $node # translation of XML node into info is cached | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 231 | if ref $node eq 'HASH'; | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | 433 | my %info = (type => $kind, node => $node, full => $full); | |||||||||||||||||||||||||||
| 234 | 433 | @info{'ns', 'name'} = unpack_type $full; | |||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | 433 | $self->{$kind}{$full} = \%info; | |||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | 433 | ▶ | my $abstract = $node->getAttribute('abstract') || ''; | ||||||||||||||||||||||||||
|
Condition100%2/2
$node->getAttribute('abstract') || ''
MC/DC100%1/1
$node->getAttribute('abstract') || ''
$node->getAttribute('abstract')
Truth table100%2/2
A
A= $node->getAttribute('abstract')
| |||||||||||||||||||||||||||||
| 239 | 433 | ▶ | $info{abstract} = $abstract eq 'true' || $abstract eq '1'; | ||||||||||||||||||||||||||
|
Condition66%2/3
$abstract eq 'true' || $abstract eq '1'
MC/DC50%1/2
$abstract eq 'true' || $abstract eq '1'
$abstract eq 'true'
$abstract eq '1'
Truth table66%2/3
A || B
A= $abstract eq 'true'B= $abstract eq '1'
| |||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | 433 | ▶ | my $final = $node->getAttribute('final') || ''; | ||||||||||||||||||||||||||
|
Condition50%1/2
$node->getAttribute('final') || ''
MC/DC0%0/1
$node->getAttribute('final') || ''
$node->getAttribute('final')
Truth table50%1/2
A
A= $node->getAttribute('final')
| |||||||||||||||||||||||||||||
| 242 | 433 | ▶ | $info{final} = $final eq 'true' || $final eq '1'; | ||||||||||||||||||||||||||
|
Condition33%1/3
$final eq 'true' || $final eq '1'
MC/DC0%0/2
$final eq 'true' || $final eq '1'
$final eq 'true'
$final eq '1'
Truth table33%1/3
A || B
A= $final eq 'true'B= $final eq '1'
| |||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | 433 | my $local = $node->localName; | |||||||||||||||||||||||||||
| 245 | 433 | ▶ | if($local eq 'element') { $info{efd} = $node->getAttribute('form') } | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 246 | 4 | elsif($local eq 'attribute'){ $info{afd} = $node->getAttribute('form') } | |||||||||||||||||||||||||||
| 247 | 433 | ▶ | $info{efd} ||= $self->{efd}; # both needed for nsContext | ||||||||||||||||||||||||||
|
Condition33%1/3
$info{"efd"} ||= $self->{"efd"}
MC/DC0%0/2
$info{"efd"} ||= $self->{"efd"}
$info{"efd"}
$self->{"efd"}
Truth table33%1/3
A ||= B
A= $info{"efd"}B= $self->{"efd"}
| |||||||||||||||||||||||||||||
| 248 | 433 | ▶ | $info{afd} ||= $self->{afd}; | ||||||||||||||||||||||||||
|
Condition33%1/3
$info{"afd"} ||= $self->{"afd"}
MC/DC0%0/2
$info{"afd"} ||= $self->{"afd"}
$info{"afd"}
$self->{"afd"}
Truth table33%1/3
A ||= B
A= $info{"afd"}B= $self->{"afd"}
| |||||||||||||||||||||||||||||
| 249 | 433 | \%info; | |||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 50 | 1; | |||||||||||||||||||||||||||