| 1 | |||||||||||||||||||||||||||||
| 2 | package XML::Toolset; | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use App; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use App::Service; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use vars qw($VERSION @ISA); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 1 | $VERSION = sprintf"%d.%03d", q$Revision: 1.25 $ =~ /: (\d+)\.(\d+)/; | |||||||||||||||||||||||||||
| 10 | 1 | @ISA = ("App::Service"); | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use XML::Toolset::Document; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | =head1 NAME | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | XML::Toolset - perform XML construction, parsing, validation, and XPath operations using whatever underlying XML library is available (ALPHA!) | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | use App; | ||||||||||||||||||||||||||||
| 21 | use XML::Toolset; | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | my $context = App->context(); | ||||||||||||||||||||||||||||
| 24 | my $toolset = $context->xml_toolset(class => "XML::Toolset::BestAvailable"); | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | ... | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | The XML-Toolset distribution is a wrapper which provides a simplified XML | ||||||||||||||||||||||||||||
| 31 | processing API which uses XPath to construct and dissect XML messages. | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | The architecture of the XML-Toolset distribution allows for the user of | ||||||||||||||||||||||||||||
| 34 | the API to access XML capabilities independent of the underlying XML | ||||||||||||||||||||||||||||
| 35 | toolset technology: i.e. Xerces, LibXML, XML::XMLDOM, MSXML. | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | =cut | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | ########################################################################### | ||||||||||||||||||||||||||||
| 40 | # abstract methods | ||||||||||||||||||||||||||||
| 41 | ########################################################################### | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | sub get_value { | ||||||||||||||||||||||||||
|
Subroutine
get_value: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | &App::sub_entry if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 0 | my ($self, $xpath) = @_; | |||||||||||||||||||||||||||
| 46 | 0 | my ($value); | |||||||||||||||||||||||||||
| 47 | 0 | die "get_value() must be implemented in a subclass"; | |||||||||||||||||||||||||||
| 48 | 0 | ▶ | &App::sub_exit($value) if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 0 | return($value); | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub set_value { | ||||||||||||||||||||||||||
|
Subroutine
set_value: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 53 | 0 | ▶ | &App::sub_entry if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 0 | my ($self, $xpath, $value) = @_; | |||||||||||||||||||||||||||
| 55 | 0 | die "set_value() must be implemented in a subclass"; | |||||||||||||||||||||||||||
| 56 | 0 | ▶ | &App::sub_exit() if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | ▶ | sub get_nodes { | ||||||||||||||||||||||||||
|
Subroutine
get_nodes: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 60 | 0 | ▶ | &App::sub_entry if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | 0 | my ($self, $xpath) = @_; | |||||||||||||||||||||||||||
| 62 | 0 | my (@nodes); | |||||||||||||||||||||||||||
| 63 | 0 | die "set_nodes() must be implemented in a subclass"; | |||||||||||||||||||||||||||
| 64 | 0 | ▶ | &App::sub_exit(@nodes) if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 0 | return(@nodes); | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | ▶ | sub set_nodes { | ||||||||||||||||||||||||||
|
Subroutine
set_nodes: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 69 | 0 | ▶ | &App::sub_entry if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | 0 | my ($self, @nodes) = @_; | |||||||||||||||||||||||||||
| 71 | 0 | die "set_nodes() must be implemented in a subclass"; | |||||||||||||||||||||||||||
| 72 | 0 | ▶ | &App::sub_exit() if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | ▶ | sub to_string { | ||||||||||||||||||||||||||
|
Subroutine
to_string: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 76 | 0 | ▶ | &App::sub_entry if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 78 | 0 | my ($xml); | |||||||||||||||||||||||||||
| 79 | 0 | die "to_string() must be implemented in a subclass"; | |||||||||||||||||||||||||||
| 80 | 0 | ▶ | &App::sub_exit($xml) if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | 0 | return($xml); | |||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 0 | ▶ | sub transform { | ||||||||||||||||||||||||||
|
Subroutine
transform: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 85 | 0 | ▶ | &App::sub_entry if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 87 | 0 | die "transform() must be implemented in a subclass"; | |||||||||||||||||||||||||||
| 88 | 0 | ▶ | &App::sub_exit() if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 0 | ▶ | sub version { | ||||||||||||||||||||||||||
|
Subroutine
version: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 92 | 0 | ▶ | &App::sub_entry if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 94 | 0 | my ($version); | |||||||||||||||||||||||||||
| 95 | 0 | die "version() must be implemented in a subclass"; | |||||||||||||||||||||||||||
| 96 | 0 | ▶ | &App::sub_exit($version) if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 97 | 0 | return($version); | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 0 | ▶ | sub new_parser { | ||||||||||||||||||||||||||
|
Subroutine
new_parser: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 101 | 0 | ▶ | &App::sub_entry if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | 0 | my ($self, $options) = @_; | |||||||||||||||||||||||||||
| 103 | 0 | my $parser = undef; | |||||||||||||||||||||||||||
| 104 | 0 | die "new_parser() must be implemented in a subclass"; | |||||||||||||||||||||||||||
| 105 | 0 | ▶ | &App::sub_exit($parser) if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | 0 | return($parser); | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 0 | ▶ | sub new_dom { | ||||||||||||||||||||||||||
|
Subroutine
new_dom: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 110 | 0 | ▶ | &App::sub_entry if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 111 | 0 | my ($self, $root_tag, $xmlns) = @_; | |||||||||||||||||||||||||||
| 112 | 0 | my ($dom); | |||||||||||||||||||||||||||
| 113 | 0 | die "new_dom() must be implemented in a subclass"; | |||||||||||||||||||||||||||
| 114 | 0 | ▶ | &App::sub_exit($dom) if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | 0 | return($dom); | |||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 0 | ▶ | sub parse { | ||||||||||||||||||||||||||
|
Subroutine
parse: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 119 | 0 | ▶ | &App::sub_entry if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | 0 | my ($self, $xml, $options) = @_; | |||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 0 | my $valid = 1; | |||||||||||||||||||||||||||
| 123 | 0 | die "parse() must be implemented in a subclass"; | |||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 0 | ▶ | &App::sub_exit($valid) if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 126 | 0 | return($valid); | |||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | ########################################################################### | ||||||||||||||||||||||||||||
| 130 | # base class methods | ||||||||||||||||||||||||||||
| 131 | ########################################################################### | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | #<?xml version="1.0" encoding="UTF-8"?> | ||||||||||||||||||||||||||||
| 134 | #<OTA_PingRS ... /> | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 0 | ▶ | sub get_root_tag { | ||||||||||||||||||||||||||
|
Subroutine
get_root_tag: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 137 | 0 | ▶ | &App::sub_entry if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | 0 | my ($self, $doc) = @_; | |||||||||||||||||||||||||||
| 139 | 0 | my ($tag); | |||||||||||||||||||||||||||
| 140 | 0 | my $xml = $self->doc2xml($doc); | |||||||||||||||||||||||||||
| 141 | 0 | ▶ | if ($xml =~ /^(<\?xml[^<>]*\?>)?\s*<\s*(\S+)/s) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | 0 | $tag = $2; | |||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | 0 | ▶ | &App::sub_exit($tag) if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 145 | 0 | return($tag); | |||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | 0 | ▶ | sub get_root_element_attribute { | ||||||||||||||||||||||||||
|
Subroutine
get_root_element_attribute: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 149 | 0 | ▶ | &App::sub_entry if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 150 | 0 | my ($self, $xml, $attrib) = @_; | |||||||||||||||||||||||||||
| 151 | 0 | my ($root_tag, $value); | |||||||||||||||||||||||||||
| 152 | 0 | ▶ | if ($xml =~ /^(<\?xml[^<>]*\?>)?\s*<\s*(\S+)[^<>]*\s+$attrib\s*=\s*['"]([^<>'"]*)['"]/s) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 153 | 0 | $root_tag = $2; | |||||||||||||||||||||||||||
| 154 | 0 | $value = $3; | |||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | 0 | ▶ | &App::sub_exit($value) if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 157 | 0 | return($value); | |||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | 0 | ▶ | sub set_root_element_attribute { | ||||||||||||||||||||||||||
|
Subroutine
set_root_element_attribute: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 161 | 0 | ▶ | &App::sub_entry if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | 0 | my ($self, $xmlref, $attrib, $value) = @_; | |||||||||||||||||||||||||||
| 163 | 0 | my ($root_tag); | |||||||||||||||||||||||||||
| 164 | 0 | $$xmlref =~ s/^(<\?xml[^<>]*\?>)?(\s*<\s*\S+[^<>]*\s+$attrib\s*=\s*['"])([^<>'"]*)(['"])/$1$2$value$4/s; | |||||||||||||||||||||||||||
| 165 | 0 | ▶ | &App::sub_exit() if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 0 | ▶ | sub new_document { | ||||||||||||||||||||||||||
|
Subroutine
new_document: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 169 | 0 | ▶ | &App::sub_entry if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 170 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||
| 171 | 0 | my $doc = XML::Toolset::Document->new(@args, xml_toolset => $self); | |||||||||||||||||||||||||||
| 172 | 0 | ▶ | &App::sub_exit($doc) if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 173 | 0 | return($doc); | |||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 0 | ▶ | sub type { | ||||||||||||||||||||||||||
|
Subroutine
type: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 177 | 0 | ▶ | &App::sub_entry if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 178 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 179 | 0 | my $class = ref($self); | |||||||||||||||||||||||||||
| 180 | 0 | $class =~ m/XML::Toolset::(.*)/; | |||||||||||||||||||||||||||
| 181 | 0 | my $type = $1; | |||||||||||||||||||||||||||
| 182 | 0 | ▶ | &App::sub_exit($type) if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | 0 | return($type); | |||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | 0 | ▶ | sub validate_document { | ||||||||||||||||||||||||||
|
Subroutine
validate_document: not called CC=13 SCAR=52.0
Pod
documented
| |||||||||||||||||||||||||||||
| 187 | 0 | ▶ | &App::sub_entry if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 188 | 0 | my ($self, $doc, $options) = @_; | |||||||||||||||||||||||||||
| 189 | 0 | my $xml = $self->doc2xml($doc); | |||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | 0 | ▶ | if ($self->{xmlns} && $self->{schema_location}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"xmlns"} and $self->{"schema_location"}
MC/DC0%0/2
$self->{"xmlns"} and $self->{"schema_location"}
$self->{"xmlns"}
$self->{"schema_location"}
Truth table0%0/3
A and B
A= $self->{"xmlns"}B= $self->{"schema_location"}
| |||||||||||||||||||||||||||||
| 192 | 0 | my $schema_location = $self->get_root_element_attribute($xml,"xsi:schemaLocation"); | |||||||||||||||||||||||||||
| 193 | #if ($schema_location && $schema_location =~ /^$self->{xmlns} /) { } | ||||||||||||||||||||||||||||
| 194 | 0 | ▶ | if ($schema_location) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 195 | 0 | my $schema_file = $schema_location; | |||||||||||||||||||||||||||
| 196 | 0 | $schema_file =~ s/.* //; | |||||||||||||||||||||||||||
| 197 | 0 | ▶ | if ($schema_file =~ m/^[a-z]:/i || $schema_file =~ m/^[\\\/]/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$schema_file =~ /^[a-z]:/i or $schema_file =~ m[^[\\/]]
MC/DC0%0/2
$schema_file =~ /^[a-z]:/i or $schema_file =~ m[^[\\/]]
$schema_file =~ /^[a-z]:/i
$schema_file =~ m[^[\\/]]
Truth table0%0/3
A or B
A= $schema_file =~ /^[a-z]:/iB= $schema_file =~ m[^[\\/]]
| |||||||||||||||||||||||||||||
| 198 | 0 | $schema_file =~ s/.*[\\\/]//; | |||||||||||||||||||||||||||
| 199 | 0 | my $good_schema_location = "$self->{xmlns} $self->{schema_location}/$schema_file"; | |||||||||||||||||||||||||||
| 200 | 0 | $self->set_root_element_attribute(\$xml,"xsi:schemaLocation",$good_schema_location); | |||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | 0 | ▶ | $options = {} if (!$options); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 206 | 0 | my $valid = 1; | |||||||||||||||||||||||||||
| 207 | 0 | delete $options->{dom}; | |||||||||||||||||||||||||||
| 208 | 0 | delete $options->{error}; | |||||||||||||||||||||||||||
| 209 | 0 | delete $options->{error_line}; | |||||||||||||||||||||||||||
| 210 | 0 | delete $options->{error_column}; | |||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | 0 | ▶ | die "validate called with no data to validate\n" unless defined $xml and length $xml > 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $xml and length $xml > 0
MC/DC0%0/2
defined $xml and length $xml > 0
defined $xml
length $xml > 0
Truth table0%0/3
A and B
A= defined $xmlB= length $xml > 0
| |||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | 0 | my $dom = $self->parse($xml, $options); | |||||||||||||||||||||||||||
| 215 | 0 | ▶ | if ($dom && !$options->{error}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$dom and not $options->{"error"}
MC/DC0%0/2
$dom and not $options->{"error"}
$dom
not $options->{"error"}
Truth table0%0/3
A and not(B)
A= $domB= not $options->{"error"}
| |||||||||||||||||||||||||||||
| 216 | 0 | $options->{dom} = $dom; | |||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||
| 218 | else { | ||||||||||||||||||||||||||||
| 219 | 0 | $valid = 0; | |||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 0 | ▶ | &App::sub_exit($valid) if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 223 | 0 | return($valid); | |||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | 0 | ▶ | sub doc2dom { | ||||||||||||||||||||||||||
|
Subroutine
doc2dom: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 227 | 0 | ▶ | &App::sub_entry if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 228 | 0 | my ($self, $doc) = @_; | |||||||||||||||||||||||||||
| 229 | 0 | my $ref = ref($doc); | |||||||||||||||||||||||||||
| 230 | 0 | my ($dom); | |||||||||||||||||||||||||||
| 231 | 0 | ▶ | if (!$ref) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 232 | 0 | $dom = $self->parse($doc); | |||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | elsif ($ref eq "XML::Toolset::Document") { | ||||||||||||||||||||||||||||
| 235 | 0 | $dom = $doc->dom(); | |||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||
| 237 | else { | ||||||||||||||||||||||||||||
| 238 | 0 | $dom = $doc; | |||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||
| 240 | 0 | ▶ | &App::sub_exit($dom) if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 241 | 0 | return($dom); | |||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | 0 | ▶ | sub doc2xml { | ||||||||||||||||||||||||||
|
Subroutine
doc2xml: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 245 | 0 | ▶ | &App::sub_entry if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 246 | 0 | my ($self, $doc) = @_; | |||||||||||||||||||||||||||
| 247 | 0 | my $ref = ref($doc); | |||||||||||||||||||||||||||
| 248 | 0 | my ($xml); | |||||||||||||||||||||||||||
| 249 | 0 | ▶ | if (!$ref) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 250 | 0 | $xml = $doc; | |||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||
| 252 | elsif ($ref eq "XML::Toolset::Document") { | ||||||||||||||||||||||||||||
| 253 | 0 | $xml = $doc->xml(); | |||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||
| 255 | else { | ||||||||||||||||||||||||||||
| 256 | 0 | $xml = $doc->to_string(); | |||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||
| 258 | 0 | ▶ | &App::sub_exit($xml) if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 259 | 0 | return($xml); | |||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | 0 | ▶ | sub set_validation { | ||||||||||||||||||||||||||
|
Subroutine
set_validation: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 263 | 0 | ▶ | &App::sub_entry if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 264 | 0 | my ($self, $validation) = @_; | |||||||||||||||||||||||||||
| 265 | 0 | $self->{validation} = $validation; | |||||||||||||||||||||||||||
| 266 | 0 | delete $self->{parser}; # the next parser will have the new validation setting | |||||||||||||||||||||||||||
| 267 | 0 | ▶ | &App::sub_exit() if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | 0 | ▶ | sub parser { | ||||||||||||||||||||||||||
|
Subroutine
parser: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 271 | 0 | ▶ | &App::sub_entry if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 272 | 0 | my ($self, $options) = @_; | |||||||||||||||||||||||||||
| 273 | 0 | my $parser = $self->{parser}; | |||||||||||||||||||||||||||
| 274 | 0 | ▶ | if (!$parser) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 275 | 0 | $parser = $self->new_parser($options); | |||||||||||||||||||||||||||
| 276 | 0 | $self->{parser} = $parser; | |||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||
| 278 | 0 | ▶ | &App::sub_exit($parser) if ($App::trace); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 279 | 0 | return($parser); | |||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | 1 | 1; | |||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | __END__ | ||||||||||||||||||||||||||||