<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>19.12. xml.sax.xmlreader — Interface for XML parsers — Python v2.6.6 documentation</title>
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '2.6.6',
COLLAPSE_MODINDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="search" type="application/opensearchdescription+xml"
title="Search within Python v2.6.6 documentation"
href="../_static/opensearch.xml"/>
<link rel="author" title="About these documents" href="../about.html" />
<link rel="copyright" title="Copyright" href="../copyright.html" />
<link rel="top" title="Python v2.6.6 documentation" href="../index.html" />
<link rel="up" title="19. Structured Markup Processing Tools" href="markup.html" />
<link rel="next" title="19.13. xml.etree.ElementTree — The ElementTree XML API" href="xml.etree.elementtree.html" />
<link rel="prev" title="19.11. xml.sax.saxutils — SAX Utilities" href="xml.sax.utils.html" />
<link rel="shortcut icon" type="image/png" href="../_static/py.png" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../modindex.html" title="Global Module Index"
accesskey="M">modules</a> |</li>
<li class="right" >
<a href="xml.etree.elementtree.html" title="19.13. xml.etree.ElementTree — The ElementTree XML API"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="xml.sax.utils.html" title="19.11. xml.sax.saxutils — SAX Utilities"
accesskey="P">previous</a> |</li>
<li><img src="../_static/py.png" alt=""
style="vertical-align: middle; margin-top: -1px"/></li>
<li><a href="../index.html">Python v2.6.6 documentation</a> »</li>
<li><a href="index.html" >The Python Standard Library</a> »</li>
<li><a href="markup.html" accesskey="U">19. Structured Markup Processing Tools</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="module-xml.sax.xmlreader">
<h1>19.12. <tt class="xref docutils literal"><span class="pre">xml.sax.xmlreader</span></tt> — Interface for XML parsers<a class="headerlink" href="#module-xml.sax.xmlreader" title="Permalink to this headline">¶</a></h1>
<p class="versionadded">
<span class="versionmodified">New in version 2.0.</span></p>
<p>SAX parsers implement the <a title="xml.sax.xmlreader.XMLReader" class="reference internal" href="#xml.sax.xmlreader.XMLReader"><tt class="xref docutils literal"><span class="pre">XMLReader</span></tt></a> interface. They are implemented in
a Python module, which must provide a function <tt class="xref docutils literal"><span class="pre">create_parser()</span></tt>. This
function is invoked by <a title="xml.sax.make_parser" class="reference external" href="xml.sax.html#xml.sax.make_parser"><tt class="xref docutils literal"><span class="pre">xml.sax.make_parser()</span></tt></a> with no arguments to create
a new parser object.</p>
<dl class="class">
<dt id="xml.sax.xmlreader.XMLReader">
<em class="property">class </em><tt class="descclassname">xml.sax.xmlreader.</tt><tt class="descname">XMLReader</tt><a class="headerlink" href="#xml.sax.xmlreader.XMLReader" title="Permalink to this definition">¶</a></dt>
<dd>Base class which can be inherited by SAX parsers.</dd></dl>
<dl class="class">
<dt id="xml.sax.xmlreader.IncrementalParser">
<em class="property">class </em><tt class="descclassname">xml.sax.xmlreader.</tt><tt class="descname">IncrementalParser</tt><a class="headerlink" href="#xml.sax.xmlreader.IncrementalParser" title="Permalink to this definition">¶</a></dt>
<dd><p>In some cases, it is desirable not to parse an input source at once, but to feed
chunks of the document as they get available. Note that the reader will normally
not read the entire file, but read it in chunks as well; still <tt class="xref docutils literal"><span class="pre">parse()</span></tt>
won’t return until the entire document is processed. So these interfaces should
be used if the blocking behaviour of <tt class="xref docutils literal"><span class="pre">parse()</span></tt> is not desirable.</p>
<p>When the parser is instantiated it is ready to begin accepting data from the
feed method immediately. After parsing has been finished with a call to close
the reset method must be called to make the parser ready to accept new data,
either from feed or using the parse method.</p>
<p>Note that these methods must <em>not</em> be called during parsing, that is, after
parse has been called and before it returns.</p>
<p>By default, the class also implements the parse method of the XMLReader
interface using the feed, close and reset methods of the IncrementalParser
interface as a convenience to SAX 2.0 driver writers.</p>
</dd></dl>
<dl class="class">
<dt id="xml.sax.xmlreader.Locator">
<em class="property">class </em><tt class="descclassname">xml.sax.xmlreader.</tt><tt class="descname">Locator</tt><a class="headerlink" href="#xml.sax.xmlreader.Locator" title="Permalink to this definition">¶</a></dt>
<dd>Interface for associating a SAX event with a document location. A locator object
will return valid results only during calls to DocumentHandler methods; at any
other time, the results are unpredictable. If information is not available,
methods may return <tt class="xref docutils literal"><span class="pre">None</span></tt>.</dd></dl>
<dl class="class">
<dt id="xml.sax.xmlreader.InputSource">
<em class="property">class </em><tt class="descclassname">xml.sax.xmlreader.</tt><tt class="descname">InputSource</tt><big>(</big><span class="optional">[</span><em>systemId</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.InputSource" title="Permalink to this definition">¶</a></dt>
<dd><p>Encapsulation of the information needed by the <a title="xml.sax.xmlreader.XMLReader" class="reference internal" href="#xml.sax.xmlreader.XMLReader"><tt class="xref docutils literal"><span class="pre">XMLReader</span></tt></a> to read
entities.</p>
<p>This class may include information about the public identifier, system
identifier, byte stream (possibly with character encoding information) and/or
the character stream of an entity.</p>
<p>Applications will create objects of this class for use in the
<a title="xml.sax.xmlreader.XMLReader.parse" class="reference internal" href="#xml.sax.xmlreader.XMLReader.parse"><tt class="xref docutils literal"><span class="pre">XMLReader.parse()</span></tt></a> method and for returning from
EntityResolver.resolveEntity.</p>
<p>An <a title="xml.sax.xmlreader.InputSource" class="reference internal" href="#xml.sax.xmlreader.InputSource"><tt class="xref docutils literal"><span class="pre">InputSource</span></tt></a> belongs to the application, the <a title="xml.sax.xmlreader.XMLReader" class="reference internal" href="#xml.sax.xmlreader.XMLReader"><tt class="xref docutils literal"><span class="pre">XMLReader</span></tt></a> is
not allowed to modify <a title="xml.sax.xmlreader.InputSource" class="reference internal" href="#xml.sax.xmlreader.InputSource"><tt class="xref docutils literal"><span class="pre">InputSource</span></tt></a> objects passed to it from the
application, although it may make copies and modify those.</p>
</dd></dl>
<dl class="class">
<dt id="xml.sax.xmlreader.AttributesImpl">
<em class="property">class </em><tt class="descclassname">xml.sax.xmlreader.</tt><tt class="descname">AttributesImpl</tt><big>(</big><em>attrs</em><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.AttributesImpl" title="Permalink to this definition">¶</a></dt>
<dd>This is an implementation of the <tt class="xref docutils literal"><span class="pre">Attributes</span></tt> interface (see section
<a class="reference internal" href="#attributes-objects"><em>The Attributes Interface</em></a>). This is a dictionary-like object which
represents the element attributes in a <tt class="xref docutils literal"><span class="pre">startElement()</span></tt> call. In addition
to the most useful dictionary operations, it supports a number of other
methods as described by the interface. Objects of this class should be
instantiated by readers; <em>attrs</em> must be a dictionary-like object containing
a mapping from attribute names to attribute values.</dd></dl>
<dl class="class">
<dt id="xml.sax.xmlreader.AttributesNSImpl">
<em class="property">class </em><tt class="descclassname">xml.sax.xmlreader.</tt><tt class="descname">AttributesNSImpl</tt><big>(</big><em>attrs</em>, <em>qnames</em><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.AttributesNSImpl" title="Permalink to this definition">¶</a></dt>
<dd>Namespace-aware variant of <a title="xml.sax.xmlreader.AttributesImpl" class="reference internal" href="#xml.sax.xmlreader.AttributesImpl"><tt class="xref docutils literal"><span class="pre">AttributesImpl</span></tt></a>, which will be passed to
<tt class="xref docutils literal"><span class="pre">startElementNS()</span></tt>. It is derived from <a title="xml.sax.xmlreader.AttributesImpl" class="reference internal" href="#xml.sax.xmlreader.AttributesImpl"><tt class="xref docutils literal"><span class="pre">AttributesImpl</span></tt></a>, but
understands attribute names as two-tuples of <em>namespaceURI</em> and
<em>localname</em>. In addition, it provides a number of methods expecting qualified
names as they appear in the original document. This class implements the
<tt class="xref docutils literal"><span class="pre">AttributesNS</span></tt> interface (see section <a class="reference internal" href="#attributes-ns-objects"><em>The AttributesNS Interface</em></a>).</dd></dl>
<div class="section" id="xmlreader-objects">
<span id="id1"></span><h2>19.12.1. XMLReader Objects<a class="headerlink" href="#xmlreader-objects" title="Permalink to this headline">¶</a></h2>
<p>The <a title="xml.sax.xmlreader.XMLReader" class="reference internal" href="#xml.sax.xmlreader.XMLReader"><tt class="xref docutils literal"><span class="pre">XMLReader</span></tt></a> interface supports the following methods:</p>
<dl class="method">
<dt id="xml.sax.xmlreader.XMLReader.parse">
<tt class="descclassname">XMLReader.</tt><tt class="descname">parse</tt><big>(</big><em>source</em><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.XMLReader.parse" title="Permalink to this definition">¶</a></dt>
<dd>Process an input source, producing SAX events. The <em>source</em> object can be a
system identifier (a string identifying the input source – typically a file
name or an URL), a file-like object, or an <a title="xml.sax.xmlreader.InputSource" class="reference internal" href="#xml.sax.xmlreader.InputSource"><tt class="xref docutils literal"><span class="pre">InputSource</span></tt></a> object. When
<a title="xml.sax.xmlreader.XMLReader.parse" class="reference internal" href="#xml.sax.xmlreader.XMLReader.parse"><tt class="xref docutils literal"><span class="pre">parse()</span></tt></a> returns, the input is completely processed, and the parser object
can be discarded or reset. As a limitation, the current implementation only
accepts byte streams; processing of character streams is for further study.</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.XMLReader.getContentHandler">
<tt class="descclassname">XMLReader.</tt><tt class="descname">getContentHandler</tt><big>(</big><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.XMLReader.getContentHandler" title="Permalink to this definition">¶</a></dt>
<dd>Return the current <tt class="xref docutils literal"><span class="pre">ContentHandler</span></tt>.</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.XMLReader.setContentHandler">
<tt class="descclassname">XMLReader.</tt><tt class="descname">setContentHandler</tt><big>(</big><em>handler</em><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.XMLReader.setContentHandler" title="Permalink to this definition">¶</a></dt>
<dd>Set the current <tt class="xref docutils literal"><span class="pre">ContentHandler</span></tt>. If no <tt class="xref docutils literal"><span class="pre">ContentHandler</span></tt> is set,
content events will be discarded.</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.XMLReader.getDTDHandler">
<tt class="descclassname">XMLReader.</tt><tt class="descname">getDTDHandler</tt><big>(</big><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.XMLReader.getDTDHandler" title="Permalink to this definition">¶</a></dt>
<dd>Return the current <tt class="xref docutils literal"><span class="pre">DTDHandler</span></tt>.</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.XMLReader.setDTDHandler">
<tt class="descclassname">XMLReader.</tt><tt class="descname">setDTDHandler</tt><big>(</big><em>handler</em><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.XMLReader.setDTDHandler" title="Permalink to this definition">¶</a></dt>
<dd>Set the current <tt class="xref docutils literal"><span class="pre">DTDHandler</span></tt>. If no <tt class="xref docutils literal"><span class="pre">DTDHandler</span></tt> is set, DTD
events will be discarded.</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.XMLReader.getEntityResolver">
<tt class="descclassname">XMLReader.</tt><tt class="descname">getEntityResolver</tt><big>(</big><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.XMLReader.getEntityResolver" title="Permalink to this definition">¶</a></dt>
<dd>Return the current <tt class="xref docutils literal"><span class="pre">EntityResolver</span></tt>.</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.XMLReader.setEntityResolver">
<tt class="descclassname">XMLReader.</tt><tt class="descname">setEntityResolver</tt><big>(</big><em>handler</em><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.XMLReader.setEntityResolver" title="Permalink to this definition">¶</a></dt>
<dd>Set the current <tt class="xref docutils literal"><span class="pre">EntityResolver</span></tt>. If no <tt class="xref docutils literal"><span class="pre">EntityResolver</span></tt> is set,
attempts to resolve an external entity will result in opening the system
identifier for the entity, and fail if it is not available.</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.XMLReader.getErrorHandler">
<tt class="descclassname">XMLReader.</tt><tt class="descname">getErrorHandler</tt><big>(</big><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.XMLReader.getErrorHandler" title="Permalink to this definition">¶</a></dt>
<dd>Return the current <tt class="xref docutils literal"><span class="pre">ErrorHandler</span></tt>.</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.XMLReader.setErrorHandler">
<tt class="descclassname">XMLReader.</tt><tt class="descname">setErrorHandler</tt><big>(</big><em>handler</em><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.XMLReader.setErrorHandler" title="Permalink to this definition">¶</a></dt>
<dd>Set the current error handler. If no <tt class="xref docutils literal"><span class="pre">ErrorHandler</span></tt> is set, errors will
be raised as exceptions, and warnings will be printed.</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.XMLReader.setLocale">
<tt class="descclassname">XMLReader.</tt><tt class="descname">setLocale</tt><big>(</big><em>locale</em><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.XMLReader.setLocale" title="Permalink to this definition">¶</a></dt>
<dd><p>Allow an application to set the locale for errors and warnings.</p>
<p>SAX parsers are not required to provide localization for errors and warnings; if
they cannot support the requested locale, however, they must throw a SAX
exception. Applications may request a locale change in the middle of a parse.</p>
</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.XMLReader.getFeature">
<tt class="descclassname">XMLReader.</tt><tt class="descname">getFeature</tt><big>(</big><em>featurename</em><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.XMLReader.getFeature" title="Permalink to this definition">¶</a></dt>
<dd>Return the current setting for feature <em>featurename</em>. If the feature is not
recognized, <tt class="xref docutils literal"><span class="pre">SAXNotRecognizedException</span></tt> is raised. The well-known
featurenames are listed in the module <a title="Base classes for SAX event handlers." class="reference external" href="xml.sax.handler.html#module-xml.sax.handler"><tt class="xref docutils literal"><span class="pre">xml.sax.handler</span></tt></a>.</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.XMLReader.setFeature">
<tt class="descclassname">XMLReader.</tt><tt class="descname">setFeature</tt><big>(</big><em>featurename</em>, <em>value</em><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.XMLReader.setFeature" title="Permalink to this definition">¶</a></dt>
<dd>Set the <em>featurename</em> to <em>value</em>. If the feature is not recognized,
<tt class="xref docutils literal"><span class="pre">SAXNotRecognizedException</span></tt> is raised. If the feature or its setting is not
supported by the parser, <em>SAXNotSupportedException</em> is raised.</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.XMLReader.getProperty">
<tt class="descclassname">XMLReader.</tt><tt class="descname">getProperty</tt><big>(</big><em>propertyname</em><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.XMLReader.getProperty" title="Permalink to this definition">¶</a></dt>
<dd>Return the current setting for property <em>propertyname</em>. If the property is not
recognized, a <tt class="xref docutils literal"><span class="pre">SAXNotRecognizedException</span></tt> is raised. The well-known
propertynames are listed in the module <a title="Base classes for SAX event handlers." class="reference external" href="xml.sax.handler.html#module-xml.sax.handler"><tt class="xref docutils literal"><span class="pre">xml.sax.handler</span></tt></a>.</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.XMLReader.setProperty">
<tt class="descclassname">XMLReader.</tt><tt class="descname">setProperty</tt><big>(</big><em>propertyname</em>, <em>value</em><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.XMLReader.setProperty" title="Permalink to this definition">¶</a></dt>
<dd>Set the <em>propertyname</em> to <em>value</em>. If the property is not recognized,
<tt class="xref docutils literal"><span class="pre">SAXNotRecognizedException</span></tt> is raised. If the property or its setting is
not supported by the parser, <em>SAXNotSupportedException</em> is raised.</dd></dl>
</div>
<div class="section" id="incrementalparser-objects">
<span id="incremental-parser-objects"></span><h2>19.12.2. IncrementalParser Objects<a class="headerlink" href="#incrementalparser-objects" title="Permalink to this headline">¶</a></h2>
<p>Instances of <a title="xml.sax.xmlreader.IncrementalParser" class="reference internal" href="#xml.sax.xmlreader.IncrementalParser"><tt class="xref docutils literal"><span class="pre">IncrementalParser</span></tt></a> offer the following additional methods:</p>
<dl class="method">
<dt id="xml.sax.xmlreader.IncrementalParser.feed">
<tt class="descclassname">IncrementalParser.</tt><tt class="descname">feed</tt><big>(</big><em>data</em><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.IncrementalParser.feed" title="Permalink to this definition">¶</a></dt>
<dd>Process a chunk of <em>data</em>.</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.IncrementalParser.close">
<tt class="descclassname">IncrementalParser.</tt><tt class="descname">close</tt><big>(</big><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.IncrementalParser.close" title="Permalink to this definition">¶</a></dt>
<dd>Assume the end of the document. That will check well-formedness conditions that
can be checked only at the end, invoke handlers, and may clean up resources
allocated during parsing.</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.IncrementalParser.reset">
<tt class="descclassname">IncrementalParser.</tt><tt class="descname">reset</tt><big>(</big><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.IncrementalParser.reset" title="Permalink to this definition">¶</a></dt>
<dd>This method is called after close has been called to reset the parser so that it
is ready to parse new documents. The results of calling parse or feed after
close without calling reset are undefined.</dd></dl>
</div>
<div class="section" id="locator-objects">
<span id="id2"></span><h2>19.12.3. Locator Objects<a class="headerlink" href="#locator-objects" title="Permalink to this headline">¶</a></h2>
<p>Instances of <a title="xml.sax.xmlreader.Locator" class="reference internal" href="#xml.sax.xmlreader.Locator"><tt class="xref docutils literal"><span class="pre">Locator</span></tt></a> provide these methods:</p>
<dl class="method">
<dt id="xml.sax.xmlreader.Locator.getColumnNumber">
<tt class="descclassname">Locator.</tt><tt class="descname">getColumnNumber</tt><big>(</big><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.Locator.getColumnNumber" title="Permalink to this definition">¶</a></dt>
<dd>Return the column number where the current event ends.</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.Locator.getLineNumber">
<tt class="descclassname">Locator.</tt><tt class="descname">getLineNumber</tt><big>(</big><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.Locator.getLineNumber" title="Permalink to this definition">¶</a></dt>
<dd>Return the line number where the current event ends.</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.Locator.getPublicId">
<tt class="descclassname">Locator.</tt><tt class="descname">getPublicId</tt><big>(</big><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.Locator.getPublicId" title="Permalink to this definition">¶</a></dt>
<dd>Return the public identifier for the current event.</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.Locator.getSystemId">
<tt class="descclassname">Locator.</tt><tt class="descname">getSystemId</tt><big>(</big><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.Locator.getSystemId" title="Permalink to this definition">¶</a></dt>
<dd>Return the system identifier for the current event.</dd></dl>
</div>
<div class="section" id="inputsource-objects">
<span id="input-source-objects"></span><h2>19.12.4. InputSource Objects<a class="headerlink" href="#inputsource-objects" title="Permalink to this headline">¶</a></h2>
<dl class="method">
<dt id="xml.sax.xmlreader.InputSource.setPublicId">
<tt class="descclassname">InputSource.</tt><tt class="descname">setPublicId</tt><big>(</big><em>id</em><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.InputSource.setPublicId" title="Permalink to this definition">¶</a></dt>
<dd>Sets the public identifier of this <a title="xml.sax.xmlreader.InputSource" class="reference internal" href="#xml.sax.xmlreader.InputSource"><tt class="xref docutils literal"><span class="pre">InputSource</span></tt></a>.</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.InputSource.getPublicId">
<tt class="descclassname">InputSource.</tt><tt class="descname">getPublicId</tt><big>(</big><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.InputSource.getPublicId" title="Permalink to this definition">¶</a></dt>
<dd>Returns the public identifier of this <a title="xml.sax.xmlreader.InputSource" class="reference internal" href="#xml.sax.xmlreader.InputSource"><tt class="xref docutils literal"><span class="pre">InputSource</span></tt></a>.</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.InputSource.setSystemId">
<tt class="descclassname">InputSource.</tt><tt class="descname">setSystemId</tt><big>(</big><em>id</em><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.InputSource.setSystemId" title="Permalink to this definition">¶</a></dt>
<dd>Sets the system identifier of this <a title="xml.sax.xmlreader.InputSource" class="reference internal" href="#xml.sax.xmlreader.InputSource"><tt class="xref docutils literal"><span class="pre">InputSource</span></tt></a>.</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.InputSource.getSystemId">
<tt class="descclassname">InputSource.</tt><tt class="descname">getSystemId</tt><big>(</big><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.InputSource.getSystemId" title="Permalink to this definition">¶</a></dt>
<dd>Returns the system identifier of this <a title="xml.sax.xmlreader.InputSource" class="reference internal" href="#xml.sax.xmlreader.InputSource"><tt class="xref docutils literal"><span class="pre">InputSource</span></tt></a>.</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.InputSource.setEncoding">
<tt class="descclassname">InputSource.</tt><tt class="descname">setEncoding</tt><big>(</big><em>encoding</em><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.InputSource.setEncoding" title="Permalink to this definition">¶</a></dt>
<dd><p>Sets the character encoding of this <a title="xml.sax.xmlreader.InputSource" class="reference internal" href="#xml.sax.xmlreader.InputSource"><tt class="xref docutils literal"><span class="pre">InputSource</span></tt></a>.</p>
<p>The encoding must be a string acceptable for an XML encoding declaration (see
section 4.3.3 of the XML recommendation).</p>
<p>The encoding attribute of the <a title="xml.sax.xmlreader.InputSource" class="reference internal" href="#xml.sax.xmlreader.InputSource"><tt class="xref docutils literal"><span class="pre">InputSource</span></tt></a> is ignored if the
<a title="xml.sax.xmlreader.InputSource" class="reference internal" href="#xml.sax.xmlreader.InputSource"><tt class="xref docutils literal"><span class="pre">InputSource</span></tt></a> also contains a character stream.</p>
</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.InputSource.getEncoding">
<tt class="descclassname">InputSource.</tt><tt class="descname">getEncoding</tt><big>(</big><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.InputSource.getEncoding" title="Permalink to this definition">¶</a></dt>
<dd>Get the character encoding of this InputSource.</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.InputSource.setByteStream">
<tt class="descclassname">InputSource.</tt><tt class="descname">setByteStream</tt><big>(</big><em>bytefile</em><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.InputSource.setByteStream" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the byte stream (a Python file-like object which does not perform
byte-to-character conversion) for this input source.</p>
<p>The SAX parser will ignore this if there is also a character stream specified,
but it will use a byte stream in preference to opening a URI connection itself.</p>
<p>If the application knows the character encoding of the byte stream, it should
set it with the setEncoding method.</p>
</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.InputSource.getByteStream">
<tt class="descclassname">InputSource.</tt><tt class="descname">getByteStream</tt><big>(</big><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.InputSource.getByteStream" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the byte stream for this input source.</p>
<p>The getEncoding method will return the character encoding for this byte stream,
or None if unknown.</p>
</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.InputSource.setCharacterStream">
<tt class="descclassname">InputSource.</tt><tt class="descname">setCharacterStream</tt><big>(</big><em>charfile</em><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.InputSource.setCharacterStream" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the character stream for this input source. (The stream must be a Python 1.6
Unicode-wrapped file-like that performs conversion to Unicode strings.)</p>
<p>If there is a character stream specified, the SAX parser will ignore any byte
stream and will not attempt to open a URI connection to the system identifier.</p>
</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.InputSource.getCharacterStream">
<tt class="descclassname">InputSource.</tt><tt class="descname">getCharacterStream</tt><big>(</big><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.InputSource.getCharacterStream" title="Permalink to this definition">¶</a></dt>
<dd>Get the character stream for this input source.</dd></dl>
</div>
<div class="section" id="the-attributes-interface">
<span id="attributes-objects"></span><h2>19.12.5. The <tt class="xref docutils literal"><span class="pre">Attributes</span></tt> Interface<a class="headerlink" href="#the-attributes-interface" title="Permalink to this headline">¶</a></h2>
<p><tt class="xref docutils literal"><span class="pre">Attributes</span></tt> objects implement a portion of the mapping protocol,
including the methods <tt class="xref docutils literal"><span class="pre">copy()</span></tt>, <tt class="xref docutils literal"><span class="pre">get()</span></tt>, <tt class="xref docutils literal"><span class="pre">has_key()</span></tt>, <tt class="xref docutils literal"><span class="pre">items()</span></tt>,
<tt class="xref docutils literal"><span class="pre">keys()</span></tt>, and <tt class="xref docutils literal"><span class="pre">values()</span></tt>. The following methods are also provided:</p>
<dl class="method">
<dt id="xml.sax.xmlreader.Attributes.getLength">
<tt class="descclassname">Attributes.</tt><tt class="descname">getLength</tt><big>(</big><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.Attributes.getLength" title="Permalink to this definition">¶</a></dt>
<dd>Return the number of attributes.</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.Attributes.getNames">
<tt class="descclassname">Attributes.</tt><tt class="descname">getNames</tt><big>(</big><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.Attributes.getNames" title="Permalink to this definition">¶</a></dt>
<dd>Return the names of the attributes.</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.Attributes.getType">
<tt class="descclassname">Attributes.</tt><tt class="descname">getType</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.Attributes.getType" title="Permalink to this definition">¶</a></dt>
<dd>Returns the type of the attribute <em>name</em>, which is normally <tt class="docutils literal"><span class="pre">'CDATA'</span></tt>.</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.Attributes.getValue">
<tt class="descclassname">Attributes.</tt><tt class="descname">getValue</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.Attributes.getValue" title="Permalink to this definition">¶</a></dt>
<dd>Return the value of attribute <em>name</em>.</dd></dl>
</div>
<div class="section" id="the-attributesns-interface">
<span id="attributes-ns-objects"></span><h2>19.12.6. The <tt class="xref docutils literal"><span class="pre">AttributesNS</span></tt> Interface<a class="headerlink" href="#the-attributesns-interface" title="Permalink to this headline">¶</a></h2>
<p>This interface is a subtype of the <tt class="xref docutils literal"><span class="pre">Attributes</span></tt> interface (see section
<a class="reference internal" href="#attributes-objects"><em>The Attributes Interface</em></a>). All methods supported by that interface are also
available on <tt class="xref docutils literal"><span class="pre">AttributesNS</span></tt> objects.</p>
<p>The following methods are also available:</p>
<dl class="method">
<dt id="xml.sax.xmlreader.AttributesNS.getValueByQName">
<tt class="descclassname">AttributesNS.</tt><tt class="descname">getValueByQName</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.AttributesNS.getValueByQName" title="Permalink to this definition">¶</a></dt>
<dd>Return the value for a qualified name.</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.AttributesNS.getNameByQName">
<tt class="descclassname">AttributesNS.</tt><tt class="descname">getNameByQName</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.AttributesNS.getNameByQName" title="Permalink to this definition">¶</a></dt>
<dd>Return the <tt class="docutils literal"><span class="pre">(namespace,</span> <span class="pre">localname)</span></tt> pair for a qualified <em>name</em>.</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.AttributesNS.getQNameByName">
<tt class="descclassname">AttributesNS.</tt><tt class="descname">getQNameByName</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.AttributesNS.getQNameByName" title="Permalink to this definition">¶</a></dt>
<dd>Return the qualified name for a <tt class="docutils literal"><span class="pre">(namespace,</span> <span class="pre">localname)</span></tt> pair.</dd></dl>
<dl class="method">
<dt id="xml.sax.xmlreader.AttributesNS.getQNames">
<tt class="descclassname">AttributesNS.</tt><tt class="descname">getQNames</tt><big>(</big><big>)</big><a class="headerlink" href="#xml.sax.xmlreader.AttributesNS.getQNames" title="Permalink to this definition">¶</a></dt>
<dd>Return the qualified names of all attributes.</dd></dl>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="../contents.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference external" href="#">19.12. <tt class="docutils literal"><span class="pre">xml.sax.xmlreader</span></tt> — Interface for XML parsers</a><ul>
<li><a class="reference external" href="#xmlreader-objects">19.12.1. XMLReader Objects</a></li>
<li><a class="reference external" href="#incrementalparser-objects">19.12.2. IncrementalParser Objects</a></li>
<li><a class="reference external" href="#locator-objects">19.12.3. Locator Objects</a></li>
<li><a class="reference external" href="#inputsource-objects">19.12.4. InputSource Objects</a></li>
<li><a class="reference external" href="#the-attributes-interface">19.12.5. The <tt class="docutils literal"><span class="pre">Attributes</span></tt> Interface</a></li>
<li><a class="reference external" href="#the-attributesns-interface">19.12.6. The <tt class="docutils literal"><span class="pre">AttributesNS</span></tt> Interface</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="xml.sax.utils.html"
title="previous chapter">19.11. <tt class="docutils literal docutils literal"><span class="pre">xml.sax.saxutils</span></tt> — SAX Utilities</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="xml.etree.elementtree.html"
title="next chapter">19.13. <tt class="docutils literal docutils literal docutils literal"><span class="pre">xml.etree.ElementTree</span></tt> — The ElementTree XML API</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../bugs.html">Report a Bug</a></li>
<li><a href="../_sources/library/xml.sax.reader.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="../search.html" method="get">
<input type="text" name="q" size="18" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../modindex.html" title="Global Module Index"
>modules</a> |</li>
<li class="right" >
<a href="xml.etree.elementtree.html" title="19.13. xml.etree.ElementTree — The ElementTree XML API"
>next</a> |</li>
<li class="right" >
<a href="xml.sax.utils.html" title="19.11. xml.sax.saxutils — SAX Utilities"
>previous</a> |</li>
<li><img src="../_static/py.png" alt=""
style="vertical-align: middle; margin-top: -1px"/></li>
<li><a href="../index.html">Python v2.6.6 documentation</a> »</li>
<li><a href="index.html" >The Python Standard Library</a> »</li>
<li><a href="markup.html" >19. Structured Markup Processing Tools</a> »</li>
</ul>
</div>
<div class="footer">
© <a href="../copyright.html">Copyright</a> 1990-2011, Python Software Foundation.
<br />
The Python Software Foundation is a non-profit corporation.
<a href="http://www.python.org/psf/donations/">Please donate.</a>
<br />
Last updated on Jul 20, 2011.
<a href="../bugs.html">Found a bug</a>?
<br />
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.6.
</div>
</body>
</html>
Copyright 2K16 - 2K18 Indonesian Hacker Rulez