1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
|
#
# PPM::XML::PPD
#
# Definition of the PPD file format.
#
###############################################################################
use PPM::XML::ValidatingElement;
use Exporter;
###############################################################################
# Set up PPM::XML::PPD to export its sub-packages so that we can use them in
# other XML documents without too much effort.
###############################################################################
package PPM::XML::PPD;
use vars qw( $VERSION );
$VERSION = '0.01_01';
@ISA = qw( Exporter );
%EXPORT_TAGS = ( 'elements' =>
[ '%SOFTPKG::', '%IMPLEMENTATION::', '%DEPENDENCY::',
'%TITLE::', '%ABSTRACT::', '%AUTHOR::',
'%LANGUAGE::', '%LICENSE::', '%OS::',
'%OSVERSION::', '%PERLCORE::', '%PROCESSOR::',
'%CODEBASE::', '%INSTALL::', '%UNINSTALL::',
'%ARCHITECTURE::', '%PROVIDE::', '%REQUIRE::',
] );
Exporter::export_ok_tags( 'elements' );
###############################################################################
# PPD Element: SOFTPKG
###############################################################################
package PPM::XML::PPD::SOFTPKG;
@ISA = qw( PPM::XML::ValidatingElement );
@oattrs = qw( VERSION );
@rattrs = qw( NAME );
@okids = qw( ABSTRACT AUTHOR IMPLEMENTATION LICENSE
TITLE INSTALL UNINSTALL PROVIDE REQUIRE);
###############################################################################
# PPD Element: TITLE
###############################################################################
package PPM::XML::PPD::TITLE;
@ISA = qw( PPM::XML::ValidatingElement );
###############################################################################
# PPD Element: ABSTRACT
###############################################################################
package PPM::XML::PPD::ABSTRACT;
@ISA = qw( PPM::XML::ValidatingElement );
###############################################################################
# PPD Element: AUTHOR
###############################################################################
package PPM::XML::PPD::AUTHOR;
@ISA = qw( PPM::XML::ValidatingElement );
###############################################################################
# PPD Element: PROVIDE
###############################################################################
package PPM::XML::PPD::PROVIDE;
@ISA = qw( PPM::XML::ValidatingElement );
@oattrs = qw( VERSION );
@rattrs = qw( NAME );
###############################################################################
# PPD Element: REQUIRE
###############################################################################
package PPM::XML::PPD::REQUIRE;
@ISA = qw( PPM::XML::ValidatingElement );
@oattrs = qw( VERSION );
@rattrs = qw( NAME );
###############################################################################
# PPD Element: LICENSE
###############################################################################
package PPM::XML::PPD::LICENSE;
@ISA = qw( PPM::XML::ValidatingElement );
@rattrs = qw( HREF );
###############################################################################
# PPD Element: IMPLEMENTATION
###############################################################################
package PPM::XML::PPD::IMPLEMENTATION;
@ISA = qw( PPM::XML::ValidatingElement );
@okids = qw( DEPENDENCY INSTALL LANGUAGE OS OSVERSION PERLCORE PROCESSOR
UNINSTALL ARCHITECTURE PROVIDE REQUIRE);
@rkids = qw( CODEBASE );
###############################################################################
# PPD Element: OS
###############################################################################
package PPM::XML::PPD::OS;
@ISA = qw( PPM::XML::ValidatingElement );
@rattrs = qw( VALUE );
sub validate_possible_attrs
{
my $self = shift;
$self->compatibility_check();
$self->SUPER::validate_possible_attrs( @_ );
}
sub validate_required_attrs
{
my $self = shift;
$self->compatibility_check();
$self->SUPER::validate_required_attrs( @_ );
}
sub compatibility_check
{
my $self = shift;
if (exists $self->{NAME})
{
$self->{VALUE} = $self->{NAME};
delete $self->{NAME};
}
}
###############################################################################
# PPD Element: OSVERSION
###############################################################################
package PPM::XML::PPD::OSVERSION;
@ISA = qw( PPM::XML::ValidatingElement );
@rattrs = qw( VALUE );
sub validate_possible_attrs
{
my $self = shift;
$self->compatibility_check();
$self->SUPER::validate_possible_attrs( @_ );
}
sub validate_required_attrs
{
my $self = shift;
$self->compatibility_check();
$self->SUPER::validate_required_attrs( @_ );
}
sub compatibility_check
{
my $self = shift;
if (exists $self->{NAME})
{
$self->{VALUE} = $self->{NAME};
delete $self->{NAME};
}
}
###############################################################################
# PPD Element: PROCESSOR
###############################################################################
package PPM::XML::PPD::PROCESSOR;
@ISA = qw( PPM::XML::ValidatingElement );
@rattrs = qw( VALUE );
sub validate_possible_attrs
{
my $self = shift;
$self->compatibility_check();
$self->SUPER::validate_possible_attrs( @_ );
}
sub validate_required_attrs
{
my $self = shift;
$self->compatibility_check();
$self->SUPER::validate_required_attrs( @_ );
}
sub compatibility_check
{
my $self = shift;
if (exists $self->{NAME})
{
$self->{VALUE} = $self->{NAME};
delete $self->{NAME};
}
}
###############################################################################
# PPD Element: ARCHITECTURE
###############################################################################
package PPM::XML::PPD::ARCHITECTURE;
@ISA = qw( PPM::XML::ValidatingElement );
@rattrs = qw( VALUE );
sub validate_possible_attrs
{
my $self = shift;
$self->compatibility_check();
$self->SUPER::validate_possible_attrs( @_ );
}
sub validate_required_attrs
{
my $self = shift;
$self->compatibility_check();
$self->SUPER::validate_required_attrs( @_ );
}
sub compatibility_check
{
my $self = shift;
if (exists $self->{NAME})
{
$self->{VALUE} = $self->{NAME};
delete $self->{NAME};
}
}
###############################################################################
# PPD Element: CODEBASE
###############################################################################
package PPM::XML::PPD::CODEBASE;
@ISA = qw( PPM::XML::ValidatingElement );
@oattrs = qw( FILENAME );
@rattrs = qw( HREF );
###############################################################################
# PPD Element: DEPENDENCY
###############################################################################
package PPM::XML::PPD::DEPENDENCY;
@ISA = qw( PPM::XML::ValidatingElement );
@rattrs = qw( NAME );
@oattrs = qw( VERSION );
###############################################################################
# PPD Element: LANGUAGE
###############################################################################
package PPM::XML::PPD::LANGUAGE;
@ISA = qw( PPM::XML::ValidatingElement );
@rattrs = qw( VALUE );
###############################################################################
# PPD Element: PERLCORE
###############################################################################
package PPM::XML::PPD::PERLCORE;
@ISA = qw( PPM::XML::ValidatingElement );
@rattrs = qw( VERSION );
###############################################################################
# PPD Element: INSTALL
###############################################################################
package PPM::XML::PPD::INSTALL;
@ISA = qw( PPM::XML::ValidatingElement );
@oattrs = qw( HREF EXEC );
###############################################################################
# PPD Element: UNINSTALL
###############################################################################
package PPM::XML::PPD::UNINSTALL;
@ISA = qw( PPM::XML::ValidatingElement );
@oattrs = qw( HREF EXEC );
__END__
###############################################################################
# POD
###############################################################################
=head1 NAME
PPM::XML::PPD - PPD file format and XML parsing elements
=head1 SYNOPSIS
use XML::Parser;
use PPM::XML::PPD;
$p = new PPM::XML::Parser( Style => 'Objects', Pkg => 'PPM::XML::PPD' );
...
=head1 DESCRIPTION
This module provides a set of classes for parsing PPD files using the
C<XML::Parser> module. Each of the classes is derived from
C<PPM::XML::ValidatingElement>, with optional/required attributes/children
enforced.
=head1 MAJOR ELEMENTS
=head2 SOFTPKG
Defines a Perl Package. The root of a PPD document is B<always> a SOFTPKG
element. The SOFTPKG element allows for the following attributes:
=over 4
=item NAME
Required attribute. Name of the package (e.g. "Foobar").
=item VERSION
Version number of the package, in comma-delimited format (e.g. "1,0,0,0").
=back
=head2 IMPLEMENTATION
Child of SOFTPKG, used to describe a particular implementation of the Perl
Package. Multiple instances are valid, and should be used to describe
different implementations/ports for different operating systems or
architectures.
=head2 DEPENDENCY
Child of SOFTPKG or IMPLEMENTATION, used to indicate a dependency this Perl
Package has on another Perl Package. Multiple instances are valid. The
DEPENDENCY element allows for the following attributes:
=over 4
=item NAME
Name of the package that this implementation is dependant upon.
=item VERSION
Version number of the dependency, in comma-delimited format (e.g. "1,0,0,0").
=back
=head1 MINOR ELEMENTS
=head2 TITLE
Child of SOFTPKG, used to state the title of the Perl Package. Only one
instance should be present.
=head2 ABSTRACT
Child of SOFTPKG, used to provide a short description outlining the nature and
purpose of the Perl Package. Only one instance should be present.
=head2 AUTHOR
Child of SOFTPKG, used to provide information about the author(s) of the Perl
Package. Multiple instances are valid.
=head2 LANGUAGE
Child of IMPLEMENTATION, used to specify the language used within the given
implementation of the Perl Package. Only one instance should be present.
=head2 LICENSE
Child of SOFTPKG, indicating the location of the appropriate license agreement
or copyright notice for the Perl Package. Only one instance should be
present. The LICENSE element allows for the following attributes:
=over 4
=item HREF
Required attribute. A reference to the location of the license agreement or
copyright notice for this package.
=back
=head2 OS
Child of IMPLEMENTATION, used to outline the operating system required for this
implementation of the Perl Package. Multiple instances are valid. Valid
values can be taken from the OSD Specification and it's OS element. The OS
element allows for the following attributes:
=over 4
=item VALUE
The name of the operating system required for this implementation of the Perl
Package. This value should be obtained from Config.pm as 'osname'.
=back
Note that previous versions of the PPD format used a 'NAME' attribute. It's
use has been deprecated in preference of the 'VALUE' attribute. Also note that
during validation, this element will automatically convert any existing 'NAME'
attribute to be a 'VALUE' attribute.
=head2 OSVERSION
Child of IMPLEMENTATION, used to outline the required version of the operating
system required for this implementation of the Perl Package. Only one instance
should be present. The OSVERSION element allows for the following attributes:
=over 4
=item VALUE
The version of the operating system required for installation of this
implementation of the package, in a comma-delimited format (e.g. "3,1,0,0").
=back
Note that previous versions of the PPD format used a 'NAME' attribute. It's
use has been deprecated in preference of the 'VALUE' attribute. Also note that
during validation, this element will automatically convert any existing 'NAME'
attribute to be a 'VALUE' attribute.
=head2 PERLCORE
Child of IMPLEMENTATION, used to specify the minimum version of the Perl core
distribution that this Perl Package is to be used with. Only one instance
should be present. The PERLCORE element allows for the following attributes:
=over 4
=item VERSION
Version of the Perl core that is required for this implementation of the Perl
Package.
=back
=head2 PROCESSOR
Child of IMPLEMENTATION, outlining the cpu required for this implementation
of the Perl Package. Only one instance should be present. The PROCESSOR
element allows for the following attributes:
=over 4
=item VALUE
CPU required for the installation of this implementation of the Perl Package.
The following values are all valid according to the OSD Specification:
x86 alpha mips sparc 680x0
=back
Note that previous versions of the PPD format used a 'NAME' attribute. It's
use has been deprecated in preference of the 'VALUE' attribute. Also note that
during validation, this element will automatically convert any existing 'NAME'
attribute to be a 'VALUE' attribute.
=head2 CODEBASE
Child of IMPLEMENTATION, indicating a location where an archive of the Perl
Package can be retrieved. Multiple instances are valid, and can be used to
indicate multiple possible locations where the same version of the Perl Package
can be retrieved. The CODEBASE element allows for the following attributes:
=over 4
=item FILENAME
???
=item HREF
Required attribute. A reference to the location of the Perl Package
distribution.
=back
=head2 INSTALL
Child of IMPLEMENTATION, used to provide either a reference to an
installation script or a series of commands which can be used to install
the Perl Package once it has been retrieved. If the EXEC attribute is not
specified, the value is assumed to be one or more commands, separated by
`;;'. Each such command will be executed by the Perl `system()' function.
Only one instance should be present. The INSTALL element allows for
the following attributes:
=over 4
=item HREF
Reference to an external script which should be retrieved and run as part
of the installation process. Both filenames and URLs should be considered
valid.
=item EXEC
Name of interpreter/shell used to execute the installation script.
If the value of EXEC is `PPM_PERL', the copy of Perl that is executing
PPM itself ($^X) is used to execute the install script.
=back
=head2 UNINSTALL
Child of IMPLEMENTATION, used to provide either a reference to an
uninstallation script or a raw Perl script which can be used to uninstall the
Perl Package at a later point. Only one instance should be present. The
UNINSTALL element allows for the following attributs:
=over 4
=item HREF
Reference to an external script which should be retrieved and run as part of
the removal process. Both filenames and URLs should be considered valid.
=item EXEC
Name of interpreter/shell used to execute the uninstallation script.
If the value of EXEC is `PPM_PERL', the copy of Perl that is executing
PPM itself ($^X) is used to execute the install script.
=back
=head1 DOCUMENT TYPE DEFINITION
The DTD for PPD documents is available from the ActiveState website and the
latest version can be found at http://www.ActiveState.com/PPM/DTD/ppd.dtd
This revision of the C<PPM::XML::PPD> module implements the following DTD:
<!ELEMENT SOFTPKG (ABSTRACT | AUTHOR | IMPLEMENTATION | LICENSE | TITLE)*>
<!ATTLIST SOFTPKG NAME CDATA #REQUIRED
VERSION CDATA #IMPLIED>
<!ELEMENT TITLE (#PCDATA)>
<!ELEMENT ABSTRACT (#PCDATA)>
<!ELEMENT AUTHOR (#PCDATA)>
<!ELEMENT LICENSE EMPTY>
<!ATTLIST LICENSE HREF CDATA #REQUIRED>
<!ELEMENT IMPLEMENTATION (CODEBASE | DEPENDENCY | LANGUAGE | OS |
OSVERSION | PERLCORE | PROCESSOR | INSTALL |
UNINSTALL) *>
<!ELEMENT CODEBASE EMPTY>
<!ATTLIST CODEBASE FILENAME CDATA #IMPLIED
HREF CDATA #REQUIRED>
<!ELEMENT DEPENDENCY EMPTY>
<!ATTLIST DEPENDENCY VERSION CDATA #IMPLIED
NAME CDATA #REQUIRED>
<!ELEMENT LANGUAGE EMPTY>
<!ATTLIST LANGUAGE VALUE CDATA #REQUIRED>
<!ELEMENT OS EMPTY>
<!ATTLIST OS VALUE CDATA #REQUIRED>
<!ELEMENT OSVERSION EMPTY>
<!ATTLIST OSVERSION VALUE CDATA #REQUIRED>
<!ELEMENT PERLCORE EMPTY>
<!ATTLIST PERLCORE VERSION CDATA #REQUIRED>
<!ELEMENT PROCESSOR EMPTY>
<!ATTLIST PROCESSOR VALUE CDATA #REQUIRED>
<!ELEMENT INSTALL (#PCDATA)>
<!ATTLIST INSTALL HREF CDATA #IMPLIED
EXEC CDATA #IMPLIED>
<!ELEMENT UNINSTALL (#PCDATA)>
<!ATTLIST UNINSTALL HREF CDATA #IMPLIED
EXEC CDATA #IMPLIED>
=head1 SAMPLE PPD FILE
The following is a sample PPD file describing the C<Math-MatrixBool> module.
Note that this may B<not> be a current/proper description of this module and is
for sample purposes only.
<SOFTPKG NAME="Math-MatrixBool" VERSION="4,2,0,0">
<TITLE>Math-MatrixBool</TITLE>
<ABSTRACT>Easy manipulation of matrices of booleans (Boolean Algebra)</ABSTRACT>
<AUTHOR>Steffen Beyer (sb@sdm.de)</AUTHOR>
<LICENSE HREF="http://www.ActiveState.com/packages/Math-MatrixBool/license.html" />
<IMPLEMENTATION>
<OS VALUE="WinNT" />
<OS VALUE="Win95" />
<PROCESSOR VALUE="x86" />
<CODEBASE HREF="http://www.ActiveState.com/packages/Math-MatrixBool/Math-MatrixBool-4.2-bin-1-Win32.tar.gz" />
<DEPENDENCY NAME="Bit-Vector" />
<INSTALL>
</INSTALL>
<UNINSTALL>
</UNINSTALL>
</IMPLEMENTATION>
<IMPLEMENTATION>
<DEPENDENCY NAME="Bit-Vector" />
<CODEBASE HREF="&CPAN;/CPAN/modules/by-module/Math/Math-MatrixBool-4.2.tar.gz" />
<INSTALL>
system("make"); ;;
system("make test"); ;;
system("make install"); ;;
</INSTALL>
</IMPLEMENTATION>
</SOFTPKG>
=head1 KNOWN BUGS/ISSUES
Elements which are required to be empty (e.g. LICENSE) are not enforced as
such.
Notations above about elements for which "only one instance" or "multiple
instances" are valid are not enforced; this primarily a guideline for
generating your own PPD files.
=head1 AUTHORS
Graham TerMarsch <grahamt@ActiveState.com>
Murray Nesbitt <murrayn@ActiveState.com>
Dick Hardt <dick_hardt@ActiveState.com>
=head1 HISTORY
v0.1 - Initial release
=head1 SEE ALSO
L<PPM::XML::ValidatingElement>,
L<PPM::XML::Element>,
L<XML::Parser>,
OSD Specification (http://www.microsoft.com/standards/osd/)
=cut
|