perlSGML.1997Sep

 view release on metacpan or  search on metacpan

doc/html/SGML..Parser.html  view on Meta::CPAN

<html>
<head>
<title>perlSGML -- SGML::Parser</title>
<link rev="made" href="mailto:ehood@medusa.acs.uci.edu">
</head>


<!-- =================================================================== -->
<hr><h2><a name="Name">Name</a></h2>

<p>SGML::Parser - SGML instance parser</p>

<!-- =================================================================== -->
<hr><h2><a name="Synopsis">Synopsis</a></h2>
<pre>
  package MyParser;
  use SGML::Parser;
  @ISA = qw( SGML::Parser );

  sub cdata { ... }
  sub char_ref { ... }
  sub comment_decl { ... }
  sub end_tag { ... }
  sub entity_ref { ... }
  sub ignored_data { ... }
  sub marked_sect_close { ... }
  sub marked_sect_open { ... }
  sub parm_entity_ref { ... }
  sub processing_inst { ... }
  sub start_tag { ... }
  sub error { ... }

  $myparser = new MyParser;
  $myparser->parse_data(\*FILEHANDLE);
</pre>

<!-- =================================================================== -->
<hr><h2><a name="Description">Description</a></h2>

<p><strong>SGML::Parser</strong> is a simple SGML instance parser;
it cannot parse document type declarations.  To use the class, you
create a derived class of <strong>SGML::Parser</strong> and redefine
the various methods invoked when certain events occur during parsing.
</p>

<!-- =================================================================== -->
<hr><h2><a name="Class_Methods">Class_Methods</a></h2>

<p>The following class methods are defined:
</p>
<ul>
<li><a href="#new">new</a></li>
</ul>

<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<hr size=0 width="50%" align=left noshade>
<h3><a name="new">new</a></h3>

<p>Instantiate a new parser object.  The way <b>SGML::Parser</b>
is defined, an <b>SGML::Parser</b> object will probably never
be directed instantiated, but a derived class will be.
The <b>new</b> method is implemented to be reused by derived classes,
so redefinition of the method is not required (unless derived
class must perform custom initialization beyond what <b>SGML::Parser</b>
performs).
</p>

<!-- =================================================================== -->
<hr><h2><a name="Object_Methods">Object Methods</a></h2>

<p>The following lists the methods defined by
<strong>SGML::Parser</strong> that should not be overriden:
</p>
<ul>
<li><a href="#parse_data">parse_data</a></li>
<li><a href="#get_line_no">get_line_no</a></li>
<li><a href="#get_input_label">get_input_label</a></li>
</ul>

<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

doc/html/SGML..Parser.html  view on Meta::CPAN

</dl>

<h4>Return:</h4>
<p>The return value of the method should be <tt>undef</tt>.  However, if
any data was in the current buffer and parsing was aborted, the return
value is the buffer's contents.
</p>

<h4>Description:</h4>
<p><strong>parse_data</strong> parses an SGML instance.  When
parsing, the various <a href="#Callback_Methods">callback methods</a>
are called when the various lexical contructs are encountered.
</p>

<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<hr size=0 width="50%" align=left noshade>
<h3><a name="get_line_no">get_line_no</a></h3>
<pre>
    $parser-><strong>get_line_no</strong>();
</pre>

<h4>Arguments:</h4>
<p>N/A</p>

<h4>Return:</h4>
<p>The current line number.
</p>

<h4>Description:</h4>
<p>Get the current line number.  Method useful in callback methods.
</p>

<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<hr size=0 width="50%" align=left noshade>
<h3><a name="get_input_label">get_input_label</a></h3>
<pre>
    $parser-><strong>get_input_label</strong>()
</pre>

<h4>Arguments:</h4>
<p>N/A</p>

<h4>Return:</h4>
<p>Label string.
</p>

<h4>Description:</h4>
<p>Retrieves the label given to the input being parsed.  Label is defined
when the <strong>parse_data</strong> method is called.  Method useful
in callback methods.
</p>

<!-- =================================================================== -->
<hr><h2><a name="Callback_Methods">Callback Methods</a></h2>

<p>The following methods are intended to be redefined by a derived
class to handle the processing events generated by the
<strong>parse_data</strong> method.
</p>
<ul>
<li><a href="#cdata">cdata</a></li>
<li><a href="#char_ref">char_ref</a></li>
<li><a href="#comment_decl">comment_decl</a></li>
<li><a href="#end_tag">end_tag</a></li>
<li><a href="#entity_ref">entity_ref</a></li>
<li><a href="#error">error</a></li>
<li><a href="#ignored_data">ignored_data</a></li>
<li><a href="#marked_sect_close">marked_sect_close</a></li>
<li><a href="#marked_sect_open">marked_sect_open</a></li>
<li><a href="#parm_entity_ref">parm_entity_ref</a></li>
<li><a href="#processing_inst">processing_inst</a></li>
<li><a href="#start_tag">start_tag</a></li>
</ul>

<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<hr size=0 width="50%" align=left noshade>
<h3><a name="cdata">cdata</a></h3>
<pre>
    $parser-><strong>cdata</strong>(<var>$data</var>);
</pre>

<h4>Arguments:</h4>
<dl>
<dt><var>$data</var>
<dd>Character data.
</dl>

<h4>Return:</h4>
<p>N/A
</p>

<h4>Description:</h4>
<p><strong>cdata</strong> is invoked when character data is encountered.
The character data is passed into the method.  Multiple lines of
character data may generate multiple <strong>cdata</strong> calls.
</p>

<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<hr size=0 width="50%" align=left noshade>
<h3><a name="char_ref">char_ref</a></h3>
<pre>
    $parser-><strong>char_ref</strong>(<var>$value</var>);
</pre>

<h4>Arguments:</h4>
<dl>
<dt><var>$value</var>
<dd>The character number or function name.
</dl>

<h4>Return:</h4>
<p>N/A
</p>

<h4>Description:</h4>
<p><strong>char_ref</strong> is invoked when a character reference
is encountered.  The number/name of the character reference
is passed in as an argument.
</p>

<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<hr size=0 width="50%" align=left noshade>
<h3><a name="comment_decl">comment_decl</a></h3>
<pre>
    $parser-><strong>comment_decl</strong>(<var>\@comments</var>);
</pre>

<h4>Arguments:</h4>
<dl>
<dt><var>\@comments</var>
<dd>Reference to an array of strings.  Each string is the content
of each comment block in the declaration.
</dl>

<h4>Return:</h4>
<p>N/A
</p>

<h4>Description:</h4>
<p><strong>comment_decl</strong> is called when a comment declaration is
parsed.  The passed in argument is a reference to an array containing
the comment blocks defined in the declaration.
</p>

<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<hr size=0 width="50%" align=left noshade>
<h3><a name="end_tag">end_tag</a></h3>
<pre>
    $parser-><strong>end_tag</strong>(<var>$gi</var>);
</pre>

<h4>Arguments:</h4>
<dl>
<dt><var>$gi</var>
<dd>Generic identifier.



( run in 1.727 second using v1.01-cache-2.11-cpan-5837b0d9d2c )