1.1 --- a/XSLForms/Prepare.py Wed Oct 26 00:37:53 2005 +0000
1.2 +++ b/XSLForms/Prepare.py Thu Oct 27 16:30:30 2005 +0000
1.3 @@ -34,6 +34,12 @@
1.4
1.5 fn(template_name, output_name, *args, **kw)
1.6
1.7 +def _make_document(input_name, output_name, stylesheet_names, encoding=None):
1.8 + stylesheets = [os.path.join(resource_dir, stylesheet_name) for stylesheet_name in stylesheet_names]
1.9 + proc = XSLOutput.Processor(stylesheets)
1.10 + input = libxml2dom.parse(input_name)
1.11 + proc.send_output(open(output_name, "wb"), encoding, input)
1.12 +
1.13 # Web template functions.
1.14
1.15 def make_stylesheet(template_name, output_name, stylesheet_names=["PrepareMacro.xsl", "Prepare.xsl"], encoding=None):
1.16 @@ -43,10 +49,7 @@
1.17 producing a file with the given 'output_name'.
1.18 """
1.19
1.20 - stylesheets = [os.path.join(resource_dir, stylesheet_name) for stylesheet_name in stylesheet_names]
1.21 - proc = XSLOutput.Processor(stylesheets)
1.22 - template = libxml2dom.parse(template_name)
1.23 - proc.send_output(open(output_name, "wb"), encoding, template)
1.24 + _make_document(template_name, output_name, stylesheet_names, encoding)
1.25
1.26 def make_stylesheet_fragment(template_name, output_name, element_id, stylesheet_name="Extract.xsl", encoding=None):
1.27
1.28 @@ -91,10 +94,7 @@
1.29 ensure the general structure of an input document.
1.30 """
1.31
1.32 - stylesheets = [os.path.join(resource_dir, stylesheet_name) for stylesheet_name in stylesheet_names]
1.33 - proc = XSLOutput.Processor(stylesheets)
1.34 - template = libxml2dom.parse(template_name)
1.35 - proc.send_output(open(input_name, "wb"), encoding, template)
1.36 + _make_document(template_name, input_name, stylesheet_names, encoding)
1.37
1.38 def ensure_input_stylesheet(template_name, input_name):
1.39
1.40 @@ -106,6 +106,17 @@
1.41
1.42 _ensure_stylesheet(template_name, input_name, make_input_stylesheet)
1.43
1.44 +# Schema-related functions.
1.45 +
1.46 +def make_schema(template_name, output_name, stylesheet_names=["Schema.xsl"], encoding=None):
1.47 +
1.48 + """
1.49 + Make a schema document using the file with the given 'template_name',
1.50 + producing a file with the given 'output_name'.
1.51 + """
1.52 +
1.53 + _make_document(template_name, output_name, stylesheet_names, encoding)
1.54 +
1.55 # Qt Designer functions.
1.56
1.57 def make_qt_fragment(template_name, output_name, widget_name, stylesheet_name="QtDesignerExtract.xsl", encoding=None):