man SGMLS () - class for postprocessing the output from the sgmls and nsgmls parsers.
NAME
SGMLS - class for postprocessing the output from the sgmls and nsgmls parsers.
SYNOPSIS
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; }
DESCRIPTION
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 CWSGMLS 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 CW.sgml files in the CWDOC/ directory of the CWSGMLS.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 CWSTDIN):
my $parse = new SGMLS(STDIN);
The most important method for this class is CWnext_event, which reads and returns the next major event from the input stream. It is important to note that the CWSGMLS 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 CWSGMLS class: This class holds a single major event, as generated by the CWnext_event method in the CWSGMLS 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 CWSGMLS_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:
AUTHOR AND COPYRIGHT
Copyright 1994 and 1995 by David Megginson, CWdmeggins@aix1.uottawa.ca. Distributed under the terms of the Gnu General Public License (version 2, 1991) see the file CWCOPYING which is included in the SGMLS.pm distribution.
SEE ALSO:
SGMLS::Output and SGMLS::Refs.