Package CedarBackup2 :: Module xmlutil :: Class Serializer
[show private | hide private]
[frames | no frames]

Type Serializer

object --+
         |
        Serializer


XML serializer class.

This is a customized serializer that I hacked together based on what I found in the PyXML distribution. Basically, around release 2.7.0, the only reason I still had around a dependency on PyXML was for the PrettyPrint functionality, and that seemed pointless. So, I stripped the PrettyPrint code out of PyXML and hacked bits of it off until it did just what I needed and no more.

This code started out being called PrintVisitor, but I decided it makes more sense just calling it a serializer. I've made nearly all of the methods private, and I've added a new high-level serialize() method rather than having clients call visit().

Anyway, as a consequence of my hacking with it, this can't quite be called a complete XML serializer any more. I ripped out support for HTML and XHTML, and there is also no longer any support for namespaces (which I took out because this dragged along a lot of extra code, and Cedar Backup doesn't use namespaces). However, everything else should pretty much work as expected.

Copyright: This code, prior to customization, was part of the PyXML codebase, and before that was part of the 4DOM suite developed by Fourthought, Inc. It its original form, it was Copyright (c) 2000 Fourthought Inc, USA; All Rights Reserved.

Method Summary
  __init__(self, stream, encoding, indent)
Initialize a serializer.
  _tryIndent(self)
  _visit(self, node)
  _visitAttr(self, node)
  _visitCDATASection(self, node)
  _visitComment(self, node)
  _visitDocument(self, node)
  _visitDocumentFragment(self, node)
  _visitDocumentType(self, doctype)
  _visitElement(self, node)
  _visitEntity(self, node)
Visited from a NamedNodeMap in DocumentType
  _visitEntityReference(self, node)
  _visitNamedNodeMap(self, node)
  _visitNodeList(self, node, exclude)
  _visitNotation(self, node)
Visited from a NamedNodeMap in DocumentType
  _visitProcessingInstruction(self, node)
  _visitProlog(self)
  _visitText(self, node)
  _write(self, text)
  serialize(self, xmlDom)
Serialize the passed-in XML document.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Method Details

__init__(self, stream=<epydoc.imports._DevNull instance at 0x401f566c>, encoding='UTF-8', indent=3)
(Constructor)

Initialize a serializer.
Parameters:
stream - Stream to write output to.
encoding - Output encoding.
indent - Number of spaces to indent, as an integer
Overrides:
__builtin__.object.__init__

_visit(self, node)

Raises:
ValueError - If there's an unknown node type in the document.

_visitEntity(self, node)

Visited from a NamedNodeMap in DocumentType

_visitNotation(self, node)

Visited from a NamedNodeMap in DocumentType

serialize(self, xmlDom)

Serialize the passed-in XML document.
Parameters:
xmlDom - XML DOM tree to serialize
Raises:
ValueError - If there's an unknown node type in the document.

Generated by Epydoc 2.1 on Thu Dec 22 20:45:16 2005 http://epydoc.sf.net