src/http/modules/xxslt/ngx_http_xxslt_parse.c File Reference

#include "ngx_http_xxslt_parse.h"
#include "ngx_http_xxslt_selector.h"

Go to the source code of this file.

Functions

static  u_char * ngx_http_xxslt_parse_get_prefix (void)
 Returns prefix for xsl parsing.
static u_char * ngx_http_xxslt_parse_get_suffix (void)
 Returns suffix for xsl parsing.
static ngx_http_xxslt_include_tngx_http_xxslt_parse_create_new_include (ngx_http_xxslt_parse_data_t *parse_data)
 Creates a new include context structure.
static void ngx_http_xxslt_parse_get_include (ngx_http_xxslt_include_t *include, ngx_flag_t use_cache)
 Gets an include.
static void ngx_http_xxslt_parse_use_alt_src (ngx_http_xxslt_include_t *include)
 Tries to use alternative include source.
static ngx_int_t ngx_http_xxslt_parse_get_external_include (ngx_http_xxslt_include_t *include)
 Enqueues a new download of include.
static ngx_int_t ngx_http_xxslt_parse_get_local_include (ngx_http_xxslt_include_t *include)
 Reads a include from disk.
static void ngx_http_xxslt_parse_download_handler (ngx_http_download_conn_t *dl_ctx)
 Function called when include download is finished.
static ngx_int_t ngx_http_xxslt_parse_add_include (ngx_http_xxslt_include_t *include)
 Adds include to result.
static void ngx_http_xxslt_parse_add_buffer_chain (ngx_http_xxslt_parse_data_t *parse_data, ngx_chain_t *in)
 Adds buffer chain to the result of parse processing and updates length properly.
static ngx_int_t ngx_http_xxslt_parse_set_cached_include (ngx_http_request_t *r, ngx_http_xxslt_include_t *include)
 Tries to set include in cache.
static void ngx_http_xxslt_parse_mxcache_set_handler (ngx_http_mxcache_conn_t *conn)
 Called when include is set in cache.
static ngx_int_t ngx_http_xxslt_parse_get_cached_include (ngx_http_request_t *r, ngx_http_xxslt_include_t *include, u_char *uri)
 Enqueues cache connection and try to get cached include.
static void ngx_http_xxslt_parse_mxcache_get_handler (ngx_http_mxcache_conn_t *conn)
 Handler called when response from cache is ready.
static void ngx_http_xxslt_parse_process_include (ngx_http_xxslt_include_t *include, ngx_flag_t set_cache)
 Process downloaded include.
static void ngx_http_xxslt_parse_include_node (ngx_http_xxslt_parse_data_t *parse_data, int nb_attributes, const xmlChar **attributes)
 Parses include node and begins download / reading from disk.
static void ngx_http_xxslt_parse_include_error (ngx_http_xxslt_parse_data_t *parse_data, char *msg,...)
 Logs error which occurred during include declaration parsing.
static void ngx_http_xxslt_parse_sax_start_document (void *data)
static void ngx_http_xxslt_parse_sax_end_document (void *data)
static void ngx_http_xxslt_parse_sax_internal_subset (void *data, const xmlChar *name, const xmlChar *externalId, const xmlChar *systemId)
static void ngx_http_xxslt_parse_sax_external_subset (void *data, const xmlChar *name, const xmlChar *externalId, const xmlChar *systemId)
static void ngx_http_xxslt_parse_sax_entity_decl (void *data, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
static void ngx_http_xxslt_parse_sax_attribute_decl (void *data, const xmlChar *elem, const xmlChar *fullname, int type, int def, const xmlChar *defaultValue, xmlEnumerationPtr tree)
static void ngx_http_xxslt_parse_sax_element_decl (void *data, const xmlChar *name, int type, xmlElementContentPtr content)
static void ngx_http_xxslt_parse_sax_notation_decl (void *data, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId)
static void ngx_http_xxslt_parse_sax_unparsed_entity_decl (void *data, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId, const xmlChar *notationName)
static void ngx_http_xxslt_parse_sax_start_element (void *data, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI, int nb_namespaces, const xmlChar **namespaces, int nb_attributes, int nb_defaulted, const xmlChar **attributes)
static void ngx_http_xxslt_parse_sax_end_element (void *data, const xmlChar *localname ATTRIBUTE_UNUSED, const xmlChar *prefix ATTRIBUTE_UNUSED, const xmlChar *URI ATTRIBUTE_UNUSED)
static void ngx_http_xxslt_parse_sax_characters (void *data, const xmlChar *p, int len)
static void ngx_http_xxslt_parse_sax_cdata_block (void *data, const xmlChar *p, int len)
static xmlEntityPtr ngx_http_xxslt_parse_sax_get_entity (void *data, const xmlChar *name)
static xmlEntityPtr ngx_http_xxslt_parse_sax_get_parameter_entity (void *data, const xmlChar *name)
static xmlParserInputPtr ngx_http_xxslt_parse_sax_resolve_entity (void *data, const xmlChar *publicId, const xmlChar *systemId)
static void ngx_http_xxslt_parse_sax_reference (void *data, const xmlChar *name)
static void ngx_http_xxslt_parse_sax_comment (void *data, const xmlChar *value)
static void ngx_http_xxslt_parse_sax_processing_instruction (void *data, const xmlChar *target, const xmlChar *pidata)
static int ngx_http_xxslt_parse_sax_is_standalone (void *data)
static int ngx_http_xxslt_parse_sax_has_internal_subset (void *data)
static int ngx_http_xxslt_parse_sax_has_external_subset (void *data)
static void ngx_cdecl ngx_http_xxslt_parse_sax_error (void *data, const char *msg,...)
ngx_http_xxslt_parse_data_tngx_http_xxslt_parse_create_new (ngx_http_request_t *r)
 Creates new parse data context structure.
ngx_int_t ngx_http_xxslt_parse_add_data_chunk (ngx_http_xxslt_parse_data_t *parse_data, ngx_chain_t *in)
 Parses a chunk of parse (xslt) data using libxml functions.
ngx_int_t ngx_http_xxslt_parse_apply (ngx_http_xxslt_parse_data_t *parse_data)
 Applies parsed xslt directives to the XML document containing all downloaded includes.
void ngx_http_xxslt_parse_cleanup (ngx_http_xxslt_parse_data_t *parse_data)
 Cleanups parse data context.

Function Documentation

static void ngx_http_xxslt_parse_add_buffer_chain ( ngx_http_xxslt_parse_data_t parse_data,
ngx_chain_t *  in 
) [static]

Adds buffer chain to the result of parse processing and updates length properly.

Parameters:
parse_data parse data context structure
in nginx chain which will be added

Definition at line 455 of file ngx_http_xxslt_parse.c.

References ngx_http_xxslt_parse_data_t::buffer_chain, ngx_http_xxslt_parse_data_t::buffer_chain_tail, and ngx_http_xxslt_parse_data_t::res_len.

Referenced by ngx_http_xxslt_parse_add_include(), and ngx_http_xxslt_parse_apply().

ngx_int_t ngx_http_xxslt_parse_add_data_chunk ( ngx_http_xxslt_parse_data_t parse_data,
ngx_chain_t *  in 
)
static ngx_int_t ngx_http_xxslt_parse_add_include ( ngx_http_xxslt_include_t include  )  [static]

Adds include to result.

When dca is XSLT then include is parsed. By default, an included object will be included as flat text.

Parameters:
include include structure
Returns:
NGX_OK or NGX_ERROR in case of error

!

Definition at line 804 of file ngx_http_xxslt_parse.c.

References ngx_http_xxslt_include_s::buffer_chain, ngx_http_xxslt_include_s::data_type, ngx_http_xxslt_include_s::error, ngx_http_xxslt_parse_data_t::includes, ngx_http_xxslt_include_s::name, ngx_http_xxslt_parse_add_buffer_chain(), ngx_http_xxslt_include_s::parent_parse, PARSE_XML, ngx_http_xxslt_include_s::paste, and ngx_http_xxslt_parse_data_t::r.

Referenced by ngx_http_xxslt_parse_process_include().

ngx_int_t ngx_http_xxslt_parse_apply ( ngx_http_xxslt_parse_data_t parse_data  ) 

Applies parsed xslt directives to the XML document containing all downloaded includes.

Parameters:
parse_data parse data context structure
Returns:
NGX_OK or NGX_ERROR in case of error

Definition at line 347 of file ngx_http_xxslt_parse.c.

References ngx_http_xxslt_parse_data_t::includes, ngx_http_xxslt_finalize_with_error(), ngx_http_xxslt_parse_add_buffer_chain(), ngx_http_xxslt_parse_data_t::r, and ngx_http_xxslt_parse_data_t::stylesheet.

Referenced by ngx_http_xxslt_process_data().

void ngx_http_xxslt_parse_cleanup ( ngx_http_xxslt_parse_data_t parse_data  ) 

Cleanups parse data context.

Terminate all remaining downloads or mxcache connections.

Parameters:
parse_data parse data context structure

Definition at line 972 of file ngx_http_xxslt_parse.c.

References ngx_http_download_cleanup(), ngx_http_mxcache_cleanup(), and ngx_http_xxslt_parse_data_t::r.

Referenced by ngx_http_xxslt_cleanup().

ngx_http_xxslt_parse_data_t* ngx_http_xxslt_parse_create_new ( ngx_http_request_t *  r  ) 
static ngx_http_xxslt_include_t * ngx_http_xxslt_parse_create_new_include ( ngx_http_xxslt_parse_data_t parse_data  )  [static]

Creates a new include context structure.

New include structure is added to list of style sheets in xml data context.

Parameters:
parse_data parse data context structure
Returns:
include structure or NULL in case of error

Definition at line 488 of file ngx_http_xxslt_parse.c.

References ngx_http_xxslt_parse_data_t::inc_act, ngx_http_xxslt_parse_data_t::inc_list, ngx_http_xxslt_parse_data_t::inc_list_tail, ngx_http_xxslt_include_s::next, ngx_http_xxslt_include_s::parent_parse, and ngx_http_xxslt_parse_data_t::r.

Referenced by ngx_http_xxslt_parse_include_node().

static void ngx_http_xxslt_parse_download_handler ( ngx_http_download_conn_t dl_ctx  )  [static]
static ngx_int_t ngx_http_xxslt_parse_get_cached_include ( ngx_http_request_t *  r,
ngx_http_xxslt_include_t include,
u_char *  uri 
) [static]
static ngx_int_t ngx_http_xxslt_parse_get_external_include ( ngx_http_xxslt_include_t include  )  [static]
static void ngx_http_xxslt_parse_get_include ( ngx_http_xxslt_include_t include,
ngx_flag_t  use_cache 
) [static]

Gets an include.

When URI is local then include is read from disk. When http:// prefix is found then a new download is enqueued.

Parameters:
include include context structure
use_cache flag which indicates whether to use cache or not

Definition at line 533 of file ngx_http_xxslt_parse.c.

References ngx_http_xxslt_include_s::error, ngx_http_xxslt_parse_get_cached_include(), ngx_http_xxslt_parse_get_external_include(), ngx_http_xxslt_parse_get_local_include(), ngx_http_xxslt_parse_process_include(), ngx_http_xxslt_include_s::parent_parse, ngx_http_xxslt_parse_data_t::r, ngx_http_xxslt_include_s::src, ngx_http_xxslt_include_s::ttl, and XXSLT_USE_CACHE.

Referenced by ngx_http_xxslt_parse_include_node(), ngx_http_xxslt_parse_mxcache_get_handler(), and ngx_http_xxslt_parse_use_alt_src().

static ngx_int_t ngx_http_xxslt_parse_get_local_include ( ngx_http_xxslt_include_t include  )  [static]

Reads a include from disk.

When include is read then ngx_http_xxslt_parse_process_include is called.

Parameters:
include include context structure
Returns:
NGX_OK or NGX_ERROR in case of error

Definition at line 928 of file ngx_http_xxslt_parse.c.

References ngx_http_xxslt_include_s::buffer_chain, ngx_http_filesync_get(), ngx_http_xxslt_finalize_with_error(), ngx_http_xxslt_parse_process_include(), ngx_http_xxslt_include_s::parent_parse, ngx_http_xxslt_parse_data_t::r, ngx_http_xxslt_include_s::ready, ngx_http_xxslt_include_s::src, and XXSLT_USE_CACHE.

Referenced by ngx_http_xxslt_parse_get_include().

static u_char * ngx_http_xxslt_parse_get_prefix ( void   )  [static]

Returns prefix for xsl parsing.

It is used to generate dummy root for XML document.

Definition at line 1023 of file ngx_http_xxslt_parse.c.

References PARSE_DUMMY_NODE.

Referenced by ngx_http_xxslt_parse_add_data_chunk().

static u_char * ngx_http_xxslt_parse_get_suffix ( void   )  [static]

Returns suffix for xsl parsing.

It is used to generate dummy root for XML document.

Definition at line 1034 of file ngx_http_xxslt_parse.c.

References PARSE_DUMMY_NODE.

Referenced by ngx_http_xxslt_parse_add_data_chunk().

static void ngx_http_xxslt_parse_include_error ( ngx_http_xxslt_parse_data_t parse_data,
char *  msg,
  ... 
) [static]

Logs error which occurred during include declaration parsing.

It is used because ngx_http_xxslt_finalize_with_error can't be called from libxml callback - it frees libxml parser context.

Parameters:
parse_data parse data context structure
msg formatted error message

Definition at line 1270 of file ngx_http_xxslt_parse.c.

References ngx_http_xxslt_parse_data_t::include_err, ngx_http_xxslt_parse_data_t::include_err_msg, and ngx_http_xxslt_parse_data_t::r.

Referenced by ngx_http_xxslt_parse_include_node().

static void ngx_http_xxslt_parse_include_node ( ngx_http_xxslt_parse_data_t parse_data,
int  nb_attributes,
const xmlChar **  attributes 
) [static]
static void ngx_http_xxslt_parse_mxcache_get_handler ( ngx_http_mxcache_conn_t conn  )  [static]
static void ngx_http_xxslt_parse_mxcache_set_handler ( ngx_http_mxcache_conn_t conn  )  [static]

Called when include is set in cache.

Cleanup of cache structure is called.

Parameters:
conn cache structure

Definition at line 1253 of file ngx_http_xxslt_parse.c.

References ngx_http_mxcache_conn_s::error, ngx_http_mxcache_conn_s::log, ngx_http_mxcache_cleanup(), and ngx_http_mxcache_conn_s::res_uri.

Referenced by ngx_http_xxslt_parse_set_cached_include().

static void ngx_http_xxslt_parse_process_include ( ngx_http_xxslt_include_t include,
ngx_flag_t  set_cache 
) [static]
static void ngx_http_xxslt_parse_sax_attribute_decl ( void *  data,
const xmlChar *  elem,
const xmlChar *  fullname,
int  type,
int  def,
const xmlChar *  defaultValue,
xmlEnumerationPtr  tree 
) [static]
static void ngx_http_xxslt_parse_sax_cdata_block ( void *  data,
const xmlChar *  p,
int  len 
) [static]
static void ngx_http_xxslt_parse_sax_characters ( void *  data,
const xmlChar *  p,
int  len 
) [static]
static void ngx_http_xxslt_parse_sax_comment ( void *  data,
const xmlChar *  value 
) [static]
static void ngx_http_xxslt_parse_sax_element_decl ( void *  data,
const xmlChar *  name,
int  type,
xmlElementContentPtr  content 
) [static]
static void ngx_http_xxslt_parse_sax_end_document ( void *  data  )  [static]
static void ngx_http_xxslt_parse_sax_end_element ( void *  data,
const xmlChar *localname  ATTRIBUTE_UNUSED,
const xmlChar *prefix  ATTRIBUTE_UNUSED,
const xmlChar *URI  ATTRIBUTE_UNUSED 
) [static]
static void ngx_http_xxslt_parse_sax_entity_decl ( void *  data,
const xmlChar *  name,
int  type,
const xmlChar *  publicId,
const xmlChar *  systemId,
xmlChar *  content 
) [static]
static void ngx_cdecl ngx_http_xxslt_parse_sax_error ( void *  data,
const char *  msg,
  ... 
) [static]
static void ngx_http_xxslt_parse_sax_external_subset ( void *  data,
const xmlChar *  name,
const xmlChar *  externalId,
const xmlChar *  systemId 
) [static]

Definition at line 1522 of file ngx_http_xxslt_parse.c.

Referenced by ngx_http_xxslt_parse_create_new().

static xmlEntityPtr ngx_http_xxslt_parse_sax_get_entity ( void *  data,
const xmlChar *  name 
) [static]
static xmlEntityPtr ngx_http_xxslt_parse_sax_get_parameter_entity ( void *  data,
const xmlChar *  name 
) [static]
static int ngx_http_xxslt_parse_sax_has_external_subset ( void *  data  )  [static]
static int ngx_http_xxslt_parse_sax_has_internal_subset ( void *  data  )  [static]
static void ngx_http_xxslt_parse_sax_internal_subset ( void *  data,
const xmlChar *  name,
const xmlChar *  externalId,
const xmlChar *  systemId 
) [static]
static int ngx_http_xxslt_parse_sax_is_standalone ( void *  data  )  [static]
static void ngx_http_xxslt_parse_sax_notation_decl ( void *  data,
const xmlChar *  name,
const xmlChar *  publicId,
const xmlChar *  systemId 
) [static]
static void ngx_http_xxslt_parse_sax_processing_instruction ( void *  data,
const xmlChar *  target,
const xmlChar *  pidata 
) [static]
static void ngx_http_xxslt_parse_sax_reference ( void *  data,
const xmlChar *  name 
) [static]
static xmlParserInputPtr ngx_http_xxslt_parse_sax_resolve_entity ( void *  data,
const xmlChar *  publicId,
const xmlChar *  systemId 
) [static]
static void ngx_http_xxslt_parse_sax_start_document ( void *  data  )  [static]
static void ngx_http_xxslt_parse_sax_start_element ( void *  data,
const xmlChar *  localname,
const xmlChar *  prefix,
const xmlChar *  URI,
int  nb_namespaces,
const xmlChar **  namespaces,
int  nb_attributes,
int  nb_defaulted,
const xmlChar **  attributes 
) [static]
static void ngx_http_xxslt_parse_sax_unparsed_entity_decl ( void *  data,
const xmlChar *  name,
const xmlChar *  publicId,
const xmlChar *  systemId,
const xmlChar *  notationName 
) [static]
static ngx_int_t ngx_http_xxslt_parse_set_cached_include ( ngx_http_request_t *  r,
ngx_http_xxslt_include_t include 
) [static]
static void ngx_http_xxslt_parse_use_alt_src ( ngx_http_xxslt_include_t include  )  [static]

Tries to use alternative include source.

If it is present then error flag is reseted and alternative source is used. When alternative source is NULL then functions returns.

Definition at line 588 of file ngx_http_xxslt_parse.c.

References ngx_http_xxslt_include_s::alt, ngx_http_xxslt_include_s::error, ngx_http_xxslt_parse_get_include(), ngx_http_xxslt_include_s::src, and XXSLT_USE_CACHE.

Referenced by ngx_http_xxslt_parse_process_include().


Generated on Mon Oct 12 14:03:36 2009 for XXSLT by  doxygen 1.6.1