home *** CD-ROM | disk | FTP | other *** search
/ Chip: Windows 2000 Professional Resource Kit / W2KPRK.iso / apps / perl / ActivePerl.exe / data.z / PPD.pm < prev    next >
Encoding:
Text File  |  1999-10-14  |  18.1 KB  |  606 lines

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