FAQ

Page Discussion Edit History

HttpXsltModule

Contents

[edit] Synopsis

This module is a filter which converts an XML response with the aid of one or more XSLT templates.

This module was introduced in 0.7.8 and needs to be enabled via

./configure --with-http_xslt_module

Example:

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

[edit] Directives

[edit] xml_entities

Syntax: xml_entities path
Default:
Context: http
server
location
Reference:xml_entities


Specifies the DTD file which describes symbolic elements (xml entities). This file is compiled at the stage of configuration. For technical reasons it's not possible to specify entities in the XML being processed, therefore they are ignored, but this specially assigned file is used instead. In this file it is not necessary to describe structure of processed XML, it is sufficient only to declare necessary symbolic elements, for example:

  <! ENTITY of nbsp 鈥  鈥>

[edit] xslt_param

Syntax: xslt_param parameter value
Default:
Context: http
server
location
Appeared in: 1.1.18
Reference:xslt_param


[edit] xslt_string_param

Syntax: xslt_string_param parameter value
Default:
Context: http
server
location
Appeared in: 1.1.18
Reference:xslt_string_param


[edit] xslt_stylesheet

Syntax: xslt_stylesheet stylesheet [ parameter = value ...]
Default:
Context: location
Reference:xslt_stylesheet


Specifies the XSLT template with its parameters. Template is compiled at the stage of configuration. The parameters are assigned as shown:

  param=value

You can specify parameters either one per line, or separate multiple parameters with colon (鈥: 鈥) If the parameter itself contains the character 鈥:鈥, escape it as 鈥%3A鈥. Furthermore, libxslt requires that string parameters should be quoted by the single or dual quotation marks if they contain non-alphanumeric characters, for example:

  param1='http%3A//www.example.com': param2=value2

It's possible to use variables as parameters, for example, the entire line of the parameters can be substituted with one variable:

  location / {
    xslt_stylesheet /site/xslt/one.xslt
    $arg_xslt_params
    param1='$value1': param2=value2
    param3=value3;
  }

It is possible to specify several templates, in which case they would be chained together in the order of their declaration.

[edit] xslt_types

Syntax: xslt_types mime-type ...
Default: text/xml
Context: http
server
location
Reference:xslt_types


Permit processing responses with specified MIME-types in addition to 鈥渢ext/xml鈥. If XSLT output mode is HTML, then the response MIME-type changes to 鈥渢ext/HTML鈥.

[edit] References

Original Documentation