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.
SGMLS
.sgml
DOC/
SGMLS.pm
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):
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:
next_event
next_event()
SGMLS_Event
element()
SGMLS_Element
file()
-l
line()
appinfo()
APPINFO
notation(NNAME)
SGMLS_Notation
NNAME
entity(ENAME)
SGMLS_Entity
ENAME
ext()
This class holds a single major event, as generated by the next_event method in the SGMLS class. It uses the following methods:
type()
data()
SGMLS_ELement
key()
parse()
notation(ENAME)
This class is used for elements, and contains all associated information (such as the element's attributes). It recognises the following methods:
name()
parent()
attributes()
SGMLS_Attribute
attribute_names()
attribute(ANAME)
ANAME
set_attribute(ATTRIB)
ATTRIB
in(GI)
true
GI
false
within(GI)
Each instance of an attribute for each SGMLS_Element is an object belonging to this class, which recognises the following methods:
value()
is_implied()
set_type(TYPE)
TYPE
set_value(VALUE)
VALUE
All declared notations appear as objects belonging to this class, which recognises the following methods:
sysid()
pubid()
All declared entities appear as objects belonging to this class, which recognises the following methods:
filenames()
notation()
data_attributes()
data_attribute_names()
data_attribute(ANAME)
set_data_attribute(ATTRIB)
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.
dmeggins@aix1.uottawa.ca
COPYING
SGMLS::Output and SGMLS::Refs.
12 POD Errors
The following errors were encountered while parsing the POD:
'=item' outside of any '=over'
You forgot a '=back' before '=head2'
You forgot a '=back' before '=head1'
To install SGMLS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SGMLS
CPAN shell
perl -MCPAN -e shell install SGMLS
For more information on module installation, please visit the detailed CPAN module installation guide.