| 1 | #============================================================= -*-perl-*- | ||||||||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||||||||
| 3 | # XML::Schema::Instance | ||||||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||||||
| 5 | # DESCRIPTION | ||||||||||||||||||||||||||||||||||||||
| 6 | # Module implementing an object for representing instance documents. | ||||||||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||||||||
| 8 | # AUTHOR | ||||||||||||||||||||||||||||||||||||||
| 9 | # Andy Wardley <abw@kfs.org> | ||||||||||||||||||||||||||||||||||||||
| 10 | # | ||||||||||||||||||||||||||||||||||||||
| 11 | # COPYRIGHT | ||||||||||||||||||||||||||||||||||||||
| 12 | # Copyright (C) 2001 Canon Research Centre Europe Ltd. | ||||||||||||||||||||||||||||||||||||||
| 13 | # All Rights Reserved. | ||||||||||||||||||||||||||||||||||||||
| 14 | # | ||||||||||||||||||||||||||||||||||||||
| 15 | # This module is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||||||||||||
| 16 | # modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||
| 17 | # | ||||||||||||||||||||||||||||||||||||||
| 18 | # REVISION | ||||||||||||||||||||||||||||||||||||||
| 19 | # $Id: Instance.pm,v 1.2 2001/12/20 13:26:27 abw Exp $ | ||||||||||||||||||||||||||||||||||||||
| 20 | # | ||||||||||||||||||||||||||||||||||||||
| 21 | #======================================================================== | ||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||
| 23 | package XML::Schema::Instance; | ||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||
| 25 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 26 | 2 | ▶ | use XML::Schema; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 27 | 2 | ▶ | use vars qw( $VERSION $DEBUG $ERROR $ETYPE @MANDATORY ); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 28 | 2 | ▶ | use base qw( XML::Schema::Base ); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||
| 30 | 2 | $VERSION = sprintf("%d.%02d", q$Revision: 1.2 $ =~ /(\d+)\.(\d+)/); | |||||||||||||||||||||||||||||||||||||
| 31 | 2 | ▶ | $DEBUG = 0 unless defined $DEBUG; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 32 | 2 | $ERROR = ''; | |||||||||||||||||||||||||||||||||||||
| 33 | 2 | $ETYPE = 'Instance'; | |||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||
| 35 | 2 | @MANDATORY = qw( schema ); | |||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||
| 38 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 39 | # init(\%config) | ||||||||||||||||||||||||||||||||||||||
| 40 | # | ||||||||||||||||||||||||||||||||||||||
| 41 | # Initialiser method called by the base class new() method. | ||||||||||||||||||||||||||||||||||||||
| 42 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||
| 44 | 3 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=4 SCAR=14.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 45 | 3 | my ($self, $config) = @_; | |||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||
| 47 | 3 | ▶ | $self->TRACE("config => ", $config) if $DEBUG; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||
| 49 | 3 | my ($mand) = @{ $self->_baseargs( qw( @MANDATORY ) ) }; | |||||||||||||||||||||||||||||||||||||
| 50 | 3 | ▶ | $self->_mandatory($mand, $config) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 51 | || return; | ||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||
| 53 | 3 | $self->{ _ID } = { }; | |||||||||||||||||||||||||||||||||||||
| 54 | 3 | $self->{ _SCHEMA_STACK } = [ ]; | |||||||||||||||||||||||||||||||||||||
| 55 | 3 | ▶ | $self->{ _FACTORY } = $config->{ FACTORY } || $XML::Schema::FACTORY; | ||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$config->{'FACTORY'} || $XML::Schema::FACTORY
MC/DC0%0/2
$config->{'FACTORY'} || $XML::Schema::FACTORY
$config->{'FACTORY'}
$XML::Schema::FACTORY
Truth table33%1/3
A || B
A= $config->{'FACTORY'}B= $XML::Schema::FACTORY
| |||||||||||||||||||||||||||||||||||||||
| 56 | 3 | $self->{ content } = [ ]; | |||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||
| 59 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||
| 63 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 64 | # id($id, $value) | ||||||||||||||||||||||||||||||||||||||
| 65 | # | ||||||||||||||||||||||||||||||||||||||
| 66 | # Stores the specified value as an ID within the instance document, | ||||||||||||||||||||||||||||||||||||||
| 67 | # indexed by $id. | ||||||||||||||||||||||||||||||||||||||
| 68 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||
| 70 | 2 | ▶ | sub id { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
id: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 71 | 2 | my ($self, $id, $ref) = @_; | |||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||
| 73 | 2 | ▶ | $self->TRACE("ID: ", $id, " => ", $ref) if $DEBUG; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||
| 75 | 2 | ▶ | return $self->error("no value defined, did you mean to call idref()?") | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 76 | unless defined $ref; | ||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||
| 78 | return $self->error("an element is already defined with id '$id'") | ||||||||||||||||||||||||||||||||||||||
| 79 | 1 | ▶ | if defined $self->{ _ID }->{ $id }; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||
| 81 | 1 | $self->{ _ID }->{ $id } = $ref; | |||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||
| 83 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||
| 87 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 88 | # idref($id) | ||||||||||||||||||||||||||||||||||||||
| 89 | # | ||||||||||||||||||||||||||||||||||||||
| 90 | # Returns the value of an ID previously specified via a call to id() | ||||||||||||||||||||||||||||||||||||||
| 91 | # or undef if the ID isn't defined, with an appropriate error message | ||||||||||||||||||||||||||||||||||||||
| 92 | # being set. | ||||||||||||||||||||||||||||||||||||||
| 93 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||
| 95 | 2 | ▶ | sub idref { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
idref: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 96 | 2 | my ($self, $idref) = @_; | |||||||||||||||||||||||||||||||||||||
| 97 | 2 | ▶ | $self->TRACE("IDREF: ", $idref) if $DEBUG; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 98 | 2 | ▶ | return $self->{ _ID }->{ $idref } | ||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{'_ID'}{$idref} || $self->error("no such id: $idref")
MC/DC50%1/2
$self->{'_ID'}{$idref} || $self->error("no such id: $idref")
$self->{'_ID'}{$idref}
$self->error("no such id: $idref")
Truth table66%2/3
A || B
A= $self->{'_ID'}{$idref}B= $self->error("no such id: $idref")
| |||||||||||||||||||||||||||||||||||||||
| 99 | || $self->error("no such id: $idref"); | ||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||
| 102 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 103 | # TODO: | ||||||||||||||||||||||||||||||||||||||
| 104 | # also need to implement entity and notation handlers... | ||||||||||||||||||||||||||||||||||||||
| 105 | # (see comments in XML::Schema::Type::Builtin header) | ||||||||||||||||||||||||||||||||||||||
| 106 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||
| 109 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 110 | # schema_handler(...) | ||||||||||||||||||||||||||||||||||||||
| 111 | # | ||||||||||||||||||||||||||||||||||||||
| 112 | # Return a parser handler for parsing the top-level of the schema. | ||||||||||||||||||||||||||||||||||||||
| 113 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | sub schema_handler { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
schema_handler: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | $self->TRACE() if $DEBUG; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 118 | 0 | my $schema = $self->{ schema }; | |||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | return $schema->handler(@_) | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$schema->handler(@_) || $self->error($schema->error)
MC/DC0%0/2
$schema->handler(@_) || $self->error($schema->error)
$schema->handler(@_)
$self->error($schema->error)
Truth table0%0/3
A || B
A= $schema->handler(@_)B= $self->error($schema->error)
| |||||||||||||||||||||||||||||||||||||||
| 120 | || $self->error($schema->error()); | ||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||
| 123 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 124 | # simple_handler(...) | ||||||||||||||||||||||||||||||||||||||
| 125 | # | ||||||||||||||||||||||||||||||||||||||
| 126 | # Return a parser handler for parsing a simple element. | ||||||||||||||||||||||||||||||||||||||
| 127 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||
| 129 | 1 | ▶ | sub simple_handler { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
simple_handler: called CC=10 SCAR=39.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 130 | 1 | my ($self, $type, $element) = @_; | |||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||
| 132 | 1 | ▶ | if ($DEBUG) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | my $tid = ref($type) && UNIVERSAL::can($type, 'ID') | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
ref $type and UNIVERSAL::can($type, "ID")
$type or "<undef>"
MC/DC0%0/2
ref $type and UNIVERSAL::can($type, "ID")
ref $type
UNIVERSAL::can($type, "ID")
MC/DC0%0/1
$type or "<undef>"
$type
Truth table0%0/3
A and B
A= ref $typeB= UNIVERSAL::can($type, "ID")
Truth table0%0/2
A
A= $type
| |||||||||||||||||||||||||||||||||||||||
| 134 | ? $type->ID : ($type || '<undef>'); | ||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | my $eid = ref($element) && UNIVERSAL::can($element, 'ID') | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
ref $element and UNIVERSAL::can($element, "ID")
$element or "<undef>"
MC/DC0%0/2
ref $element and UNIVERSAL::can($element, "ID")
ref $element
UNIVERSAL::can($element, "ID")
MC/DC0%0/1
$element or "<undef>"
$element
Truth table0%0/3
A and B
A= ref $elementB= UNIVERSAL::can($element, "ID")
Truth table0%0/2
A
A= $element
| |||||||||||||||||||||||||||||||||||||||
| 136 | ? $element->ID : ($element || '<undef>'); | ||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $self->TRACE("type => $tid, element => $eid"); | |||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||
| 140 | my $factory = $self->{ _FACTORY } | ||||||||||||||||||||||||||||||||||||||
| 141 | 1 | ▶ | || return $self->error("no factory defined"); | ||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'_FACTORY'} || (return $self->error('no factory defined'))
MC/DC0%0/1
$self->{'_FACTORY'} || (return $self->error('no factory defined'))
$self->{'_FACTORY'}
Truth table50%1/2
A
A= $self->{'_FACTORY'}
| |||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||
| 143 | 1 | ▶ | return $factory->create( simple_handler => { | ||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$factory->create('simple_handler', {'type', $type, 'element', $element}) || $self->error($factory->error)
MC/DC0%0/2
$factory->create('simple_handler', {'type', $type, 'element', $element}) || $self->error($factory->error)
$factory->create('simple_handler', {'type', $type, 'element', $element})
$self->error($factory->error)
Truth table33%1/3
A || B
A= $factory->create('simple_handler', {'type', $type, 'element', $element})B= $self->error($factory->error)
| |||||||||||||||||||||||||||||||||||||||
| 144 | type => $type, | ||||||||||||||||||||||||||||||||||||||
| 145 | element => $element, | ||||||||||||||||||||||||||||||||||||||
| 146 | }) || $self->error($factory->error()); | ||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||
| 150 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 151 | # complex_handler($type, $element) | ||||||||||||||||||||||||||||||||||||||
| 152 | # | ||||||||||||||||||||||||||||||||||||||
| 153 | # Return a parser handler for parsing a complex element. | ||||||||||||||||||||||||||||||||||||||
| 154 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | sub complex_handler { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
complex_handler: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 157 | 0 | my ($self, $type, $element) = @_; | |||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | $self->TRACE("type => ", $type->ID, ", element => ", $element->ID) if $DEBUG; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||
| 161 | my $factory = $self->{ _FACTORY } | ||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | || return $self->error("no factory defined"); | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'_FACTORY'} || (return $self->error('no factory defined'))
MC/DC0%0/1
$self->{'_FACTORY'} || (return $self->error('no factory defined'))
$self->{'_FACTORY'}
Truth table0%0/2
A
A= $self->{'_FACTORY'}
| |||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | return $factory->create( complex_handler => { | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$factory->create('complex_handler', {'type', $type, 'element', $element}) || $self->error($factory->error)
MC/DC0%0/2
$factory->create('complex_handler', {'type', $type, 'element', $element}) || $self->error($factory->error)
$factory->create('complex_handler', {'type', $type, 'element', $element})
$self->error($factory->error)
Truth table0%0/3
A || B
A= $factory->create('complex_handler', {'type', $type, 'element', $element})B= $self->error($factory->error)
| |||||||||||||||||||||||||||||||||||||||
| 165 | type => $type, | ||||||||||||||||||||||||||||||||||||||
| 166 | element => $element, | ||||||||||||||||||||||||||||||||||||||
| 167 | }) || $self->error($factory->error()); | ||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||
| 171 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 172 | # schema_push($handler) | ||||||||||||||||||||||||||||||||||||||
| 173 | # | ||||||||||||||||||||||||||||||||||||||
| 174 | # Push a parser handler onto the top of the internal schema stack, | ||||||||||||||||||||||||||||||||||||||
| 175 | # making it the target for all subsequent parse events until masked | ||||||||||||||||||||||||||||||||||||||
| 176 | # by another handler pushed on top of it, or popped off the stack | ||||||||||||||||||||||||||||||||||||||
| 177 | # by a call to schema_pop() (e.g. at the element end tag) | ||||||||||||||||||||||||||||||||||||||
| 178 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | sub schema_push { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
schema_push: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 181 | 0 | my ($self, $node) = @_; | |||||||||||||||||||||||||||||||||||||
| 182 | 0 | push(@{ $self->{ _SCHEMA_STACK } }, $node); | |||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||
| 186 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 187 | # schema_pop() | ||||||||||||||||||||||||||||||||||||||
| 188 | # | ||||||||||||||||||||||||||||||||||||||
| 189 | # Pop the top parser handler from the internal schema stack and return it. | ||||||||||||||||||||||||||||||||||||||
| 190 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | sub schema_pop { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
schema_pop: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 193 | 0 | pop(@{ $_[0]->{ _SCHEMA_STACK } }); | |||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||
| 197 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 198 | # schema_top() | ||||||||||||||||||||||||||||||||||||||
| 199 | # | ||||||||||||||||||||||||||||||||||||||
| 200 | # Return the top item on the internal schema stack. | ||||||||||||||||||||||||||||||||||||||
| 201 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | sub schema_top { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
schema_top: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 204 | 0 | $_[0]->{ _SCHEMA_STACK }->[-1]; | |||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||
| 208 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 209 | # expat_handlers() | ||||||||||||||||||||||||||||||||||||||
| 210 | # | ||||||||||||||||||||||||||||||||||||||
| 211 | # Returns a hash array for configuring XML::Parser to correctly use | ||||||||||||||||||||||||||||||||||||||
| 212 | # this schema instance as a recipient of parse events. May return a | ||||||||||||||||||||||||||||||||||||||
| 213 | # hash ref as { Init => ..., Start => ..., etc. } in which case the | ||||||||||||||||||||||||||||||||||||||
| 214 | # instance class is automatically used by the caller as the 'Style' | ||||||||||||||||||||||||||||||||||||||
| 215 | # value leading to this class receiving parse events. Alternately, a | ||||||||||||||||||||||||||||||||||||||
| 216 | # hash of the form { Style => 'MyClass', Handlers => { Start => ... } } | ||||||||||||||||||||||||||||||||||||||
| 217 | # may be passed to explicitly denote the intended recipient. | ||||||||||||||||||||||||||||||||||||||
| 218 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | sub expat_handlers { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
expat_handlers: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 221 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||
| 222 | 0 | my $schema = $self->{ schema }; | |||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | my $handler = $self->schema_handler() | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->schema_handler || (return)
MC/DC0%0/1
$self->schema_handler || (return)
$self->schema_handler
Truth table0%0/2
A
A= $self->schema_handler
| |||||||||||||||||||||||||||||||||||||||
| 225 | || return; | ||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | $handler->start_element($self) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 228 | || return $self->error($handler->error()); | ||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||
| 230 | return { | ||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | Init => sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | $self->DEBUG($self->ID, "->[Init] $self\n") if $DEBUG; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 233 | 0 | my $expat = shift; | |||||||||||||||||||||||||||||||||||||
| 234 | 0 | $expat->{ _SCHEMA_INSTANCE } = $self; | |||||||||||||||||||||||||||||||||||||
| 235 | 0 | $expat->{ _SCHEMA_TEXT } = ''; | |||||||||||||||||||||||||||||||||||||
| 236 | 0 | $self->{ _SCHEMA_STACK } = [ $handler ]; | |||||||||||||||||||||||||||||||||||||
| 237 | 0 | $self->{ _SCHEMA_EXPAT } = $expat; | |||||||||||||||||||||||||||||||||||||
| 238 | }, | ||||||||||||||||||||||||||||||||||||||
| 239 | 0 | }; | |||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||
| 243 | #======================================================================== | ||||||||||||||||||||||||||||||||||||||
| 244 | # XML::Parser::Expat callbacks | ||||||||||||||||||||||||||||||||||||||
| 245 | #======================================================================== | ||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||
| 247 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 248 | # Start($expat, $name, %attr) | ||||||||||||||||||||||||||||||||||||||
| 249 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | sub Start { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
Start: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 252 | 0 | my ($expat, $name, %attr) = @_; | |||||||||||||||||||||||||||||||||||||
| 253 | 0 | my $self = $expat->{ _SCHEMA_INSTANCE }; | |||||||||||||||||||||||||||||||||||||
| 254 | 0 | my $stack = $self->{ _SCHEMA_STACK }; | |||||||||||||||||||||||||||||||||||||
| 255 | 0 | my $parent = $stack->[-1]; | |||||||||||||||||||||||||||||||||||||
| 256 | 0 | my $text; | |||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | if ($DEBUG) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 259 | 0 | my $attr = join(' ', map { "$_=\"$attr{$_}\"" } keys %attr); | |||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | $attr = " $attr" if $attr; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 261 | 0 | $self->TRACE("[Start] <$name$attr>"); | |||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||
| 264 | # flush any character content | ||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | if (length ($text = $expat->{ _SCHEMA_TEXT })) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | $self->TRACE("flushing text: '", $self->_text_snippet($text), "'") if $DEBUG; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | $parent->text($self, $text) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 268 | || $self->parse_error($parent->error()); | ||||||||||||||||||||||||||||||||||||||
| 269 | 0 | $expat->{ _SCHEMA_TEXT } = ''; | |||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | my $child = $parent->start_child($self, $name, \%attr) | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$parent->start_child($self, $name, \%attr) || (return $self->parse_error($parent->error))
MC/DC0%0/1
$parent->start_child($self, $name, \%attr) || (return $self->parse_error($parent->error))
$parent->start_child($self, $name, \%attr)
Truth table0%0/2
A
A= $parent->start_child($self, $name, \%attr)
| |||||||||||||||||||||||||||||||||||||||
| 273 | || return $self->parse_error($parent->error()); | ||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||
| 275 | my $handler = $child->{ handler } | ||||||||||||||||||||||||||||||||||||||
| 276 | || return $self->parse_error($child->{ error } || | ||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | "no child handler defined"); | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
$child->{'handler'} || (return $self->parse_error($child->{'error'} || 'no child handler defined'))
$child->{'error'} || 'no child handler defined'
MC/DC0%0/1
$child->{'handler'} || (return $self->parse_error($child->{'error'} || 'no child handler defined'))
$child->{'handler'}
MC/DC0%0/1
$child->{'error'} || 'no child handler defined'
$child->{'error'}
Truth table0%0/2
A
A= $child->{'handler'}
Truth table0%0/2
A
A= $child->{'error'}
| |||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | $handler->start_element($self, @$child{ qw( name attributes ) }) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 280 | || $self->parse_error($handler->error()); | ||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||
| 282 | 0 | push(@$stack, $handler); | |||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||
| 286 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 287 | # End($expat, $name) | ||||||||||||||||||||||||||||||||||||||
| 288 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | sub End { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
End: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 291 | 0 | my ($expat, $name) = @_; | |||||||||||||||||||||||||||||||||||||
| 292 | 0 | my $self = $expat->{ _SCHEMA_INSTANCE }; | |||||||||||||||||||||||||||||||||||||
| 293 | 0 | my $stack = $self->{ _SCHEMA_STACK }; | |||||||||||||||||||||||||||||||||||||
| 294 | 0 | my $element = pop( @$stack ); | |||||||||||||||||||||||||||||||||||||
| 295 | 0 | my $text; | |||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | $self->TRACE("[End] </$name>") if $DEBUG; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||
| 299 | # flush any character content | ||||||||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | if (length ($text = $expat->{ _SCHEMA_TEXT })) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | $self->TRACE("flushing text: '", $self->_text_snippet($text), "'") if $DEBUG; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | $element->text($self, $text) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 303 | || $self->parse_error($element->error()); | ||||||||||||||||||||||||||||||||||||||
| 304 | 0 | $expat->{ _SCHEMA_TEXT } = ''; | |||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | my $child = $element->end_element($self, $name) | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$element->end_element($self, $name) || (return $self->parse_error($element->error))
MC/DC0%0/1
$element->end_element($self, $name) || (return $self->parse_error($element->error))
$element->end_element($self, $name)
Truth table0%0/2
A
A= $element->end_element($self, $name)
| |||||||||||||||||||||||||||||||||||||||
| 308 | || return $self->parse_error($element->error()); | ||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | my $parent = $stack->[-1] | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$stack->[-1] || $self->parse_error("no parent element for $name")
MC/DC0%0/2
$stack->[-1] || $self->parse_error("no parent element for $name")
$stack->[-1]
$self->parse_error("no parent element for $name")
Truth table0%0/3
A || B
A= $stack->[-1]B= $self->parse_error("no parent element for $name")
| |||||||||||||||||||||||||||||||||||||||
| 311 | || $self->parse_error("no parent element for $name"); | ||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | return $parent->end_child($self, $name, $child) | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$parent->end_child($self, $name, $child) || $self->error($parent->error)
MC/DC0%0/2
$parent->end_child($self, $name, $child) || $self->error($parent->error)
$parent->end_child($self, $name, $child)
$self->error($parent->error)
Truth table0%0/3
A || B
A= $parent->end_child($self, $name, $child)B= $self->error($parent->error)
| |||||||||||||||||||||||||||||||||||||||
| 314 | || $self->error($parent->error()); | ||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||
| 318 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 319 | # Char($expat, $char) | ||||||||||||||||||||||||||||||||||||||
| 320 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | sub Char { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
Char: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 323 | 0 | my ($expat, $char) = @_; | |||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||
| 325 | # $self->TRACE("[Char] '$char'") if $DEBUG; | ||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||
| 327 | # push character content onto buffer | ||||||||||||||||||||||||||||||||||||||
| 328 | 0 | $expat->{ _SCHEMA_TEXT } .= $char; | |||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||
| 332 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 333 | # Final($expat) | ||||||||||||||||||||||||||||||||||||||
| 334 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | sub Final { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
Final: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 337 | 0 | my $expat = shift; | |||||||||||||||||||||||||||||||||||||
| 338 | 0 | my $self = $expat->{ _SCHEMA_INSTANCE }; | |||||||||||||||||||||||||||||||||||||
| 339 | 0 | my $stack = $self->{ _SCHEMA_STACK }; | |||||||||||||||||||||||||||||||||||||
| 340 | 0 | my $element = pop( @$stack ); | |||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | $self->TRACE("[Final] calling $element->end()\n") if $DEBUG; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||
| 344 | # TODO: may need to flush text? | ||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||
| 346 | 0 | delete $expat->{ _SCHEMA_INSTANCE }; | |||||||||||||||||||||||||||||||||||||
| 347 | 0 | delete $expat->{ _SCHEMA_TEXT }; | |||||||||||||||||||||||||||||||||||||
| 348 | 0 | delete $self->{ _SCHEMA_EXPAT }; | |||||||||||||||||||||||||||||||||||||
| 349 | 0 | delete $self->{ _SCHEMA_STACK }; | |||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | my $result = $element->end_element($self) | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$element->end_element($self) || $self->parse_error($element->error)
MC/DC0%0/2
$element->end_element($self) || $self->parse_error($element->error)
$element->end_element($self)
$self->parse_error($element->error)
Truth table0%0/3
A || B
A= $element->end_element($self)B= $self->parse_error($element->error)
| |||||||||||||||||||||||||||||||||||||||
| 353 | || $self->parse_error($element->error()); | ||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||
| 355 | # $self->throw("instance finally popped off foreign handler (got $element not $self") | ||||||||||||||||||||||||||||||||||||||
| 356 | # unless $element == $self; | ||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||
| 358 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | sub parse_error { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_error: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 363 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||
| 364 | 0 | my $msg = join('', @_); | |||||||||||||||||||||||||||||||||||||
| 365 | 0 | my $expat = $self->{ _SCHEMA_EXPAT }; | |||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | die "?? lost expat instance ??\n" unless $expat; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 367 | 0 | die $expat->position_in_context(4), "\n$msg\n"; | |||||||||||||||||||||||||||||||||||||
| 368 | # $expat->xpcroak($msg); | ||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||
| 371 | 2 | 1; | |||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||