SGMLS(3) User Contributed Perl Documentation SGMLS(3)

SGMLS - class for postprocessing the output from the sgmls and nsgmls parsers.

use SGMLS;
my $parse = new SGMLS(STDIN);
my $event = $parse->next_event;
while ($event) {
  SWITCH: {
    ($event->type eq 'start_element') && do {
      my $element = $event->data;    # An object of class SGMLS_Element
      [[your code for the beginning of an element]]
      last SWITCH;
    };
    ($event->type eq 'end_element') && do {
      my $element = $event->data;    # An object of class SGMLS_Element
      [[your code for the end of an element]]
      last SWITCH;
    };
    ($event->type eq 'cdata') && do {
      my $cdata = $event->data;      # A string
      [[your code for character data]]
      last SWITCH;
    };
    ($event->type eq 'sdata') && do {
      my $sdata = $event->data;      # A string
      [[your code for system data]]
      last SWITCH;
    };
    ($event->type eq 're') && do {
      [[your code for a record end]]
      last SWITCH;
    };
    ($event->type eq 'pi') && do {
      my $pi = $event->data;         # A string
      [[your code for a processing instruction]]
      last SWITCH;
    };
    ($event->type eq 'entity') && do {
      my $entity = $event->data;     # An object of class SGMLS_Entity
      [[your code for an external entity]]
      last SWITCH;
    };
    ($event->type eq 'start_subdoc') && do {
      my $entity = $event->data;     # An object of class SGMLS_Entity
      [[your code for the beginning of a subdoc entity]]
      last SWITCH;
    };
    ($event->type eq 'end_subdoc') && do {
      my $entity = $event->data;     # An object of class SGMLS_Entity
      [[your code for the end of a subdoc entity]]
      last SWITCH;
    };
    ($event->type eq 'conforming') && do {
      [[your code for a conforming document]]
      last SWITCH;
    };
    die "Internal error: unknown event type " . $event->type . "\n";
  }
  $event = $parse->next_event;
}

The SGMLS package consists of several related classes: see "SGMLS", "SGMLS_Event", "SGMLS_Element", "SGMLS_Attribute", "SGMLS_Notation", and "SGMLS_Entity". All of these classes are available when you specify

use SGMLS;

Generally, the only object which you will create explicitly will belong to the "SGMLS" class; all of the others will then be created automatically for you over the course of the parse. Much fuller documentation is available in the ".sgml" files in the "DOC/" directory of the "SGMLS.pm" distribution.

This class holds a single parse. When you create an instance of it, you specify a file handle as an argument (if you are reading the output of sgmls or nsgmls from a pipe, the file handle will ordinarily be "STDIN"):

my $parse = new SGMLS(STDIN);

The most important method for this class is "next_event", which reads and returns the next major event from the input stream. It is important to note that the "SGMLS" class deals with most ESIS events itself: attributes and entity definitions, for example, are collected and stored automatically and invisibly to the user. The following list contains all of the methods for the "SGMLS" class:

This class holds a single major event, as generated by the "next_event" method in the "SGMLS" class. It uses the following methods:

This class is used for elements, and contains all associated information (such as the element's attributes). It recognises the following methods:

Each instance of an attribute for each "SGMLS_Element" is an object belonging to this class, which recognises the following methods:

All declared notations appear as objects belonging to this class, which recognises the following methods:

All declared entities appear as objects belonging to this class, which recognises the following methods:

Copyright 1994 and 1995 by David Megginson, "dmeggins@aix1.uottawa.ca". Distributed under the terms of the Gnu General Public License (version 2, 1991) -- see the file "COPYING" which is included in the SGMLS.pm distribution.

SGMLS::Output and SGMLS::Refs.

Hey! The above document had some coding errors, which are explained below:

'=item' outside of any '=over'
You forgot a '=back' before '=head2'
'=item' outside of any '=over'
You forgot a '=back' before '=head2'
'=item' outside of any '=over'
You forgot a '=back' before '=head2'
'=item' outside of any '=over'
You forgot a '=back' before '=head2'
'=item' outside of any '=over'
You forgot a '=back' before '=head2'
'=item' outside of any '=over'
You forgot a '=back' before '=head1'
2024-09-01 perl v5.40.0