1.1 --- a/XSLForms/Prepare.py Fri May 06 19:07:59 2005 +0000
1.2 +++ b/XSLForms/Prepare.py Fri May 06 19:10:17 2005 +0000
1.3 @@ -16,4 +16,22 @@
1.4 template = libxml2dom.parse(template_name)
1.5 proc.send_output(open(output_name, "wb"), encoding, template)
1.6
1.7 +def make_stylesheet_fragment(template_name, output_name, element_id, stylesheet_name="Extract.xsl", encoding="utf-8"):
1.8 + global resource_dir
1.9 + proc = XSLOutput.Processor([os.path.join(resource_dir, stylesheet_name)], parameters={"element-id" : element_id})
1.10 + template = libxml2dom.parse(template_name)
1.11 + proc.send_output(open(output_name, "wb"), encoding, template)
1.12 +
1.13 +def ensure_stylesheet(template_name, output_name):
1.14 + if not os.path.exists(output_name) or \
1.15 + os.path.getmtime(output_name) < os.path.getmtime(template_name):
1.16 +
1.17 + make_stylesheet(template_name, output_name)
1.18 +
1.19 +def ensure_stylesheet_fragment(template_name, output_name, element_id):
1.20 + if not os.path.exists(output_name) or \
1.21 + os.path.getmtime(output_name) < os.path.getmtime(template_name):
1.22 +
1.23 + make_stylesheet_fragment(template_name, output_name, element_id)
1.24 +
1.25 # vim: tabstop=4 expandtab shiftwidth=4