src/http/modules/xslt2/ngx_http_xslt2_xml.c File Reference

#include "ngx_http_xslt2_xml.h"
#include "ngx_http_xslt2_filter_module.h"

Go to the source code of this file.

Functions

static  ngx_http_xslt2_sheet_tngx_http_xslt2_xml_create_new_stylesheet (ngx_http_xslt2_xml_data_t *xml_data)
 Creates new xsl style sheet context structure.
static ngx_int_t ngx_http_xslt2_xml_return_original (ngx_http_xslt2_xml_data_t *xml_data)
 Returns original content of XML document if no style sheet declaration is found.
static ngx_int_t ngx_http_xslt2_xml_get_local_stylesheet (ngx_http_xslt2_sheet_t *sheet)
 Reads a style sheet from disk.
static ngx_int_t ngx_http_xslt2_xml_get_external_stylesheet (ngx_http_xslt2_sheet_t *sheet)
 Enqueues a new download of style sheet.
static void ngx_http_xslt2_xml_download_handler (ngx_http_download_conn_t *dl_ctx)
 Function called when style sheet download is finished.
static ngx_int_t ngx_http_xslt2_xml_parse_stylesheet (ngx_http_xslt2_sheet_t *sheet)
 Parses style sheet.
static ngx_int_t ngx_http_xslt2_xml_apply_stylesheets (ngx_http_xslt2_xml_data_t *xml_data)
 Tries to apply style sheets connected with XML document.
static ngx_int_t ngx_http_xslt2_xml_get_cached_stylesheet (ngx_http_request_t *r, ngx_http_xslt2_sheet_t *sheet)
 Enqueues cache connection and try to get cached style sheet.
static void ngx_http_xslt2_xml_mxcache_get_handler (ngx_http_mxcache_conn_t *conn)
 Handler called when response from cache is ready.
static ngx_int_t ngx_http_xslt2_xml_set_cached_stylesheet (ngx_http_request_t *r, ngx_http_xslt2_sheet_t *sheet)
 Tries to set style sheet in cache.
static void ngx_http_xslt2_xml_mxcache_set_handler (ngx_http_mxcache_conn_t *conn)
 Called when style sheet is set in cache.
static void ngx_http_xslt2_xml_get_stylesheet (ngx_http_xslt2_sheet_t *sheet, ngx_flag_t use_cache)
 Gets a style sheet.
static void ngx_http_xslt2_xml_stylesheet_node (ngx_http_xslt2_xml_data_t *xml_data, const xmlChar *pidata)
 Parses processing instruction and begins download.
static void ngx_http_xslt2_xml_stylesheet_error (ngx_http_xslt2_xml_data_t *xml_data, char *msg,...)
 Logs error which occurred during style sheet declaration parsing.
static void ngx_http_xslt2_xml_sax_start_document (void *data)
static void ngx_http_xslt2_xml_sax_end_document (void *data)
static void ngx_http_xslt2_xml_sax_internal_subset (void *data, const xmlChar *name, const xmlChar *externalId, const xmlChar *systemId)
static void ngx_http_xslt2_xml_sax_external_subset (void *data, const xmlChar *name, const xmlChar *externalId, const xmlChar *systemId)
static void ngx_http_xslt2_xml_sax_entity_decl (void *data, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
static void ngx_http_xslt2_xml_sax_attribute_decl (void *data, const xmlChar *elem, const xmlChar *fullname, int type, int def, const xmlChar *defaultValue, xmlEnumerationPtr tree)
static void ngx_http_xslt2_xml_sax_element_decl (void *data, const xmlChar *name, int type, xmlElementContentPtr content)
static void ngx_http_xslt2_xml_sax_notation_decl (void *data, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId)
static void ngx_http_xslt2_xml_sax_unparsed_entity_decl (void *data, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId, const xmlChar *notationName)
static void ngx_http_xslt2_xml_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_xslt2_xml_sax_end_element (void *data, const xmlChar *localname ATTRIBUTE_UNUSED, const xmlChar *prefix ATTRIBUTE_UNUSED, const xmlChar *URI ATTRIBUTE_UNUSED)
static void ngx_http_xslt2_xml_sax_characters (void *data, const xmlChar *p, int len)
static void ngx_http_xslt2_xml_sax_cdata_block (void *data, const xmlChar *p, int len)
static xmlEntityPtr ngx_http_xslt2_xml_sax_get_entity (void *data, const xmlChar *name)
static xmlEntityPtr ngx_http_xslt2_xml_sax_get_parameter_entity (void *data, const xmlChar *name)
static xmlParserInputPtr ngx_http_xslt2_xml_sax_resolve_entity (void *data, const xmlChar *publicId, const xmlChar *systemId)
static void ngx_http_xslt2_xml_sax_reference (void *data, const xmlChar *name)
static void ngx_http_xslt2_xml_sax_comment (void *data, const xmlChar *value)
static void ngx_http_xslt2_xml_sax_processing_instruction (void *data, const xmlChar *target, const xmlChar *pidata)
 XSL style sheet is interpreted as processing instruction.
static int ngx_http_xslt2_xml_sax_is_standalone (void *data)
static int ngx_http_xslt2_xml_sax_has_internal_subset (void *data)
static int ngx_http_xslt2_xml_sax_has_external_subset (void *data)
static void ngx_cdecl ngx_http_xslt2_xml_sax_error (void *data, const char *msg,...)
ngx_http_xslt2_xml_data_tngx_http_xslt2_xml_create_new (ngx_http_request_t *r)
 Creates new xml data context structure.
ngx_int_t ngx_http_xslt2_xml_add_data_chunk (ngx_http_xslt2_xml_data_t *xml_data, ngx_chain_t *in)
 Parses a chunk of xml data using libxml functions.
void ngx_http_xslt2_xml_cleanup (ngx_http_xslt2_xml_data_t *xml_data)
 Cleanups xml data context.

Function Documentation

ngx_int_t ngx_http_xslt2_xml_add_data_chunk ( ngx_http_xslt2_xml_data_t xml_data,
ngx_chain_t *  in 
)

Parses a chunk of xml data using libxml functions.

When style sheet declaration is found, proper callback function of SAX handler will handle it and begin reading from disk or enqueue download.

Parameters:
xml_data xml data context structure
in nginx chain structure

Definition at line 184 of file ngx_http_xslt2_xml.c.

References ngx_http_xslt2_xml_data_t::ctxt, ngx_http_xslt2_xml_data_t::doc, ngx_http_xslt2_xml_data_t::libxml_error, ngx_http_xslt2_finalize_with_error(), ngx_http_xslt2_xml_apply_stylesheets(), ngx_http_xslt2_xml_return_original(), ngx_http_xslt2_xml_data_t::r, ngx_http_xslt2_xml_data_t::sheets, ngx_http_xslt2_xml_data_t::stylesheet_err, ngx_http_xslt2_xml_data_t::stylesheet_err_msg, and ngx_http_xslt2_xml_data_t::xml_ready.

Referenced by ngx_http_xslt2_body_filter().

static ngx_int_t ngx_http_xslt2_xml_apply_stylesheets ( ngx_http_xslt2_xml_data_t xml_data  )  [static]
void ngx_http_xslt2_xml_cleanup ( ngx_http_xslt2_xml_data_t xml_data  ) 
ngx_http_xslt2_xml_data_t* ngx_http_xslt2_xml_create_new ( ngx_http_request_t *  r  ) 
static ngx_http_xslt2_sheet_t * ngx_http_xslt2_xml_create_new_stylesheet ( ngx_http_xslt2_xml_data_t xml_data  )  [static]

Creates new xsl style sheet context structure.

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

Parameters:
xml_data xml data context structure
Returns:
style sheet structure or NULL in case of error

Definition at line 383 of file ngx_http_xslt2_xml.c.

References ngx_http_xslt2_xml_data_t::act_sheet, ngx_http_xslt2_sheet_s::id, ngx_http_xslt2_sheet_s::next, ngx_http_xslt2_sheet_s::parent_xml, ngx_http_xslt2_xml_data_t::r, ngx_http_xslt2_xml_data_t::sheets, ngx_http_xslt2_xml_data_t::sheets_n, and ngx_http_xslt2_xml_data_t::sheets_tail.

Referenced by ngx_http_xslt2_xml_stylesheet_node().

static void ngx_http_xslt2_xml_download_handler ( ngx_http_download_conn_t dl_ctx  )  [static]
static ngx_int_t ngx_http_xslt2_xml_get_cached_stylesheet ( ngx_http_request_t *  r,
ngx_http_xslt2_sheet_t sheet 
) [static]
static ngx_int_t ngx_http_xslt2_xml_get_external_stylesheet ( ngx_http_xslt2_sheet_t sheet  )  [static]
static ngx_int_t ngx_http_xslt2_xml_get_local_stylesheet ( ngx_http_xslt2_sheet_t sheet  )  [static]

Reads a style sheet from disk.

When style sheet is read then apply_stylesheet is called.

Parameters:
sheet style sheet context structure
Returns:
result of ngx_http_xslt2_xml_apply_stylesheets or NGX_ERROR in case of error

Definition at line 680 of file ngx_http_xslt2_xml.c.

References ngx_http_xslt2_sheet_s::buffer_chain, ngx_http_filesync_get(), ngx_http_xslt2_finalize_with_error(), ngx_http_xslt2_xml_apply_stylesheets(), ngx_http_xslt2_xml_parse_stylesheet(), ngx_http_xslt2_xml_set_cached_stylesheet(), ngx_http_xslt2_sheet_s::parent_xml, ngx_http_xslt2_xml_data_t::r, ngx_http_xslt2_sheet_s::ready, and ngx_http_xslt2_sheet_s::res_uri.

Referenced by ngx_http_xslt2_xml_get_stylesheet().

static void ngx_http_xslt2_xml_get_stylesheet ( ngx_http_xslt2_sheet_t sheet,
ngx_flag_t  use_cache 
) [static]

Gets a style sheet.

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

Parameters:
sheet style sheet structure
use_cache flag which indicates whether to use cache or not

Definition at line 633 of file ngx_http_xslt2_xml.c.

References ngx_http_xslt2_xml_get_cached_stylesheet(), ngx_http_xslt2_xml_get_external_stylesheet(), ngx_http_xslt2_xml_get_local_stylesheet(), ngx_http_xslt2_sheet_s::parent_xml, ngx_http_xslt2_xml_data_t::r, ngx_http_xslt2_sheet_s::res_uri, and XXSLT_USE_CACHE.

Referenced by ngx_http_xslt2_xml_mxcache_get_handler(), and ngx_http_xslt2_xml_stylesheet_node().

static void ngx_http_xslt2_xml_mxcache_get_handler ( ngx_http_mxcache_conn_t conn  )  [static]
static void ngx_http_xslt2_xml_mxcache_set_handler ( ngx_http_mxcache_conn_t conn  )  [static]

Called when style sheet is set in cache.

Cleanup of cache structure is called.

Parameters:
conn cache structure

Definition at line 616 of file ngx_http_xslt2_xml.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_xslt2_xml_set_cached_stylesheet().

static ngx_int_t ngx_http_xslt2_xml_parse_stylesheet ( ngx_http_xslt2_sheet_t sheet  )  [static]

Parses style sheet.

Parameters:
sheet style sheet context structure.
Returns:
NGX_OK or NGX_ERROR in case of error

Definition at line 878 of file ngx_http_xslt2_xml.c.

References ngx_http_xslt2_sheet_s::buffer_chain, ngx_http_xslt2_sheet_s::parent_xml, ngx_http_xslt2_xml_data_t::r, and ngx_http_xslt2_sheet_s::stylesheet.

Referenced by ngx_http_xslt2_xml_download_handler(), ngx_http_xslt2_xml_get_local_stylesheet(), and ngx_http_xslt2_xml_mxcache_get_handler().

static ngx_int_t ngx_http_xslt2_xml_return_original ( ngx_http_xslt2_xml_data_t xml_data  )  [static]

Returns original content of XML document if no style sheet declaration is found.

Parameters:
xml_data xml data context structure
Returns:
NGX_OK or NGX_ERROR in case of error
Todo:
it's very ugly and slow way to do it. Buffers should be collected and returned in case of lack of style sheets.

Definition at line 270 of file ngx_http_xslt2_xml.c.

References ngx_http_xslt2_xml_data_t::buffer_chain, ngx_http_xslt2_xml_data_t::doc, ngx_http_xslt2_xml_data_t::done, ngx_http_xslt2_finalize_with_error(), ngx_http_xslt2_process_data(), ngx_http_xslt2_xml_data_t::r, and ngx_http_xslt2_xml_data_t::res_len.

Referenced by ngx_http_xslt2_xml_add_data_chunk().

static void ngx_http_xslt2_xml_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_xslt2_xml_sax_cdata_block ( void *  data,
const xmlChar *  p,
int  len 
) [static]
static void ngx_http_xslt2_xml_sax_characters ( void *  data,
const xmlChar *  p,
int  len 
) [static]
static void ngx_http_xslt2_xml_sax_comment ( void *  data,
const xmlChar *  value 
) [static]
static void ngx_http_xslt2_xml_sax_element_decl ( void *  data,
const xmlChar *  name,
int  type,
xmlElementContentPtr  content 
) [static]
static void ngx_http_xslt2_xml_sax_end_document ( void *  data  )  [static]
static void ngx_http_xslt2_xml_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_xslt2_xml_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_xslt2_xml_sax_error ( void *  data,
const char *  msg,
  ... 
) [static]
static void ngx_http_xslt2_xml_sax_external_subset ( void *  data,
const xmlChar *  name,
const xmlChar *  externalId,
const xmlChar *  systemId 
) [static]

Definition at line 1201 of file ngx_http_xslt2_xml.c.

Referenced by ngx_http_xslt2_xml_create_new().

static xmlEntityPtr ngx_http_xslt2_xml_sax_get_entity ( void *  data,
const xmlChar *  name 
) [static]
static xmlEntityPtr ngx_http_xslt2_xml_sax_get_parameter_entity ( void *  data,
const xmlChar *  name 
) [static]
static int ngx_http_xslt2_xml_sax_has_external_subset ( void *  data  )  [static]
static int ngx_http_xslt2_xml_sax_has_internal_subset ( void *  data  )  [static]
static void ngx_http_xslt2_xml_sax_internal_subset ( void *  data,
const xmlChar *  name,
const xmlChar *  externalId,
const xmlChar *  systemId 
) [static]
static int ngx_http_xslt2_xml_sax_is_standalone ( void *  data  )  [static]
static void ngx_http_xslt2_xml_sax_notation_decl ( void *  data,
const xmlChar *  name,
const xmlChar *  publicId,
const xmlChar *  systemId 
) [static]
static void ngx_http_xslt2_xml_sax_processing_instruction ( void *  data,
const xmlChar *  target,
const xmlChar *  pidata 
) [static]

XSL style sheet is interpreted as processing instruction.

Definition at line 1162 of file ngx_http_xslt2_xml.c.

References ngx_http_xslt2_xml_data_t::ctxt, ngx_http_xslt2_xml_stylesheet_node(), and ngx_http_xslt2_xml_data_t::sax.

Referenced by ngx_http_xslt2_xml_create_new().

static void ngx_http_xslt2_xml_sax_reference ( void *  data,
const xmlChar *  name 
) [static]
static xmlParserInputPtr ngx_http_xslt2_xml_sax_resolve_entity ( void *  data,
const xmlChar *  publicId,
const xmlChar *  systemId 
) [static]
static void ngx_http_xslt2_xml_sax_start_document ( void *  data  )  [static]
static void ngx_http_xslt2_xml_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_xslt2_xml_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_xslt2_xml_set_cached_stylesheet ( ngx_http_request_t *  r,
ngx_http_xslt2_sheet_t sheet 
) [static]
static void ngx_http_xslt2_xml_stylesheet_error ( ngx_http_xslt2_xml_data_t xml_data,
char *  msg,
  ... 
) [static]

Logs error which occurred during style sheet declaration parsing.

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

Parameters:
xml_data xml data context structure
msg formatted error message

Definition at line 1123 of file ngx_http_xslt2_xml.c.

References ngx_http_xslt2_xml_data_t::r, ngx_http_xslt2_xml_data_t::stylesheet_err, and ngx_http_xslt2_xml_data_t::stylesheet_err_msg.

Referenced by ngx_http_xslt2_xml_stylesheet_node().

static void ngx_http_xslt2_xml_stylesheet_node ( ngx_http_xslt2_xml_data_t xml_data,
const xmlChar *  pidata 
) [static]

Parses processing instruction and begins download.

Parameters:
xml_data xml data context structure
pidata processing instruction content

Definition at line 1067 of file ngx_http_xslt2_xml.c.

References ngx_http_xslt2_xml_create_new_stylesheet(), ngx_http_xslt2_xml_get_stylesheet(), ngx_http_xslt2_xml_stylesheet_error(), ngx_http_xslt2_xml_data_t::r, ngx_http_xslt2_sheet_s::res_uri, and XXSLT_USE_CACHE.

Referenced by ngx_http_xslt2_xml_sax_processing_instruction().


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