annotate src/http/modules/ngx_http_xslt_filter_module.c @ 2299:3e213fa0cbb3

exslt support
author Igor Sysoev <igor@sysoev.ru>
date Tue, 11 Nov 2008 15:22:24 +0000
parents fab3fa7339ff
children a6954ce88b80
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
2 /*
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
3 * Copyright (C) Igor Sysoev
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
4 */
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
5
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
6
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
7 #include <ngx_config.h>
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
8 #include <ngx_core.h>
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
9 #include <ngx_http.h>
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
10
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
11 #include <libxml/parser.h>
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
12 #include <libxml/tree.h>
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
13 #include <libxslt/xslt.h>
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
14 #include <libxslt/xsltInternals.h>
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
15 #include <libxslt/transform.h>
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
16 #include <libxslt/xsltutils.h>
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
17
2299
3e213fa0cbb3 exslt support
Igor Sysoev <igor@sysoev.ru>
parents: 2196
diff changeset
18 #if (NGX_HAVE_EXSLT)
3e213fa0cbb3 exslt support
Igor Sysoev <igor@sysoev.ru>
parents: 2196
diff changeset
19 #include <libexslt/exslt.h>
3e213fa0cbb3 exslt support
Igor Sysoev <igor@sysoev.ru>
parents: 2196
diff changeset
20 #endif
3e213fa0cbb3 exslt support
Igor Sysoev <igor@sysoev.ru>
parents: 2196
diff changeset
21
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
22
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
23 #ifndef NGX_HTTP_XSLT_REUSE_DTD
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
24 #define NGX_HTTP_XSLT_REUSE_DTD 1
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
25 #endif
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
26
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
27
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
28 typedef struct {
2154
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
29 u_char *name;
2156
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
30 void *data;
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
31 } ngx_http_xslt_file_t;
2154
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
32
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
33
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
34 typedef struct {
2156
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
35 ngx_array_t dtd_files; /* ngx_http_xslt_file_t */
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
36 ngx_array_t sheet_files; /* ngx_http_xslt_file_t */
2154
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
37 } ngx_http_xslt_filter_main_conf_t;
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
38
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
39
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
40 typedef struct {
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
41 ngx_array_t *lengths;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
42 ngx_array_t *values;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
43 } ngx_http_xslt_param_t;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
44
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
45
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
46 typedef struct {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
47 xsltStylesheetPtr stylesheet;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
48 ngx_array_t params; /* ngx_http_xslt_param_t */
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
49 } ngx_http_xslt_sheet_t;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
50
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
51
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
52 typedef struct {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
53 xmlDtdPtr dtd;
2153
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
54 ngx_array_t sheets; /* ngx_http_xslt_sheet_t */
2148
071bc0fc1459 style fix
Igor Sysoev <igor@sysoev.ru>
parents: 2139
diff changeset
55 ngx_hash_t types;
071bc0fc1459 style fix
Igor Sysoev <igor@sysoev.ru>
parents: 2139
diff changeset
56 ngx_array_t *types_keys;
2154
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
57 } ngx_http_xslt_filter_loc_conf_t;
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
58
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
59
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
60 typedef struct {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
61 xmlDocPtr doc;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
62 xmlParserCtxtPtr ctxt;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
63 xmlSAXHandler *sax;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
64 ngx_http_request_t *request;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
65 ngx_array_t params;
2153
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
66
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
67 ngx_uint_t done; /* unsigned done:1; */
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
68 } ngx_http_xslt_filter_ctx_t;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
69
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
70
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
71 static ngx_int_t ngx_http_xslt_send(ngx_http_request_t *r,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
72 ngx_http_xslt_filter_ctx_t *ctx, ngx_buf_t *b);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
73 static ngx_int_t ngx_http_xslt_filter_internal_error(ngx_http_request_t *r);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
74 static ngx_int_t ngx_http_xslt_add_chunk(ngx_http_request_t *r,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
75 ngx_http_xslt_filter_ctx_t *ctx, ngx_buf_t *b);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
76
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
77
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
78 static void ngx_http_xslt_sax_start_document(void *data);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
79 static void ngx_http_xslt_sax_end_document(void *data);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
80 static void ngx_http_xslt_sax_internal_subset(void *data, const xmlChar *name,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
81 const xmlChar *externalId, const xmlChar *systemId);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
82 static void ngx_http_xslt_sax_external_subset(void *data, const xmlChar *name,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
83 const xmlChar *externalId, const xmlChar *systemId);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
84 static void ngx_http_xslt_sax_entity_decl(void *data, const xmlChar *name,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
85 int type, const xmlChar *publicId, const xmlChar *systemId,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
86 xmlChar *content);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
87 static void ngx_http_xslt_sax_attribute_decl(void *data, const xmlChar *elem,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
88 const xmlChar *fullname, int type, int def, const xmlChar *defaultValue,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
89 xmlEnumerationPtr tree);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
90 static void ngx_http_xslt_sax_element_decl(void *data, const xmlChar * name,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
91 int type, xmlElementContentPtr content);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
92 static void ngx_http_xslt_sax_notation_decl(void *data, const xmlChar *name,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
93 const xmlChar *publicId, const xmlChar *systemId);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
94 static void ngx_http_xslt_sax_unparsed_entity_decl(void *data,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
95 const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
96 const xmlChar *notationName);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
97 static void ngx_http_xslt_sax_start_element(void *data,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
98 const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
99 int nb_namespaces, const xmlChar **namespaces, int nb_attributes,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
100 int nb_defaulted, const xmlChar **attributes);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
101 static void ngx_http_xslt_sax_end_element(void *data,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
102 const xmlChar * localname ATTRIBUTE_UNUSED,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
103 const xmlChar * prefix ATTRIBUTE_UNUSED,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
104 const xmlChar * URI ATTRIBUTE_UNUSED);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
105 static void ngx_http_xslt_sax_characters(void *data, const xmlChar *p, int len);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
106 static void ngx_http_xslt_sax_cdata_block(void *data, const xmlChar *p,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
107 int len);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
108 static xmlEntityPtr ngx_http_xslt_sax_get_entity(void *data,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
109 const xmlChar *name);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
110 static xmlEntityPtr ngx_http_xslt_sax_get_parameter_entity(void *data,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
111 const xmlChar *name);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
112 static xmlParserInputPtr ngx_http_xslt_sax_resolve_entity(void *data,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
113 const xmlChar *publicId, const xmlChar *systemId);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
114 static void ngx_http_xslt_sax_reference(void *data, const xmlChar *name);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
115 static void ngx_http_xslt_sax_comment(void *data, const xmlChar *value);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
116 static void ngx_http_xslt_sax_processing_instruction(void *data,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
117 const xmlChar *target, const xmlChar *pidata);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
118 static int ngx_http_xslt_sax_is_standalone(void *data);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
119 static int ngx_http_xslt_sax_has_internal_subset(void *data);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
120 static int ngx_http_xslt_sax_has_external_subset(void *data);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
121 static void ngx_cdecl ngx_http_xslt_sax_error(void *data, const char *msg, ...);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
122
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
123
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
124 static ngx_buf_t *ngx_http_xslt_apply_stylesheet(ngx_http_request_t *r,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
125 ngx_http_xslt_filter_ctx_t *ctx);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
126 static ngx_int_t ngx_http_xslt_params(ngx_http_request_t *r,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
127 ngx_http_xslt_filter_ctx_t *ctx, ngx_array_t *params);
2153
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
128 static u_char *ngx_http_xslt_content_type(xsltStylesheetPtr s);
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
129 static u_char *ngx_http_xslt_encoding(xsltStylesheetPtr s);
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
130 static void ngx_http_xslt_cleanup(void *data);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
131
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
132 static char *ngx_http_xslt_entities(ngx_conf_t *cf, ngx_command_t *cmd,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
133 void *conf);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
134 static char *ngx_http_xslt_stylesheet(ngx_conf_t *cf, ngx_command_t *cmd,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
135 void *conf);
2156
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
136 static void ngx_http_xslt_cleanup_dtd(void *data);
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
137 static void ngx_http_xslt_cleanup_stylesheet(void *data);
2154
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
138 static void *ngx_http_xslt_filter_create_main_conf(ngx_conf_t *cf);
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
139 static void *ngx_http_xslt_filter_create_conf(ngx_conf_t *cf);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
140 static char *ngx_http_xslt_filter_merge_conf(ngx_conf_t *cf, void *parent,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
141 void *child);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
142 static ngx_int_t ngx_http_xslt_filter_init(ngx_conf_t *cf);
2196
fab3fa7339ff call ngx_http_xslt_filter_exit()
Igor Sysoev <igor@sysoev.ru>
parents: 2159
diff changeset
143 static void ngx_http_xslt_filter_exit(ngx_cycle_t *cycle);
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
144
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
145
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
146 ngx_str_t ngx_http_xslt_default_types[] = {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
147 ngx_string("text/xml"),
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
148 ngx_null_string
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
149 };
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
150
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
151
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
152 static ngx_command_t ngx_http_xslt_filter_commands[] = {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
153
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
154 { ngx_string("xml_entities"),
2150
50cede290146 fix xslt module context levels
Igor Sysoev <igor@sysoev.ru>
parents: 2148
diff changeset
155 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
156 ngx_http_xslt_entities,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
157 NGX_HTTP_LOC_CONF_OFFSET,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
158 0,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
159 NULL },
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
160
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
161 { ngx_string("xslt_stylesheet"),
2151
c8331f70d799 xslt_stylesheet should be valid for location only
Igor Sysoev <igor@sysoev.ru>
parents: 2150
diff changeset
162 NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
163 ngx_http_xslt_stylesheet,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
164 NGX_HTTP_LOC_CONF_OFFSET,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
165 0,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
166 NULL },
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
167
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
168 { ngx_string("xslt_types"),
2150
50cede290146 fix xslt module context levels
Igor Sysoev <igor@sysoev.ru>
parents: 2148
diff changeset
169 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
170 ngx_http_types_slot,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
171 NGX_HTTP_LOC_CONF_OFFSET,
2154
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
172 offsetof(ngx_http_xslt_filter_loc_conf_t, types_keys),
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
173 &ngx_http_xslt_default_types[0] },
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
174
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
175 ngx_null_command
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
176 };
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
177
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
178
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
179 static ngx_http_module_t ngx_http_xslt_filter_module_ctx = {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
180 NULL, /* preconfiguration */
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
181 ngx_http_xslt_filter_init, /* postconfiguration */
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
182
2154
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
183 ngx_http_xslt_filter_create_main_conf, /* create main configuration */
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
184 NULL, /* init main configuration */
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
185
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
186 NULL, /* create server configuration */
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
187 NULL, /* merge server configuration */
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
188
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
189 ngx_http_xslt_filter_create_conf, /* create location configuration */
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
190 ngx_http_xslt_filter_merge_conf /* merge location configuration */
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
191 };
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
192
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
193
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
194 ngx_module_t ngx_http_xslt_filter_module = {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
195 NGX_MODULE_V1,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
196 &ngx_http_xslt_filter_module_ctx, /* module context */
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
197 ngx_http_xslt_filter_commands, /* module directives */
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
198 NGX_HTTP_MODULE, /* module type */
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
199 NULL, /* init master */
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
200 NULL, /* init module */
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
201 NULL, /* init process */
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
202 NULL, /* init thread */
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
203 NULL, /* exit thread */
2196
fab3fa7339ff call ngx_http_xslt_filter_exit()
Igor Sysoev <igor@sysoev.ru>
parents: 2159
diff changeset
204 ngx_http_xslt_filter_exit, /* exit process */
fab3fa7339ff call ngx_http_xslt_filter_exit()
Igor Sysoev <igor@sysoev.ru>
parents: 2159
diff changeset
205 ngx_http_xslt_filter_exit, /* exit master */
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
206 NGX_MODULE_V1_PADDING
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
207 };
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
208
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
209
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
210 static ngx_http_output_header_filter_pt ngx_http_next_header_filter;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
211 static ngx_http_output_body_filter_pt ngx_http_next_body_filter;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
212
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
213
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
214 static ngx_int_t
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
215 ngx_http_xslt_header_filter(ngx_http_request_t *r)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
216 {
2154
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
217 ngx_http_xslt_filter_ctx_t *ctx;
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
218 ngx_http_xslt_filter_loc_conf_t *conf;
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
219
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
220 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
221 "xslt filter header");
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
222
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
223 if (r->headers_out.status == NGX_HTTP_NOT_MODIFIED) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
224 return ngx_http_next_header_filter(r);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
225 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
226
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
227 conf = ngx_http_get_module_loc_conf(r, ngx_http_xslt_filter_module);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
228
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
229 if (conf->sheets.nelts == 0
2148
071bc0fc1459 style fix
Igor Sysoev <igor@sysoev.ru>
parents: 2139
diff changeset
230 || ngx_http_test_content_type(r, &conf->types) == NULL)
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
231 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
232 return ngx_http_next_header_filter(r);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
233 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
234
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
235 ctx = ngx_http_get_module_ctx(r, ngx_http_xslt_filter_module);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
236
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
237 if (ctx) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
238 return ngx_http_next_header_filter(r);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
239 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
240
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
241 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_xslt_filter_ctx_t));
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
242 if (ctx == NULL) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
243 return NGX_ERROR;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
244 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
245
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
246 ngx_http_set_ctx(r, ctx, ngx_http_xslt_filter_module);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
247
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
248 r->main_filter_need_in_memory = 1;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
249
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
250 return NGX_OK;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
251 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
252
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
253
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
254 static ngx_int_t
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
255 ngx_http_xslt_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
256 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
257 ngx_chain_t *cl;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
258 ngx_http_xslt_filter_ctx_t *ctx;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
259
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
260 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
261 "xslt filter body");
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
262
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
263 if (in == NULL) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
264 return ngx_http_next_body_filter(r, in);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
265 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
266
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
267 ctx = ngx_http_get_module_ctx(r, ngx_http_xslt_filter_module);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
268
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
269 if (ctx == NULL || ctx->done) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
270 return ngx_http_next_body_filter(r, in);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
271 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
272
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
273 for (cl = in; cl; cl = cl->next) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
274
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
275 if (ngx_http_xslt_add_chunk(r, ctx, cl->buf) != NGX_OK) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
276
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
277 if (ctx->ctxt->myDoc){
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
278
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
279 #if (NGX_HTTP_XSLT_REUSE_DTD)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
280 ctx->ctxt->myDoc->extSubset = NULL;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
281 #endif
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
282 xmlFreeDoc(ctx->ctxt->myDoc);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
283 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
284
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
285 xmlFreeParserCtxt(ctx->ctxt);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
286
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
287 return ngx_http_xslt_send(r, ctx, NULL);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
288 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
289
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
290 if (cl->buf->last_buf) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
291
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
292 ctx->doc = ctx->ctxt->myDoc;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
293
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
294 #if (NGX_HTTP_XSLT_REUSE_DTD)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
295 ctx->doc->extSubset = NULL;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
296 #endif
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
297
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
298 xmlFreeParserCtxt(ctx->ctxt);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
299
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
300 if (ctx->ctxt->wellFormed) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
301 return ngx_http_xslt_send(r, ctx,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
302 ngx_http_xslt_apply_stylesheet(r, ctx));
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
303 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
304
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
305 xmlFreeDoc(ctx->doc);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
306
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
307 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
308 "not well formed XML document");
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
309
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
310 return ngx_http_xslt_send(r, ctx, NULL);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
311 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
312 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
313
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
314 return NGX_OK;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
315 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
316
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
317
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
318 static ngx_int_t
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
319 ngx_http_xslt_send(ngx_http_request_t *r, ngx_http_xslt_filter_ctx_t *ctx,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
320 ngx_buf_t *b)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
321 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
322 ngx_int_t rc;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
323 ngx_chain_t out;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
324 ngx_pool_cleanup_t *cln;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
325
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
326 ctx->done = 1;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
327
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
328 if (b == NULL) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
329 return ngx_http_xslt_filter_internal_error(r);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
330 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
331
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
332 cln = ngx_pool_cleanup_add(r->pool, 0);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
333
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
334 if (cln == NULL) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
335 ngx_free(b->pos);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
336 return ngx_http_special_response_handler(r,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
337 NGX_HTTP_INTERNAL_SERVER_ERROR);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
338 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
339
2159
0ec936b0010a clear Last-Modified; set content-type and length for main request only
Igor Sysoev <igor@sysoev.ru>
parents: 2158
diff changeset
340 if (r == r->main) {
0ec936b0010a clear Last-Modified; set content-type and length for main request only
Igor Sysoev <igor@sysoev.ru>
parents: 2158
diff changeset
341 r->headers_out.content_length_n = b->last - b->pos;
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
342
2159
0ec936b0010a clear Last-Modified; set content-type and length for main request only
Igor Sysoev <igor@sysoev.ru>
parents: 2158
diff changeset
343 if (r->headers_out.content_length) {
0ec936b0010a clear Last-Modified; set content-type and length for main request only
Igor Sysoev <igor@sysoev.ru>
parents: 2158
diff changeset
344 r->headers_out.content_length->hash = 0;
0ec936b0010a clear Last-Modified; set content-type and length for main request only
Igor Sysoev <igor@sysoev.ru>
parents: 2158
diff changeset
345 r->headers_out.content_length = NULL;
0ec936b0010a clear Last-Modified; set content-type and length for main request only
Igor Sysoev <igor@sysoev.ru>
parents: 2158
diff changeset
346 }
0ec936b0010a clear Last-Modified; set content-type and length for main request only
Igor Sysoev <igor@sysoev.ru>
parents: 2158
diff changeset
347
0ec936b0010a clear Last-Modified; set content-type and length for main request only
Igor Sysoev <igor@sysoev.ru>
parents: 2158
diff changeset
348 ngx_http_clear_last_modified(r);
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
349 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
350
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
351 rc = ngx_http_next_header_filter(r);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
352
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
353 if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
354 ngx_free(b->pos);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
355 return rc;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
356 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
357
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
358 cln->handler = ngx_http_xslt_cleanup;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
359 cln->data = b->pos;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
360
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
361 out.buf = b;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
362 out.next = NULL;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
363
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
364 return ngx_http_next_body_filter(r, &out);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
365 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
366
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
367
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
368 static ngx_int_t
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
369 ngx_http_xslt_filter_internal_error(ngx_http_request_t *r)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
370 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
371 ngx_int_t rc;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
372
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
373 /* clear the modules contexts */
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
374 ngx_memzero(r->ctx, sizeof(void *) * ngx_http_max_module);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
375
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
376 rc = ngx_http_special_response_handler(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
377
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
378 /* NGX_ERROR resets any pending data */
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
379
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
380 return (rc == NGX_OK) ? NGX_ERROR : rc;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
381 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
382
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
383
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
384 static ngx_int_t
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
385 ngx_http_xslt_add_chunk(ngx_http_request_t *r, ngx_http_xslt_filter_ctx_t *ctx,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
386 ngx_buf_t *b)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
387 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
388 int err;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
389 xmlSAXHandler *sax;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
390 xmlParserCtxtPtr ctxt;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
391
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
392 if (ctx->ctxt == NULL) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
393
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
394 ctxt = xmlCreatePushParserCtxt(NULL, NULL, NULL, 0, NULL);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
395 if (ctxt == NULL) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
396 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
397 "xmlCreatePushParserCtxt() failed");
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
398 return NGX_ERROR;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
399 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
400
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
401 ctx->sax = ngx_palloc(r->pool, sizeof(xmlSAXHandler));
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
402 if (ctx->sax == NULL) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
403 return NGX_ERROR;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
404 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
405
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
406 sax = ctxt->sax;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
407
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
408 ngx_memcpy(ctx->sax, sax, sizeof(xmlSAXHandler));
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
409
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
410 sax->startDocument = ngx_http_xslt_sax_start_document;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
411 sax->endDocument = ngx_http_xslt_sax_end_document;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
412
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
413 sax->internalSubset = ngx_http_xslt_sax_internal_subset;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
414 sax->externalSubset = ngx_http_xslt_sax_external_subset;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
415 sax->entityDecl = ngx_http_xslt_sax_entity_decl;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
416 sax->attributeDecl = ngx_http_xslt_sax_attribute_decl;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
417 sax->elementDecl = ngx_http_xslt_sax_element_decl;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
418 sax->notationDecl = ngx_http_xslt_sax_notation_decl;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
419 sax->unparsedEntityDecl = ngx_http_xslt_sax_unparsed_entity_decl;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
420 sax->setDocumentLocator = NULL;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
421
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
422 sax->startElementNs = ngx_http_xslt_sax_start_element;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
423 sax->endElementNs = ngx_http_xslt_sax_end_element;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
424
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
425 sax->characters = ngx_http_xslt_sax_characters;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
426 sax->ignorableWhitespace = ngx_http_xslt_sax_characters;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
427 sax->cdataBlock = ngx_http_xslt_sax_cdata_block;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
428 sax->getEntity = ngx_http_xslt_sax_get_entity;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
429 sax->resolveEntity = ngx_http_xslt_sax_resolve_entity;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
430 sax->getParameterEntity = ngx_http_xslt_sax_get_parameter_entity;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
431 sax->reference = ngx_http_xslt_sax_reference;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
432 sax->comment = ngx_http_xslt_sax_comment;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
433 sax->processingInstruction = ngx_http_xslt_sax_processing_instruction;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
434
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
435 sax->isStandalone = ngx_http_xslt_sax_is_standalone;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
436 sax->hasInternalSubset = ngx_http_xslt_sax_has_internal_subset;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
437 sax->hasExternalSubset = ngx_http_xslt_sax_has_external_subset;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
438
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
439 sax->warning = NULL;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
440 sax->error = ngx_http_xslt_sax_error;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
441 sax->fatalError = ngx_http_xslt_sax_error;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
442
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
443 ctxt->userData = ctx;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
444
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
445 ctxt->replaceEntities = 1;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
446 ctxt->loadsubset = 1;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
447
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
448 ctx->ctxt = ctxt;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
449 ctx->request = r;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
450 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
451
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
452 err = xmlParseChunk(ctx->ctxt, (char *) b->pos,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
453 (int) (b->last - b->pos), b->last_buf);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
454
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
455 if (err == 0) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
456 b->pos = b->last;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
457 return NGX_OK;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
458 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
459
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
460 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
461 "xmlParseChunk() failed, error:%d", err);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
462
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
463 return NGX_ERROR;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
464 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
465
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
466
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
467 static void
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
468 ngx_http_xslt_sax_start_document(void *data)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
469 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
470 ngx_http_xslt_filter_ctx_t *ctx = data;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
471
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
472 ctx->sax->startDocument(ctx->ctxt);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
473 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
474
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
475
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
476 static void
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
477 ngx_http_xslt_sax_end_document(void *data)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
478 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
479 ngx_http_xslt_filter_ctx_t *ctx = data;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
480
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
481 ctx->sax->endDocument(ctx->ctxt);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
482 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
483
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
484
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
485 static void
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
486 ngx_http_xslt_sax_internal_subset(void *data, const xmlChar *name,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
487 const xmlChar *externalId, const xmlChar *systemId)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
488 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
489 ngx_http_xslt_filter_ctx_t *ctx = data;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
490
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
491 ctx->sax->internalSubset(ctx->ctxt, name, externalId, systemId);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
492 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
493
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
494
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
495 static void
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
496 ngx_http_xslt_sax_external_subset(void *data, const xmlChar *name,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
497 const xmlChar *externalId, const xmlChar *systemId)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
498 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
499 ngx_http_xslt_filter_ctx_t *ctx = data;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
500
2154
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
501 xmlDocPtr doc;
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
502 xmlDtdPtr dtd;
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
503 ngx_http_request_t *r;
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
504 ngx_http_xslt_filter_loc_conf_t *conf;
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
505
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
506 r = ctx->request;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
507
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
508 conf = ngx_http_get_module_loc_conf(r, ngx_http_xslt_filter_module);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
509
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
510 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
511 "xslt filter extSubset: \"%s\" \"%s\" \"%s\"",
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
512 name ? name : (xmlChar *) "",
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
513 externalId ? externalId : (xmlChar *) "",
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
514 systemId ? systemId : (xmlChar *) "");
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
515
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
516 doc = ctx->ctxt->myDoc;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
517
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
518 #if (NGX_HTTP_XSLT_REUSE_DTD)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
519
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
520 dtd = conf->dtd;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
521
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
522 #else
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
523
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
524 dtd = xmlCopyDtd(conf->dtd);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
525 if (dtd == NULL) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
526 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
527 "xmlCopyDtd() failed");
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
528 return;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
529 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
530
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
531 if (doc->children == NULL) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
532 xmlAddChild((xmlNodePtr) doc, (xmlNodePtr) dtd);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
533
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
534 } else {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
535 xmlAddPrevSibling(doc->children, (xmlNodePtr) dtd);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
536 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
537
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
538 #endif
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
539
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
540 doc->extSubset = dtd;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
541 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
542
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
543
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
544 static void
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
545 ngx_http_xslt_sax_entity_decl(void *data, const xmlChar *name, int type,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
546 const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
547 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
548 ngx_http_xslt_filter_ctx_t *ctx = data;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
549
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
550 ctx->sax->entityDecl(ctx->ctxt, name, type, publicId, systemId, content);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
551 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
552
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
553
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
554 static void
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
555 ngx_http_xslt_sax_attribute_decl(void *data, const xmlChar *elem,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
556 const xmlChar *fullname, int type, int def, const xmlChar *defaultValue,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
557 xmlEnumerationPtr tree)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
558 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
559 ngx_http_xslt_filter_ctx_t *ctx = data;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
560
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
561 ctx->sax->attributeDecl(ctx->ctxt, elem, fullname, type, def, defaultValue,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
562 tree);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
563 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
564
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
565
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
566 static void
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
567 ngx_http_xslt_sax_element_decl(void *data, const xmlChar * name, int type,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
568 xmlElementContentPtr content)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
569 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
570 ngx_http_xslt_filter_ctx_t *ctx = data;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
571
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
572 ctx->sax->elementDecl(ctx->ctxt, name, type, content);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
573 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
574
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
575
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
576 static void
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
577 ngx_http_xslt_sax_notation_decl(void *data, const xmlChar *name,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
578 const xmlChar *publicId, const xmlChar *systemId)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
579 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
580 ngx_http_xslt_filter_ctx_t *ctx = data;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
581
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
582 ctx->sax->notationDecl(ctx->ctxt, name, publicId, systemId);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
583 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
584
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
585
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
586 static void
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
587 ngx_http_xslt_sax_unparsed_entity_decl(void *data, const xmlChar *name,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
588 const xmlChar *publicId, const xmlChar *systemId,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
589 const xmlChar *notationName)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
590 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
591 ngx_http_xslt_filter_ctx_t *ctx = data;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
592
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
593 ctx->sax->unparsedEntityDecl(ctx->ctxt, name, publicId, systemId,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
594 notationName);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
595 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
596
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
597
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
598 static void
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
599 ngx_http_xslt_sax_start_element(void *data, const xmlChar *localname,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
600 const xmlChar *prefix, const xmlChar *URI, int nb_namespaces,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
601 const xmlChar **namespaces, int nb_attributes, int nb_defaulted,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
602 const xmlChar **attributes)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
603 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
604 ngx_http_xslt_filter_ctx_t *ctx = data;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
605
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
606 ctx->sax->startElementNs(ctx->ctxt, localname, prefix, URI, nb_namespaces,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
607 namespaces, nb_attributes, nb_defaulted, attributes);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
608 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
609
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
610
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
611 static void
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
612 ngx_http_xslt_sax_end_element(void *data,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
613 const xmlChar * localname ATTRIBUTE_UNUSED,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
614 const xmlChar * prefix ATTRIBUTE_UNUSED,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
615 const xmlChar * URI ATTRIBUTE_UNUSED)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
616 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
617 ngx_http_xslt_filter_ctx_t *ctx = data;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
618
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
619 ctx->sax->endElementNs(ctx->ctxt, localname, prefix, URI);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
620 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
621
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
622
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
623 static void
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
624 ngx_http_xslt_sax_characters(void *data, const xmlChar *p, int len)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
625 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
626 ngx_http_xslt_filter_ctx_t *ctx = data;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
627
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
628 ctx->sax->characters(ctx->ctxt, p, len);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
629 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
630
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
631
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
632 static void
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
633 ngx_http_xslt_sax_cdata_block(void *data, const xmlChar *p, int len)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
634 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
635 ngx_http_xslt_filter_ctx_t *ctx = data;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
636
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
637 ctx->sax->cdataBlock(ctx->ctxt, p, len);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
638 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
639
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
640
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
641 static xmlEntityPtr
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
642 ngx_http_xslt_sax_get_entity(void *data, const xmlChar *name)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
643 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
644 ngx_http_xslt_filter_ctx_t *ctx = data;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
645
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
646 return ctx->sax->getEntity(ctx->ctxt, name);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
647 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
648
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
649
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
650 static xmlEntityPtr
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
651 ngx_http_xslt_sax_get_parameter_entity(void *data, const xmlChar *name)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
652 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
653 ngx_http_xslt_filter_ctx_t *ctx = data;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
654
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
655 return ctx->sax->getParameterEntity(ctx->ctxt, name);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
656 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
657
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
658
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
659 static xmlParserInputPtr
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
660 ngx_http_xslt_sax_resolve_entity(void *data, const xmlChar *publicId,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
661 const xmlChar *systemId)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
662 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
663 ngx_http_xslt_filter_ctx_t *ctx = data;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
664
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
665 return ctx->sax->resolveEntity(ctx->ctxt, publicId, systemId);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
666 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
667
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
668
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
669 static void
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
670 ngx_http_xslt_sax_reference(void *data, const xmlChar *name)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
671 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
672 ngx_http_xslt_filter_ctx_t *ctx = data;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
673
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
674 ctx->sax->reference(ctx->ctxt, name);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
675 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
676
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
677
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
678 static void
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
679 ngx_http_xslt_sax_comment(void *data, const xmlChar *value)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
680 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
681 ngx_http_xslt_filter_ctx_t *ctx = data;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
682
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
683 ctx->sax->comment(ctx->ctxt, value);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
684 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
685
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
686
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
687 static void
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
688 ngx_http_xslt_sax_processing_instruction(void *data, const xmlChar *target,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
689 const xmlChar *pidata)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
690 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
691 ngx_http_xslt_filter_ctx_t *ctx = data;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
692
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
693 ctx->sax->processingInstruction(ctx->ctxt, target, pidata);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
694 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
695
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
696
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
697 static int
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
698 ngx_http_xslt_sax_is_standalone(void *data)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
699 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
700 ngx_http_xslt_filter_ctx_t *ctx = data;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
701
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
702 return ctx->sax->isStandalone(ctx->ctxt);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
703 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
704
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
705
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
706 static int
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
707 ngx_http_xslt_sax_has_internal_subset(void *data)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
708 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
709 ngx_http_xslt_filter_ctx_t *ctx = data;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
710
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
711 return ctx->sax->hasInternalSubset(ctx->ctxt);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
712 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
713
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
714
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
715 static int
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
716 ngx_http_xslt_sax_has_external_subset(void *data)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
717 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
718 ngx_http_xslt_filter_ctx_t *ctx = data;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
719
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
720 return ctx->sax->hasExternalSubset(ctx->ctxt);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
721 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
722
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
723
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
724 static void ngx_cdecl
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
725 ngx_http_xslt_sax_error(void *data, const char *msg, ...)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
726 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
727 ngx_http_xslt_filter_ctx_t *ctx = data;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
728
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
729 size_t n;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
730 va_list args;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
731 u_char buf[NGX_MAX_ERROR_STR];
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
732
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
733 buf[0] = '\0';
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
734
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
735 va_start(args, msg);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
736 n = (size_t) vsnprintf((char *) buf, NGX_MAX_ERROR_STR, msg, args);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
737 va_end(args);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
738
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
739 while (--n && (buf[n] == CR || buf[n] == LF)) { /* void */ }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
740
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
741 ngx_log_error(NGX_LOG_ERR, ctx->request->connection->log, 0,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
742 "libxml2 error: \"%*s\"", n, buf);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
743 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
744
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
745
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
746 static ngx_buf_t *
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
747 ngx_http_xslt_apply_stylesheet(ngx_http_request_t *r,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
748 ngx_http_xslt_filter_ctx_t *ctx)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
749 {
2154
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
750 int len, rc, doc_type;
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
751 u_char *type, *encoding;
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
752 ngx_buf_t *b;
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
753 ngx_uint_t i;
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
754 xmlChar *buf;
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
755 xmlDocPtr doc, res;
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
756 ngx_http_xslt_sheet_t *sheet;
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
757 ngx_http_xslt_filter_loc_conf_t *conf;
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
758
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
759 conf = ngx_http_get_module_loc_conf(r, ngx_http_xslt_filter_module);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
760 sheet = conf->sheets.elts;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
761 doc = ctx->doc;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
762
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
763 /* preallocate array for 4 params */
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
764
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
765 if (ngx_array_init(&ctx->params, r->pool, 4 * 2 + 1, sizeof(char *))
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
766 != NGX_OK)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
767 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
768 xmlFreeDoc(doc);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
769 return NULL;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
770 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
771
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
772 for (i = 0; i < conf->sheets.nelts; i++) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
773
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
774 if (ngx_http_xslt_params(r, ctx, &sheet[i].params) != NGX_OK) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
775 xmlFreeDoc(doc);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
776 return NULL;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
777 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
778
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
779 res = xsltApplyStylesheet(sheet[i].stylesheet, doc, ctx->params.elts);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
780
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
781 xmlFreeDoc(doc);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
782
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
783 if (res == NULL) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
784 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
785 "xsltApplyStylesheet() failed");
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
786 return NULL;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
787 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
788
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
789 doc = res;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
790
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
791 /* reset array elements */
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
792 ctx->params.nelts = 0;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
793 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
794
2153
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
795 /* there must be at least one stylesheet */
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
796
2159
0ec936b0010a clear Last-Modified; set content-type and length for main request only
Igor Sysoev <igor@sysoev.ru>
parents: 2158
diff changeset
797 if (r == r->main) {
0ec936b0010a clear Last-Modified; set content-type and length for main request only
Igor Sysoev <igor@sysoev.ru>
parents: 2158
diff changeset
798 type = ngx_http_xslt_content_type(sheet[i - 1].stylesheet);
0ec936b0010a clear Last-Modified; set content-type and length for main request only
Igor Sysoev <igor@sysoev.ru>
parents: 2158
diff changeset
799
0ec936b0010a clear Last-Modified; set content-type and length for main request only
Igor Sysoev <igor@sysoev.ru>
parents: 2158
diff changeset
800 } else {
0ec936b0010a clear Last-Modified; set content-type and length for main request only
Igor Sysoev <igor@sysoev.ru>
parents: 2158
diff changeset
801 type = NULL;
0ec936b0010a clear Last-Modified; set content-type and length for main request only
Igor Sysoev <igor@sysoev.ru>
parents: 2158
diff changeset
802 }
0ec936b0010a clear Last-Modified; set content-type and length for main request only
Igor Sysoev <igor@sysoev.ru>
parents: 2158
diff changeset
803
2153
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
804 encoding = ngx_http_xslt_encoding(sheet[i - 1].stylesheet);
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
805 doc_type = doc->type;
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
806
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
807 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
808 "xslt filter type: %d t:%s e:%s",
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
809 doc_type, type ? type : (u_char *) "(null)",
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
810 encoding ? encoding : (u_char *) "(null)");
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
811
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
812 rc = xsltSaveResultToString(&buf, &len, doc, sheet[i - 1].stylesheet);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
813
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
814 xmlFreeDoc(doc);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
815
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
816 if (rc != 0) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
817 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
818 "xsltSaveResultToString() failed");
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
819 return NULL;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
820 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
821
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
822 if (len == 0) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
823 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
824 "xsltSaveResultToString() returned zero-length result");
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
825 return NULL;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
826 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
827
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
828 b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
829 if (b == NULL) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
830 ngx_free(buf);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
831 return NULL;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
832 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
833
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
834 b->pos = buf;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
835 b->last = buf + len;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
836 b->memory = 1;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
837 b->last_buf = 1;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
838
2159
0ec936b0010a clear Last-Modified; set content-type and length for main request only
Igor Sysoev <igor@sysoev.ru>
parents: 2158
diff changeset
839 if (encoding) {
0ec936b0010a clear Last-Modified; set content-type and length for main request only
Igor Sysoev <igor@sysoev.ru>
parents: 2158
diff changeset
840 r->headers_out.charset.len = ngx_strlen(encoding);
0ec936b0010a clear Last-Modified; set content-type and length for main request only
Igor Sysoev <igor@sysoev.ru>
parents: 2158
diff changeset
841 r->headers_out.charset.data = encoding;
0ec936b0010a clear Last-Modified; set content-type and length for main request only
Igor Sysoev <igor@sysoev.ru>
parents: 2158
diff changeset
842 }
0ec936b0010a clear Last-Modified; set content-type and length for main request only
Igor Sysoev <igor@sysoev.ru>
parents: 2158
diff changeset
843
0ec936b0010a clear Last-Modified; set content-type and length for main request only
Igor Sysoev <igor@sysoev.ru>
parents: 2158
diff changeset
844 if (r != r->main) {
0ec936b0010a clear Last-Modified; set content-type and length for main request only
Igor Sysoev <igor@sysoev.ru>
parents: 2158
diff changeset
845 return b;
0ec936b0010a clear Last-Modified; set content-type and length for main request only
Igor Sysoev <igor@sysoev.ru>
parents: 2158
diff changeset
846 }
0ec936b0010a clear Last-Modified; set content-type and length for main request only
Igor Sysoev <igor@sysoev.ru>
parents: 2158
diff changeset
847
2153
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
848 if (type) {
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
849 len = ngx_strlen(type);
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
850
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
851 r->headers_out.content_type_len = len;
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
852 r->headers_out.content_type.len = len;
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
853 r->headers_out.content_type.data = type;
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
854
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
855 } else if (doc_type == XML_HTML_DOCUMENT_NODE) {
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
856
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
857 r->headers_out.content_type_len = sizeof("text/html") - 1;
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
858 r->headers_out.content_type.len = sizeof("text/html") - 1;
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
859 r->headers_out.content_type.data = (u_char *) "text/html";
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
860 }
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
861
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
862 return b;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
863 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
864
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
865
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
866 static ngx_int_t
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
867 ngx_http_xslt_params(ngx_http_request_t *r, ngx_http_xslt_filter_ctx_t *ctx,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
868 ngx_array_t *params)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
869 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
870 u_char *p, *last, *value, *dst, *src, **s;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
871 size_t len;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
872 ngx_uint_t i;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
873 ngx_str_t string;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
874 ngx_http_xslt_param_t *param;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
875
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
876 param = params->elts;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
877
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
878 for (i = 0; i < params->nelts; i++) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
879
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
880 if (ngx_http_script_run(r, &string, param[i].lengths->elts, 1,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
881 param[i].values->elts)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
882 == NULL)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
883 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
884 return NGX_ERROR;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
885 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
886
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
887 last = string.data + string.len - 1;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
888 *last = '\0';
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
889
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
890 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
891 "xslt filter param: \"%s\"", string.data);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
892
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
893 p = string.data;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
894
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
895 while (p && *p) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
896
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
897 value = p;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
898 p = (u_char *) ngx_strchr(p, '=');
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
899 if (p == NULL) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
900 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
901 "invalid libxslt parameter \"%s\"", value);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
902 return NGX_ERROR;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
903 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
904 *p++ = '\0';
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
905
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
906 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
907 "xslt filter param name: \"%s\"", value);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
908
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
909 s = ngx_array_push(&ctx->params);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
910 if (s == NULL) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
911 return NGX_ERROR;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
912 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
913
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
914 *s = value;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
915
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
916 value = p;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
917 p = (u_char *) ngx_strchr(p, ':');
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
918
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
919 if (p) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
920 len = p - value;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
921 *p++ = '\0';
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
922
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
923 } else {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
924 len = last - value;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
925 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
926
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
927 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
928 "xslt filter param value: \"%s\"", value);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
929
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
930 dst = value;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
931 src = value;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
932
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
933 ngx_unescape_uri(&dst, &src, len, 0);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
934
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
935 *dst = '\0';
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
936
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
937 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
938 "xslt filter param unescaped: \"%s\"", value);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
939
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
940 s = ngx_array_push(&ctx->params);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
941 if (s == NULL) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
942 return NGX_ERROR;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
943 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
944
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
945 *s = value;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
946 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
947 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
948
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
949 s = ngx_array_push(&ctx->params);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
950 if (s == NULL) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
951 return NGX_ERROR;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
952 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
953
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
954 *s = NULL;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
955
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
956 return NGX_OK;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
957 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
958
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
959
2153
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
960 static u_char *
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
961 ngx_http_xslt_content_type(xsltStylesheetPtr s)
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
962 {
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
963 u_char *type;
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
964
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
965 if (s->mediaType) {
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
966 return s->mediaType;
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
967 }
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
968
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
969 for (s = s->imports; s; s = s->next) {
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
970
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
971 type = ngx_http_xslt_content_type(s);
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
972
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
973 if (type) {
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
974 return type;
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
975 }
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
976 }
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
977
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
978 return NULL;
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
979 }
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
980
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
981
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
982 static u_char *
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
983 ngx_http_xslt_encoding(xsltStylesheetPtr s)
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
984 {
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
985 u_char *encoding;
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
986
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
987 if (s->encoding) {
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
988 return s->encoding;
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
989 }
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
990
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
991 for (s = s->imports; s; s = s->next) {
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
992
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
993 encoding = ngx_http_xslt_encoding(s);
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
994
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
995 if (encoding) {
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
996 return encoding;
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
997 }
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
998 }
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
999
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
1000 return NULL;
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
1001 }
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
1002
6476e445d6ce xsl:output's media-type and encoding support
Igor Sysoev <igor@sysoev.ru>
parents: 2152
diff changeset
1003
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1004 static void
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1005 ngx_http_xslt_cleanup(void *data)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1006 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1007 ngx_free(data);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1008 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1009
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1010
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1011 static char *
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1012 ngx_http_xslt_entities(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1013 {
2154
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1014 ngx_http_xslt_filter_loc_conf_t *xlcf = conf;
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1015
2156
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1016 ngx_str_t *value;
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1017 ngx_uint_t i;
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1018 ngx_pool_cleanup_t *cln;
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1019 ngx_http_xslt_file_t *file;
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1020 ngx_http_xslt_filter_main_conf_t *xmcf;
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1021
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1022 if (xlcf->dtd) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1023 return "is duplicate";
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1024 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1025
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1026 value = cf->args->elts;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1027
2156
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1028 xmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_xslt_filter_module);
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1029
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1030 file = xmcf->dtd_files.elts;
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1031 for (i = 0; i < xmcf->dtd_files.nelts; i++) {
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1032 if (ngx_strcmp(file[i].name, &value[1].data) == 0) {
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1033 xlcf->dtd = file[i].data;
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1034 return NGX_CONF_OK;
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1035 }
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1036 }
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1037
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1038 cln = ngx_pool_cleanup_add(cf->pool, 0);
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1039 if (cln == NULL) {
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1040 return NGX_CONF_ERROR;
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1041 }
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1042
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1043 xlcf->dtd = xmlParseDTD(NULL, (xmlChar *) value[1].data);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1044
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1045 if (xlcf->dtd == NULL) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1046 ngx_conf_log_error(NGX_LOG_ERR, cf, 0, "xmlParseDTD() failed");
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1047 return NGX_CONF_ERROR;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1048 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1049
2156
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1050 cln->handler = ngx_http_xslt_cleanup_dtd;
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1051 cln->data = xlcf->dtd;
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1052
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1053 file = ngx_array_push(&xmcf->dtd_files);
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1054 if (file == NULL) {
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1055 return NGX_CONF_ERROR;
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1056 }
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1057
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1058 file->name = value[1].data;
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1059 file->data = xlcf->dtd;
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1060
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1061 return NGX_CONF_OK;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1062 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1063
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1064
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1065
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1066 static char *
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1067 ngx_http_xslt_stylesheet(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1068 {
2154
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1069 ngx_http_xslt_filter_loc_conf_t *xlcf = conf;
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1070
2154
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1071 ngx_str_t *value;
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1072 ngx_uint_t i, n;
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1073 ngx_pool_cleanup_t *cln;
2156
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1074 ngx_http_xslt_file_t *file;
2154
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1075 ngx_http_xslt_sheet_t *sheet;
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1076 ngx_http_xslt_param_t *param;
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1077 ngx_http_script_compile_t sc;
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1078 ngx_http_xslt_filter_main_conf_t *xmcf;
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1079
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1080 value = cf->args->elts;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1081
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1082 if (xlcf->sheets.elts == NULL) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1083 if (ngx_array_init(&xlcf->sheets, cf->pool, 1,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1084 sizeof(ngx_http_xslt_sheet_t))
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1085 != NGX_OK)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1086 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1087 return NGX_CONF_ERROR;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1088 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1089 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1090
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1091 sheet = ngx_array_push(&xlcf->sheets);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1092 if (sheet == NULL) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1093 return NGX_CONF_ERROR;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1094 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1095
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1096 ngx_memzero(sheet, sizeof(ngx_http_xslt_sheet_t));
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1097
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1098 if (ngx_conf_full_name(cf->cycle, &value[1], 0) != NGX_OK) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1099 return NGX_CONF_ERROR;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1100 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1101
2154
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1102 xmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_xslt_filter_module);
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1103
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1104 file = xmcf->sheet_files.elts;
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1105 for (i = 0; i < xmcf->sheet_files.nelts; i++) {
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1106 if (ngx_strcmp(file[i].name, &value[1].data) == 0) {
2156
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1107 sheet->stylesheet = file[i].data;
2154
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1108 goto found;
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1109 }
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1110 }
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1111
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1112 cln = ngx_pool_cleanup_add(cf->pool, 0);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1113 if (cln == NULL) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1114 return NGX_CONF_ERROR;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1115 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1116
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1117 sheet->stylesheet = xsltParseStylesheetFile(value[1].data);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1118 if (sheet->stylesheet == NULL) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1119 ngx_conf_log_error(NGX_LOG_ERR, cf, 0,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1120 "xsltParseStylesheetFile(\"%s\") failed",
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1121 value[1].data);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1122 return NGX_CONF_ERROR;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1123 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1124
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1125 cln->handler = ngx_http_xslt_cleanup_stylesheet;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1126 cln->data = sheet->stylesheet;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1127
2154
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1128 file = ngx_array_push(&xmcf->sheet_files);
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1129 if (file == NULL) {
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1130 return NGX_CONF_ERROR;
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1131 }
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1132
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1133 file->name = value[1].data;
2156
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1134 file->data = sheet->stylesheet;
2154
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1135
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1136 found:
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1137
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1138 n = cf->args->nelts;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1140 if (n == 2) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1141 return NGX_CONF_OK;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1142 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1143
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1144 if (ngx_array_init(&sheet->params, cf->pool, n - 2,
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1145 sizeof(ngx_http_xslt_param_t))
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1146 != NGX_OK)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1147 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1148 return NGX_CONF_ERROR;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1149 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1150
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1151 for (i = 2; i < n; i++) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1152
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1153 param = ngx_array_push(&sheet->params);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1154 if (param == NULL) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1155 return NGX_CONF_ERROR;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1156 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1157
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1158 param->lengths = NULL;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1159 param->values = NULL;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1160
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1161 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1162
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1163 sc.cf = cf;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1164 sc.source = &value[i];
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1165 sc.lengths = &param->lengths;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1166 sc.values = &param->values;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1167 sc.variables = ngx_http_script_variables_count(&value[i]);
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1168 sc.complete_lengths = 1;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1169 sc.complete_values = 1;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1170
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1171 if (ngx_http_script_compile(&sc) != NGX_OK) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1172 return NGX_CONF_ERROR;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1173 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1174 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1175
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1176 return NGX_CONF_OK;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1177 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1178
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1179
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1180 static void
2156
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1181 ngx_http_xslt_cleanup_dtd(void *data)
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1182 {
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1183 xmlFreeDtd(data);
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1184 }
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1185
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1186
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1187 static void
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1188 ngx_http_xslt_cleanup_stylesheet(void *data)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1189 {
2156
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1190 xsltFreeStylesheet(data);
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1191 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1192
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1193
2154
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1194 static void *
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1195 ngx_http_xslt_filter_create_main_conf(ngx_conf_t *cf)
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1196 {
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1197 ngx_http_xslt_filter_main_conf_t *conf;
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1198
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1199 conf = ngx_palloc(cf->pool, sizeof(ngx_http_xslt_filter_main_conf_t));
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1200 if (conf == NULL) {
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1201 return NGX_CONF_ERROR;
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1202 }
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1203
2156
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1204 if (ngx_array_init(&conf->dtd_files, cf->pool, 1,
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1205 sizeof(ngx_http_xslt_file_t))
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1206 != NGX_OK)
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1207 {
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1208 return NULL;
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1209 }
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1210
2154
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1211 if (ngx_array_init(&conf->sheet_files, cf->pool, 1,
2156
0c6d0bd60579 reuse compiled DTD hash in different locations, add DTD cleanup
Igor Sysoev <igor@sysoev.ru>
parents: 2154
diff changeset
1212 sizeof(ngx_http_xslt_file_t))
2154
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1213 != NGX_OK)
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1214 {
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1215 return NULL;
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1216 }
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1217
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1218 return conf;
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1219 }
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1220
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1221
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1222 static void *
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1223 ngx_http_xslt_filter_create_conf(ngx_conf_t *cf)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1224 {
2154
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1225 ngx_http_xslt_filter_loc_conf_t *conf;
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1226
2154
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1227 conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_xslt_filter_loc_conf_t));
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1228 if (conf == NULL) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1229 return NGX_CONF_ERROR;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1230 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1231
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1232 /*
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1233 * set by ngx_pcalloc():
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1234 *
2148
071bc0fc1459 style fix
Igor Sysoev <igor@sysoev.ru>
parents: 2139
diff changeset
1235 * conf->dtd = NULL;
071bc0fc1459 style fix
Igor Sysoev <igor@sysoev.ru>
parents: 2139
diff changeset
1236 * conf->sheets = { NULL };
071bc0fc1459 style fix
Igor Sysoev <igor@sysoev.ru>
parents: 2139
diff changeset
1237 * conf->types = { NULL };
071bc0fc1459 style fix
Igor Sysoev <igor@sysoev.ru>
parents: 2139
diff changeset
1238 * conf->types_keys = NULL;
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1239 */
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1240
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1241 return conf;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1242 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1243
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1244
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1245 static char *
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1246 ngx_http_xslt_filter_merge_conf(ngx_conf_t *cf, void *parent, void *child)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1247 {
2154
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1248 ngx_http_xslt_filter_loc_conf_t *prev = parent;
4f48a2765da0 reuse compiled XSLT tree in different locations
Igor Sysoev <igor@sysoev.ru>
parents: 2153
diff changeset
1249 ngx_http_xslt_filter_loc_conf_t *conf = child;
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1250
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1251 if (conf->dtd == NULL) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1252 conf->dtd = prev->dtd;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1253 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1254
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1255 if (conf->sheets.nelts == 0) {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1256 conf->sheets = prev->sheets;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1257 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1258
2148
071bc0fc1459 style fix
Igor Sysoev <igor@sysoev.ru>
parents: 2139
diff changeset
1259 if (ngx_http_merge_types(cf, conf->types_keys, &conf->types,
071bc0fc1459 style fix
Igor Sysoev <igor@sysoev.ru>
parents: 2139
diff changeset
1260 prev->types_keys, &prev->types,
071bc0fc1459 style fix
Igor Sysoev <igor@sysoev.ru>
parents: 2139
diff changeset
1261 ngx_http_xslt_default_types)
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1262 != NGX_OK)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1263 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1264 return NGX_CONF_ERROR;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1265 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1266
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1267 return NGX_CONF_OK;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1268 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1269
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1270
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1271 static ngx_int_t
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1272 ngx_http_xslt_filter_init(ngx_conf_t *cf)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1273 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1274 xmlInitParser();
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1275
2299
3e213fa0cbb3 exslt support
Igor Sysoev <igor@sysoev.ru>
parents: 2196
diff changeset
1276 #if (NGX_HAVE_EXSLT)
3e213fa0cbb3 exslt support
Igor Sysoev <igor@sysoev.ru>
parents: 2196
diff changeset
1277 exsltRegisterAll();
3e213fa0cbb3 exslt support
Igor Sysoev <igor@sysoev.ru>
parents: 2196
diff changeset
1278 #endif
3e213fa0cbb3 exslt support
Igor Sysoev <igor@sysoev.ru>
parents: 2196
diff changeset
1279
2139
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1280 ngx_http_next_header_filter = ngx_http_top_header_filter;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1281 ngx_http_top_header_filter = ngx_http_xslt_header_filter;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1282
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1283 ngx_http_next_body_filter = ngx_http_top_body_filter;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1284 ngx_http_top_body_filter = ngx_http_xslt_body_filter;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1285
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1286 return NGX_OK;
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1287 }
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1288
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1289
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1290 static void
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1291 ngx_http_xslt_filter_exit(ngx_cycle_t *cycle)
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1292 {
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1293 xsltCleanupGlobals();
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1294 xmlCleanupParser();
dad4423ef56a ngx_http_xslt_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1295 }