xslt_stylesheet

The `xslt_stylesheet` directive specifies the XSLT stylesheet to apply to XML responses in NGINX.

Syntaxxslt_stylesheet path | path;
Defaultnone
Contextlocation
Arguments1+

Description

The xslt_stylesheet directive is used in NGINX to define one or more XSLT stylesheets that will be applied to XML responses when they are requested. This directive is defined within a location block and can take one or more arguments, each specifying the path to XSLT files or parameters that will be applied during the transformation process. When an XML response is generated, NGINX will use the provided XSLT stylesheet(s) to transform the XML into a different format, such as HTML, before the data is passed to the client's browser.

When using xslt_stylesheet, it is important to correctly configure the paths to your XSLT files and ensure that the XML responses are properly formatted to be transformed. The processing of XSLT can also be influenced by other directives related to XML processing in NGINX, such as xslt_types and xslt_last_modified. Furthermore, the effective transformation relies on the presence of a valid XSLT processor within the NGINX configuration, and any errors in the XSLT can lead to failure in transforming the XML response.

Furthermore, it can accept both absolute paths and relative paths based on the NGINX root directory. The directive behaves in such a way that if multiple stylesheets are specified, they will be applied sequentially in the order they are provided, aiding in complex XML manipulations where multiple transformations are necessary.

Config Example

location /xml {
    xslt_stylesheet /path/to/stylesheet.xsl;
}

Ensure that the path to the XSLT files is correct; otherwise, the transformation will not work.

Remember to validate the XML and XSLT files separately for syntax errors before deploying in production.

If multiple XSLT files are specified, the ordering of application affects the final output.

← Back to all directives