777 lines
24 KiB
HTML
777 lines
24 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of Expat</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>Expat</H1>
|
|
Section: User Contributed Perl Documentation (3pm)<BR>Updated: 2019-10-03<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
XML::Parser::Expat - Lowlevel access to James Clark's expat XML parser
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
use XML::Parser::Expat;
|
|
|
|
$parser = XML::Parser::Expat->new;
|
|
$parser->setHandlers('Start' => \&sh,
|
|
'End' => \&eh,
|
|
'Char' => \&ch);
|
|
open(my $fh, '<', 'info.xml') or die "Couldn't open";
|
|
$parser->parse($fh);
|
|
close($fh);
|
|
# $parser->parse('<foo id="me"> here <em>we</em> go </foo>');
|
|
|
|
sub sh
|
|
{
|
|
my ($p, $el, %atts) = @_;
|
|
$p->setHandlers('Char' => \&spec)
|
|
if ($el eq 'special');
|
|
...
|
|
}
|
|
|
|
sub eh
|
|
{
|
|
my ($p, $el) = @_;
|
|
$p->setHandlers('Char' => \&ch) # Special elements won't contain
|
|
if ($el eq 'special'); # other special elements
|
|
...
|
|
}
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
|
|
|
|
This module provides an interface to James Clark's <FONT SIZE="-1">XML</FONT> parser, expat. As in
|
|
expat, a single instance of the parser can only parse one document. Calls
|
|
to parsestring after the first for a given instance will die.
|
|
<P>
|
|
|
|
Expat (and XML::Parser::Expat) are event based. As the parser recognizes
|
|
parts of the document (say the start or end of an <FONT SIZE="-1">XML</FONT> element), then any
|
|
handlers registered for that type of an event are called with suitable
|
|
parameters.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>METHODS</H2>
|
|
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="1">new<DD>
|
|
|
|
|
|
This is a class method, the constructor for XML::Parser::Expat. Options are
|
|
passed as keyword value pairs. The recognized options are:
|
|
<DL COMPACT><DT id="2"><DD>
|
|
<DL COMPACT>
|
|
<DT id="3">•<DD>
|
|
ProtocolEncoding
|
|
|
|
|
|
<P>
|
|
|
|
|
|
The protocol encoding name. The default is none. The expat built-in
|
|
encodings are: <TT>"UTF-8"</TT>, <TT>"ISO-8859-1"</TT>, <TT>"UTF-16"</TT>, and <TT>"US-ASCII"</TT>.
|
|
Other encodings may be used if they have encoding maps in one of the
|
|
directories in the <TT>@Encoding_Path</TT> list. Setting the protocol encoding
|
|
overrides any encoding in the <FONT SIZE="-1">XML</FONT> declaration.
|
|
<DT id="4">•<DD>
|
|
Namespaces
|
|
|
|
|
|
<P>
|
|
|
|
|
|
When this option is given with a true value, then the parser does namespace
|
|
processing. By default, namespace processing is turned off. When it is
|
|
turned on, the parser consumes <I>xmlns</I> attributes and strips off prefixes
|
|
from element and attributes names where those prefixes have a defined
|
|
namespace. A name's namespace can be found using the ``namespace'' method
|
|
and two names can be checked for absolute equality with the ``eq_name''
|
|
method.
|
|
<DT id="5">•<DD>
|
|
NoExpand
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Normally, the parser will try to expand references to entities defined in
|
|
the internal subset. If this option is set to a true value, and a default
|
|
handler is also set, then the default handler will be called when an
|
|
entity reference is seen in text. This has no effect if a default handler
|
|
has not been registered, and it has no effect on the expansion of entity
|
|
references inside attribute values.
|
|
<DT id="6">•<DD>
|
|
Stream_Delimiter
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This option takes a string value. When this string is found alone on a line
|
|
while parsing from a stream, then the parse is ended as if it saw an end of
|
|
file. The intended use is with a stream of xml documents in a <FONT SIZE="-1">MIME</FONT> multipart
|
|
format. The string should not contain a trailing newline.
|
|
<DT id="7">•<DD>
|
|
ErrorContext
|
|
|
|
|
|
<P>
|
|
|
|
|
|
When this option is defined, errors are reported in context. The value
|
|
of ErrorContext should be the number of lines to show on either side of
|
|
the line in which the error occurred.
|
|
<DT id="8">•<DD>
|
|
ParseParamEnt
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Unless standalone is set to ``yes'' in the <FONT SIZE="-1">XML</FONT> declaration, setting this to
|
|
a true value allows the external <FONT SIZE="-1">DTD</FONT> to be read, and parameter entities
|
|
to be parsed and expanded.
|
|
<DT id="9">•<DD>
|
|
Base
|
|
|
|
|
|
<P>
|
|
|
|
|
|
The base to use for relative pathnames or URLs. This can also be done by
|
|
using the base method.
|
|
</DL>
|
|
</DL>
|
|
|
|
<DL COMPACT><DT id="10"><DD>
|
|
</DL>
|
|
|
|
<DT id="11">setHandlers(<FONT SIZE="-1">TYPE, HANDLER</FONT> [, <FONT SIZE="-1">TYPE, HANDLER</FONT> [...]])<DD>
|
|
|
|
|
|
This method registers handlers for the various events. If no handlers are
|
|
registered, then a call to parsestring or parsefile will only determine if
|
|
the corresponding <FONT SIZE="-1">XML</FONT> document is well formed (by returning without error.)
|
|
This may be called from within a handler, after the parse has started.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Setting a handler to something that evaluates to false unsets that
|
|
handler.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This method returns a list of type, handler pairs corresponding to the
|
|
input. The handlers returned are the ones that were in effect before the
|
|
call to setHandlers.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
The recognized events and the parameters passed to the corresponding
|
|
handlers are:
|
|
<DL COMPACT><DT id="12"><DD>
|
|
<DL COMPACT>
|
|
<DT id="13">•<DD>
|
|
Start (Parser, Element [, Attr, Val [,...]])
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This event is generated when an <FONT SIZE="-1">XML</FONT> start tag is recognized. Parser is
|
|
an XML::Parser::Expat instance. Element is the name of the <FONT SIZE="-1">XML</FONT> element that
|
|
is opened with the start tag. The Attr & Val pairs are generated for each
|
|
attribute in the start tag.
|
|
<DT id="14">•<DD>
|
|
End (Parser, Element)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This event is generated when an <FONT SIZE="-1">XML</FONT> end tag is recognized. Note that
|
|
an <FONT SIZE="-1">XML</FONT> empty tag (<foo/>) generates both a start and an end event.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
There is always a lower level start and end handler installed that wrap
|
|
the corresponding callbacks. This is to handle the context mechanism.
|
|
A consequence of this is that the default handler (see below) will not
|
|
see a start tag or end tag unless the default_current method is called.
|
|
<DT id="15">•<DD>
|
|
Char (Parser, String)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This event is generated when non-markup is recognized. The non-markup
|
|
sequence of characters is in String. A single non-markup sequence of
|
|
characters may generate multiple calls to this handler. Whatever the
|
|
encoding of the string in the original document, this is given to the
|
|
handler in <FONT SIZE="-1">UTF-8.</FONT>
|
|
<DT id="16">•<DD>
|
|
Proc (Parser, Target, Data)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This event is generated when a processing instruction is recognized.
|
|
<DT id="17">•<DD>
|
|
Comment (Parser, String)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This event is generated when a comment is recognized.
|
|
<DT id="18">•<DD>
|
|
CdataStart (Parser)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This is called at the start of a <FONT SIZE="-1">CDATA</FONT> section.
|
|
<DT id="19">•<DD>
|
|
CdataEnd (Parser)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This is called at the end of a <FONT SIZE="-1">CDATA</FONT> section.
|
|
<DT id="20">•<DD>
|
|
Default (Parser, String)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This is called for any characters that don't have a registered handler.
|
|
This includes both characters that are part of markup for which no
|
|
events are generated (markup declarations) and characters that
|
|
could generate events, but for which no handler has been registered.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Whatever the encoding in the original document, the string is returned to
|
|
the handler in <FONT SIZE="-1">UTF-8.</FONT>
|
|
<DT id="21">•<DD>
|
|
Unparsed (Parser, Entity, Base, Sysid, Pubid, Notation)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This is called for a declaration of an unparsed entity. Entity is the name
|
|
of the entity. Base is the base to be used for resolving a relative <FONT SIZE="-1">URI.</FONT>
|
|
Sysid is the system id. Pubid is the public id. Notation is the notation
|
|
name. Base and Pubid may be undefined.
|
|
<DT id="22">•<DD>
|
|
Notation (Parser, Notation, Base, Sysid, Pubid)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This is called for a declaration of notation. Notation is the notation name.
|
|
Base is the base to be used for resolving a relative <FONT SIZE="-1">URI.</FONT> Sysid is the system
|
|
id. Pubid is the public id. Base, Sysid, and Pubid may all be undefined.
|
|
<DT id="23">•<DD>
|
|
ExternEnt (Parser, Base, Sysid, Pubid)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This is called when an external entity is referenced. Base is the base to be
|
|
used for resolving a relative <FONT SIZE="-1">URI.</FONT> Sysid is the system id. Pubid is the public
|
|
id. Base, and Pubid may be undefined.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This handler should either return a string, which represents the contents of
|
|
the external entity, or return an open filehandle that can be read to obtain
|
|
the contents of the external entity, or return undef, which indicates the
|
|
external entity couldn't be found and will generate a parse error.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
If an open filehandle is returned, it must be returned as either a glob
|
|
(*FOO) or as a reference to a glob (e.g. an instance of IO::Handle).
|
|
<DT id="24">•<DD>
|
|
ExternEntFin (Parser)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This is called after an external entity has been parsed. It allows
|
|
applications to perform cleanup on actions performed in the above
|
|
ExternEnt handler.
|
|
<DT id="25">•<DD>
|
|
Entity (Parser, Name, Val, Sysid, Pubid, Ndata, IsParam)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This is called when an entity is declared. For internal entities, the Val
|
|
parameter will contain the value and the remaining three parameters will
|
|
be undefined. For external entities, the Val parameter
|
|
will be undefined, the Sysid parameter will have the system id, the Pubid
|
|
parameter will have the public id if it was provided (it will be undefined
|
|
otherwise), the Ndata parameter will contain the notation for unparsed
|
|
entities. If this is a parameter entity declaration, then the IsParam
|
|
parameter is true.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Note that this handler and the Unparsed handler above overlap. If both are
|
|
set, then this handler will not be called for unparsed entities.
|
|
<DT id="26">•<DD>
|
|
Element (Parser, Name, Model)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
The element handler is called when an element declaration is found. Name is
|
|
the element name, and Model is the content model as an
|
|
XML::Parser::ContentModel object. See ``XML::Parser::ContentModel Methods''
|
|
for methods available for this class.
|
|
<DT id="27">•<DD>
|
|
Attlist (Parser, Elname, Attname, Type, Default, Fixed)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This handler is called for each attribute in an <FONT SIZE="-1">ATTLIST</FONT> declaration.
|
|
So an <FONT SIZE="-1">ATTLIST</FONT> declaration that has multiple attributes
|
|
will generate multiple calls to this handler. The Elname parameter is the
|
|
name of the element with which the attribute is being associated. The Attname
|
|
parameter is the name of the attribute. Type is the attribute type, given as
|
|
a string. Default is the default value, which will either be ``#REQUIRED'',
|
|
``#IMPLIED'' or a quoted string (i.e. the returned string will begin and end
|
|
with a quote character). If Fixed is true, then this is a fixed attribute.
|
|
<DT id="28">•<DD>
|
|
Doctype (Parser, Name, Sysid, Pubid, Internal)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This handler is called for <FONT SIZE="-1">DOCTYPE</FONT> declarations. Name is the document type
|
|
name. Sysid is the system id of the document type, if it was provided,
|
|
otherwise it's undefined. Pubid is the public id of the document type,
|
|
which will be undefined if no public id was given. Internal will be
|
|
true or false, indicating whether or not the doctype declaration contains
|
|
an internal subset.
|
|
<DT id="29">•<DD>
|
|
DoctypeFin (Parser)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This handler is called after parsing of the <FONT SIZE="-1">DOCTYPE</FONT> declaration has finished,
|
|
including any internal or external <FONT SIZE="-1">DTD</FONT> declarations.
|
|
<DT id="30">•<DD>
|
|
XMLDecl (Parser, Version, Encoding, Standalone)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This handler is called for <FONT SIZE="-1">XML</FONT> declarations. Version is a string containing
|
|
the version. Encoding is either undefined or contains an encoding string.
|
|
Standalone is either undefined, or true or false. Undefined indicates
|
|
that no standalone parameter was given in the <FONT SIZE="-1">XML</FONT> declaration. True or
|
|
false indicates ``yes'' or ``no'' respectively.
|
|
</DL>
|
|
</DL>
|
|
|
|
<DL COMPACT><DT id="31"><DD>
|
|
</DL>
|
|
|
|
<DT id="32">namespace(name)<DD>
|
|
|
|
|
|
Return the <FONT SIZE="-1">URI</FONT> of the namespace that the name belongs to. If the name doesn't
|
|
belong to any namespace, an undef is returned. This is only valid on names
|
|
received through the Start or End handlers from a single document, or through
|
|
a call to the generate_ns_name method. In other words, don't use names
|
|
generated from one instance of XML::Parser::Expat with other instances.
|
|
<DT id="33">eq_name(name1, name2)<DD>
|
|
|
|
|
|
Return true if name1 and name2 are identical (i.e. same name and from
|
|
the same namespace.) This is only meaningful if both names were obtained
|
|
through the Start or End handlers from a single document, or through
|
|
a call to the generate_ns_name method.
|
|
<DT id="34">generate_ns_name(name, namespace)<DD>
|
|
|
|
|
|
Return a name, associated with a given namespace, good for using with the
|
|
above 2 methods. The namespace argument should be the namespace <FONT SIZE="-1">URI,</FONT> not
|
|
a prefix.
|
|
<DT id="35">new_ns_prefixes<DD>
|
|
|
|
|
|
When called from a start tag handler, returns namespace prefixes declared
|
|
with this start tag. If called elsewhere (or if there were no namespace
|
|
prefixes declared), it returns an empty list. Setting of the default
|
|
namespace is indicated with '#default' as a prefix.
|
|
<DT id="36">expand_ns_prefix(prefix)<DD>
|
|
|
|
|
|
Return the uri to which the given prefix is currently bound. Returns
|
|
undef if the prefix isn't currently bound. Use '#default' to find the
|
|
current binding of the default namespace (if any).
|
|
<DT id="37">current_ns_prefixes<DD>
|
|
|
|
|
|
Return a list of currently bound namespace prefixes. The order of the
|
|
the prefixes in the list has no meaning. If the default namespace is
|
|
currently bound, '#default' appears in the list.
|
|
<DT id="38">recognized_string<DD>
|
|
|
|
|
|
Returns the string from the document that was recognized in order to call
|
|
the current handler. For instance, when called from a start handler, it
|
|
will give us the start-tag string. The string is encoded in <FONT SIZE="-1">UTF-8.</FONT>
|
|
This method doesn't return a meaningful string inside declaration handlers.
|
|
<DT id="39">original_string<DD>
|
|
|
|
|
|
Returns the verbatim string from the document that was recognized in
|
|
order to call the current handler. The string is in the original document
|
|
encoding. This method doesn't return a meaningful string inside declaration
|
|
handlers.
|
|
<DT id="40">default_current<DD>
|
|
|
|
|
|
When called from a handler, causes the sequence of characters that generated
|
|
the corresponding event to be sent to the default handler (if one is
|
|
registered). Use of this method is deprecated in favor the recognized_string
|
|
method, which you can use without installing a default handler. This
|
|
method doesn't deliver a meaningful string to the default handler when
|
|
called from inside declaration handlers.
|
|
<DT id="41">xpcroak(message)<DD>
|
|
|
|
|
|
Concatenate onto the given message the current line number within the
|
|
<FONT SIZE="-1">XML</FONT> document plus the message implied by ErrorContext. Then croak with
|
|
the formed message.
|
|
<DT id="42">xpcarp(message)<DD>
|
|
|
|
|
|
Concatenate onto the given message the current line number within the
|
|
<FONT SIZE="-1">XML</FONT> document plus the message implied by ErrorContext. Then carp with
|
|
the formed message.
|
|
<DT id="43">current_line<DD>
|
|
|
|
|
|
Returns the line number of the current position of the parse.
|
|
<DT id="44">current_column<DD>
|
|
|
|
|
|
Returns the column number of the current position of the parse.
|
|
<DT id="45">current_byte<DD>
|
|
|
|
|
|
Returns the current position of the parse.
|
|
<DT id="46">base([<FONT SIZE="-1">NEWBASE</FONT>]);<DD>
|
|
|
|
|
|
Returns the current value of the base for resolving relative URIs. If
|
|
<FONT SIZE="-1">NEWBASE</FONT> is supplied, changes the base to that value.
|
|
<DT id="47">context<DD>
|
|
|
|
|
|
Returns a list of element names that represent open elements, with the
|
|
last one being the innermost. Inside start and end tag handlers, this
|
|
will be the tag of the parent element.
|
|
<DT id="48">current_element<DD>
|
|
|
|
|
|
Returns the name of the innermost currently opened element. Inside
|
|
start or end handlers, returns the parent of the element associated
|
|
with those tags.
|
|
<DT id="49">in_element(<FONT SIZE="-1">NAME</FONT>)<DD>
|
|
|
|
|
|
Returns true if <FONT SIZE="-1">NAME</FONT> is equal to the name of the innermost currently opened
|
|
element. If namespace processing is being used and you want to check
|
|
against a name that may be in a namespace, then use the generate_ns_name
|
|
method to create the <FONT SIZE="-1">NAME</FONT> argument.
|
|
<DT id="50">within_element(<FONT SIZE="-1">NAME</FONT>)<DD>
|
|
|
|
|
|
Returns the number of times the given name appears in the context list.
|
|
If namespace processing is being used and you want to check
|
|
against a name that may be in a namespace, then use the generate_ns_name
|
|
method to create the <FONT SIZE="-1">NAME</FONT> argument.
|
|
<DT id="51">depth<DD>
|
|
|
|
|
|
Returns the size of the context list.
|
|
<DT id="52">element_index<DD>
|
|
|
|
|
|
Returns an integer that is the depth-first visit order of the current
|
|
element. This will be zero outside of the root element. For example,
|
|
this will return 1 when called from the start handler for the root element
|
|
start tag.
|
|
<DT id="53">skip_until(<FONT SIZE="-1">INDEX</FONT>)<DD>
|
|
|
|
|
|
<FONT SIZE="-1">INDEX</FONT> is an integer that represents an element index. When this method
|
|
is called, all handlers are suspended until the start tag for an element
|
|
that has an index number equal to <FONT SIZE="-1">INDEX</FONT> is seen. If a start handler has
|
|
been set, then this is the first tag that the start handler will see
|
|
after skip_until has been called.
|
|
<DT id="54">position_in_context(<FONT SIZE="-1">LINES</FONT>)<DD>
|
|
|
|
|
|
Returns a string that shows the current parse position. <FONT SIZE="-1">LINES</FONT> should be
|
|
an integer >= 0 that represents the number of lines on either side of the
|
|
current parse line to place into the returned string.
|
|
<DT id="55">xml_escape(<FONT SIZE="-1">TEXT</FONT> [, <FONT SIZE="-1">CHAR</FONT> [, <FONT SIZE="-1">CHAR ...</FONT>]])<DD>
|
|
|
|
|
|
Returns <FONT SIZE="-1">TEXT</FONT> with markup characters turned into character entities. Any
|
|
additional characters provided as arguments are also turned into character
|
|
references where found in <FONT SIZE="-1">TEXT.</FONT>
|
|
<DT id="56">parse (<FONT SIZE="-1">SOURCE</FONT>)<DD>
|
|
|
|
|
|
The <FONT SIZE="-1">SOURCE</FONT> parameter should either be a string containing the whole <FONT SIZE="-1">XML</FONT>
|
|
document, or it should be an open IO::Handle. Only a single document
|
|
may be parsed for a given instance of XML::Parser::Expat, so this will croak
|
|
if it's been called previously for this instance.
|
|
<DT id="57">parsestring(<FONT SIZE="-1">XML_DOC_STRING</FONT>)<DD>
|
|
|
|
|
|
Parses the given string as an <FONT SIZE="-1">XML</FONT> document. Only a single document may be
|
|
parsed for a given instance of XML::Parser::Expat, so this will die if either
|
|
parsestring or parsefile has been called for this instance previously.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This method is deprecated in favor of the parse method.
|
|
<DT id="58">parsefile(<FONT SIZE="-1">FILENAME</FONT>)<DD>
|
|
|
|
|
|
Parses the <FONT SIZE="-1">XML</FONT> document in the given file. Will die if parsestring or
|
|
parsefile has been called previously for this instance.
|
|
<DT id="59">is_defaulted(<FONT SIZE="-1">ATTNAME</FONT>)<DD>
|
|
|
|
|
|
<FONT SIZE="-1">NO LONGER WORKS.</FONT> To find out if an attribute is defaulted please use
|
|
the specified_attr method.
|
|
<DT id="60">specified_attr<DD>
|
|
|
|
|
|
When the start handler receives lists of attributes and values, the
|
|
non-defaulted (i.e. explicitly specified) attributes occur in the list
|
|
first. This method returns the number of specified items in the list.
|
|
So if this number is equal to the length of the list, there were no
|
|
defaulted values. Otherwise the number points to the index of the
|
|
first defaulted attribute name.
|
|
<DT id="61">finish<DD>
|
|
|
|
|
|
Unsets all handlers (including internal ones that set context), but expat
|
|
continues parsing to the end of the document or until it finds an error.
|
|
It should finish up a lot faster than with the handlers set.
|
|
<DT id="62">release<DD>
|
|
|
|
|
|
There are data structures used by XML::Parser::Expat that have circular
|
|
references. This means that these structures will never be garbage
|
|
collected unless these references are explicitly broken. Calling this
|
|
method breaks those references (and makes the instance unusable.)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Normally, higher level calls handle this for you, but if you are using
|
|
XML::Parser::Expat directly, then it's your responsibility to call it.
|
|
</DL>
|
|
<A NAME="lbAF"> </A>
|
|
<H3>XML::Parser::ContentModel Methods</H3>
|
|
|
|
|
|
|
|
The element declaration handlers are passed objects of this class as the
|
|
content model of the element declaration. They also represent content
|
|
particles, components of a content model.
|
|
<P>
|
|
|
|
When referred to as a string, these objects are automagicly converted to a
|
|
string representation of the model (or content particle).
|
|
<DL COMPACT>
|
|
<DT id="63">isempty<DD>
|
|
|
|
|
|
This method returns true if the object is ``<FONT SIZE="-1">EMPTY'',</FONT> false otherwise.
|
|
<DT id="64">isany<DD>
|
|
|
|
|
|
This method returns true if the object is ``<FONT SIZE="-1">ANY'',</FONT> false otherwise.
|
|
<DT id="65">ismixed<DD>
|
|
|
|
|
|
This method returns true if the object is ``(#PCDATA)'' or ``(#PCDATA|...)*'',
|
|
false otherwise.
|
|
<DT id="66">isname<DD>
|
|
|
|
|
|
This method returns if the object is an element name.
|
|
<DT id="67">ischoice<DD>
|
|
|
|
|
|
This method returns true if the object is a choice of content particles.
|
|
<DT id="68">isseq<DD>
|
|
|
|
|
|
This method returns true if the object is a sequence of content particles.
|
|
<DT id="69">quant<DD>
|
|
|
|
|
|
This method returns undef or a string representing the quantifier
|
|
('?', '*', '+') associated with the model or particle.
|
|
<DT id="70">children<DD>
|
|
|
|
|
|
This method returns undef or (for mixed, choice, and sequence types)
|
|
an array of component content particles. There will always be at least
|
|
one component for choices and sequences, but for a mixed content model
|
|
of pure <FONT SIZE="-1">PCDATA, ``</FONT>(#PCDATA)'', then an undef is returned.
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H3>XML::Parser::ExpatNB Methods</H3>
|
|
|
|
|
|
|
|
The class XML::Parser::ExpatNB is a subclass of XML::Parser::Expat used
|
|
for non-blocking access to the expat library. It does not support the parse,
|
|
parsestring, or parsefile methods, but it does have these additional methods:
|
|
<DL COMPACT>
|
|
<DT id="71">parse_more(<FONT SIZE="-1">DATA</FONT>)<DD>
|
|
|
|
|
|
Feed expat more text to munch on.
|
|
<DT id="72">parse_done<DD>
|
|
|
|
|
|
Tell expat that it's gotten the whole document.
|
|
</DL>
|
|
<A NAME="lbAH"> </A>
|
|
<H2>FUNCTIONS</H2>
|
|
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="73">XML::Parser::Expat::load_encoding(<FONT SIZE="-1">ENCODING</FONT>)<DD>
|
|
|
|
|
|
Load an external encoding. <FONT SIZE="-1">ENCODING</FONT> is either the name of an encoding or
|
|
the name of a file. The basename is converted to lowercase and a '.enc'
|
|
extension is appended unless there's one already there. Then, unless
|
|
it's an absolute pathname (i.e. begins with '/'), the first file by that
|
|
name discovered in the <TT>@Encoding_Path</TT> path list is used.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
The encoding in the file is loaded and kept in the <TT>%Encoding_Table</TT>
|
|
table. Earlier encodings of the same name are replaced.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This function is automatically called by expat when it encounters an encoding
|
|
it doesn't know about. Expat shouldn't call this twice for the same
|
|
encoding name. The only reason users should use this function is to
|
|
explicitly load an encoding not contained in the <TT>@Encoding_Path</TT> list.
|
|
</DL>
|
|
<A NAME="lbAI"> </A>
|
|
<H2>AUTHORS</H2>
|
|
|
|
|
|
|
|
Larry Wall <<I><A HREF="mailto:larry@wall.org">larry@wall.org</A></I>> wrote version 1.0.
|
|
<P>
|
|
|
|
Clark Cooper <<I><A HREF="mailto:coopercc@netheaven.com">coopercc@netheaven.com</A></I>> picked up support, changed the <FONT SIZE="-1">API</FONT>
|
|
for this version (2.x), provided documentation, and added some standard
|
|
package features.
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="74"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="75"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="76"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="77"><A HREF="#lbAE">METHODS</A><DD>
|
|
<DL>
|
|
<DT id="78"><A HREF="#lbAF">XML::Parser::ContentModel Methods</A><DD>
|
|
<DT id="79"><A HREF="#lbAG">XML::Parser::ExpatNB Methods</A><DD>
|
|
</DL>
|
|
<DT id="80"><A HREF="#lbAH">FUNCTIONS</A><DD>
|
|
<DT id="81"><A HREF="#lbAI">AUTHORS</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:06:01 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|