XSLT#
The module is a filter that transforms XML responses using one or more XSLT stylesheets.
When building from the source code,
this module isn't built by default;
it should be enabled with the
‑‑with‑http_xslt_module
build option.
In our repositories, the module is built
dynamically
and is available as a separate package named angie-module-xslt
or angie-pro-module-xslt
.
Configuration Example#
location / {
xml_entities /site/dtd/entities.dtd;
xslt_stylesheet /site/xslt/one.xslt param=value;
xslt_stylesheet /site/xslt/two.xslt;
}
Directives#
xml_entities#
Specifies the DTD file that declares character entities. This file is compiled at the configuration stage. For technical reasons, the module is unable to use the external subset declared in the processed XML, so it is ignored and a specially defined file is used instead. This file should not describe the XML structure. It is enough to declare just the required character entities, for example:
<!ENTITY nbsp " ">
xslt_last_modified#
Allows preserving the "Last-Modified" header field from the original response during XSLT transformations to facilitate response caching.
By default, the header field is removed as contents of the response are modified during transformations and may contain dynamically generated elements or parts that are changed independently of the original response.
xslt_param#
Defines the parameters for XSLT stylesheets. The value is treated as an XPath expression. The value can contain variables. To pass a string value to a stylesheet, the xslt_string_param directive can be used.
There could be several xslt_param directives. These directives are inherited from the previous configuration level if and only if there are no xslt_param and xslt_string_param directives defined on the current level.
xslt_string_param#
Defines the string parameters for XSLT stylesheets. XPath expressions in the value are not interpreted. The value can contain variables.
There could be several xslt_string_param directives. These directives are inherited from the previous configuration level if and only if there are no xslt_param and xslt_string_param directives defined on the current level.
xslt_stylesheet#
Defines the XSLT stylesheet and its optional parameters. A stylesheet is compiled at the configuration stage.
Parameters can either be specified separately, or grouped in a single line using the ":" delimiter. If a parameter includes the ":" character, it should be escaped as "%3A". Also, libxslt requires to enclose parameters that contain non-alphanumeric characters into single or double quotes, for example:
param1='http%3A//www.example.com':param2=value2
The parameters description can contain variables, for example, the whole line of parameters can be taken from a single variable:
location / {
xslt_stylesheet /site/xslt/one.xslt
$arg_xslt_params
param1='$value1':param2=value2
param3=value3;
}
It is possible to specify several stylesheets. They will be applied sequentially in the specified order.
xslt_types#
Enables transformations in responses with the specified MIME types in addition to "text/xml". The special value "*" matches any MIME type. If the transformation result is an HTML response, its MIME type is changed to "text/html".