xslt.RuntimeOptions

The xslt.RuntimeOptions class is used to initialize the dynamic context components for the execution of an xslt.Stylesheet.

class xslt.RuntimeOptions(Session session, bool _report_unknown_args=True, *, **kwargs)

Attributes

xslt.RuntimeOptions.base_output_uri

The URI of the principal result document; also used as the base URI for resolving relative URIs of secondary result documents.

xslt.RuntimeOptions.current_datetime

An xsd.dateTime value used for the current-dateTime component of the dynamic context. If absent, the system time will be used for the execution.

xslt.RuntimeOptions.debugger
xslt.RuntimeOptions.delivery_format

One of the enumeration values xpath.DeliveryFormat. When saving of result documents is selected, then the xslt.RuntimeOptions.output_stream_factory must be set as well.

xslt.RuntimeOptions.function_params

An xpath.ArrayItem used as the arguments to the initial function call.

xslt.RuntimeOptions.global_context_item

An xpath.Item that acts as the global context item for the transformation. The default value is set from xslt.RuntimeOptions.source_node.

xslt.RuntimeOptions.initial_function

The xsd.QName of the initial function to be called for call-function invocation. The arity of the function is inferred from the array length of xslt.RuntimeOptions.function_params.

xslt.RuntimeOptions.initial_match_selection

An xpath.Sequence that acts as the initial match selection corresponding to an initial xsl:apply-templates. The default value is set from xslt.RuntimeOptions.source_node.

xslt.RuntimeOptions.initial_mode

The name of the initial processing mode.

xslt.RuntimeOptions.initial_template

The xsd.QName of a named template in the stylesheet to act as the initial entry point. If no template name is supplied, the default template name is ‘xsl:initial-template’.

xslt.RuntimeOptions.message_target
xslt.RuntimeOptions.output_stream_factory

This object is required to provide the output stream(s) for the final result(s), when saving of result documents is specified in xslt.RuntimeOptions.delivery_format. The factory member is invoked with the xpath.Result.uri of the currently constructed/processed result. The binary octets resulting from the serialization and encoding of the result are written to the provided output stream. See xslt.RuntimeOptions.base_output_uri and xslt.RuntimeOptions.serialization_params for further options. Note: When writing large amount of data to disk, use buffered io objects for better performance.

The factory object must have create_stream(uri: str) method and the created stream object must have a write() method.

>>> from urllib.parse import urlparse
>>> from urllib.request import url2pathname
>>> from pathlib import Path
>>>
>>> class OutputStream:
>>>     '''A sample output stream class that wraps a file object.'''
>>>     def __init__(self, file_path):
>>>         self.f = open(file_path, 'wb')
>>>
>>>     def __del__(self):
>>>         self.f.close()
>>>
>>>     def write(self, data):
>>>         self.f.write(data)
>>>
>>> class OutputStreamFactory:
>>>     '''A demo class to convert uri to os specific path and create eventually missing directory structure for the output.'''
>>>     def create_stream(self, uri):
>>>         p = Path(url2pathname(urlparse(uri).path))
>>>         Path(p / '..').mkdir(parents=True, exist_ok=True)
>>>         return OutputStream(p)
>>>
>>> opts.output_stream_factory = OutputStreamFactory()
>>> opts.delivery_format = xpath.DeliveryFormat.SAVED
xslt.RuntimeOptions.serialization_params

Overrides the values of the unnamed xsl:output

xslt.RuntimeOptions.source_node

A xpath.NodeItem that sets the default values for both the xslt.RuntimeOptions.global_context_item and the xslt.RuntimeOptions.initial_match_selection.

xslt.RuntimeOptions.stylesheet_params

A xpath.MapItem holding the values to be supplied for stylesheet parameters. The xpath.AtomicItem keys are created to match the xsd.QName of the corresponding parameter, while the values are provided as xpath.Sequence.

xslt.RuntimeOptions.template_params

A xpath.MapItem holding the values of non-tunnel parameters to be supplied to the initial template, used with both apply-templates and call-template invocation. The xpath.AtomicItem keys are created to match the xsd.QName of the corresponding parameter, while the values are provided as xpath.Sequence.

xslt.RuntimeOptions.trace_target
xslt.RuntimeOptions.tunnel_params

A xpath.MapItem holding the values of tunnel parameters to be supplied to the initial template, used with both apply-templates and call-template invocation. The xpath.AtomicItem keys are created to match the xsd.QName of the corresponding parameter, while the values are provided as xpath.Sequence.

xslt.RuntimeOptions.xml_document_options_provider

Special methods

__eq__, __ge__, __gt__, __le__, __lt__, __ne__