XSLTools

Annotated scripts/output.py

178:7e7d9dbcec62
2005-07-22 paulb [project @ 2005-07-22 18:26:38 by paulb] Tidied up the function names and added some API documentation. Added child-element and child-attribute functions for coherent references to potentially non-existent nodes in the form data.
paulb@1 1
#!/usr/bin/env python
paulb@1 2
paulb@1 3
"Prepare a templating stylesheet."
paulb@1 4
paulb@1 5
import XSLForms.Output
paulb@1 6
import XSLOutput
paulb@1 7
import libxml2dom
paulb@1 8
import sys
paulb@1 9
paulb@1 10
if __name__ == "__main__":
paulb@1 11
    try:
paulb@1 12
        input_xml = sys.argv[1]
paulb@1 13
        trans_xsl = sys.argv[2]
paulb@1 14
        output_xml = sys.argv[3]
paulb@1 15
    except IndexError:
paulb@1 16
        print "Please specify an input filename, a template filename and an output filename."
paulb@1 17
        print "For example:"
paulb@1 18
        print "output.py input.xml output.xsl output.xhtml"
paulb@1 19
        sys.exit(1)
paulb@1 20
paulb@1 21
    proc = XSLOutput.Processor([trans_xsl])
paulb@1 22
    proc.send_output(open(output_xml, "wb"), "utf-8", libxml2dom.parse(input_xml))
paulb@1 23
paulb@1 24
# vim: tabstop=4 expandtab shiftwidth=4