The formatters.py example show how to provide a custom formatter. It is based on the simple.py code so be sure to give it a look before reading on.
In order to write your own formatter you should follow these simple steps:
Add the xmlns:<formatname> attribute to the root element of your xml file (xmlns:shop in the example)
The line <heading shop:txt="12" /> tells the parser to apply the {shop} formatter before invoking the heading method
Subclass the XmlCommandParser class and add your formatting logic to the apply_formatter method (see the MyParser class)
The line doc = MyDocument(path='.', name='formatter.xml', args=document_args, parser=MyParser)