xslt¶
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 xslt.Stylesheet.compile() and xslt.Stylesheet.execute().
There are also utility functions xslt.compile() and xslt.execute() for simplified usage.
Classes¶
Functions¶
- xslt.compile(stylesheet, *, Session session, **kwargs)¶
- Validate the specified stylesheet and creates a compiled - 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- xslt.CompileOptions.
- 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 - xslt.CompileOptionsand- 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”)
