• HttpXSLT
  • 指令
  • xslt_entities
  • xslt_stylesheet
  • xslt_types

    HttpXSLT

    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

    1. ./configure --with-http_xslt_module

    Example:

    1. location / {
    2. xml_entities /site/dtd/entities.dtd;
    3. xslt_stylesheet /site/xslt/one.xslt param=value;
    4. xslt_stylesheet /site/xslt/two.xslt;
    5. }

    指令

    xslt_entities

    syntax:*xml_entities *

    default:*no*

    context:*http, server, location*

    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:

    1. <! ENTITY of nbsp “ “>

    xslt_stylesheet

    syntax:*xsltstylesheet template [parameter[[ parameter… ]] default:_no*

    context:*http, server, location*

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

    1. 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:

    1. 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:

    1. location / {
    2. xslt_stylesheet /site/xslt/one.xslt
    3. $arg_xslt_params
    4. param1='$value1': param2=value2
    5. param3=value3;
    6. }

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

    xslt_types

    syntax:*xslt_types mime-type [mime-type…]*

    default:*xslt_types text/xml*

    context:*http, server, location*

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

    原文: https://wizardforcel.gitbooks.io/nginx-doc/content/Text/4.13_xslt.html