The xslt module provides a Python API for the XSLT 3.0 specification. This Python interface enables the user to compile an xslt stylesheet and to execute it with different input data. The typical starting point would be the functions beta.xslt.Stylesheet.compile() and beta.xslt.Stylesheet.execute().

There are also utility functions beta.xslt.compile() and beta.xslt.execute() for simplified usage.


beta.xslt.compile(stylesheet, *, Session session, **kwargs)

Validate the specified stylesheet and creates a compiled beta.xslt.Stylesheet. This involves loading of the xslt from a file or an xml text representation, validating and preparing for execution. On success returns an xslt.Styelesheet object, on error raises an xslt.:obj:CompileError. The keyword arguments are used to set the corresponding properties of the beta.xslt.CompileOptions.

beta.xslt.execute(stylesheet, *, Session session, source_node=None, **kwargs)

Compile and execute the xslt stylesheet. The keyword arguments are used to set the corresponding properties of the beta.xslt.CompileOptions and beta.xslt.RuntimeOptions. Returns an xslt.ResultList, or raises an exception if an error is encountered. print( execute(‘foo.xsl’, source=’bar.xml’, delivery_format=DeliveryFormat.SERIALIZED).main_value ) Note: the results can be directly saved, by specifying DeliveryFormat.SAVED and a base_output_uri pointing to a location with write permissions: execute(stylesheet_location=’foo.xsl’, source_location=’bar.xml’, delivery_format=DeliveryFormat.SAVED, base_output_uri=”baz.out”)