view xml/en/docs/http/ngx_http_xslt_module.xml @ 3011:55d49eb065ac

Fixed example in the js_periodic directive.
author Yaroslav Zhuravlev <yar@nginx.com>
date Thu, 14 Sep 2023 16:38:00 +0100
parents eeed494bba51
children
line wrap: on
line source

<?xml version="1.0"?>

<!--
  Copyright (C) Igor Sysoev
  Copyright (C) Nginx, Inc.
  -->

<!DOCTYPE module SYSTEM "../../../../dtd/module.dtd">

<module name="Module ngx_http_xslt_module"
        link="/en/docs/http/ngx_http_xslt_module.html"
        lang="en"
        rev="3">

<section id="summary">

<para>
The <literal>ngx_http_xslt_module</literal> (0.7.8+) is a filter
that transforms XML responses using one or more XSLT stylesheets.
</para>

<para>
This module is not built by default, it should be enabled with the
<literal>--with-http_xslt_module</literal>
configuration parameter.
<note>
This module requires the
<link url="http://xmlsoft.org">libxml2</link> and
<link url="http://xmlsoft.org/XSLT/">libxslt</link> libraries.
</note>
</para>

</section>


<section id="example" name="Example Configuration">

<para>
<example>
location / {
    xml_entities    /site/dtd/entities.dtd;
    xslt_stylesheet /site/xslt/one.xslt param=value;
    xslt_stylesheet /site/xslt/two.xslt;
}
</example>
</para>

</section>


<section id="directives" name="Directives">

<directive name="xml_entities">
<syntax><value>path</value></syntax>
<default/>
<context>http</context>
<context>server</context>
<context>location</context>

<para>
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:
<example>
&lt;!ENTITY nbsp "&amp;#xa0;"&gt;
</example>
</para>

</directive>


<directive name="xslt_last_modified">
<syntax><literal>on</literal> | <literal>off</literal></syntax>
<default>off</default>
<context>http</context>
<context>server</context>
<context>location</context>
<appeared-in>1.5.1</appeared-in>

<para>
Allows preserving the <header>Last-Modified</header> header field
from the original response during XSLT transformations
to facilitate response caching.
</para>

<para>
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.
</para>

</directive>


<directive name="xslt_param">
<syntax><value>parameter</value> <value>value</value></syntax>
<default/>
<context>http</context>
<context>server</context>
<context>location</context>
<appeared-in>1.1.18</appeared-in>

<para>
Defines the parameters for XSLT stylesheets.
The <value>value</value> is treated as an XPath expression.
The <value>value</value> can contain variables.
To pass a string value to a stylesheet,
the <link id="xslt_string_param"/> directive can be used.
</para>

<para>
There could be several <literal>xslt_param</literal> directives.
These directives are inherited from the previous configuration level
if and only if there are no <literal>xslt_param</literal> and
<link id="xslt_string_param"/> directives
defined on the current level.
</para>

</directive>


<directive name="xslt_string_param">
<syntax><value>parameter</value> <value>value</value></syntax>
<default/>
<context>http</context>
<context>server</context>
<context>location</context>
<appeared-in>1.1.18</appeared-in>

<para>
Defines the string parameters for XSLT stylesheets.
XPath expressions in the <value>value</value> are not interpreted.
The <value>value</value> can contain variables.
</para>

<para>
There could be several <literal>xslt_string_param</literal> directives.
These directives are inherited from the previous configuration level
if and only if there are no <link id="xslt_param"/> and
<literal>xslt_string_param</literal> directives
defined on the current level.
</para>

</directive>


<directive name="xslt_stylesheet">
<syntax>
    <value>stylesheet</value>
    [<value>parameter</value>=<value>value</value> ...]</syntax>
<default/>
<context>location</context>

<para>
Defines the XSLT stylesheet and its optional parameters.
A stylesheet is compiled at the configuration stage.
</para>

<para>
Parameters can either be specified separately, or grouped in a
single line using the “<literal>:</literal>” delimiter.
If a parameter includes the “<literal>:</literal>” character,
it should be escaped as “<literal>%3A</literal>”.
Also, <command>libxslt</command> requires to enclose parameters
that contain non-alphanumeric characters into single or double quotes,
for example:
<example>
param1='http%3A//www.example.com':param2=value2
</example>
</para>

<para>
The parameters description can contain variables, for example,
the whole line of parameters can be taken from a single variable:
<example>
location / {
    xslt_stylesheet /site/xslt/one.xslt
                    $arg_xslt_params
                    param1='$value1':param2=value2
                    param3=value3;
}
</example>
</para>

<para>
It is possible to specify several stylesheets.
They will be applied sequentially in the specified order.
</para>

</directive>


<directive name="xslt_types">
<syntax><value>mime-type</value> ...</syntax>
<default>text/xml</default>
<context>http</context>
<context>server</context>
<context>location</context>

<para>
Enables transformations in responses with the specified MIME types
in addition to “<literal>text/xml</literal>”.
The special value “<literal>*</literal>” matches any MIME type (0.8.29).
If the transformation result is an HTML response, its MIME type
is changed to “<literal>text/html</literal>”.
</para>

</directive>

</section>

</module>