模块 ngx_http_xslt_module
xml_entities xslt_last_modified xslt_param xslt_string_param xslt_stylesheet xslt_types 的配置 Directives 示例 |
(0.7.8+) 是一个过滤器
,它使用一个或多个 XSLT 样式表转换 XML 响应。ngx_http_xslt_module
默认情况下,此模块不是构建的,应使用 configuration 参数启用它。--with-http_xslt_module
此模块需要 libxml2 和 libxslt 库。
示例配置
location / { xml_entities /site/dtd/entities.dtd; xslt_stylesheet /site/xslt/one.xslt param=value; xslt_stylesheet /site/xslt/two.xslt; }
Directives
语法: |
xml_entities |
---|---|
默认值: | — |
上下文: |
http , ,server location |
指定声明字符实体的 DTD 文件。 此文件在配置阶段编译。 由于技术原因,该模块无法使用 外部子集,因此它是 ignored 的 URL,而是使用专门定义的文件。 此文件不应描述 XML 结构。 只需声明所需的字符实体就足够了,例如:
<!ENTITY nbsp " ">
语法: |
xslt_last_modified |
---|---|
默认值: |
xslt_last_modified off; |
上下文: |
http , ,server location |
该Directives出现在版本 1.5.1 中。
允许保留 “Last-Modified” 报头字段 从 XSLT 转换期间的原始响应 以促进响应缓存。
默认情况下,标头字段将作为响应的内容删除 在转换期间被修改,并且可能包含动态生成的 独立于原始响应而更改的元素或部分。
语法: |
xslt_param |
---|---|
默认值: | — |
上下文: |
http , ,server location |
该Directives出现在版本 1.1.18 中。
定义 XSLT 样式表的参数。
这被视为 XPath 表达式。
可以包含变量。
要将字符串值传递给样式表,
可以使用 xslt_string_param Directives。value
value
可能有多个Directives。
这些Directives继承自之前的配置级别
当且仅当存在 no 和 xslt_string_param Directives时
在当前级别上定义。xslt_param
xslt_param
语法: |
xslt_string_param |
---|---|
默认值: | — |
上下文: |
http , ,server location |
该Directives出现在版本 1.1.18 中。
定义 XSLT 样式表的字符串参数。
中的 XPath 表达式。
可以包含变量。value
value
可能有多个Directives。
这些Directives继承自之前的配置级别
当且仅当没有 xslt_param 和 Directives
在当前级别上定义。xslt_string_param
xslt_string_param
语法: |
xslt_stylesheet
|
---|---|
默认值: | — |
上下文: |
location |
定义 XSLT 样式表及其可选参数。 stylesheet 在配置阶段编译。
参数可以单独指定,也可以在
使用 “” 分隔符的单行。
如果参数包含 “” 字符,则
它应该转义为 “”。
此外,需要将参数括起来
包含非字母数字字符的单引号或双引号,
例如::
:
%3A
libxslt
param1='http%3A//www.example.com':param2=value2
参数描述可以包含变量,例如 整行参数可以从单个变量中获取:
location / { xslt_stylesheet /site/xslt/one.xslt $arg_xslt_params param1='$value1':param2=value2 param3=value3; }
可以指定多个样式表。 它们将按指定顺序顺序应用。
语法: |
xslt_types |
---|---|
默认值: |
xslt_types text/xml; |
上下文: |
http , ,server location |
在具有指定 MIME 类型的响应中启用转换
除了 “”之外。
特殊值 “” 与任何 MIME 类型 (0.8.29) 匹配。
如果转换结果是 HTML 响应,则其 MIME 类型
更改为 “”。text/xml
*
text/html