Package genshi :: Module output

Module output



This module provides different kinds of serialization methods for XML event streams.

Classes
  DocType
Defines a number of commonly used DOCTYPE declarations as constants.
  XMLSerializer
Produces XML text from an event stream.
  XHTMLSerializer
Produces XHTML text from an event stream.
  HTMLSerializer
Produces HTML text from an event stream.
  TextSerializer
Produces plain text from an event stream.
Functions
 
encode(iterator, method='xml', encoding='utf-8')
Encode serializer output into a string.
 
get_serializer(method='xml', **kwargs)
Return a serializer object for the given method.
Function Details

encode(iterator, method='xml', encoding='utf-8')

 
Encode serializer output into a string.
Parameters:
  • iterator - the iterator returned from serializing a stream (basically any iterator that yields unicode objects)
  • method - the serialization method; determines how characters not representable in the specified encoding are treated
  • encoding - how the output string should be encoded; if set to None, this method returns a unicode object
Returns:
a string or unicode object (depending on the encoding parameter)

Since: version 0.4.1

get_serializer(method='xml', **kwargs)

 

Return a serializer object for the given method.

Any additional keyword arguments are passed to the serializer, and thus depend on the method parameter value.

Parameters:
  • method - the serialization method; can be either "xml", "xhtml", "html", "text", or a custom serializer class

See Also: XMLSerializer, XHTMLSerializer, HTMLSerializer, TextSerializer

Since: version 0.4.1