Name

InputSource

Synopsis

The application can use instances of the InputSource class, provided in the xml.sax.xmlreader module, as return values from the resolveEntity method of the EntityResolver interface, or as parameters to the parse convenience function or XMLReader method. There should not normally be a reason to use an alternate implementation of this class, but it is allowed. When the application prepares an InputSource to provide to the parser, it should use the various set methods to configure the object with as much information as it has about the input source.

When the parser receives the InputSource instance, it first attempts to use the character stream if it is available; otherwise it uses the byte stream. If neither of those is available, it uses the system identifier and attempts to open a byte stream itself.

getByteStream( )

Returns the byte stream associated with this input source. This is a stream that returns raw bytes from the input source rather than decoded Unicode characters.

getCharacterStream( )

Returns the character stream associated with this input source. A character stream provides the parser with decoded Unicode characters rather than raw bytes.

getEncoding( )

Returns the encoding of the byte stream if known. If it is not known, return None. If the encoding is not known, the parser applies the rules for auto-detection of the encoding based on the leading bytes of the input stream.

getPublicId( )

Returns the public identifier of the input source, or None ...

Get Python & XML now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.