summaryrefslogtreecommitdiffstats
path: root/Doc/library/xml.sax.reader.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/library/xml.sax.reader.rst')
-rw-r--r--Doc/library/xml.sax.reader.rst37
1 files changed, 17 insertions, 20 deletions
diff --git a/Doc/library/xml.sax.reader.rst b/Doc/library/xml.sax.reader.rst
index 113e9e9..17aa8f0 100644
--- a/Doc/library/xml.sax.reader.rst
+++ b/Doc/library/xml.sax.reader.rst
@@ -1,15 +1,14 @@
+
:mod:`xml.sax.xmlreader` --- Interface for XML parsers
======================================================
.. module:: xml.sax.xmlreader
:synopsis: Interface which SAX-compliant XML parsers must implement.
-
.. moduleauthor:: Lars Marius Garshol <larsga@garshol.priv.no>
.. sectionauthor:: Martin v. Löwis <martin@v.loewis.de>
-**Source code:** :source:`Lib/xml/sax/xmlreader.py`
---------------
+.. versionadded:: 2.0
SAX parsers implement the :class:`XMLReader` interface. They are implemented in
a Python module, which must provide a function :func:`create_parser`. This
@@ -51,7 +50,7 @@ a new parser object.
methods may return ``None``.
-.. class:: InputSource(system_id=None)
+.. class:: InputSource([systemId])
Encapsulation of the information needed by the :class:`XMLReader` to read
entities.
@@ -102,16 +101,10 @@ The :class:`XMLReader` interface supports the following methods:
Process an input source, producing SAX events. The *source* object can be a
system identifier (a string identifying the input source -- typically a file
- name or a URL), a :class:`pathlib.Path` or :term:`path-like <path-like object>`
- object, or an :class:`InputSource` object. When
+ name or a URL), a file-like object, or an :class:`InputSource` object. When
:meth:`parse` returns, the input is completely processed, and the parser object
- can be discarded or reset.
-
- .. versionchanged:: 3.5
- Added support of character streams.
-
- .. versionchanged:: 3.8
- Added support of path-like objects.
+ can be discarded or reset. As a limitation, the current implementation only
+ accepts byte streams; processing of character streams is for further study.
.. method:: XMLReader.getContentHandler()
@@ -298,7 +291,8 @@ InputSource Objects
.. method:: InputSource.setByteStream(bytefile)
- Set the byte stream (a :term:`binary file`) for this input source.
+ Set the byte stream (a Python file-like object which does not perform
+ byte-to-character conversion) for this input source.
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.
@@ -317,7 +311,8 @@ InputSource Objects
.. method:: InputSource.setCharacterStream(charfile)
- Set the character stream (a :term:`text file`) for this input source.
+ 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.)
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.
@@ -333,11 +328,13 @@ InputSource Objects
The :class:`Attributes` Interface
---------------------------------
-:class:`Attributes` objects implement a portion of the :term:`mapping protocol
-<mapping>`, including the methods :meth:`~collections.abc.Mapping.copy`,
-:meth:`~collections.abc.Mapping.get`, :meth:`~object.__contains__`,
-:meth:`~collections.abc.Mapping.items`, :meth:`~collections.abc.Mapping.keys`,
-and :meth:`~collections.abc.Mapping.values`. The following methods
+:class:`Attributes` objects implement a portion of the mapping protocol,
+including the methods :meth:`~collections.Mapping.copy`,
+:meth:`~collections.Mapping.get`,
+:meth:`~collections.Mapping.has_key`,
+:meth:`~collections.Mapping.items`,
+:meth:`~collections.Mapping.keys`,
+and :meth:`~collections.Mapping.values`. The following methods
are also provided: