2006-04-28 13:54:48

Classes providing a standard interface and encapsulation of metadata for document/entity streams intended for input to various XML processors.

Copyright 2005 Fourthought, Inc. (USA). Detailed license and copyright information: http://4suite.org/COPYRIGHT Project home, documentation, distributions: http://4suite.org/

An input source is an encapsulation of a source of content. It includes a stream (Python file-like object) from which the content can be read, a URI to identify the stream and facilitate resolution of relative URI references / system IDs encountered within the stream, and parameters used by the processors of the stream (XML parsers, XSLT processors).

It is designed to be overridden as applications need different functionality from sources.

#Pickle routines. We need to be able to pickle an input source #but cannot pickle a stream

InputSource constructor

source = InputSource(...)

stream - the stream associated with this input source uri - the absolute URI of the input source processIncludes - Whether or not XIncludes should be expanded stripElements - Space stripping rules factory - The factory that created this instance resolver - URI resolver; defaults to Ft.Lib.Uri.BASIC_RESOLVER catalog - TR9401/XML Catalog object for resolving public IDs encoding - a string externally declaring the stream's encoding

Clones this input source, creating a new instance with the known params.

If your derived InputSource requires additional state information then you have to override how it is cloned and pickled.

This method returns the URI resolver that is used by this input source to normalize (resolve to absolute form) and resolve (dereference) URI references. This is the public method to use if just URI resolution is needed.

Resolve a URI reference into a new InputSource.

This function is used when a URI reference is encountered in the original stream and needs to be resolved (e.g. xi:include, xsl:include, xsl:import, document(), etc.). When a catalog is available, its URI entries are used first. If no entry is found, the URI is resolved against the current URI and then opened.

The hint parameter is used to give a hint as to what the resolution will be used for.

If the ignoreErrors flag is set, an error during resolution (such as "file not found") will result in None's being returned, rather than a raised exception.

Resolve an external entity to a new InputSource.

Presented with an optional public identifier and a system identifier, this function attempts to locate a mapping in the catalog, if one is defined. If no mapping is found, the system identifier will be dereferenced as a URL.
- 'CATALOG URI'
- 'EXTERNAL ENTITY'
- 'RESOLVE URI'

A factory for creating new InputSource instances.

Creates an InputSource from the given stream. The uri argument is the URI to use for the stream (one should always be given, even if it's bogus).

Creates an InputSource from a stream derived from the given string. The uri argument is the URI to use for the stream (one should always be given, even if it's bogus).

Creates an InputSource from the stream resulting from the resolution of the given URI.

uri - a URI from which the input will be read. Important: a file path is generally not a URI. To be safe, if you wish to read from a file, use the following pattern: from Ft.Lib import Uri uri = Uri.OsPathToUri("/path/to/file.ext") OR uri = Uri.OsPathToUri("C:\path\to\file.ext")
- 'FACTORY URI'

An InputSource that simulates an empty stream.

<Ft.Xml.InputSource.InputSourceFactory instance>
<Ft.Xml.InputSource.InputSourceFactory instance>
['InputSource', 'NullInputSource', 'InputSourceFactory', 'DefaultFactory', 'NoCatalogFactory']