xsltutils.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. /*
  2. * Summary: set of utilities for the XSLT engine
  3. * Description: interfaces for the utilities module of the XSLT engine.
  4. * things like message handling, profiling, and other
  5. * generally useful routines.
  6. *
  7. * Copy: See Copyright for the status of this software.
  8. *
  9. * Author: Daniel Veillard
  10. */
  11. #ifndef __XML_XSLTUTILS_H__
  12. #define __XML_XSLTUTILS_H__
  13. #include <libxslt/xsltconfig.h>
  14. #ifdef HAVE_STDARG_H
  15. #include <stdarg.h>
  16. #endif
  17. #include <libxml/xpath.h>
  18. #include <libxml/dict.h>
  19. #include <libxml/xmlerror.h>
  20. #include "xsltexports.h"
  21. #include "xsltInternals.h"
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /**
  26. * XSLT_TODO:
  27. *
  28. * Macro to flag unimplemented blocks.
  29. */
  30. #define XSLT_TODO \
  31. xsltGenericError(xsltGenericErrorContext, \
  32. "Unimplemented block at %s:%d\n", \
  33. __FILE__, __LINE__);
  34. /**
  35. * XSLT_STRANGE:
  36. *
  37. * Macro to flag that a problem was detected internally.
  38. */
  39. #define XSLT_STRANGE \
  40. xsltGenericError(xsltGenericErrorContext, \
  41. "Internal error at %s:%d\n", \
  42. __FILE__, __LINE__);
  43. /**
  44. * IS_XSLT_ELEM:
  45. *
  46. * Checks that the element pertains to XSLT namespace.
  47. */
  48. #define IS_XSLT_ELEM(n) \
  49. (((n) != NULL) && ((n)->type == XML_ELEMENT_NODE) && \
  50. ((n)->ns != NULL) && (xmlStrEqual((n)->ns->href, XSLT_NAMESPACE)))
  51. /**
  52. * IS_XSLT_NAME:
  53. *
  54. * Checks the value of an element in XSLT namespace.
  55. */
  56. #define IS_XSLT_NAME(n, val) \
  57. (xmlStrEqual((n)->name, (const xmlChar *) (val)))
  58. /**
  59. * IS_XSLT_REAL_NODE:
  60. *
  61. * Check that a node is a 'real' one: document, element, text or attribute.
  62. */
  63. #define IS_XSLT_REAL_NODE(n) \
  64. (((n) != NULL) && \
  65. (((n)->type == XML_ELEMENT_NODE) || \
  66. ((n)->type == XML_TEXT_NODE) || \
  67. ((n)->type == XML_CDATA_SECTION_NODE) || \
  68. ((n)->type == XML_ATTRIBUTE_NODE) || \
  69. ((n)->type == XML_DOCUMENT_NODE) || \
  70. ((n)->type == XML_HTML_DOCUMENT_NODE) || \
  71. ((n)->type == XML_COMMENT_NODE) || \
  72. ((n)->type == XML_PI_NODE)))
  73. /*
  74. * Our own version of namespaced attributes lookup.
  75. */
  76. XSLTPUBFUN xmlChar * XSLTCALL
  77. xsltGetNsProp (xmlNodePtr node,
  78. const xmlChar *name,
  79. const xmlChar *nameSpace);
  80. XSLTPUBFUN const xmlChar * XSLTCALL
  81. xsltGetCNsProp (xsltStylesheetPtr style,
  82. xmlNodePtr node,
  83. const xmlChar *name,
  84. const xmlChar *nameSpace);
  85. XSLTPUBFUN int XSLTCALL
  86. xsltGetUTF8Char (const unsigned char *utf,
  87. int *len);
  88. /*
  89. * XSLT Debug Tracing Tracing Types
  90. */
  91. typedef enum {
  92. XSLT_TRACE_ALL = -1,
  93. XSLT_TRACE_NONE = 0,
  94. XSLT_TRACE_COPY_TEXT = 1<<0,
  95. XSLT_TRACE_PROCESS_NODE = 1<<1,
  96. XSLT_TRACE_APPLY_TEMPLATE = 1<<2,
  97. XSLT_TRACE_COPY = 1<<3,
  98. XSLT_TRACE_COMMENT = 1<<4,
  99. XSLT_TRACE_PI = 1<<5,
  100. XSLT_TRACE_COPY_OF = 1<<6,
  101. XSLT_TRACE_VALUE_OF = 1<<7,
  102. XSLT_TRACE_CALL_TEMPLATE = 1<<8,
  103. XSLT_TRACE_APPLY_TEMPLATES = 1<<9,
  104. XSLT_TRACE_CHOOSE = 1<<10,
  105. XSLT_TRACE_IF = 1<<11,
  106. XSLT_TRACE_FOR_EACH = 1<<12,
  107. XSLT_TRACE_STRIP_SPACES = 1<<13,
  108. XSLT_TRACE_TEMPLATES = 1<<14,
  109. XSLT_TRACE_KEYS = 1<<15,
  110. XSLT_TRACE_VARIABLES = 1<<16
  111. } xsltDebugTraceCodes;
  112. /**
  113. * XSLT_TRACE:
  114. *
  115. * Control the type of xsl debugtrace messages emitted.
  116. */
  117. #define XSLT_TRACE(ctxt,code,call) \
  118. if (ctxt->traceCode && (*(ctxt->traceCode) & code)) \
  119. call
  120. XSLTPUBFUN void XSLTCALL
  121. xsltDebugSetDefaultTrace(xsltDebugTraceCodes val);
  122. XSLTPUBFUN xsltDebugTraceCodes XSLTCALL
  123. xsltDebugGetDefaultTrace(void);
  124. /*
  125. * XSLT specific error and debug reporting functions.
  126. */
  127. XSLTPUBVAR xmlGenericErrorFunc xsltGenericError;
  128. XSLTPUBVAR void *xsltGenericErrorContext;
  129. XSLTPUBVAR xmlGenericErrorFunc xsltGenericDebug;
  130. XSLTPUBVAR void *xsltGenericDebugContext;
  131. XSLTPUBFUN void XSLTCALL
  132. xsltPrintErrorContext (xsltTransformContextPtr ctxt,
  133. xsltStylesheetPtr style,
  134. xmlNodePtr node);
  135. XSLTPUBFUN void XSLTCALL
  136. xsltMessage (xsltTransformContextPtr ctxt,
  137. xmlNodePtr node,
  138. xmlNodePtr inst);
  139. XSLTPUBFUN void XSLTCALL
  140. xsltSetGenericErrorFunc (void *ctx,
  141. xmlGenericErrorFunc handler);
  142. XSLTPUBFUN void XSLTCALL
  143. xsltSetGenericDebugFunc (void *ctx,
  144. xmlGenericErrorFunc handler);
  145. XSLTPUBFUN void XSLTCALL
  146. xsltSetTransformErrorFunc (xsltTransformContextPtr ctxt,
  147. void *ctx,
  148. xmlGenericErrorFunc handler);
  149. XSLTPUBFUN void XSLTCALL
  150. xsltTransformError (xsltTransformContextPtr ctxt,
  151. xsltStylesheetPtr style,
  152. xmlNodePtr node,
  153. const char *msg,
  154. ...) LIBXSLT_ATTR_FORMAT(4,5);
  155. XSLTPUBFUN int XSLTCALL
  156. xsltSetCtxtParseOptions (xsltTransformContextPtr ctxt,
  157. int options);
  158. /*
  159. * Sorting.
  160. */
  161. XSLTPUBFUN void XSLTCALL
  162. xsltDocumentSortFunction (xmlNodeSetPtr list);
  163. XSLTPUBFUN void XSLTCALL
  164. xsltSetSortFunc (xsltSortFunc handler);
  165. XSLTPUBFUN void XSLTCALL
  166. xsltSetCtxtSortFunc (xsltTransformContextPtr ctxt,
  167. xsltSortFunc handler);
  168. XSLTPUBFUN void XSLTCALL
  169. xsltDefaultSortFunction (xsltTransformContextPtr ctxt,
  170. xmlNodePtr *sorts,
  171. int nbsorts);
  172. XSLTPUBFUN void XSLTCALL
  173. xsltDoSortFunction (xsltTransformContextPtr ctxt,
  174. xmlNodePtr * sorts,
  175. int nbsorts);
  176. XSLTPUBFUN xmlXPathObjectPtr * XSLTCALL
  177. xsltComputeSortResult (xsltTransformContextPtr ctxt,
  178. xmlNodePtr sort);
  179. /*
  180. * QNames handling.
  181. */
  182. XSLTPUBFUN const xmlChar * XSLTCALL
  183. xsltSplitQName (xmlDictPtr dict,
  184. const xmlChar *name,
  185. const xmlChar **prefix);
  186. XSLTPUBFUN const xmlChar * XSLTCALL
  187. xsltGetQNameURI (xmlNodePtr node,
  188. xmlChar **name);
  189. XSLTPUBFUN const xmlChar * XSLTCALL
  190. xsltGetQNameURI2 (xsltStylesheetPtr style,
  191. xmlNodePtr node,
  192. const xmlChar **name);
  193. /*
  194. * Output, reuse libxml I/O buffers.
  195. */
  196. XSLTPUBFUN int XSLTCALL
  197. xsltSaveResultTo (xmlOutputBufferPtr buf,
  198. xmlDocPtr result,
  199. xsltStylesheetPtr style);
  200. XSLTPUBFUN int XSLTCALL
  201. xsltSaveResultToFilename (const char *URI,
  202. xmlDocPtr result,
  203. xsltStylesheetPtr style,
  204. int compression);
  205. XSLTPUBFUN int XSLTCALL
  206. xsltSaveResultToFile (FILE *file,
  207. xmlDocPtr result,
  208. xsltStylesheetPtr style);
  209. XSLTPUBFUN int XSLTCALL
  210. xsltSaveResultToFd (int fd,
  211. xmlDocPtr result,
  212. xsltStylesheetPtr style);
  213. XSLTPUBFUN int XSLTCALL
  214. xsltSaveResultToString (xmlChar **doc_txt_ptr,
  215. int * doc_txt_len,
  216. xmlDocPtr result,
  217. xsltStylesheetPtr style);
  218. /*
  219. * XPath interface
  220. */
  221. XSLTPUBFUN xmlXPathCompExprPtr XSLTCALL
  222. xsltXPathCompile (xsltStylesheetPtr style,
  223. const xmlChar *str);
  224. XSLTPUBFUN xmlXPathCompExprPtr XSLTCALL
  225. xsltXPathCompileFlags (xsltStylesheetPtr style,
  226. const xmlChar *str,
  227. int flags);
  228. /*
  229. * Profiling.
  230. */
  231. XSLTPUBFUN void XSLTCALL
  232. xsltSaveProfiling (xsltTransformContextPtr ctxt,
  233. FILE *output);
  234. XSLTPUBFUN xmlDocPtr XSLTCALL
  235. xsltGetProfileInformation (xsltTransformContextPtr ctxt);
  236. XSLTPUBFUN long XSLTCALL
  237. xsltTimestamp (void);
  238. XSLTPUBFUN void XSLTCALL
  239. xsltCalibrateAdjust (long delta);
  240. /**
  241. * XSLT_TIMESTAMP_TICS_PER_SEC:
  242. *
  243. * Sampling precision for profiling
  244. */
  245. #define XSLT_TIMESTAMP_TICS_PER_SEC 100000l
  246. /*
  247. * Hooks for the debugger.
  248. */
  249. typedef enum {
  250. XSLT_DEBUG_NONE = 0, /* no debugging allowed */
  251. XSLT_DEBUG_INIT,
  252. XSLT_DEBUG_STEP,
  253. XSLT_DEBUG_STEPOUT,
  254. XSLT_DEBUG_NEXT,
  255. XSLT_DEBUG_STOP,
  256. XSLT_DEBUG_CONT,
  257. XSLT_DEBUG_RUN,
  258. XSLT_DEBUG_RUN_RESTART,
  259. XSLT_DEBUG_QUIT
  260. } xsltDebugStatusCodes;
  261. XSLTPUBVAR int xslDebugStatus;
  262. typedef void (*xsltHandleDebuggerCallback) (xmlNodePtr cur, xmlNodePtr node,
  263. xsltTemplatePtr templ, xsltTransformContextPtr ctxt);
  264. typedef int (*xsltAddCallCallback) (xsltTemplatePtr templ, xmlNodePtr source);
  265. typedef void (*xsltDropCallCallback) (void);
  266. XSLTPUBFUN void XSLTCALL
  267. xsltSetDebuggerStatus (int value);
  268. XSLTPUBFUN int XSLTCALL
  269. xsltGetDebuggerStatus (void);
  270. XSLTPUBFUN int XSLTCALL
  271. xsltSetDebuggerCallbacks (int no, void *block);
  272. XSLTPUBFUN int XSLTCALL
  273. xslAddCall (xsltTemplatePtr templ,
  274. xmlNodePtr source);
  275. XSLTPUBFUN void XSLTCALL
  276. xslDropCall (void);
  277. #ifdef __cplusplus
  278. }
  279. #endif
  280. #endif /* __XML_XSLTUTILS_H__ */