CedarBackup2.xmlutil.Serializer

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

# Class Serializer

source code

    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.

Instance Methods | [hide private]
__init__(self, stream=sys.stdout, encoding=`'``UTF-8``'`, indent=3) Initialize a serializer. | source code
serialize(self, xmlDom) Serialize the passed-in XML document. | source code
_write(self, text) | source code
_tryIndent(self) | source code
_visit(self, node) | source code
_visitNodeList(self, node, exclude=None) | source code
_visitNamedNodeMap(self, node) | source code
_visitAttr(self, node) | source code
_visitProlog(self) | source code
_visitDocument(self, node) | source code
_visitDocumentFragment(self, node) | source code
_visitElement(self, node) | source code
_visitText(self, node) | source code
_visitDocumentType(self, doctype) | source code
_visitEntity(self, node) Visited from a NamedNodeMap in DocumentType | source code
_visitNotation(self, node) Visited from a NamedNodeMap in DocumentType | source code
_visitCDATASection(self, node) | source code
_visitComment(self, node) | source code
_visitEntityReference(self, node) | source code
_visitProcessingInstruction(self, node) | source code
Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Properties | [hide private]
Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, stream=sys.stdout, encoding=`'``UTF-8``'`, indent=3) (Constructor) | source code
Initialize a serializer. Parameters: `stream` - Stream to write output to. `encoding` - Output encoding. `indent` - Number of spaces to indent, as an integer Overrides: object.__init__

### serialize(self, xmlDom) | source code
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.

### _visit(self, node) | source code
Raises: `ValueError` - If there's an unknown node type in the document.