paulb@1 | 1 | #!/usr/bin/env python |
paulb@1 | 2 | |
paulb@1 | 3 | """ |
paulb@1 | 4 | Preparation of templating stylesheets. |
paulb@1 | 5 | """ |
paulb@1 | 6 | |
paulb@1 | 7 | import XSLOutput |
paulb@1 | 8 | import libxml2dom |
paulb@1 | 9 | import os |
paulb@1 | 10 | |
paulb@1 | 11 | resource_dir = os.path.join(os.path.split(__file__)[0], "XSL") |
paulb@1 | 12 | |
paulb@1 | 13 | def make_stylesheet(template_name, output_name, stylesheet_name="Prepare.xsl", encoding="utf-8"): |
paulb@1 | 14 | global resource_dir |
paulb@1 | 15 | proc = XSLOutput.Processor([os.path.join(resource_dir, stylesheet_name)]) |
paulb@1 | 16 | template = libxml2dom.parse(template_name) |
paulb@1 | 17 | proc.send_output(open(output_name, "wb"), encoding, template) |
paulb@1 | 18 | |
paulb@1 | 19 | # vim: tabstop=4 expandtab shiftwidth=4 |