\documentstyle[11pt]{article}

\setlength{\parskip}{3ex}
\raggedright

\title{sgmlspl: a simple post-processor for SGMLS and NSGMLS (for use
with {\sc SGMLS.pm} version 1.03)}
\author{David Megginson \\
  Department of English, \\
  University of Ottawa, \\
  Email: {\tt dmeggins@aix1.uottawa.ca} \\
}


\begin{document}
\maketitle


Welcome to {\sc sgmlspl}, a simple sample {\sc perl5} application which
uses the {\sc SGMLS.pm} class library.


{\em\section{Terms}
\label{TERMS}


This program, along with its documentation, is free software;
you can redistribute it and/or modify it under the terms of the GNU
General Public License as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later
version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


}



\section{What is {\sc sgmlspl}?}
\label{DEFINITION}


{\sc sgmlspl} is a sample application distributed with the
{\sc SGMLS.pm} {\sc perl5} class library {---} you can use it to convert
{\sc SGML} documents to other formats by providing a {\em specification file\/}
detailing exactly how you want to handle each element, external data
entity, subdocument entity, CDATA string, record end, SDATA string,
and processing instruction.  {\sc sgmlspl} also uses the {\sc SGMLS::Output}
library (included in this distribution) to allow you to redirect or
capture output.

To use {\sc sgmlspl}, you simply prepare a specification file
containing regular {\sc perl5} code.  If your {\sc SGML} document were named
{\tt doc.sgml}, your {\sc sgmlspl} specification file
were named, {\tt spec.pl}, and the name of your new
file were {\tt doc.latex}, then you could use the
following command in a Unix shell to convert your {\sc SGML} document:

{\footnotesize\begin{verbatim}
sgmls doc.sgml | sgmlspl spec.pl > doc.latex
\end{verbatim}}

{\sc sgmlspl} will pass any additional arguments on to the specification
file, which can process them in the regular {\sc perl5} fashion.  The
specification files used to convert this manual {---}
{\tt tolatex.pl} and {\tt tohtml.pl}
{---} are available with the {\sc SGMLS.pm} distribution.




\section{How do I install {\sc sgmlspl} on my system?}
\label{INSTALLATION}


To use {\sc sgmlspl}, you need to install {\sc SGMLS.pm} on your system,
by copying the {\sc SGMLS.pm} file to a directory searched by {\sc perl5}.
You also need to install {\sc SGMLS::Output} in the same directory, and
{\sc sgmlspl} (with execute permission) somewhere on your
{\tt PATH}.  The easiest way to do all of this on a Unix
system is to change to the root directory of this distribution
({\tt SGMLSpm}), edit the {\tt Makefile}
appropriately, and type

{\footnotesize\begin{verbatim}
make install
\end{verbatim}}




\section{Is {\sc sgmlspl} the best way to convert {\sc SGML} documents?}
\label{DSSSL}


Not necessarily.  While {\sc sgmlspl} is fully functional, it is not
always particularly intuitive or pleasant to use.  There is a new
proposed standard, {\em Document Style Semantics and
Specification Language\/} ({\sc DSSSL}), based
on the {\sc Scheme} programming language, and
implementations should soon be available.  To read more about the
{\sc DSSSL} standard, see {\tt http://www.jclark.com/dsssl/}
on the Internet.

That said, {\sc DSSSL} is a declarative,
side-effect-free programming language, while {\sc sgmlspl} allows you to
use any programming constructions available in {\sc perl5}, including
those with side-effects.  This means that if you want to do more than
simply format the document or convert it from one {\em Document
Type Definition\/} ({\sc DTD}) to another,
{\sc sgmlspl} might be a good choice.




\section{How does the specification file tell {\sc sgmlspl} what to do?}
\label{SPECS}


{\sc sgmlspl} uses an {\em event model\/} rather than
a {\em procedural model\/} {---} instead of
saying {``}do A then B then C{''} you say {``}whenever X
happens, do A; whenever Y happens, do B; whenever Z happens, do
C{''}.  In other words, while you design the code, {\sc sgmlspl}
decides when and how often to run it.

The specification file, which contains your instructions, is
regular {\sc perl5} code, and you can define packages and subroutines,
display information, read files, create variables, etc.  For
processing the {\sc SGML} document, however, {\sc sgmlspl} exports a single
subroutine, {\tt sgml({\tt\sl event\/},
{\tt\sl handler\/})}, into the 'main' package
{---} each time you call {\tt sgml}, you declare a
handler for a specific type of {\sc sgmls} event, and {\sc sgmlspl} will then
execute that handler every time the event occurs.  You may use
{\tt sgml} to declare a handler for a {\em generic event\/}, like
{\tt 'start\_element'}, or a {\em specific event\/},
like {\tt '$<$DOC$>$'} {---} a specific event will
always take precedence over a generic event, so when the
{\tt DOC} element begins, {\sc sgmlspl} will execute the
{\tt '$<$DOC$>$'} handler rather than the
{\tt 'start\_element'} handler.




\section{What about the {\tt\sl handler\/} argument?}
\label{HANDLERS}


The second argument to the {\tt sgml} subroutine is
the actual code or data associated with each event.  If it is a
string, it will be printed literally using the
{\tt output} subroutine from the {\sc SGMLS::Output} library; if
it is a reference to a {\sc perl5} subroutine, the subroutine will be
called whenever the event occurs.  The following three
{\tt sgml} commands will have identical results:

{\footnotesize\begin{verbatim}
# Example 1
sgml('<DOC>', "\\begin{document}\n");

# Example 2
sgml('<DOC>', sub {
  output "\\begin{document}\n";
});

# Example 3
sub do_begin_document { output "\\begin{document}\n"; }
sgml('<DOC>', \&do_begin_document);
\end{verbatim}}

For simply printing a string, of course, it does not make sense
to use a subroutine; however, the subroutines can be useful when you
need to check the value of an attribute, perform different actions in
different contexts, or perform other types of relatively more
complicated post-processing.

If your handler is a subroutine, then it will receive two
arguments: the {\sc SGMLS.pm} event's data, and the {\sc SGMLS.pm} event
itself (see the {\sc SGMLS.pm} documentation for a description
of event and data types).  The following example will print
{\tt '\verb|\|begin\{enumerate\}'} if the value of the attribute
{\tt TYPE} is {\tt 'ORDERED'}, and
{\tt '\verb|\|begin\{itemize\}'} if the value of the attribute
{\tt TYPE} is {\tt 'UNORDERED'}:

{\footnotesize\begin{verbatim}
sgml('<LIST>', sub {
  my ($element,$event) = @_;
  my $type = $element->attribute('TYPE')->value;

  if ($type eq 'ORDERED') {
    output "\\begin{enumerate}\n";
  } elsif ($type eq 'UNORDERED') {
    output "\\begin{itemize}\n";
  } else {
    die "Bad TYPE '$type' for element LIST at line " .
      $event->line . " in " . $event->file . "\n";
  }
});
\end{verbatim}}

You will not always need to use the {\tt\sl event\/}
argument, but it can be useful if you want to report line numbers or
file names for errors (presuming that you called {\sc sgmls} or {\sc nsgmls}
with the {\tt\sl -l\/} option).  If you have a new version
of {\sc nsgmls} which accepts the {\tt\sl -h\/} option, you
can also use the {\tt\sl event\/} argument to look up
arbitrary entities declared by the program. See the SGMLS\_Event documentation for
more information.




\section{What are the generic events?}
\label{GENERIC}


{\sc sgmlspl} recognises the twelve generic events listed in table
\ref{TABLE.EVENTS.GENERIC}.  You may provide any one of these
as the first argument to {\tt sgml} to declare a handler
(string or subroutine) for that event.

\begin{table}[htbp]
\footnotesize
\caption{{\sc sgmlspl} generic events}
\label{TABLE.EVENTS.GENERIC}
\vspace{2ex}\begin{tabular}{l|l}
\parbox[c]{2.225in}{\raggedright\vspace{4pt} Event\vspace{4pt}}	 & \parbox[c]{2.225in}{\raggedright\vspace{4pt} Description\vspace{4pt}}	\\ \hline\hline
\parbox[c]{2.225in}{\raggedright\vspace{4pt} {\tt 'start'}\vspace{4pt}}	 & \parbox[c]{2.225in}{\raggedright\vspace{4pt} Execute {\tt\sl handler\/} (with no arguments) at
the beginning of the parse.\vspace{4pt}}	\\ \hline
\parbox[c]{2.225in}{\raggedright\vspace{4pt} {\tt 'end'}\vspace{4pt}}	 & \parbox[c]{2.225in}{\raggedright\vspace{4pt} Execute {\tt\sl handler\/} (with no arguments) at
the end of the parse.\vspace{4pt}}	\\ \hline
\parbox[c]{2.225in}{\raggedright\vspace{4pt} {\tt 'start\_element'}\vspace{4pt}}	 & \parbox[c]{2.225in}{\raggedright\vspace{4pt} Execute {\tt\sl handler\/} at the beginning of every
element without a specific start handler.\vspace{4pt}}	\\ \hline
\parbox[c]{2.225in}{\raggedright\vspace{4pt} {\tt 'end\_element'}\vspace{4pt}}	 & \parbox[c]{2.225in}{\raggedright\vspace{4pt} Execute {\tt\sl handler\/} at the end of every
element without a specific end handler.\vspace{4pt}}	\\ \hline
\parbox[c]{2.225in}{\raggedright\vspace{4pt} {\tt 'cdata'}\vspace{4pt}}	 & \parbox[c]{2.225in}{\raggedright\vspace{4pt} Execute {\tt\sl handler\/} for every character-data
string.\vspace{4pt}}	\\ \hline
\parbox[c]{2.225in}{\raggedright\vspace{4pt} {\tt 'sdata'}\vspace{4pt}}	 & \parbox[c]{2.225in}{\raggedright\vspace{4pt} Execute {\tt\sl handler\/} for every special-data
string without a specific handler.\vspace{4pt}}	\\ \hline
\parbox[c]{2.225in}{\raggedright\vspace{4pt} {\tt 're'}\vspace{4pt}}	 & \parbox[c]{2.225in}{\raggedright\vspace{4pt} Execute {\tt\sl handler\/} for every
record end.\vspace{4pt}}	\\ \hline
\parbox[c]{2.225in}{\raggedright\vspace{4pt} {\tt 'pi'}\vspace{4pt}}	 & \parbox[c]{2.225in}{\raggedright\vspace{4pt} Execute {\tt\sl handler\/} for every processing
instruction.\vspace{4pt}}	\\ \hline
\parbox[c]{2.225in}{\raggedright\vspace{4pt} {\tt 'entity'}\vspace{4pt}}	 & \parbox[c]{2.225in}{\raggedright\vspace{4pt} Execute {\tt\sl handler\/} for every external data
entity without a specific handler.\vspace{4pt}}	\\ \hline
\parbox[c]{2.225in}{\raggedright\vspace{4pt} {\tt 'start\_subdoc'}\vspace{4pt}}	 & \parbox[c]{2.225in}{\raggedright\vspace{4pt} Execute {\tt\sl handler\/} at the beginning of every
subdocument entity without a specific handler.\vspace{4pt}}	\\ \hline
\parbox[c]{2.225in}{\raggedright\vspace{4pt} {\tt 'end\_subdoc'}\vspace{4pt}}	 & \parbox[c]{2.225in}{\raggedright\vspace{4pt} Execute {\tt\sl handler\/} at the end of every
subdocument entity without a specific handler.\vspace{4pt}}	\\ \hline
\parbox[c]{2.225in}{\raggedright\vspace{4pt} {\tt 'conforming'}\vspace{4pt}}	 & \parbox[c]{2.225in}{\raggedright\vspace{4pt} Execute {\tt\sl handler\/} once, at the end of the
document parse, if and only if the document was conforming.\vspace{4pt}}	\\ \hline
\end{tabular}\end{table}

The handlers for all of these except the document events
{\tt 'start'} and {\tt 'end'} will receive
two arguments whenever they are called: the first will be the data
associated with the event (if any), and the second will be the
{\tt SGMLS\_Event} object itself (see the document for
{\sc SGMLS.pm}).  Note the following example, which allows processing
instructions for including the date or the hostname in the document at
parse time:

{\footnotesize\begin{verbatim}
sgml('pi', sub {
    my ($instruction) = @_;
    if ($instruction eq 'date') {
      output `date`;
    } elsif ($instruction eq 'hostname') {
      output `hostname`;
    } else {
      print STDERR "Warning: unknown processing instruction: $instruction\n";
    }
});
\end{verbatim}}

With this handler, any occurance
of {\tt $<$?date$>$} in the original {\sc SGML} document
would be replaced by the current date and time, and any occurance of
{\tt $<$?hostname$>$} would be replaced by the name of
the host.




\section{What are the specific events?}
\label{SPECIFIC}


In addition to the generic
events listed in the previous section, {\sc sgmlspl} allows
special, specific handlers for the beginning and end of elements and
subdocument entities, for SDATA strings, and for external data
entities.  Table \ref{TABLE.EVENTS.SPECIFIC} lists the
different specific event types available.

\begin{table}[htbp]
\footnotesize
\caption{Specific event types}
\label{TABLE.EVENTS.SPECIFIC}
\vspace{2ex}\begin{tabular}{l|l}
\parbox[c]{2.225in}{\raggedright\vspace{4pt} Event\vspace{4pt}}	 & \parbox[c]{2.225in}{\raggedright\vspace{4pt} Description\vspace{4pt}}	\\ \hline\hline
\parbox[c]{2.225in}{\raggedright\vspace{4pt} {\tt '$<$GI$>$'}\vspace{4pt}}	 & \parbox[c]{2.225in}{\raggedright\vspace{4pt} Execute {\tt\sl handler\/} at the beginning of
every element named {\tt 'GI'}.\vspace{4pt}}	\\ \hline
\parbox[c]{2.225in}{\raggedright\vspace{4pt} {\tt '$<$/GI$>$'}\vspace{4pt}}	 & \parbox[c]{2.225in}{\raggedright\vspace{4pt} Execute {\tt\sl handler\/} at the end of every
element named {\tt 'GI'}.\vspace{4pt}}	\\ \hline
\parbox[c]{2.225in}{\raggedright\vspace{4pt} {\tt '|SDATA|'}\vspace{4pt}}	 & \parbox[c]{2.225in}{\raggedright\vspace{4pt} Execute {\tt\sl handler\/} for every special-data
string {\tt 'SDATA'}.\vspace{4pt}}	\\ \hline
\parbox[c]{2.225in}{\raggedright\vspace{4pt} {\tt '\&ENTITY;'}\vspace{4pt}}	 & \parbox[c]{2.225in}{\raggedright\vspace{4pt} Execute {\tt\sl handler\/} for every external data
entity named {\tt 'ENTITY'}.\vspace{4pt}}	\\ \hline
\parbox[c]{2.225in}{\raggedright\vspace{4pt} {\tt '\{ENTITY\}'}\vspace{4pt}}	 & \parbox[c]{2.225in}{\raggedright\vspace{4pt} Execute {\tt\sl handler\/} at the beginning of
every subdocument entity named {\tt 'ENTITY'}.\vspace{4pt}}	\\ \hline
\parbox[c]{2.225in}{\raggedright\vspace{4pt} {\tt '\{/ENTITY\}'}\vspace{4pt}}	 & \parbox[c]{2.225in}{\raggedright\vspace{4pt} Execute {\tt\sl handler\/} at the end of every
subdocument entity named {\tt 'ENTITY'}.\vspace{4pt}}	\\ \hline
\end{tabular}\end{table}

Note that these override the generic-event handlers.  For example, if you
were to type

{\footnotesize\begin{verbatim}
sgml('&FOO;', sub {
    output "Found a \"foo\" entity!\n";
});

sgml('entity', sub {
    output "Found an entity!\n";
});
\end{verbatim}}

And the external data entity {\tt \&FOO;}
appeared in your {\sc SGML} document, {\sc sgmlspl} would call the first
handler rather than the second.

Note also that start and end handlers are entirely separate
things: if an element has a specific start handler but no specific end
handler, the generic end handler will still be called at the end of
the element.  To prevent this, declare a handler with an empty string:

{\footnotesize\begin{verbatim}
sgml('</HACK>', '');
\end{verbatim}}




\section{Why does {\sc sgmlspl} use {\tt output} instead of
{\tt print}?}
\label{OUTPUT}


{\sc sgmlspl} uses a special {\sc perl5} library {\sc SGMLS::Output} for
printing text.  {\sc SGMLS::Output} exports the subroutines
{\tt output({\tt\sl string\/}{\ldots})},
{\tt push\_output({\tt\sl type\/}[,{\tt\sl data\/}])},
and {\tt pop\_output}.  The subroutine
{\tt output} works much like the regular {\sc perl5} function
{\tt print}, except that you are not able to specify a
file handle, and you may include multiple strings as arguments.

When you want to write data to somewhere other than
{\tt STDOUT} (the default), then you use the subroutines
{\tt push\_output} and
{\tt pop\_output} to set
a new destination or to restore an old one.

You can use the {\sc SGMLS::Output} package in other programs by adding
the following line:

{\footnotesize\begin{verbatim}
use SGMLS::Output;
\end{verbatim}}




\section{How do I use {\tt push\_output}?}
\label{PUSHOUTPUT}


The subroutine
{\tt push\_output({\tt\sl type\/}[,{\tt\sl data\/}])}
takes two arguments: the {\tt\sl type\/}, which is always
required, and the {\tt\sl data\/}, which is needed for
certain types of output.  Table \ref{TABLE.OUTPUT.PUSH.OUTPUT} lists the different types which you
can push onto the output stack.

\begin{table}[htbp]
\footnotesize
\caption{Types for {\tt push\_output}}
\label{TABLE.OUTPUT.PUSH.OUTPUT}
\vspace{2ex}\begin{tabular}{l|l|l}
\parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} Type\vspace{4pt}}	 & \parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} Data\vspace{4pt}}	 & \parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} Description\vspace{4pt}}	\\ \hline\hline
\parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} {\tt 'handle'}\vspace{4pt}}	 & \parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} a filehandle\vspace{4pt}}	 & \parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} Send all output to the supplied filehandle.\vspace{4pt}}	\\ \hline
\parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} {\tt 'file'}\vspace{4pt}}	 & \parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} a filename\vspace{4pt}}	 & \parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} Open the supplied file for writing, erasing its current
contents (if any), and send all output to it.\vspace{4pt}}	\\ \hline
\parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} {\tt 'append'}\vspace{4pt}}	 & \parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} a filename\vspace{4pt}}	 & \parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} Open the supplied file for writing and append all output to its
current contents.\vspace{4pt}}	\\ \hline
\parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} {\tt 'pipe'}\vspace{4pt}}	 & \parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} a shell command\vspace{4pt}}	 & \parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} Pipe all output to the supplied shell command.\vspace{4pt}}	\\ \hline
\parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} {\tt 'string'}\vspace{4pt}}	 & \parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} a string [optional]\vspace{4pt}}	 & \parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} Append all output to the supplied string, which will be
returned by {\tt pop\_output}.\vspace{4pt}}	\\ \hline
\parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} {\tt 'nul'}\vspace{4pt}}	 & \parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} [none]\vspace{4pt}}	 & \parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} Ignore all output.\vspace{4pt}}	\\ \hline
\end{tabular}\end{table}

Because the output is stack-based, you do not lose the previous
output destination when you push a new one.  This is especially
convenient for dealing with data in tree-structures, like {\sc SGML} data
{---} for example, you can capture the contents of sub-elements as
strings, ignore certain types of elements, and split the output from
one {\sc SGML} parse into a series of sub-files.  Here are some examples:

{\footnotesize\begin{verbatim}
push_output('string');                  # append output to an empty string
push_output('file','/tmp/foo');         # send output to this file
push_output('pipe','mail webmaster');   # mail output to 'webmaster' (!!)
push_output('nul');                     # just ignore all output
\end{verbatim}}




\section{How do I use {\tt pop\_output}?}
\label{POPOUTPUT}


When you want to restore the previous output after using {\tt push\_output}, simply
call the subroutine {\tt pop\_output}.  If the output type
was a string, {\tt pop\_output} will return the string
(containing all of the output); otherwise, the return value is not
useful.

Usually, you will want to use {\tt push\_output} in
the start handler for an element or subdocument entity, and
{\tt pop\_output} in the end handler.




\section{How about an example for {\tt output}?}
\label{OUTPUTEX}


Here is a simple example to demonstrate how {\tt output}, {\tt push\_output}, and
{\tt pop\_output} work:

{\footnotesize\begin{verbatim}
output "Hello, world!\n";               # (Written to STDOUT by default)
push_output('nul');                     # Push 'nul' ahead of STDOUT
output "Hello, again!\n";               # (Discarded)
push_output('file','foo.out');          # Push file 'foo.out' ahead of 'nul'
output "Hello, again!\n";               # (Written to the file 'foo.out')
pop_output;                             # Pop 'foo.out' and revert to 'nul'
output "Hello, again!\n";               # (Discarded)
push_output('string');                  # Push 'string' ahead of 'nul'
output "Hello, ";                       # (Written to the string)
output "again!\n";                      # (Also written to the string)
                                        # Pop the string "Hello, again!\n"
$foo = pop_output;                      # and revert to 'nul'
output "Hello, again!\n";               # (Discarded)
pop_output;                             # Pop 'nul' and revert to STDOUT
output "Hello, at last!\n";             # (Written to STDOUT)
\end{verbatim}}




\section{Is there an easier way to make specification files?}
\label{SKEL}


Yes.  The script {\tt skel.pl}, included in this
package, is an {\sc sgmlspl} specification which writes a specification
(!!!).  To use it under Unix, try something like

{\footnotesize\begin{verbatim}
sgmls foo.sgml | sgmlspl skel.pl > foo-spec.pl
\end{verbatim}}

(presuming that there is a copy of {\tt skel.pl}
in the current directory or in a directory searched by {\sc perl5}) to
generate a new, blank template named
{\tt foo-spec.pl}.




\section{How should I handle forward references?}
\label{FORWARD}


Because {\sc sgmlspl} processes the document as a linear data
stream, from beginning to end, it is easy to refer
{\em back\/} to information, but relatively difficult to
refer {\em forward\/}, since you do not know what will be
coming later in the parse.  Here are a few suggestions.

First, you could use {\tt push\_output} and
{\tt pop\_output} to
save up output in a large string.  When you have found the information
which you need, you can make any necessary modifications to the string
and print it then. This will work for relatively small chunks of a
document, but you would not want to try it for anything larger.

Next, you could use the {\tt ext} method to
add extra pointers, and build a parse tree of the whole document
before processing any of it.  This method will work well for small
documents, but large documents will place some serious stress on your
system's memory and/or swapping.

A more sophisticated solution, however, involves the
{\sc Refs.pm} module, included in this
distribution.  In your {\sc sgmlspl} script, include the line

{\footnotesize\begin{verbatim}
use SGMLS::Refs.pm;
\end{verbatim}}

to activate the library.  The library will create a database
file to keep track of references between passes, and to tell you if
any references have changed.  For example, you might want to try
something like this:

{\footnotesize\begin{verbatim}
sgml('start', sub {
  my $Refs = new SGMLS::Refs('references.refs');
});
sgml('end', sub {
  $Refs->warn;
  destroy $Refs;
});
\end{verbatim}}

This code will create an object, \$Refs, linked to a file of
references called {\tt references.refs}.  The
{\tt SGMLS::Refs} class understands the methods
listed in table \ref{TABLE.CLASS.REFS}

\begin{table}[htbp]
\footnotesize
\caption{The SGMLS::Refs class}
\label{TABLE.CLASS.REFS}
\vspace{2ex}\begin{tabular}{l|l|l}
\parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} Method\vspace{4pt}}	 & \parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} Return Type\vspace{4pt}}	 & \parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} Description\vspace{4pt}}	\\ \hline\hline
\parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} {\tt new}({\tt\sl filename\/},[{\tt\sl logfile\_handle\/}])\vspace{4pt}}	 & \parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} {\tt SGMLS::Refs}\vspace{4pt}}	 & \parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} Create a new {\tt SGMLS::Refs} object.
Arguments are the name of the hashfile and (optionally) a writable
filehandle for logging changes.\vspace{4pt}}	\\ \hline
\parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} {\tt get}({\tt\sl key\/})\vspace{4pt}}	 & \parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} string\vspace{4pt}}	 & \parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} Look up a reference key in the hash file and return its value.\vspace{4pt}}	\\ \hline
\parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} {\tt put}({\tt\sl key\/},{\tt\sl value\/})\vspace{4pt}}	 & \parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} [none]\vspace{4pt}}	 & \parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} Set a new value for the key in the hashfile.\vspace{4pt}}	\\ \hline
\parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} {\tt count}\vspace{4pt}}	 & \parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} number\vspace{4pt}}	 & \parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} Return the number of references whose values have changed (thus
far).\vspace{4pt}}	\\ \hline
\parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} {\tt warn}\vspace{4pt}}	 & \parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} 1 or 0\vspace{4pt}}	 & \parbox[c]{1.48333333333333in}{\raggedright\vspace{4pt} Print a warning mentioning the number of references which have
changed, and return 1 if a warning was printed.\vspace{4pt}}	\\ \hline
\end{tabular}\end{table}




\section{Are there any bugs?}
\label{BUGS}


Any bugs in {\sc SGMLS.pm} will be here too, since {\sc sgmlspl} relies
heavily on that {\sc perl5} library.


\end{document}
