Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v8plus / html / python / lib / xmlparser-objects.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python Documentation Index' />
<link rel="first" href="lib.html" title='Python Library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="expaterror-objects.html" />
<link rel="prev" href="module-xml.parsers.expat.html" />
<link rel="parent" href="module-xml.parsers.expat.html" />
<link rel="next" href="expaterror-objects.html" />
<meta name='aesop' content='information' />
<title>13.5.1 XMLParser Objects </title>
</head>
<body>
<DIV CLASS="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="13.5 xml.parsers.expat "
href="module-xml.parsers.expat.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="13.5 xml.parsers.expat "
href="module-xml.parsers.expat.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="13.5.2 ExpatError Exceptions"
href="expaterror-objects.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-xml.parsers.expat.html">13.5 xml.parsers.expat </A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-xml.parsers.expat.html">13.5 xml.parsers.expat </A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="expaterror-objects.html">13.5.2 ExpatError Exceptions</A>
</div>
<hr /></div>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION0015510000000000000000"></A><A NAME="xmlparser-objects"></A>
<BR>
13.5.1 XMLParser Objects
</H2>
<P>
<tt class="class">xmlparser</tt> objects have the following methods:
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-4308' xml:id='l2h-4308' class="method">Parse</tt></b>(</nobr></td>
<td><var>data</var><big>[</big><var>, isfinal</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Parses the contents of the string <var>data</var>, calling the appropriate
handler functions to process the parsed data. <var>isfinal</var> must be
true on the final call to this method. <var>data</var> can be the empty
string at any time.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-4309' xml:id='l2h-4309' class="method">ParseFile</tt></b>(</nobr></td>
<td><var>file</var>)</td></tr></table></dt>
<dd>
Parse XML data reading from the object <var>file</var>. <var>file</var> only
needs to provide the <tt class="method">read(<var>nbytes</var>)</tt> method, returning the
empty string when there's no more data.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-4310' xml:id='l2h-4310' class="method">SetBase</tt></b>(</nobr></td>
<td><var>base</var>)</td></tr></table></dt>
<dd>
Sets the base to be used for resolving relative URIs in system
identifiers in declarations. Resolving relative identifiers is left
to the application: this value will be passed through as the
<var>base</var> argument to the <tt class="function">ExternalEntityRefHandler</tt>,
<tt class="function">NotationDeclHandler</tt>, and
<tt class="function">UnparsedEntityDeclHandler</tt> functions.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-4311' xml:id='l2h-4311' class="method">GetBase</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Returns a string containing the base set by a previous call to
<tt class="method">SetBase()</tt>, or <code>None</code> if
<tt class="method">SetBase()</tt> hasn't been called.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-4312' xml:id='l2h-4312' class="method">GetInputContext</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Returns the input data that generated the current event as a string.
The data is in the encoding of the entity which contains the text.
When called while an event handler is not active, the return value is
<code>None</code>.
<span class="versionnote">New in version 2.1.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-4313' xml:id='l2h-4313' class="method">ExternalEntityParserCreate</tt></b>(</nobr></td>
<td><var>context</var><big>[</big><var>,
encoding</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Create a ``child'' parser which can be used to parse an external
parsed entity referred to by content parsed by the parent parser. The
<var>context</var> parameter should be the string passed to the
<tt class="method">ExternalEntityRefHandler()</tt> handler function, described below.
The child parser is created with the <tt class="member">ordered_attributes</tt>,
<tt class="member">returns_unicode</tt> and <tt class="member">specified_attributes</tt> set to the
values of this parser.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-4314' xml:id='l2h-4314' class="method">UseForeignDTD</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>flag</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Calling this with a true value for <var>flag</var> (the default) will cause
Expat to call the <tt class="member">ExternalEntityRefHandler</tt> with
<tt class="constant">None</tt> for all arguments to allow an alternate DTD to be
loaded. If the document does not contain a document type declaration,
the <tt class="member">ExternalEntityRefHandler</tt> will still be called, but the
<tt class="member">StartDoctypeDeclHandler</tt> and <tt class="member">EndDoctypeDeclHandler</tt>
will not be called.
<P>
Passing a false value for <var>flag</var> will cancel a previous call that
passed a true value, but otherwise has no effect.
<P>
This method can only be called before the <tt class="method">Parse()</tt> or
<tt class="method">ParseFile()</tt> methods are called; calling it after either of
those have been called causes <tt class="exception">ExpatError</tt> to be raised with
the <tt class="member">code</tt> attribute set to
<tt class="constant">errors.XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING</tt>.
<P>
<span class="versionnote">New in version 2.3.</span>
</dl>
<P>
<tt class="class">xmlparser</tt> objects have the following attributes:
<P>
<dl><dt><b><tt id='l2h-4315' xml:id='l2h-4315' class="member">buffer_size</tt></b></dt>
<dd>
The size of the buffer used when <tt class="member">buffer_text</tt> is true. This
value cannot be changed at this time.
<span class="versionnote">New in version 2.3.</span>
</dl>
<P>
<dl><dt><b><tt id='l2h-4316' xml:id='l2h-4316' class="member">buffer_text</tt></b></dt>
<dd>
Setting this to true causes the <tt class="class">xmlparser</tt> object to buffer
textual content returned by Expat to avoid multiple calls to the
<tt class="method">CharacterDataHandler()</tt> callback whenever possible. This can
improve performance substantially since Expat normally breaks
character data into chunks at every line ending. This attribute is
false by default, and may be changed at any time.
<span class="versionnote">New in version 2.3.</span>
</dl>
<P>
<dl><dt><b><tt id='l2h-4317' xml:id='l2h-4317' class="member">buffer_used</tt></b></dt>
<dd>
If <tt class="member">buffer_text</tt> is enabled, the number of bytes stored in the
buffer. These bytes represent UTF-8 encoded text. This attribute has
no meaningful interpretation when <tt class="member">buffer_text</tt> is false.
<span class="versionnote">New in version 2.3.</span>
</dl>
<P>
<dl><dt><b><tt id='l2h-4318' xml:id='l2h-4318' class="member">ordered_attributes</tt></b></dt>
<dd>
Setting this attribute to a non-zero integer causes the attributes to
be reported as a list rather than a dictionary. The attributes are
presented in the order found in the document text. For each
attribute, two list entries are presented: the attribute name and the
attribute value. (Older versions of this module also used this
format.) By default, this attribute is false; it may be changed at
any time.
<span class="versionnote">New in version 2.1.</span>
</dl>
<P>
<dl><dt><b><tt id='l2h-4319' xml:id='l2h-4319' class="member">returns_unicode</tt></b></dt>
<dd>
If this attribute is set to a non-zero integer, the handler functions
will be passed Unicode strings. If <tt class="member">returns_unicode</tt> is 0,
8-bit strings containing UTF-8 encoded data will be passed to the
handlers.
<span class="versionnote">Changed in version 1.6:
Can be changed at any time to affect the result
type.</span>
</dl>
<P>
<dl><dt><b><tt id='l2h-4320' xml:id='l2h-4320' class="member">specified_attributes</tt></b></dt>
<dd>
If set to a non-zero integer, the parser will report only those
attributes which were specified in the document instance and not those
which were derived from attribute declarations. Applications which
set this need to be especially careful to use what additional
information is available from the declarations as needed to comply
with the standards for the behavior of XML processors. By default,
this attribute is false; it may be changed at any time.
<span class="versionnote">New in version 2.1.</span>
</dl>
<P>
The following attributes contain values relating to the most recent
error encountered by an <tt class="class">xmlparser</tt> object, and will only have
correct values once a call to <tt class="method">Parse()</tt> or <tt class="method">ParseFile()</tt>
has raised a <tt class="exception">xml.parsers.expat.ExpatError</tt> exception.
<P>
<dl><dt><b><tt id='l2h-4321' xml:id='l2h-4321' class="member">ErrorByteIndex</tt></b></dt>
<dd>
Byte index at which an error occurred.
</dl>
<P>
<dl><dt><b><tt id='l2h-4322' xml:id='l2h-4322' class="member">ErrorCode</tt></b></dt>
<dd>
Numeric code specifying the problem. This value can be passed to the
<tt class="function">ErrorString()</tt> function, or compared to one of the constants
defined in the <code>errors</code> object.
</dl>
<P>
<dl><dt><b><tt id='l2h-4323' xml:id='l2h-4323' class="member">ErrorColumnNumber</tt></b></dt>
<dd>
Column number at which an error occurred.
</dl>
<P>
<dl><dt><b><tt id='l2h-4324' xml:id='l2h-4324' class="member">ErrorLineNumber</tt></b></dt>
<dd>
Line number at which an error occurred.
</dl>
<P>
The following attributes contain values relating to the current parse
location in an <tt class="class">xmlparser</tt> object. During a callback reporting
a parse event they indicate the location of the first of the sequence
of characters that generated the event. When called outside of a
callback, the position indicated will be just past the last parse
event (regardless of whether there was an associated callback).
<span class="versionnote">New in version 2.4.</span>
<P>
<dl><dt><b><tt id='l2h-4325' xml:id='l2h-4325' class="member">CurrentByteIndex</tt></b></dt>
<dd>
Current byte index in the parser input.
</dl>
<P>
<dl><dt><b><tt id='l2h-4326' xml:id='l2h-4326' class="member">CurrentColumnNumber</tt></b></dt>
<dd>
Current column number in the parser input.
</dl>
<P>
<dl><dt><b><tt id='l2h-4327' xml:id='l2h-4327' class="member">CurrentLineNumber</tt></b></dt>
<dd>
Current line number in the parser input.
</dl>
<P>
Here is the list of handlers that can be set. To set a handler on an
<tt class="class">xmlparser</tt> object <var>o</var>, use
<code><var>o</var>.<var>handlername</var> = <var>func</var></code>. <var>handlername</var> must
be taken from the following list, and <var>func</var> must be a callable
object accepting the correct number of arguments. The arguments are
all strings, unless otherwise stated.
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-4328' xml:id='l2h-4328' class="method">XmlDeclHandler</tt></b>(</nobr></td>
<td><var>version, encoding, standalone</var>)</td></tr></table></dt>
<dd>
Called when the XML declaration is parsed. The XML declaration is the
(optional) declaration of the applicable version of the XML
recommendation, the encoding of the document text, and an optional
``standalone'' declaration. <var>version</var> and <var>encoding</var> will be
strings of the type dictated by the <tt class="member">returns_unicode</tt>
attribute, and <var>standalone</var> will be <code>1</code> if the document is
declared standalone, <code>0</code> if it is declared not to be standalone,
or <code>-1</code> if the standalone clause was omitted.
This is only available with Expat version 1.95.0 or newer.
<span class="versionnote">New in version 2.1.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-4329' xml:id='l2h-4329' class="method">StartDoctypeDeclHandler</tt></b>(</nobr></td>
<td><var>doctypeName,
systemId, publicId,
has_internal_subset</var>)</td></tr></table></dt>
<dd>
Called when Expat begins parsing the document type declaration
(<code>&lt;!DOCTYPE ...</code>). The <var>doctypeName</var> is provided exactly
as presented. The <var>systemId</var> and <var>publicId</var> parameters give
the system and public identifiers if specified, or <code>None</code> if
omitted. <var>has_internal_subset</var> will be true if the document
contains and internal document declaration subset.
This requires Expat version 1.2 or newer.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-4330' xml:id='l2h-4330' class="method">EndDoctypeDeclHandler</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Called when Expat is done parsing the document type declaration.
This requires Expat version 1.2 or newer.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-4331' xml:id='l2h-4331' class="method">ElementDeclHandler</tt></b>(</nobr></td>
<td><var>name, model</var>)</td></tr></table></dt>
<dd>
Called once for each element type declaration. <var>name</var> is the name
of the element type, and <var>model</var> is a representation of the
content model.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-4332' xml:id='l2h-4332' class="method">AttlistDeclHandler</tt></b>(</nobr></td>
<td><var>elname, attname,
type, default, required</var>)</td></tr></table></dt>
<dd>
Called for each declared attribute for an element type. If an
attribute list declaration declares three attributes, this handler is
called three times, once for each attribute. <var>elname</var> is the name
of the element to which the declaration applies and <var>attname</var> is
the name of the attribute declared. The attribute type is a string
passed as <var>type</var>; the possible values are <code>'CDATA'</code>,
<code>'ID'</code>, <code>'IDREF'</code>, ...
<var>default</var> gives the default value for the attribute used when the
attribute is not specified by the document instance, or <code>None</code> if
there is no default value (<code>#IMPLIED</code> values). If the attribute
is required to be given in the document instance, <var>required</var> will
be true.
This requires Expat version 1.95.0 or newer.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-4333' xml:id='l2h-4333' class="method">StartElementHandler</tt></b>(</nobr></td>
<td><var>name, attributes</var>)</td></tr></table></dt>
<dd>
Called for the start of every element. <var>name</var> is a string
containing the element name, and <var>attributes</var> is a dictionary
mapping attribute names to their values.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-4334' xml:id='l2h-4334' class="method">EndElementHandler</tt></b>(</nobr></td>
<td><var>name</var>)</td></tr></table></dt>
<dd>
Called for the end of every element.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-4335' xml:id='l2h-4335' class="method">ProcessingInstructionHandler</tt></b>(</nobr></td>
<td><var>target, data</var>)</td></tr></table></dt>
<dd>
Called for every processing instruction.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-4336' xml:id='l2h-4336' class="method">CharacterDataHandler</tt></b>(</nobr></td>
<td><var>data</var>)</td></tr></table></dt>
<dd>
Called for character data. This will be called for normal character
data, CDATA marked content, and ignorable whitespace. Applications
which must distinguish these cases can use the
<tt class="member">StartCdataSectionHandler</tt>, <tt class="member">EndCdataSectionHandler</tt>,
and <tt class="member">ElementDeclHandler</tt> callbacks to collect the required
information.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-4337' xml:id='l2h-4337' class="method">UnparsedEntityDeclHandler</tt></b>(</nobr></td>
<td><var>entityName, base,
systemId, publicId,
notationName</var>)</td></tr></table></dt>
<dd>
Called for unparsed (NDATA) entity declarations. This is only present
for version 1.2 of the Expat library; for more recent versions, use
<tt class="member">EntityDeclHandler</tt> instead. (The underlying function in the
Expat library has been declared obsolete.)
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-4338' xml:id='l2h-4338' class="method">EntityDeclHandler</tt></b>(</nobr></td>
<td><var>entityName,
is_parameter_entity, value,
base, systemId,
publicId,
notationName</var>)</td></tr></table></dt>
<dd>
Called for all entity declarations. For parameter and internal
entities, <var>value</var> will be a string giving the declared contents
of the entity; this will be <code>None</code> for external entities. The
<var>notationName</var> parameter will be <code>None</code> for parsed entities,
and the name of the notation for unparsed entities.
<var>is_parameter_entity</var> will be true if the entity is a parameter
entity or false for general entities (most applications only need to
be concerned with general entities).
This is only available starting with version 1.95.0 of the Expat
library.
<span class="versionnote">New in version 2.1.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-4339' xml:id='l2h-4339' class="method">NotationDeclHandler</tt></b>(</nobr></td>
<td><var>notationName, base,
systemId, publicId</var>)</td></tr></table></dt>
<dd>
Called for notation declarations. <var>notationName</var>, <var>base</var>, and
<var>systemId</var>, and <var>publicId</var> are strings if given. If the
public identifier is omitted, <var>publicId</var> will be <code>None</code>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-4340' xml:id='l2h-4340' class="method">StartNamespaceDeclHandler</tt></b>(</nobr></td>
<td><var>prefix, uri</var>)</td></tr></table></dt>
<dd>
Called when an element contains a namespace declaration. Namespace
declarations are processed before the <tt class="member">StartElementHandler</tt> is
called for the element on which declarations are placed.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-4341' xml:id='l2h-4341' class="method">EndNamespaceDeclHandler</tt></b>(</nobr></td>
<td><var>prefix</var>)</td></tr></table></dt>
<dd>
Called when the closing tag is reached for an element
that contained a namespace declaration. This is called once for each
namespace declaration on the element in the reverse of the order for
which the <tt class="member">StartNamespaceDeclHandler</tt> was called to indicate
the start of each namespace declaration's scope. Calls to this
handler are made after the corresponding <tt class="member">EndElementHandler</tt>
for the end of the element.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-4342' xml:id='l2h-4342' class="method">CommentHandler</tt></b>(</nobr></td>
<td><var>data</var>)</td></tr></table></dt>
<dd>
Called for comments. <var>data</var> is the text of the comment, excluding
the leading `<code>&lt;!-</code><code>-</code>' and trailing `<code>-</code><code>-&gt;</code>'.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-4343' xml:id='l2h-4343' class="method">StartCdataSectionHandler</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Called at the start of a CDATA section. This and
<tt class="member">StartCdataSectionHandler</tt> are needed to be able to identify
the syntactical start and end for CDATA sections.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-4344' xml:id='l2h-4344' class="method">EndCdataSectionHandler</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Called at the end of a CDATA section.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-4345' xml:id='l2h-4345' class="method">DefaultHandler</tt></b>(</nobr></td>
<td><var>data</var>)</td></tr></table></dt>
<dd>
Called for any characters in the XML document for
which no applicable handler has been specified. This means
characters that are part of a construct which could be reported, but
for which no handler has been supplied.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-4346' xml:id='l2h-4346' class="method">DefaultHandlerExpand</tt></b>(</nobr></td>
<td><var>data</var>)</td></tr></table></dt>
<dd>
This is the same as the <tt class="function">DefaultHandler</tt>,
but doesn't inhibit expansion of internal entities.
The entity reference will not be passed to the default handler.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-4347' xml:id='l2h-4347' class="method">NotStandaloneHandler</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd> Called if the
XML document hasn't been declared as being a standalone document.
This happens when there is an external subset or a reference to a
parameter entity, but the XML declaration does not set standalone to
<code>yes</code> in an XML declaration. If this handler returns <code>0</code>,
then the parser will throw an <tt class="constant">XML_ERROR_NOT_STANDALONE</tt>
error. If this handler is not set, no exception is raised by the
parser for this condition.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-4348' xml:id='l2h-4348' class="method">ExternalEntityRefHandler</tt></b>(</nobr></td>
<td><var>context, base,
systemId, publicId</var>)</td></tr></table></dt>
<dd>
Called for references to external entities. <var>base</var> is the current
base, as set by a previous call to <tt class="method">SetBase()</tt>. The public and
system identifiers, <var>systemId</var> and <var>publicId</var>, are strings if
given; if the public identifier is not given, <var>publicId</var> will be
<code>None</code>. The <var>context</var> value is opaque and should only be
used as described below.
<P>
For external entities to be parsed, this handler must be implemented.
It is responsible for creating the sub-parser using
<code>ExternalEntityParserCreate(<var>context</var>)</code>, initializing it with
the appropriate callbacks, and parsing the entity. This handler
should return an integer; if it returns <code>0</code>, the parser will
throw an <tt class="constant">XML_ERROR_EXTERNAL_ENTITY_HANDLING</tt> error,
otherwise parsing will continue.
<P>
If this handler is not provided, external entities are reported by the
<tt class="member">DefaultHandler</tt> callback, if provided.
</dl>
<P>
<DIV CLASS="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="13.5 xml.parsers.expat "
href="module-xml.parsers.expat.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="13.5 xml.parsers.expat "
href="module-xml.parsers.expat.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="13.5.2 ExpatError Exceptions"
href="expaterror-objects.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-xml.parsers.expat.html">13.5 xml.parsers.expat </A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-xml.parsers.expat.html">13.5 xml.parsers.expat </A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="expaterror-objects.html">13.5.2 ExpatError Exceptions</A>
</div>
</div>
<hr />
<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>