4Suite API Documentation

Module Ft.Xml.InputSource

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/
Classes:
Globals:

Classes

class InputSource
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.

Methods

__getstate__(self)
#Pickle routines. We need to be able to pickle an input source #but cannot pickle a stream
__init__(self, stream, uri=None, processIncludes=True, stripElements=None, factory=None, resolver=<Ft.Lib.Uri.FtUriResolver instance at 0x4041fe8c>, catalog=None, encoding=None)
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
clone(self, stream, uri=None, hint=None)
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.
getUriResolver(self)
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(self, uri, base=None, hint=None)
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.
resolveEntity(self, publicId, systemId)
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.

Members

CATALOG_URI_HINT = 'CATALOG URI'
RESOLVE_ENTITY_HINT = 'EXTERNAL ENTITY'
RESOLVE_URI_HINT = 'RESOLVE URI'
class InputSourceFactory
A factory for creating new InputSource instances.

Methods

__init__(self, inputSourceClass=None, resolver=<Ft.Lib.Uri.FtUriResolver instance at 0x4041fe8c>, catalog=None)
fromStream(self, stream, uri=None, *v_args, **kw_args)
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).
fromString(self, st, uri=None, *v_args, **kw_args)
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).
fromUri(self, uri, *v_args, **kw_args)
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")

Members

FACTORY_URI_HINT = 'FACTORY URI'
class NullInputSource(InputSource)
An InputSource that simulates an empty stream.

Methods

__init__(self, uri=None)
Overrides: __init__ from class InputSource

Methods inherited from class InputSource

Members inherited from class InputSource

Globals

DefaultFactory = <Ft.Xml.InputSource.InputSourceFactory instance>
NoCatalogFactory = <Ft.Xml.InputSource.InputSourceFactory instance>