1.1 --- a/XSLForms/Resources.py Tue Oct 04 23:37:42 2005 +0000
1.2 +++ b/XSLForms/Resources.py Tue Oct 04 23:38:14 2005 +0000
1.3 @@ -141,14 +141,16 @@
1.4 XSLForms.Prepare.ensure_stylesheet_fragment(output_path, fragment_path, node_identifier)
1.5 return fragment_path
1.6
1.7 - def send_output(self, trans, stylesheet_filenames, document, stylesheet_parameters=None, references=None):
1.8 + def send_output(self, trans, stylesheet_filenames, document, stylesheet_parameters=None,
1.9 + stylesheet_expressions=None, references=None):
1.10
1.11 """
1.12 Send the output from the resource to the user employing the transaction
1.13 'trans', stylesheets having the given 'stylesheet_filenames', the
1.14 'document' upon which the output will be based, the optional parameters
1.15 - as defined in the 'stylesheet_parameters' dictionary, and the optional
1.16 - 'references' to external documents.
1.17 + as defined in the 'stylesheet_parameters' dictionary, the optional
1.18 + expressions are defined in the 'stylesheet_expressions' dictionary, and
1.19 + the optional 'references' to external documents.
1.20 """
1.21
1.22 # Sanity check for the filenames list.
1.23 @@ -156,18 +158,21 @@
1.24 if isinstance(stylesheet_filenames, str) or isinstance(stylesheet_filenames, unicode):
1.25 raise ValueError, stylesheet_filenames
1.26
1.27 - proc = XSLOutput.Processor(stylesheet_filenames, parameters=stylesheet_parameters, references=references)
1.28 + proc = XSLOutput.Processor(stylesheet_filenames, parameters=stylesheet_parameters,
1.29 + expressions=stylesheet_expressions, references=references)
1.30 proc.send_output(trans.get_response_stream(), trans.get_response_stream_encoding(),
1.31 document)
1.32
1.33 - def get_result(self, stylesheet_filenames, document, stylesheet_parameters=None, references=None):
1.34 + def get_result(self, stylesheet_filenames, document, stylesheet_parameters=None,
1.35 + stylesheet_expressions=None, references=None):
1.36
1.37 """
1.38 Get the result of applying a transformation using stylesheets with the
1.39 given 'stylesheet_filenames', the 'document' upon which the result will
1.40 be based, the optional parameters as defined in the
1.41 - 'stylesheet_parameters' dictionary, and the optional 'references' to
1.42 - external documents.
1.43 + 'stylesheet_parameters' dictionary, the optional parameters as defined
1.44 + in the 'stylesheet_parameters' dictionaryand the optional 'references'
1.45 + to external documents.
1.46 """
1.47
1.48 # Sanity check for the filenames list.
1.49 @@ -175,7 +180,8 @@
1.50 if isinstance(stylesheet_filenames, str) or isinstance(stylesheet_filenames, unicode):
1.51 raise ValueError, stylesheet_filenames
1.52
1.53 - proc = XSLOutput.Processor(stylesheet_filenames, parameters=stylesheet_parameters, references=references)
1.54 + proc = XSLOutput.Processor(stylesheet_filenames, parameters=stylesheet_parameters,
1.55 + expressions=stylesheet_expressions, references=references)
1.56 return proc.get_result(document)
1.57
1.58 def prepare_initialiser(self, input_identifier):
2.1 --- a/XSLTools/XSLOutput.py Tue Oct 04 23:37:42 2005 +0000
2.2 +++ b/XSLTools/XSLOutput.py Tue Oct 04 23:38:14 2005 +0000
2.3 @@ -35,16 +35,20 @@
2.4 A handler which can prepare output for an XMLTools2 template.
2.5 """
2.6
2.7 - def __init__(self, filenames, references=None, parameters=None):
2.8 + def __init__(self, filenames, references=None, parameters=None, expressions=None):
2.9
2.10 """
2.11 Initialise the handler with the 'filenames' of stylesheets producing the
2.12 final output, a 'references' dictionary indicating related stylesheets.
2.13 - Additional 'parameters' may also be specified as a dictionary.
2.14 + Additional 'parameters' may be specified as a dictionary whose values
2.15 + are converted to string values; additional 'expressions' may also be
2.16 + specified as a dictionary - such expressions are actually evaluated in
2.17 + stylesheet.
2.18 """
2.19
2.20 self.references = references or {}
2.21 self.parameters = parameters or {}
2.22 + self.expressions = expressions or {}
2.23
2.24 # Remember the stylesheet documents.
2.25
2.26 @@ -88,6 +92,7 @@
2.27 # Attempt to get the correctly formatted document.
2.28
2.29 if hasattr(stream, "fileno"):
2.30 + stream.flush()
2.31 fd = stream.fileno()
2.32 str_result = libxsltmod.xsltSaveResultToFd(fd, result, self.stylesheets[-1])
2.33 else:
2.34 @@ -129,7 +134,8 @@
2.35 parameters[name.encode("utf-8")] = ("document('%s')" % self._quote(reference)).encode("utf-8")
2.36 for name, parameter in self.parameters.items():
2.37 parameters[name.encode("utf-8")] = ("'%s'" % self._quote(parameter)).encode("utf-8")
2.38 - #print "**", repr(parameters)
2.39 + for name, parameter in self.expressions.items():
2.40 + parameters[name.encode("utf-8")] = self._quote(parameter).encode("utf-8")
2.41
2.42 last_result = document
2.43 for stylesheet in self.stylesheets: