Sablotron Python Module

What it is

Sab-Pyth is a python interface to the Sablotron XSLT module.

The underlying Sablotron module is written in C++, and provides very fast access to XSLT functionality.

How do I use it

The following example, included with Sab-pyth, uses the low level functions exported by the Sablot module to python, to process an XML file input.xml with an XSL style sheet sheet.xsl.

# read the input files:
sheet = open('sheet.xsl', 'r').read()
input = open('input.xml', 'r').read()

import Sablot

# create a processor object:
sp = Sablot.CreateProcessor()

# call the run() method:'arg:sheet', 'arg:input', 'arg:output', [], [('input', input),
('sheet', sheet)])

# print the output, assuming it is encoded in utf-8 (the default
# encoding output by Sablotron):
text = unicode(sp.getResultArg('output'), 'utf8')
print text.encode('ISO-8859-1')

More documentation is available here.


Downloads available from SourceForge Sab-Pyth File List.


This was originally developed by Guenter Radestock. Logo