lib/OPM/Parser.pm

filter: Statementstmt 98.7% 156 / 158 Branchbran 94.1% 32 / 34 Conditioncond 84.6% 11 / 13 MC/DCmcdc 75.0% 6 / 8 Subroutinesub 95.8% 23 / 24 Podpod 100% 4 / 4 totaltotal 96.2% 232 / 241 CC 31 SCAR 19.9
CC
31
Cov
97%
parse
13.0
documentation
13.0
as_sopm
5.0
CRAP 7.3
↑ Summary script/de_opm.pl »
1 package OPM::Parser;
2  
3 9 ▶use v5.24;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 # ABSTRACT: Parser for the .opm file
6  
7 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 9 our $VERSION = '1.06'; # VERSION
11  
12 9 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 9 ▶use MooX::HandlesVia;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 9 ▶use OPM::Parser::Types qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 9 ▶use MIME::Base64 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
17 9 ▶use OPM::Validate;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 9 ▶use Path::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 9 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 9 ▶use XML::LibXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 # declare attributes
23 9 has product => ( is => 'rw', isa => Str, );
24 9 has name => ( is => 'rw', isa => Str, );
25 9 has version => ( is => 'rw', isa => VersionString, );
26 9 has vendor => ( is => 'rw', isa => Str, );
27 9 has url => ( is => 'rw', isa => Str, );
28 9 has license => ( is => 'rw', isa => Str, );
29 9 has description => ( is => 'rw', isa => Str, );
30 9 has error_string => ( is => 'rw', isa => Str, );
31 9 has tree => ( is => 'rw', isa => XMLTree, );
32  
33 9 has opm_file => (
34 is => 'ro',
35 isa => Str,
36 required => 1,
37 );
38  
39 has files => (
40 is => 'rw',
41 isa => ArrayRef[HashRef],
42 17 ▶ default => sub{ [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
43 9 handles_via => 'Array',
44 handles => {
45 add_file => 'push',
46 },
47 );
48  
49 has framework => (
50 handles_via => 'Array',
51 is => 'rw',
52 isa => ArrayRef[FrameworkVersionString],
53 17 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
54 9 handles => {
55 add_framework => 'push',
56 },
57 );
58  
59 has framework_details => (
60 handles_via => 'Array',
61 is => 'rw',
62 isa => ArrayRef[HashRef],
63 17 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
64 9 handles => {
65 add_framework_detail => 'push',
66 },
67 );
68  
69 has dependencies => (
70 handles_via => 'Array',
71 is => 'rw',
72 isa => ArrayRef[HashRef[Str]],
73 17 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
74 9 handles => {
75 add_dependency => 'push',
76 },
77 );
78  
79  
80 9 ▶sub documentation {
Subroutine documentation: called CC=13 SCAR=25.6
Pod documented
81 9 my ($self,%params) = @_;
82
83 9 my $doc_file;
84 my $found_file;
85
86 9 ▶ my $lang = $params{lang} || 'en';
Condition100%2/2
$params{'lang'} || 'en'
l!l
63
MC/DC100%1/1
$params{'lang'} || 'en'
$params{'lang'}
Truth table100%2/2
A
A= $params{'lang'}
Aresult
11
00
87 9 ▶ my $type = $params{type} || '';
Condition100%2/2
$params{'type'} || ''
l!l
45
MC/DC100%1/1
$params{'type'} || ''
$params{'type'}
Truth table100%2/2
A
A= $params{'type'}
Aresult
11
00
88  
89 9 for my $file ( $self->files->@* ) {
90  
91 35 my $filename = $file->{filename};
92 35 ▶ next if $filename !~ m{ \A doc/ }x;
Branch: 1 branch
BranchTrueFalseTotal
unless $filename =~ m[ \A doc/ ]ux 16 19 35
93
94 19 ▶ if ( !$doc_file ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($doc_file) 8 11 19
95 8 $doc_file = $file;
96 8 $found_file = $filename;
97 }
98
99 19 ▶ next if $filename !~ m{ \A doc/$lang/ }x;
Branch: 1 branch
BranchTrueFalseTotal
unless $filename =~ m[ \A doc/$lang/ ]ux 10 9 19
100
101 9 ▶ if ( $found_file !~ m{ \A doc/$lang/ }x ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($found_file =~ m[ \A doc/$lang/ ]ux) 3 6 9
102 3 $doc_file = $file;
103 3 $found_file = $filename;
104 }
105
106 9 ▶ next if $type && $filename !~ m{ \A doc/[^/]+/.*\.$type \z }x;
Branch: 1 branch
BranchTrueFalseTotal
if $type and not $filename =~ m[ \A doc/[^/]+/.*\.$type \z ]ux 2 7 9
Condition100%3/3
$type and not $filename =~ m[ \A doc/[^/]+/.*\.$type \z ]ux
!ll&&!rl&&r
432
MC/DC100%2/2
$type and not $filename =~ m[ \A doc/[^/]+/.*\.$type \z ]ux
$type not $filename =~ m[ \A doc/[^/]+/.*\.$type \z ]ux
Truth table100%3/3
A and not(B)
A= $typeB= not $filename =~ m[ \A doc/[^/]+/.*\.$type \z ]ux
ABresult
0X0
100
111
107
108 7 ▶ if ( $type && $found_file !~ m{ \A doc/[^/]+/.*\.$type \z }x ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type and not $found_file =~ m[ \A doc/[^/]+/.*\.$type \z ]ux) 1 6 7
Condition100%3/3
$type and not $found_file =~ m[ \A doc/[^/]+/.*\.$type \z ]ux
!ll&&!rl&&r
421
MC/DC100%2/2
$type and not $found_file =~ m[ \A doc/[^/]+/.*\.$type \z ]ux
$type not $found_file =~ m[ \A doc/[^/]+/.*\.$type \z ]ux
Truth table100%3/3
A and not(B)
A= $typeB= not $found_file =~ m[ \A doc/[^/]+/.*\.$type \z ]ux
ABresult
0X0
100
111
109 1 $doc_file = $file;
110 1 $found_file = $filename;
111 }
112  
113 7 ▶ last if $found_file =~ m{ \A doc/$lang/.*\.$type \z }x;
Branch: 1 branch
BranchTrueFalseTotal
if $found_file =~ m[ \A doc/$lang/.*\.$type \z ]ux 3 4 7
114 }
115
116 9 return $doc_file;
117 }
118  
119 15 ▶sub validate {
Subroutine validate: called CC=3 SCAR=11.0
Pod documented
120 15 my ($self) = @_;
121  
122 15 $self->error_string( '' );
123
124 15 ▶ if ( !-e $self->opm_file ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $self->opm_file) 1 14 15
125 1 $self->error_string( 'File does not exist' );
126 1 return;
127 }
128  
129 14 ▶ try {
Subroutine __ANON__: called CC=1 SCAR=0.0
130 14 my $fh = IO::File->new( $self->opm_file, 'r' );
131 14 my $content = join '', $fh->getlines;
132 14 OPM::Validate->validate( $content );
133 }
134 3 ▶ catch {
Subroutine __ANON__: called CC=1 SCAR=0.0
135 3 $self->error_string( 'opm file is invalid: ' . $_ );
136 14 };
137  
138 14 ▶ return if $self->error_string;
Branch: 1 branch
BranchTrueFalseTotal
if $self->error_string 3 11 14
139 11 return 1;
140 }
141  
142 10 ▶sub parse {
Subroutine parse: called CC=13 SCAR=25.7
Pod documented
143 10 my ($self, %params) = @_;
144  
145 10 $self->error_string( '' );
146
147 10 ▶ if ( !-e $self->opm_file ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $self->opm_file) 1 9 10
148 1 $self->error_string( 'File does not exist' );
149 1 return;
150 }
151
152 9 my $tree;
153 9 ▶ try {
Subroutine __ANON__: called CC=1 SCAR=0.0
154 9 my $parser = XML::LibXML->new;
155 9 $tree = $parser->parse_file( $self->opm_file );
156  
157 8 $self->tree( $tree );
158 }
159 1 ▶ catch {
Subroutine __ANON__: called CC=1 SCAR=0.0
160 1 $self->error_string( 'Could not parse .opm: ' . $_ );
161 1 return;
162 9 };
163  
164 9 ▶ return if $self->error_string;
Branch: 1 branch
BranchTrueFalseTotal
if $self->error_string 1 8 9
165
166 8 my $is_valid = $self->validate;
167 8 ▶ if ( !$params{ignore_validation} && !$is_valid ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($params{"ignore_validation"} or $is_valid) 0 8 8
Condition33%1/3
$params{"ignore_validation"} or $is_valid
l!l&&r!l&&!r
080
MC/DC0%0/2
$params{"ignore_validation"} or $is_valid
$params{"ignore_validation"} $is_valid
Truth table33%1/3
A or B
A= $params{"ignore_validation"}B= $is_valid
ABresult
1X1
011
000
168 0 return;
169 }
170
171 8 my $root = $tree->getDocumentElement;
172
173 # collect basic data
174 8 $self->vendor( $root->findvalue( 'Vendor' ) );
175 8 $self->name( $root->findvalue( 'Name' ) );
176 8 $self->license( $root->findvalue( 'License' ) );
177 8 $self->version( $root->findvalue( 'Version' ) );
178 8 $self->url( $root->findvalue( 'URL' ) );
179  
180 8 my $root_name = $root->nodeName;
181 8 $root_name =~ s{_package}{};
182  
183 8 $self->product( $root_name );
184
185 # retrieve framework information
186 8 my @frameworks = $root->findnodes( 'Framework' );
187
188 FILE:
189 8 for my $framework ( @frameworks ) {
190 34 my $framework_version = $framework->textContent;
191
192 34 my %details = ( Content => $framework_version );
193 34 my $maximum = $framework->findvalue( '@Maximum' );
194 34 my $minimum = $framework->findvalue( '@Minimum' );
195  
196 34 ▶ $details{Maximum} = $maximum if $maximum;
Branch: 1 branch
BranchTrueFalseTotal
if $maximum 8 26 34
197 34 ▶ $details{Minimum} = $minimum if $minimum;
Branch: 1 branch
BranchTrueFalseTotal
if $minimum 8 26 34
198
199 # push framework info to attribute
200 34 $self->add_framework( $framework_version );
201 34 $self->add_framework_detail( \%details );
202 }
203  
204 # retrieve file information
205 8 my @files = $root->findnodes( 'Filelist/File' );
206
207 FILE:
208 8 for my $file ( @files ) {
209 30 my $name = $file->findvalue( '@Location' );
210
211 #next FILE if $name !~ m{ \. (?:pl|pm|pod|t) \z }xms;
212 30 my $encode = $file->findvalue( '@Encode' );
213 30 ▶ next FILE if $encode ne 'Base64';
Branch: 1 branch
BranchTrueFalseTotal
if $encode ne "Base64" 2 28 30
214
215 28 my $content_base64 = $file->textContent;
216 28 my $content = MIME::Base64::decode( $content_base64 );
217
218 # push file info to attribute
219 28 $self->add_file({
220 filename => $name,
221 content => $content,
222 });
223 }
224
225 # get description - english if available, any other language otherwise
226 8 my @descriptions = $root->findnodes( 'Description' );
227 8 my $description_string;
228
229 DESCRIPTION:
230 8 for my $description ( @descriptions ) {
231 10 $description_string = $description->textContent;
232 10 my $language = $description->findvalue( '@Lang' );
233
234 10 ▶ last DESCRIPTION if $language eq 'en';
Branch: 1 branch
BranchTrueFalseTotal
if $language eq "en" 8 2 10
235 }
236
237 8 $self->description( $description_string );
238
239 # get Addon and CPAN dependencies
240 8 my @addon_deps = $root->findnodes( 'PackageRequired' );
241 8 my @cpan_deps = $root->findnodes( 'ModuleRequired' );
242
243 8 my %types = (
244 PackageRequired => 'Addon',
245 ModuleRequired => 'CPAN',
246 );
247
248 8 for my $dep ( @addon_deps, @cpan_deps ) {
249 24 my $node_type = $dep->nodeName;
250 24 my $version = $dep->findvalue( '@Version' );
251 24 my $dep_name = $dep->textContent;
252 24 my $dep_type = $types{$node_type};
253
254 24 $self->add_dependency({
255 type => $dep_type,
256 version => $version,
257 name => $dep_name,
258 });
259 }
260
261 8 return 1;
262 }
263  
264 2 ▶sub as_sopm {
Subroutine as_sopm: called CC=5 SCAR=16.1
Pod documented
265 2 my ($self) = @_;
266  
267 2 my $tree = $self->tree->cloneNode(1);
268 2 my $root = $tree->getDocumentElement;
269
270 2 my @build_host = $root->findnodes( 'BuildHost' );
271 2 my @build_date = $root->findnodes( 'BuildDate' );
272
273 2 $root->removeChild( $_ ) for @build_host;
274 2 $root->removeChild( $_ ) for @build_date;
275  
276 #$build_host->unbindNode() if $build_host;
277 #$build_date->unbindNode() if $build_date;
278
279 2 my @files = $root->findnodes( 'Filelist/File' );
280 2 for my $file ( @files ) {
281 9 my ($encode) = $file->findnodes( '@Encode' );
282 9 ▶ $encode->unbindNode() if $encode;
Branch: 1 branch
BranchTrueFalseTotal
if $encode 9 0 9
283
284 9 $file->removeChildNodes();
285 }
286
287 2 return $tree->toString;
288 }
289  
290  
291 0 ▶sub _get_xsd {
Subroutine _get_xsd: not called CC=1 SCAR=6.9
292  
293 0 return q~<?xml version="1.0" encoding="UTF-8" standalone="no"?>
294 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
295 <xs:import namespace="http://www.w3.org/XML/1998/namespace"/>
296
297 <xs:element name="otrs_package" type="Package"/>
298 <xs:element name="otobo_package" type="Package" />
299  
300 <xs:complexType name="Package">
301 <xs:all>
302 <xs:element name="CVS" minOccurs="0" maxOccurs="1" type="xs:token"/>
303 <xs:element name="Name" minOccurs="1" maxOccurs="1" type="xs:token"/>
304 <xs:element name="Version" maxOccurs="1" type="xs:token"/>
305 <xs:element name="Vendor" maxOccurs="1" type="xs:token"/>
306 <xs:element name="URL" maxOccurs="1" type="xs:token"/>
307 <xs:element name="License" maxOccurs="1" type="xs:token"/>
308 <xs:element name="ChangeLog" minOccurs="0" type="ChangeLog" />
309 <xs:element name="Description" maxOccurs="unbounded" type="Description" />
310 <xs:element name="Framework" maxOccurs="unbounded" type="Framework" />
311 <xs:element name="OS" minOccurs="0" maxOccurs="unbounded" type="xs:token"/>
312 <xs:element name="IntroInstall" minOccurs="0" maxOccurs="unbounded" type="IntroInstall"/>
313 <xs:element name="IntroUninstall" minOccurs="0" maxOccurs="unbounded" type="IntroUninstall"/>
314 <xs:element name="IntroReinstall" minOccurs="0" maxOccurs="unbounded" type="IntroReinstall"/>
315 <xs:element name="IntroUpgrade" minOccurs="0" maxOccurs="unbounded" type="IntroUpgrade"/>
316 <xs:element name="PackageRequired" minOccurs="0" maxOccurs="unbounded" type="PackageRequired"/>
317 <xs:element name="ModuleRequired" minOccurs="0" maxOccurs="unbounded" type="ModuleRequired"/>
318 <xs:element name="CodeInstall" minOccurs="0" maxOccurs="unbounded" type="CodeInstall"/>
319 <xs:element name="CodeUpgrade" minOccurs="0" maxOccurs="unbounded" type="CodeUpgrade" />
320 <xs:element name="CodeUninstall" minOccurs="0" maxOccurs="unbounded" type="CodeUninstall" />
321 <xs:element name="CodeReinstall" minOccurs="0" maxOccurs="unbounded" type="CodeReinstall" />
322 <xs:element name="BuildDate" minOccurs="0" maxOccurs="1" type="xs:token"/>
323 <xs:element name="BuildHost" minOccurs="0" maxOccurs="1" type="xs:token"/>
324 <xs:element name="Filelist" minOccurs="1" maxOccurs="1" type="Filelist"/>
325 <xs:element name="DatabaseInstall" minOccurs="0" maxOccurs="unbounded" type="DatabaseInstall" />
326 <xs:element name="DatabaseUpgrade" minOccurs="0" maxOccurs="unbounded" type="DatabaseUpgrade" />
327 <xs:element name="DatabaseReinstall" minOccurs="0" maxOccurs="unbounded" type="DatabaseReinstall" />
328 <xs:element name="DatabaseUninstall" minOccurs="0" maxOccurs="unbounded" type="DatabaseUninstall" />
329 </xs:all>
330 <xs:attribute name="version" use="required" type="xs:anySimpleType"/>
331 </xs:complexType>
332
333 <xs:complexType name="ChangeLog">
334 <xs:simpleContent>
335 <xs:extension base="xs:string">
336 <xs:attribute name="Date" use="required" type="xs:anySimpleType"/>
337 <xs:attribute name="Version" use="required" type="xs:anySimpleType"/>
338 </xs:extension>
339 </xs:simpleContent>
340 </xs:complexType>
341
342 <xs:complexType name="Description">
343 <xs:simpleContent>
344 <xs:extension base="xs:string">
345 <xs:attribute name="Lang" use="optional" type="xs:anySimpleType"/>
346 <xs:attribute name="Format" use="optional" type="xs:anySimpleType"/>
347 <xs:attribute name="Translatable" use="optional" type="xs:anySimpleType"/>
348 </xs:extension>
349 </xs:simpleContent>
350 </xs:complexType>
351
352 <xs:complexType name="Framework">
353 <xs:simpleContent>
354 <xs:extension base="xs:string">
355 <xs:attribute name="Minimum" use="optional" type="xs:anySimpleType"/>
356 <xs:attribute name="Maximum" use="optional" type="xs:anySimpleType"/>
357 </xs:extension>
358 </xs:simpleContent>
359 </xs:complexType>
360  
361 <xs:complexType name="Filelist">
362 <xs:sequence>
363 <xs:element name="File" maxOccurs="unbounded" type="File" />
364 </xs:sequence>
365 </xs:complexType>
366
367 <xs:complexType name="File">
368 <xs:simpleContent>
369 <xs:extension base="xs:string">
370 <xs:attribute name="Location" use="required" type="xs:anySimpleType"/>
371 <xs:attribute name="Permission" use="required" type="xs:anySimpleType"/>
372 <xs:attribute name="Encode" use="required" type="xs:anySimpleType"/>
373 </xs:extension>
374 </xs:simpleContent>
375 </xs:complexType>
376
377 <xs:complexType name="PackageRequired">
378 <xs:simpleContent>
379 <xs:extension base="xs:string">
380 <xs:attribute name="Version" use="required" type="xs:anySimpleType"/>
381 </xs:extension>
382 </xs:simpleContent>
383 </xs:complexType>
384
385 <xs:complexType name="ModuleRequired">
386 <xs:simpleContent>
387 <xs:extension base="xs:string">
388 <xs:attribute name="Version" use="required" type="xs:anySimpleType"/>
389 </xs:extension>
390 </xs:simpleContent>
391 </xs:complexType>
392
393 <xs:complexType name="IntroInstall">
394 <xs:simpleContent>
395 <xs:extension base="xs:string">
396 <xs:attribute name="Type" use="required" type="xs:anySimpleType"/>
397 <xs:attribute name="Lang" use="optional" type="xs:anySimpleType"/>
398 <xs:attribute name="Title" use="optional" type="xs:anySimpleType"/>
399 <xs:attribute name="Translatable" use="optional" type="xs:anySimpleType"/>
400 <xs:attribute name="Format" use="optional" type="xs:anySimpleType"/>
401 </xs:extension>
402 </xs:simpleContent>
403 </xs:complexType>
404 <xs:complexType name="IntroUninstall">
405 <xs:simpleContent>
406 <xs:extension base="xs:string">
407 <xs:attribute name="Type" use="required" type="xs:anySimpleType"/>
408 <xs:attribute name="Lang" use="optional" type="xs:anySimpleType"/>
409 <xs:attribute name="Title" use="optional" type="xs:anySimpleType"/>
410 <xs:attribute name="Translatable" use="optional" type="xs:anySimpleType"/>
411 <xs:attribute name="Format" use="optional" type="xs:anySimpleType"/>
412 </xs:extension>
413 </xs:simpleContent>
414 </xs:complexType>
415 <xs:complexType name="IntroReinstall">
416 <xs:simpleContent>
417 <xs:extension base="xs:string">
418 <xs:attribute name="Type" use="required" type="xs:anySimpleType"/>
419 <xs:attribute name="Lang" use="optional" type="xs:anySimpleType"/>
420 <xs:attribute name="Title" use="optional" type="xs:anySimpleType"/>
421 <xs:attribute name="Translatable" use="optional" type="xs:anySimpleType"/>
422 <xs:attribute name="Format" use="optional" type="xs:anySimpleType"/>
423 </xs:extension>
424 </xs:simpleContent>
425 </xs:complexType>
426 <xs:complexType name="IntroUpgrade">
427 <xs:simpleContent>
428 <xs:extension base="xs:string">
429 <xs:attribute name="Type" use="required" type="xs:anySimpleType"/>
430 <xs:attribute name="Lang" use="optional" type="xs:anySimpleType"/>
431 <xs:attribute name="Title" use="optional" type="xs:anySimpleType"/>
432 <xs:attribute name="Translatable" use="optional" type="xs:anySimpleType"/>
433 <xs:attribute name="Version" use="optional" type="xs:anySimpleType"/>
434 <xs:attribute name="Format" use="optional" type="xs:anySimpleType"/>
435 </xs:extension>
436 </xs:simpleContent>
437 </xs:complexType>
438
439 <xs:complexType name="CodeInstall">
440 <xs:simpleContent>
441 <xs:extension base="xs:string">
442 <xs:attribute name="Type" use="optional" type="xs:anySimpleType"/>
443 </xs:extension>
444 </xs:simpleContent>
445 </xs:complexType>
446 <xs:complexType name="CodeUninstall">
447 <xs:simpleContent>
448 <xs:extension base="xs:string">
449 <xs:attribute name="Type" use="optional" type="xs:anySimpleType"/>
450 </xs:extension>
451 </xs:simpleContent>
452 </xs:complexType>
453 <xs:complexType name="CodeReinstall">
454 <xs:simpleContent>
455 <xs:extension base="xs:string">
456 <xs:attribute name="Type" use="optional" type="xs:anySimpleType"/>
457 </xs:extension>
458 </xs:simpleContent>
459 </xs:complexType>
460 <xs:complexType name="CodeUpgrade">
461 <xs:simpleContent>
462 <xs:extension base="xs:string">
463 <xs:attribute name="Type" use="optional" type="xs:anySimpleType"/>
464 <xs:attribute name="Version" use="optional" type="xs:anySimpleType"/>
465 </xs:extension>
466 </xs:simpleContent>
467 </xs:complexType>
468
469 <!-- -->
470 <!-- Database stuff -->
471 <!-- -->
472
473 <xs:complexType name="DatabaseInstall">
474 <xs:choice maxOccurs="unbounded">
475 <xs:element name="TableCreate" minOccurs="0" maxOccurs="unbounded" type="TableCreate" />
476 <xs:element name="TableAlter" minOccurs="0" maxOccurs="unbounded" type="TableAlter" />
477 <xs:element name="Insert" minOccurs="0" maxOccurs="unbounded" type="Insert" />
478 </xs:choice>
479 <xs:attribute name="Type" use="optional" type="xs:anySimpleType"/>
480 </xs:complexType>
481 <xs:complexType name="DatabaseUninstall">
482 <xs:choice maxOccurs="unbounded">
483 <xs:element name="TableDrop" minOccurs="0" maxOccurs="unbounded" type="TableDrop" />
484 <xs:element name="TableAlter" minOccurs="0" maxOccurs="unbounded" type="TableAlter" />
485 </xs:choice>
486 <xs:attribute name="Type" use="optional" type="xs:anySimpleType"/>
487 </xs:complexType>
488 <xs:complexType name="DatabaseReinstall">
489 <xs:simpleContent>
490 <xs:extension base="xs:string">
491 <xs:attribute name="Type" use="optional" type="xs:anySimpleType"/>
492 </xs:extension>
493 </xs:simpleContent>
494 </xs:complexType>
495 <xs:complexType name="DatabaseUpgrade">
496 <xs:choice maxOccurs="unbounded">
497 <xs:element name="TableCreate" minOccurs="0" maxOccurs="unbounded" type="TableCreate"/>
498 <xs:element name="TableAlter" minOccurs="0" maxOccurs="unbounded" type="TableAlter"/>
499 <xs:element name="Insert" minOccurs="0" maxOccurs="unbounded" type="Insert"/>
500 </xs:choice>
501 <xs:attribute name="Type" use="optional" type="xs:anySimpleType"/>
502 <xs:attribute name="Version" use="optional" type="xs:anySimpleType"/>
503 </xs:complexType>
504
505 <xs:complexType name="TableCreate">
506 <xs:choice maxOccurs="unbounded">
507 <xs:element name="Column" maxOccurs="unbounded" type="Column"/>
508 <xs:element name="ForeignKey" minOccurs="0" maxOccurs="unbounded" type="ForeignKey"/>
509 <xs:element name="Index" minOccurs="0" maxOccurs="unbounded" type="Index"/>
510 <xs:element name="Unique" minOccurs="0" maxOccurs="unbounded" type="Unique"/>
511 </xs:choice>
512 <xs:attribute name="Type" use="optional" type="xs:anySimpleType"/>
513 <xs:attribute name="Name" use="optional" type="xs:anySimpleType"/>
514 <xs:attribute name="Version" use="optional" type="xs:anySimpleType"/>
515 </xs:complexType>
516  
517 <xs:complexType name="TableAlter">
518 <xs:choice maxOccurs="unbounded">
519 <xs:element name="ColumnAdd" minOccurs="0" maxOccurs="unbounded" type="ColumnAdd"/>
520 <xs:element name="ColumnChange" minOccurs="0" maxOccurs="unbounded" type="ColumnChange"/>
521 <xs:element name="ColumnDrop" minOccurs="0" maxOccurs="unbounded" type="ColumnDrop"/>
522 <xs:element name="ForeignKeyCreate" minOccurs="0" maxOccurs="unbounded" type="ForeignKeyCreate"/>
523 <xs:element name="ForeignKeyDrop" minOccurs="0" maxOccurs="unbounded" type="ForeignKeyDrop"/>
524 <xs:element name="IndexCreate" minOccurs="0" maxOccurs="unbounded" type="IndexCreate"/>
525 <xs:element name="IndexDrop" minOccurs="0" maxOccurs="unbounded" type="IndexDrop"/>
526 <xs:element name="UniqueCreate" minOccurs="0" maxOccurs="unbounded" type="UniqueCreate"/>
527 <xs:element name="UniqueDrop" minOccurs="0" maxOccurs="unbounded" type="UniqueDrop"/>
528 </xs:choice>
529 <xs:attribute name="Type" use="optional" type="xs:anySimpleType"/>
530 <xs:attribute name="Name" use="optional" type="xs:anySimpleType"/>
531 <xs:attribute name="Version" use="optional" type="xs:anySimpleType"/>
532 </xs:complexType>
533
534 <xs:complexType name="TableDrop">
535 <xs:simpleContent>
536 <xs:extension base="xs:string">
537 <xs:attribute name="Name" use="required" type="xs:anySimpleType"/>
538 <xs:attribute name="Type" use="optional" type="xs:anySimpleType"/>
539 </xs:extension>
540 </xs:simpleContent>
541 </xs:complexType>
542
543 <!-- Columns -->
544
545 <xs:complexType name="Column">
546 <xs:simpleContent>
547 <xs:extension base="xs:string">
548 <xs:attribute name="Type" use="optional" type="xs:anySimpleType"/>
549 <xs:attribute name="AutoIncrement" use="optional" type="xs:anySimpleType"/>
550 <xs:attribute name="Name" use="required" type="xs:anySimpleType"/>
551 <xs:attribute name="Required" use="optional" type="xs:anySimpleType"/>
552 <xs:attribute name="Size" use="optional" type="xs:anySimpleType"/>
553 <xs:attribute name="PrimaryKey" use="optional" type="xs:anySimpleType"/>
554 <xs:attribute name="Default" use="optional" type="xs:anySimpleType"/>
555 </xs:extension>
556 </xs:simpleContent>
557 </xs:complexType>
558 <xs:complexType name="ColumnAdd">
559 <xs:simpleContent>
560 <xs:extension base="xs:string">
561 <xs:attribute name="Type" use="optional" type="xs:anySimpleType"/>
562 <xs:attribute name="AutoIncrement" use="optional" type="xs:anySimpleType"/>
563 <xs:attribute name="Name" use="required" type="xs:anySimpleType"/>
564 <xs:attribute name="Required" use="optional" type="xs:anySimpleType"/>
565 <xs:attribute name="Size" use="optional" type="xs:anySimpleType"/>
566 <xs:attribute name="PrimaryKey" use="optional" type="xs:anySimpleType"/>
567 <xs:attribute name="Default" use="optional" type="xs:anySimpleType"/>
568 </xs:extension>
569 </xs:simpleContent>
570 </xs:complexType>
571 <xs:complexType name="ColumnChange">
572 <xs:simpleContent>
573 <xs:extension base="xs:string">
574 <xs:attribute name="Type" use="optional" type="xs:anySimpleType"/>
575 <xs:attribute name="Default" use="optional" type="xs:anySimpleType"/>
576 <xs:attribute name="NameOld" use="optional" type="xs:anySimpleType"/>
577 <xs:attribute name="NameNew" use="optional" type="xs:anySimpleType"/>
578 <xs:attribute name="AutoIncrement" use="optional" type="xs:anySimpleType"/>
579 <xs:attribute name="Required" use="optional" type="xs:anySimpleType"/>
580 <xs:attribute name="Size" use="optional" type="xs:anySimpleType"/>
581 <xs:attribute name="PrimaryKey" use="optional" type="xs:anySimpleType"/>
582 </xs:extension>
583 </xs:simpleContent>
584 </xs:complexType>
585 <xs:complexType name="ColumnDrop">
586 <xs:attribute name="Name" use="required" type="xs:anySimpleType"/>
587 </xs:complexType>
588
589 <!-- Foreign Keys -->
590
591 <xs:complexType name="ForeignKey">
592 <xs:sequence>
593 <xs:element name="Reference" type="Reference" maxOccurs="unbounded" />
594 </xs:sequence>
595 <xs:attribute name="ForeignTable" use="required" type="xs:anySimpleType"/>
596 </xs:complexType>
597  
598 <xs:complexType name="ForeignKeyCreate">
599 <xs:sequence>
600 <xs:element name="Reference" type="Reference" maxOccurs="unbounded" />
601 </xs:sequence>
602 <xs:attribute name="ForeignTable" use="required" type="xs:anySimpleType"/>
603 </xs:complexType>
604  
605 <xs:complexType name="ForeignKeyDrop">
606 <xs:sequence>
607 <xs:element name="Reference" type="Reference" maxOccurs="unbounded" />
608 </xs:sequence>
609 <xs:attribute name="ForeignTable" use="required" type="xs:anySimpleType"/>
610 </xs:complexType>
611  
612 <xs:complexType name="Reference">
613 <xs:simpleContent>
614 <xs:extension base="xs:string">
615 <xs:attribute name="Local" use="required" type="xs:anySimpleType"/>
616 <xs:attribute name="Foreign" use="required" type="xs:anySimpleType"/>
617 </xs:extension>
618 </xs:simpleContent>
619 </xs:complexType>
620
621 <!-- Unique columns -->
622
623 <xs:complexType name="Unique">
624 <xs:sequence>
625 <xs:element name="UniqueColumn" maxOccurs="unbounded" type="UniqueColumn"/>
626 </xs:sequence>
627 <xs:attribute name="Name" use="optional" type="xs:anySimpleType"/>
628 </xs:complexType>
629  
630 <xs:complexType name="UniqueColumn">
631 <xs:simpleContent>
632 <xs:extension base="xs:string">
633 <xs:attribute name="Name" use="required" type="xs:anySimpleType"/>
634 </xs:extension>
635 </xs:simpleContent>
636 </xs:complexType>
637  
638 <xs:complexType name="UniqueCreate">
639 <xs:simpleContent>
640 <xs:extension base="xs:string">
641 <xs:attribute name="Name" use="required" type="xs:anySimpleType"/>
642 </xs:extension>
643 </xs:simpleContent>
644 </xs:complexType>
645  
646 <xs:complexType name="UniqueDrop">
647 <xs:simpleContent>
648 <xs:extension base="xs:string">
649 <xs:attribute name="Name" use="required" type="xs:anySimpleType"/>
650 </xs:extension>
651 </xs:simpleContent>
652 </xs:complexType>
653
654 <!-- Index columns -->
655
656 <xs:complexType name="Index">
657 <xs:sequence>
658 <xs:element name="IndexColumn" type="IndexColumn" maxOccurs="unbounded" />
659 </xs:sequence>
660 <xs:attribute name="Name" use="optional" type="xs:anySimpleType"/>
661 </xs:complexType>
662  
663 <xs:complexType name="IndexColumn">
664 <xs:simpleContent>
665 <xs:extension base="xs:string">
666 <xs:attribute name="Name" use="required" type="xs:anySimpleType"/>
667 </xs:extension>
668 </xs:simpleContent>
669 </xs:complexType>
670  
671 <xs:complexType name="IndexCreate">
672 <xs:simpleContent>
673 <xs:extension base="xs:string">
674 <xs:attribute name="Name" use="required" type="xs:anySimpleType"/>
675 </xs:extension>
676 </xs:simpleContent>
677 </xs:complexType>
678  
679 <xs:complexType name="IndexDrop">
680 <xs:simpleContent>
681 <xs:extension base="xs:string">
682 <xs:attribute name="Name" use="required" type="xs:anySimpleType"/>
683 </xs:extension>
684 </xs:simpleContent>
685 </xs:complexType>
686
687 <!-- Insert stuff into database -->
688
689 <xs:complexType name="Insert">
690 <xs:sequence>
691 <xs:element name="Data" maxOccurs="unbounded" type="Data"/>
692 </xs:sequence>
693 <xs:attribute name="Type" use="optional" type="xs:anySimpleType"/>
694 <xs:attribute name="Table" use="required" type="xs:anySimpleType"/>
695 <xs:attribute name="Version" use="optional" type="xs:anySimpleType"/>
696 </xs:complexType>
697  
698 <xs:complexType name="Data">
699 <xs:simpleContent>
700 <xs:extension base="xs:string">
701 <xs:attribute name="Key" use="optional" type="xs:anySimpleType"/>
702 <xs:attribute name="Type" use="optional" type="xs:anySimpleType"/>
703 </xs:extension>
704 </xs:simpleContent>
705 </xs:complexType>
706 </xs:schema>
707 ~;
708 }
709  
710 9 1;
711  
712 __END__
↑ Summary script/de_opm.pl »