4Suite™ API Documentation

# ► Module Ft.Xml.Domlette

Abstraction module for Domlette usage. Domlette is a DOM-like library tailored for use in XPath/XSLT.

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

Classes: EntityReaderBase, NoExtDtdReaderBase, NonvalidatingReaderBase, ValidatingReaderBase |  |  |  | Functions: CanonicalPrint, ConvertDocument, GetAllNs, NonvalParse, PrettyPrint, Print, SeekNss, ValParse |  |  |  | Globals: EntityReader, NoExtDtdReader, NonvalidatingReader, ValidatingReader, implementation

## Classes

class EntityReaderBase(Ft.Xml.Domlette._Reader)
  Base class to be used by all readers which can accept well-formed EPEs. Non-validating only. Allows an InputSource factory to be specified. Allows control over whether the external DTD subset is read.

  ### Methods

  __init__(self, inputSourceFactory=None)
    Overrides: __init__ from class _Reader

  ### Methods inherited from class Ft.Xml.Domlette._Reader

  parse(self, inputSource)
    Reads XML from an Ft.Xml.Inputsource.InputSource, and returns a Domlette document node.
  parseStream(self, stream, uri=None, *v_args, **kw_args)
    Reads an XML document entity from a python file-like object (the stream argument), and returns a Domlette document node.

        The document URI should be provided as the uri argument.
        This will be used in the resolution of system IDs in the DTD
        and document type declaration, and will be embedded in the
        Domlette nodes for use by the application, such as for
        resolution of relative URI references in XSLT's document(),
        xsl:import, and xsl:include, among others.

  parseString(self, st, uri=None, *v_args, **kw_args)
    Reads an XML document entity provided as an ordinary python byte string (the st argument), and returns a Domlette document node. st cannot be a Unicode string.

        The document URI should be provided as the uri argument.
        This will be used in the resolution of system IDs in the DTD
        and document type declaration, and will be embedded in the
        Domlette nodes for use by the application, such as for
        resolution of relative URI references in XSLT's document(),
        xsl:import, and xsl:include, among others.

  parseUri(self, uri, *v_args, **kw_args)
    Reads an XML document entity from a URI (the uri argument), and returns a Domlette document node.
class NoExtDtdReaderBase(Ft.Xml.Domlette._Reader)
  Base class to be used by all non-validating readers that do not need to read the external DTD subset. Allows an InputSource factory to be specified.

  ### Methods

  __init__(self, inputSourceFactory=None)
    Overrides: __init__ from class _Reader

  ### Methods inherited from class Ft.Xml.Domlette._Reader

  parse(self, inputSource)
    Reads XML from an Ft.Xml.Inputsource.InputSource, and returns a Domlette document node.
  parseStream(self, stream, uri=None, *v_args, **kw_args)
    Reads an XML document entity from a python file-like object (the stream argument), and returns a Domlette document node.

        The document URI should be provided as the uri argument.
        This will be used in the resolution of system IDs in the DTD
        and document type declaration, and will be embedded in the
        Domlette nodes for use by the application, such as for
        resolution of relative URI references in XSLT's document(),
        xsl:import, and xsl:include, among others.

  parseString(self, st, uri=None, *v_args, **kw_args)
    Reads an XML document entity provided as an ordinary python byte string (the st argument), and returns a Domlette document node. st cannot be a Unicode string.

        The document URI should be provided as the uri argument.
        This will be used in the resolution of system IDs in the DTD
        and document type declaration, and will be embedded in the
        Domlette nodes for use by the application, such as for
        resolution of relative URI references in XSLT's document(),
        xsl:import, and xsl:include, among others.

  parseUri(self, uri, *v_args, **kw_args)
    Reads an XML document entity from a URI (the uri argument), and returns a Domlette document node.
class NonvalidatingReaderBase(Ft.Xml.Domlette._Reader)
  Base class to be used by all non-validating readers. Allows an InputSource factory to be specified. Allows control over whether the external DTD subset is read.

  ### Methods

  __init__(self, inputSourceFactory=None)
    Overrides: __init__ from class _Reader

  ### Methods inherited from class Ft.Xml.Domlette._Reader

  parse(self, inputSource)
    Reads XML from an Ft.Xml.Inputsource.InputSource, and returns a Domlette document node.
  parseStream(self, stream, uri=None, *v_args, **kw_args)
    Reads an XML document entity from a python file-like object (the stream argument), and returns a Domlette document node.

        The document URI should be provided as the uri argument.
        This will be used in the resolution of system IDs in the DTD
        and document type declaration, and will be embedded in the
        Domlette nodes for use by the application, such as for
        resolution of relative URI references in XSLT's document(),
        xsl:import, and xsl:include, among others.

  parseString(self, st, uri=None, *v_args, **kw_args)
    Reads an XML document entity provided as an ordinary python byte string (the st argument), and returns a Domlette document node. st cannot be a Unicode string.

        The document URI should be provided as the uri argument.
        This will be used in the resolution of system IDs in the DTD
        and document type declaration, and will be embedded in the
        Domlette nodes for use by the application, such as for
        resolution of relative URI references in XSLT's document(),
        xsl:import, and xsl:include, among others.

  parseUri(self, uri, *v_args, **kw_args)
    Reads an XML document entity from a URI (the uri argument), and returns a Domlette document node.
class ValidatingReaderBase(Ft.Xml.Domlette._Reader)
  Base class to be used by all validating readers. Allows an InputSource factory to be specified.

  ### Methods

  __init__(self, inputSourceFactory=None)
    Overrides: __init__ from class _Reader

  ### Methods inherited from class Ft.Xml.Domlette._Reader

  parse(self, inputSource)
    Reads XML from an Ft.Xml.Inputsource.InputSource, and returns a Domlette document node.
  parseStream(self, stream, uri=None, *v_args, **kw_args)
    Reads an XML document entity from a python file-like object (the stream argument), and returns a Domlette document node.

        The document URI should be provided as the uri argument.
        This will be used in the resolution of system IDs in the DTD
        and document type declaration, and will be embedded in the
        Domlette nodes for use by the application, such as for
        resolution of relative URI references in XSLT's document(),
        xsl:import, and xsl:include, among others.

  parseString(self, st, uri=None, *v_args, **kw_args)
    Reads an XML document entity provided as an ordinary python byte string (the st argument), and returns a Domlette document node. st cannot be a Unicode string.

        The document URI should be provided as the uri argument.
        This will be used in the resolution of system IDs in the DTD
        and document type declaration, and will be embedded in the
        Domlette nodes for use by the application, such as for
        resolution of relative URI references in XSLT's document(),
        xsl:import, and xsl:include, among others.

  parseUri(self, uri, *v_args, **kw_args)
    Reads an XML document entity from a URI (the uri argument), and returns a Domlette document node.

## Functions

CanonicalPrint(root, stream=<open file '<stdout>', mode 'w' at 0xb7ddd068>, exclusive=False, inclusivePrefixes=None)
  Given a Node instance assumed to be the root of an XML DOM or Domlette tree, this function serializes the document to the given stream or stdout, using c14n serialization, according to http://www.w3.org/TR/xml-c14n (the default) or http://www.w3.org/TR/xml-exc-c14n/ This function does nothing if root is not a Node.

      exclusive - if true, apply exclusive c14n according to
          http://www.w3.org/TR/xml-exc-c14n/
      inclusivePrefixes - if exclusive is True, use this as a list of namespaces
          representing the "InclusiveNamespacesPrefixList" list in exclusive c14n

      Please import this from Ft.Xml.Domlette
      rather than directly from Ft.Xml.Lib.

ConvertDocument(oldDocument, documentURI=u'')
  Since foreign DOMs are not supported within 4Suite, this function lets users create a Domlette DOM from whatever DOM they are using.

      If the documentURI is not specified, it will try and get it from
      the document using DOM L3 attributes documentURI, then baseURI. If
      no URI is found, a warning is issued and a urn:uuid is generated
      for it.

GetAllNs(node)
  GetAllNs(node) -> dict

      Get all of the namespaces defined in scope of this node.

NonvalParse(isrc[, readExtDtd])
  NonvalParse(isrc[, readExtDtd]) -> Document
PrettyPrint(root, stream=<open file '<stdout>', mode 'w' at 0xb7ddd068>, encoding='UTF-8', asHtml=None)
  Given a Node instance assumed to be the root of a DOM or Domlette tree, this function serializes the document to the given stream or stdout, using the given encoding (UTF-8 is the default). Extra whitespace is added to the output for visual formatting. The asHtml flag can be used to force HTML-style serialization of an XML DOM. Otherwise, the DOM type (HTML or XML) is automatically determined. This function does nothing if root is not a Node.

      Please import this from Ft.Xml.Domlette
      rather than directly from Ft.Xml.Lib.

Print(root, stream=<open file '<stdout>', mode 'w' at 0xb7ddd068>, encoding='UTF-8', asHtml=None)
  Given a Node instance assumed to be the root of a DOM or Domlette tree, this function serializes the document to the given stream or stdout, using the given encoding (UTF-8 is the default). The asHtml flag can be used to force HTML-style serialization of an XML DOM. Otherwise, the DOM type (HTML or XML) is automatically determined. This function does nothing if root is not a Node.

      It is preferable that users import this from Ft.Xml.Domlette
      rather than directly from Ft.Xml.Lib.

SeekNss(node)
  SeekNss(node) -> dict

      Traverses the tree to seek an approximate set of defined namespaces.

ValParse(isrc)
  ValParse(isrc) -> Document

## Globals

EntityReader = <Ft.Xml.Domlette.EntityReaderBase instance>
  Non-validating reader instance that accepts well-formed XML External Parsed Entities, created from EntityReader() with no constructor arguments.

      Uses the default InputSource factory. If you need to change it,
      reassign the inputSourceFactory attribute, or, preferably, just
      create a new EntityReader instance.

NoExtDtdReader = <Ft.Xml.Domlette.NoExtDtdReaderBase instance>
  The default non-validating, external DTD subset-ignoring reader instance, created from NoExtDtdReaderBase() with no constructor arguments.

      Uses the default InputSource factory. If you need to change it,
      reassign the inputSourceFactory attribute, or, preferably, just
      create a new NoExtDtdReaderBase instance.

NonvalidatingReader = <Ft.Xml.Domlette.NonvalidatingReaderBase instance>
  The default non-validating reader instance, created from NonvalidatingReaderBase() with no constructor arguments.

      Uses the default InputSource factory. If you need to change it,
      reassign the inputSourceFactory attribute, or, preferably, just
      create a new NonvalidatingReaderBase instance.

ValidatingReader = <Ft.Xml.Domlette.ValidatingReaderBase instance>
  The default validating reader instance, created from ValidatingReaderBase() with no constructor arguments.

      Uses the default InputSource factory. If you need to change it,
      reassign the inputSourceFactory attribute, or, preferably, just
      create a new ValidatingReaderBase instance.

implementation = <DOMImplementation>
  The DOMImplementation interface provides a number of methods for performing operations that are independent of any particular instance of the document object model.