| 1 | package SVG::Parser::Base; | ||||||||||||||||||||||||||||
| 2 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 6 | $VERSION="1.03"; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | # XML declaration defaults | ||||||||||||||||||||||||||||
| 10 | 6 | ▶ | use constant SVG_DEFAULT_DECL_VERSION => "1.0"; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 6 | ▶ | use constant SVG_DEFAULT_DECL_ENCODING => "UTF-8"; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 6 | ▶ | use constant SVG_DEFAULT_DECL_STANDALONE => "yes"; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | # Document type definition defaults | ||||||||||||||||||||||||||||
| 15 | 6 | ▶ | use constant SVG_DEFAULT_DOCTYPE_NAME => "svg"; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 6 | ▶ | use constant SVG_DEFAULT_DOCTYPE_SYSID => "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 6 | ▶ | use constant SVG_DEFAULT_DOCTYPE_PUBID => "-//W3C//DTD SVG 1.0//EN"; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | # debug: simple debug method | ||||||||||||||||||||||||||||
| 22 | 208 | ▶ | sub debug ($$;@) { | ||||||||||||||||||||||||||
|
Subroutine
debug: called CC=9 SCAR=41.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 23 | 208 | my ($self,$what,@msgs)=@_; | |||||||||||||||||||||||||||
| 24 | 208 | ▶ | return unless $self->{-debug}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | my $first=1; | |||||||||||||||||||||||||||
| 27 | 0 | ▶ | my $name||=ref($self); | ||||||||||||||||||||||||||
|
Condition0%0/3
my $name ||= ref $self
MC/DC0%0/2
my $name ||= ref $self
my $name
ref $self
Truth table0%0/3
A ||= B
A= my $nameB= ref $self
| |||||||||||||||||||||||||||||
| 28 | 0 | ▶ | my $length||=length($name); | ||||||||||||||||||||||||||
|
Condition0%0/3
my $length ||= length $name
MC/DC0%0/2
my $length ||= length $name
my $length
length $name
Truth table0%0/3
A ||= B
A= my $lengthB= length $name
| |||||||||||||||||||||||||||||
| 29 | 0 | ▶ | if (@msgs) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | 0 | foreach (@msgs) { | |||||||||||||||||||||||||||
| 31 | 0 | ▶ | next unless defined $_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | 0 | ▶ | printf STDERR "+++%s %-8s: %s\n", | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 33 | ($first?$name:" "x$length), | ||||||||||||||||||||||||||||
| 34 | ($first?$what:" "),$_; | ||||||||||||||||||||||||||||
| 35 | 0 | $first=0; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | } else { | ||||||||||||||||||||||||||||
| 38 | 0 | printf STDERR "+++%s %s\n",$name,$what; | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 6 | ▶ | use constant ARG_IS_STRING => "string"; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 45 | 6 | ▶ | use constant ARG_IS_HANDLE => "handle"; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 46 | 6 | ▶ | use constant ARG_IS_HASHRF => "hash"; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 47 | 6 | ▶ | use constant ARG_IS_INVALID => "nonsuch"; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | # is it a bird...is it a plane? | ||||||||||||||||||||||||||||
| 52 | 6 | ▶ | sub identify ($$) { | ||||||||||||||||||||||||||
|
Subroutine
identify: called CC=9 SCAR=23.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 53 | 6 | my ($self,$source)=@_; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 6 | ▶ | return ARG_IS_INVALID unless $source; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | # assume a string unless we determine differently | ||||||||||||||||||||||||||||
| 58 | 6 | my $type=ARG_IS_STRING; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | # check for various filehandle cases | ||||||||||||||||||||||||||||
| 61 | 6 | ▶ | if (ref $source) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | 2 | my $class = ref($source); | |||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 2 | ▶ | if (UNIVERSAL::isa($source,'IO::Handle')) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 65 | # it's a new-style filehandle | ||||||||||||||||||||||||||||
| 66 | 0 | $type=ARG_IS_HANDLE; | |||||||||||||||||||||||||||
| 67 | } elsif (tied($source)) { | ||||||||||||||||||||||||||||
| 68 | # it's a tied filehandle? | ||||||||||||||||||||||||||||
| 69 | 6 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 70 | 0 | ▶ | $type=ARG_IS_HANDLE if defined &{"${class}::TIEHANDLE"}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | } else { | ||||||||||||||||||||||||||||
| 73 | # it's an old-style filehandle? | ||||||||||||||||||||||||||||
| 74 | 6 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 75 | 4 | ▶ | $type=ARG_IS_HANDLE if eval { *{$source}{IO} }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | # possibly a hash argument is called via parse_file (SAX) | ||||||||||||||||||||||||||||
| 79 | 6 | ▶ | $type=ARG_IS_HASHRF if ref($source) and $type eq ARG_IS_STRING; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $source and $type eq "string"
MC/DC50%1/2
ref $source and $type eq "string"
ref $source
$type eq "string"
Truth table66%2/3
A and B
A= ref $sourceB= $type eq "string"
| |||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 6 | return $type; | |||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 85 | # Additional SVG.pm processing | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 160 | ▶ | sub process_attrs ($$) { | ||||||||||||||||||||||||||
|
Subroutine
process_attrs: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 88 | 160 | my ($parser,$attrs)=@_; | |||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 160 | ▶ | if (exists $attrs->{style}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | 96 | my %styles=split /\s*[:;]\s*/,$attrs->{style}; | |||||||||||||||||||||||||||
| 92 | 96 | $attrs->{style}=\%styles; | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | #--------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 97 | # Shared Expat/SAX Handlers | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | # create and set SVG document object as root element | ||||||||||||||||||||||||||||
| 100 | 4 | ▶ | sub StartDocument { | ||||||||||||||||||||||||||
|
Subroutine
StartDocument: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 101 | 4 | my $parser=shift; | |||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | # gather SVG constuctor attributes | ||||||||||||||||||||||||||||
| 104 | 4 | my %svg_attr; | |||||||||||||||||||||||||||
| 105 | 0 | ▶ | %svg_attr=%{delete $parser->{__svg_attr}} if exists $parser->{__svg_attr}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | 4 | $svg_attr{-nostub}=1; | |||||||||||||||||||||||||||
| 107 | # instantiate SVG document object | ||||||||||||||||||||||||||||
| 108 | 4 | $parser->{__svg}=new SVG(%svg_attr); | |||||||||||||||||||||||||||
| 109 | # empty element list | ||||||||||||||||||||||||||||
| 110 | 4 | $parser->{__elements}=[]; | |||||||||||||||||||||||||||
| 111 | # empty unassigned attlist list (for internal DTD subset handling) | ||||||||||||||||||||||||||||
| 112 | 4 | $parser->{__unassigned_attlists}=[]; | |||||||||||||||||||||||||||
| 113 | # cdata count | ||||||||||||||||||||||||||||
| 114 | 4 | $parser->{__in_cdata}=0; | |||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 4 | $parser->debug("Start",$parser."/".$parser->{__svg}); | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | # handle start of element - extend chain by one | ||||||||||||||||||||||||||||
| 120 | 160 | ▶ | sub StartTag { | ||||||||||||||||||||||||||
|
Subroutine
StartTag: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 121 | 160 | my ($parser,$type,%attrs)=@_; | |||||||||||||||||||||||||||
| 122 | 160 | my $elements=$parser->{__elements}; | |||||||||||||||||||||||||||
| 123 | 160 | my $svg=$parser->{__svg}; | |||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | # some attributes need extra processing | ||||||||||||||||||||||||||||
| 126 | 160 | $parser->process_attrs(\%attrs); | |||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 160 | ▶ | if (@$elements) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | 156 | my $parent=$elements->[-1]; | |||||||||||||||||||||||||||
| 130 | 156 | push @$elements, $parent->element($type,%attrs); | |||||||||||||||||||||||||||
| 131 | } else { | ||||||||||||||||||||||||||||
| 132 | 4 | ▶ | $svg->{-inline}=1 if $type ne "svg"; #inlined | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 133 | 4 | my $el=$svg->element($type,%attrs); | |||||||||||||||||||||||||||
| 134 | 4 | $svg->{-document} = $el; | |||||||||||||||||||||||||||
| 135 | 4 | push @$elements, $el; | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 160 | $parser->debug("Element",$type); | |||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | # handle end of element - shorten chain by one | ||||||||||||||||||||||||||||
| 142 | 160 | ▶ | sub EndTag { | ||||||||||||||||||||||||||
|
Subroutine
EndTag: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 143 | 160 | my ($parser,$type)=@_; | |||||||||||||||||||||||||||
| 144 | 160 | my $elements=$parser->{__elements}; | |||||||||||||||||||||||||||
| 145 | 160 | pop @$elements; | |||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | # handle cannonical data (text) | ||||||||||||||||||||||||||||
| 149 | 260 | ▶ | sub Text { | ||||||||||||||||||||||||||
|
Subroutine
Text: called CC=5 SCAR=17.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 150 | 260 | my ($parser,$text)=@_; | |||||||||||||||||||||||||||
| 151 | 260 | my $elements=$parser->{__elements}; | |||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | 260 | ▶ | return if $text=~/^\s*$/s; #ignore redundant whitespace | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 154 | 32 | my $parent=$elements->[-1]; | |||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | # are we in a CDATA section? (see CdataStart/End below) | ||||||||||||||||||||||||||||
| 157 | 32 | ▶ | if ($parser->{__in_cdata}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 158 | 0 | ▶ | my $current=$parent->{-CDATA} || ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
$parent->{'-CDATA'} || ''
MC/DC0%0/1
$parent->{'-CDATA'} || ''
$parent->{'-CDATA'}
Truth table0%0/2
A
A= $parent->{'-CDATA'}
| |||||||||||||||||||||||||||||
| 159 | 0 | $parent->CDATA($current.$parser->{__svg}{-elsep}.$text); | |||||||||||||||||||||||||||
| 160 | } else { | ||||||||||||||||||||||||||||
| 161 | 32 | ▶ | my $current=$parent->{-cdata} || ''; | ||||||||||||||||||||||||||
|
Condition100%2/2
$parent->{'-cdata'} || ''
MC/DC100%1/1
$parent->{'-cdata'} || ''
$parent->{'-cdata'}
Truth table100%2/2
A
A= $parent->{'-cdata'}
| |||||||||||||||||||||||||||||
| 162 | 32 | $parent->cdata($current.$parser->{__svg}{-elsep}.$text); | |||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 32 | $parser->debug("CDATA","\"$text\""); | |||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | # handle cannonical data (CDATA sections) | ||||||||||||||||||||||||||||
| 169 | 0 | ▶ | sub CdataStart { | ||||||||||||||||||||||||||
|
Subroutine
CdataStart: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 170 | 0 | my $parser=shift; | |||||||||||||||||||||||||||
| 171 | 0 | $parser->{__in_cdata}++; | |||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | 0 | $parser->debug("CDATA","start->"); | |||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 0 | ▶ | sub CdataEnd { | ||||||||||||||||||||||||||
|
Subroutine
CdataEnd: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 177 | 0 | my $parser=shift; | |||||||||||||||||||||||||||
| 178 | 0 | my $elements=$parser->{__elements}; | |||||||||||||||||||||||||||
| 179 | 0 | my $parent=$elements->[-1]; | |||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | 0 | ▶ | my $current=$parent->{-CDATA} || ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
$parent->{'-CDATA'} || ''
MC/DC0%0/1
$parent->{'-CDATA'} || ''
$parent->{'-CDATA'}
Truth table0%0/2
A
A= $parent->{'-CDATA'}
| |||||||||||||||||||||||||||||
| 182 | 0 | $parent->CDATA($current.$parser->{__svg}{-elsep}); | |||||||||||||||||||||||||||
| 183 | 0 | $parser->{__in_cdata}--; | |||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | 0 | $parser->debug("CDATA","<-end"); | |||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | # handle processing instructions | ||||||||||||||||||||||||||||
| 189 | 0 | ▶ | sub PI { | ||||||||||||||||||||||||||
|
Subroutine
PI: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 190 | 0 | my ($parser,$target,$data)=@_; | |||||||||||||||||||||||||||
| 191 | 0 | my $elements=$parser->{__elements}; | |||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | 0 | ▶ | if (my $parent=$elements->[-1]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 194 | 0 | /^<\?(.*)\?>/; | |||||||||||||||||||||||||||
| 195 | 0 | $parent->pi($1); | |||||||||||||||||||||||||||
| 196 | }; | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | 0 | $parser->debug("PI",$_); | |||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | # handle XML Comments | ||||||||||||||||||||||||||||
| 202 | 8 | ▶ | sub Comment { | ||||||||||||||||||||||||||
|
Subroutine
Comment: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 203 | 8 | my ($parser,$data)=@_; | |||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | 8 | my $elements=$parser->{__elements}; | |||||||||||||||||||||||||||
| 206 | 8 | ▶ | if (my $parent=$elements->[-1]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 207 | # SVG.pm doesn't handle comment prior to document start | ||||||||||||||||||||||||||||
| 208 | 4 | $parent->comment($data); | |||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 8 | $parser->debug("Comment",$data); | |||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | # return root SVG document object as result of parse() | ||||||||||||||||||||||||||||
| 215 | 4 | ▶ | sub FinishDocument { | ||||||||||||||||||||||||||
|
Subroutine
FinishDocument: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 216 | 4 | my $parser=shift; | |||||||||||||||||||||||||||
| 217 | 4 | my $svg=$parser->{__svg}; | |||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | # add any attlists that were seen before their element | ||||||||||||||||||||||||||||
| 220 | 4 | ▶ | if (my $attlists=$parser->{__unassigned_attlists}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 221 | 4 | foreach my $unassigned_attlist (@$attlists) { | |||||||||||||||||||||||||||
| 222 | # if the element is still missing this will complain (if the parser didn't) | ||||||||||||||||||||||||||||
| 223 | 0 | $svg->attlist_decl(@$unassigned_attlist); | |||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 4 | $parser->debug("Done"); | |||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | 4 | return $parser->{__svg}; | |||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | #--------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | # handle XML declaration, if present | ||||||||||||||||||||||||||||
| 235 | 0 | ▶ | sub XMLDecl { | ||||||||||||||||||||||||||
|
Subroutine
XMLDecl: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 236 | 0 | my ($parser,$version,$encoding,$standalone)=@_; | |||||||||||||||||||||||||||
| 237 | 0 | my $svg=$parser->{__svg}; | |||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 0 | ▶ | $svg->{-version}=$version || $parser->SVG_DEFAULT_DECL_VERSION; | ||||||||||||||||||||||||||
|
Condition0%0/3
$version || $parser->SVG_DEFAULT_DECL_VERSION
MC/DC0%0/2
$version || $parser->SVG_DEFAULT_DECL_VERSION
$version
$parser->SVG_DEFAULT_DECL_VERSION
Truth table0%0/3
A || B
A= $versionB= $parser->SVG_DEFAULT_DECL_VERSION
| |||||||||||||||||||||||||||||
| 240 | 0 | ▶ | $svg->{-encoding}=$encoding || $parser->SVG_DEFAULT_DECL_ENCODING; | ||||||||||||||||||||||||||
|
Condition0%0/3
$encoding || $parser->SVG_DEFAULT_DECL_ENCODING
MC/DC0%0/2
$encoding || $parser->SVG_DEFAULT_DECL_ENCODING
$encoding
$parser->SVG_DEFAULT_DECL_ENCODING
Truth table0%0/3
A || B
A= $encodingB= $parser->SVG_DEFAULT_DECL_ENCODING
| |||||||||||||||||||||||||||||
| 241 | 0 | ▶ | $svg->{-standalone}=$standalone?"yes":"no"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | 0 | $parser->debug("XMLDecl","-version=\"$svg->{-version}\"", | |||||||||||||||||||||||||||
| 244 | "-encoding=\"$svg->{-encoding}\"","-standalone=\"$svg->{-standalone}\""); | ||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | # handle Doctype declaration, if present | ||||||||||||||||||||||||||||
| 248 | 0 | ▶ | sub Doctype { | ||||||||||||||||||||||||||
|
Subroutine
Doctype: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 249 | 0 | my ($parser,$name,$sysid,$pubid,$internal)=@_; | |||||||||||||||||||||||||||
| 250 | 0 | my $svg=$parser->{__svg}; | |||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 0 | ▶ | $svg->{-docroot}=$name || $parser->SVG_DEFAULT_DOCTYPE_NAME; | ||||||||||||||||||||||||||
|
Condition0%0/3
$name || $parser->SVG_DEFAULT_DOCTYPE_NAME
MC/DC0%0/2
$name || $parser->SVG_DEFAULT_DOCTYPE_NAME
$name
$parser->SVG_DEFAULT_DOCTYPE_NAME
Truth table0%0/3
A || B
A= $nameB= $parser->SVG_DEFAULT_DOCTYPE_NAME
| |||||||||||||||||||||||||||||
| 253 | 0 | ▶ | $svg->{-sysid}=$sysid || $parser->SVG_DEFAULT_DOCTYPE_SYSID; | ||||||||||||||||||||||||||
|
Condition0%0/3
$sysid || $parser->SVG_DEFAULT_DOCTYPE_SYSID
MC/DC0%0/2
$sysid || $parser->SVG_DEFAULT_DOCTYPE_SYSID
$sysid
$parser->SVG_DEFAULT_DOCTYPE_SYSID
Truth table0%0/3
A || B
A= $sysidB= $parser->SVG_DEFAULT_DOCTYPE_SYSID
| |||||||||||||||||||||||||||||
| 254 | 0 | ▶ | $svg->{-pubid}=$pubid || $parser->SVG_DEFAULT_DOCTYPE_PUBID; | ||||||||||||||||||||||||||
|
Condition0%0/3
$pubid || $parser->SVG_DEFAULT_DOCTYPE_PUBID
MC/DC0%0/2
$pubid || $parser->SVG_DEFAULT_DOCTYPE_PUBID
$pubid
$parser->SVG_DEFAULT_DOCTYPE_PUBID
Truth table0%0/3
A || B
A= $pubidB= $parser->SVG_DEFAULT_DOCTYPE_PUBID
| |||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | 0 | $parser->debug("Doctype", | |||||||||||||||||||||||||||
| 257 | "-docroot=\"$svg->{-docroot}\"", | ||||||||||||||||||||||||||||
| 258 | "-sysid=\"$svg->{-sysid}\"", | ||||||||||||||||||||||||||||
| 259 | "-pubid=\"$svg->{-pubid}\"", | ||||||||||||||||||||||||||||
| 260 | ); | ||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | #--------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | # Unparsed (Expat, Entity, Base, Sysid, Pubid, Notation) | ||||||||||||||||||||||||||||
| 266 | 0 | ▶ | sub Unparsed { | ||||||||||||||||||||||||||
|
Subroutine
Unparsed: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 267 | 0 | my ($parser,$name,$base,$sysid,$pubid,$notation)=@_; | |||||||||||||||||||||||||||
| 268 | 0 | my $svg=$parser->{__svg}; | |||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | 0 | my %entity=(name=>$name, sysid=>$sysid, notation=>$notation); | |||||||||||||||||||||||||||
| 271 | 0 | ▶ | $entity{base}=$base if defined $base; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 272 | 0 | ▶ | $entity{sysid}=$sysid if defined $sysid; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | 0 | $svg->entity_decl(%entity); | |||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | # Notation (Expat, Notation, Base, Sysid, Pubid) | ||||||||||||||||||||||||||||
| 278 | 0 | ▶ | sub Notation { | ||||||||||||||||||||||||||
|
Subroutine
Notation: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 279 | 0 | my ($parser,$name,$base,$sysid,$pubid)=@_; | |||||||||||||||||||||||||||
| 280 | 0 | my $svg=$parser->{__svg}; | |||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | 0 | my %notation=(name=>$name); | |||||||||||||||||||||||||||
| 283 | 0 | ▶ | $notation{base}=$base if defined $base; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 284 | 0 | ▶ | $notation{sysid}=$sysid if defined $sysid; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 285 | 0 | ▶ | $notation{pubid}=$pubid if defined $pubid; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | 0 | $svg->notation_decl(%notation); | |||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | # Entity (Expat, Name, Val, Sysid, Pubid, Ndata, IsParam) | ||||||||||||||||||||||||||||
| 291 | 0 | ▶ | sub Entity { | ||||||||||||||||||||||||||
|
Subroutine
Entity: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 292 | 0 | my ($parser,$name,$val,$sysid,$pubid,$data,$isp)=@_; | |||||||||||||||||||||||||||
| 293 | 0 | my $svg=$parser->{__svg}; | |||||||||||||||||||||||||||
| 294 | 0 | ▶ | $isp||=0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$isp ||= 0
MC/DC0%0/1
$isp ||= 0
$isp
Truth table0%0/2
A
A= $isp
| |||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | 0 | ▶ | if (defined $val) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 297 | 0 | $svg->entity_decl(name=>$name, value=>$val, isp=>$isp); | |||||||||||||||||||||||||||
| 298 | } elsif (defined $pubid) { | ||||||||||||||||||||||||||||
| 299 | 0 | $svg->entity_decl(name=>$name, sysid=>$sysid, pubid=>$pubid, ndata=>$data, isp=>$isp); | |||||||||||||||||||||||||||
| 300 | } else { | ||||||||||||||||||||||||||||
| 301 | 0 | $svg->entity_decl(name=>$name, sysid=>$sysid, ndata=>$data, isp=>$isp); | |||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | # Element (Expat, Name, Model) | ||||||||||||||||||||||||||||
| 306 | 0 | ▶ | sub Element { | ||||||||||||||||||||||||||
|
Subroutine
Element: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 307 | 0 | my ($parser,$name,$model)=@_; | |||||||||||||||||||||||||||
| 308 | 0 | my $svg=$parser->{__svg}; | |||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | 0 | ▶ | if (defined $model) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 311 | # convert model to string context | ||||||||||||||||||||||||||||
| 312 | 0 | $svg->element_decl(name=>$name, model=>qq{$model}); | |||||||||||||||||||||||||||
| 313 | } else { | ||||||||||||||||||||||||||||
| 314 | 0 | $svg->element_decl(name=>$name); | |||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | # Attlist (Expat, Elname, Attname, Type, Default, Fixed) | ||||||||||||||||||||||||||||
| 319 | 0 | ▶ | sub Attlist { | ||||||||||||||||||||||||||
|
Subroutine
Attlist: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 320 | 0 | my ($parser,$name,$attr,$type,$default,$fixed)=@_; | |||||||||||||||||||||||||||
| 321 | 0 | my $svg=$parser->{__svg}; | |||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | 0 | ▶ | if ($svg->getElementDeclByName($name)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 324 | 0 | ▶ | $svg->attlist_decl( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 325 | name=>$name, attr=>$attr, type=>$type, default=>$default, fixed=>($fixed?1:0) | ||||||||||||||||||||||||||||
| 326 | ); | ||||||||||||||||||||||||||||
| 327 | } else { | ||||||||||||||||||||||||||||
| 328 | 0 | ▶ | push @{$parser->{__unassigned_attlists}}, [ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 329 | name=>$name, attr=>$attr, type=>$type, default=>$default, fixed=>($fixed?1:0) | ||||||||||||||||||||||||||||
| 330 | ]; | ||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | #--------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | 6 | 1; | |||||||||||||||||||||||||||