ngx_http_xslt_module

The ngx_http_xslt_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 through --with-http_xslt_module at configure time.

Example:

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

Directives

xslt_entities

syntax: xml_entities <path>

default: no

context: http, server, location

The directive of [zadaet] the file DTD, in which are described symbolic elements. This file is compiled at the stage of configuration. For technical reasons the module does not have a possibility to use the external subset, assigned in workable XML; therefore it is ignored, but the specially assigned file is used instead of it. In this file it is not necessary to describe structure XML, it is sufficient only declaration of the necessary symbolic elements, for example:

  <! ENTITY of nbsp “&#xa0; “>

xslt_stylesheet

syntax: xslt_stylesheet template [parameter...]

default: no

context: http, server, location

Directive of [zadaet] XSLT- template and the parameters for this template. Template is compiled at the stage of configuration. The parameters are assigned in the size

  param=value

Can be assigned them both separately and to group in one line, dividing by symbol “: ”. But if the parameters themselves contains the symbol “: ”, then it is necessary to screen in the form “%3A”. Furthermore, it is necessary to remember about the requirement of libxslt so that the parameters, which contain not only alphanumeric symbols, would be concluded in the single or dual quotation marks, for example:

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

In the description of the parameters it is possible to use variables, for example, the entire line of the parameters can be undertaken of one variable:

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

It is possible to indicate several templates - in this case they will be used consecutively in the order of their description.

xslt_types

syntax: xslt_types mime-type [mime-type...]

default: xslt_types of text/xml

context: http, server, location

This directive permits the replacement of lines in the response with the MIME-types in addition to “text/xml”. If as a result the conversion of [vydaetsya] HTML- response, then its MIME-type changes to “text/HTML”.

NginxHttpXsltModule (last edited 2008-08-05 06:43:34 by CliffWells)