2 * xsltutils.c: Utilities for the XSL Transformation 1.0 engine
5 * http://www.w3.org/TR/1999/REC-xslt-19991116
7 * See Copyright for the status of this software.
9 * Daniel.Veillard@imag.fr
12 #include "xsltconfig.h"
17 #include <libxml/xmlmemory.h>
18 #include <libxml/tree.h>
19 #include <libxml/xmlerror.h>
20 #include "xsltutils.h"
23 /************************************************************************
25 * Handling of out of context errors *
27 ************************************************************************/
30 * xsltGenericErrorDefaultFunc:
31 * @ctx: an error context
32 * @msg: the message to display/transmit
33 * @...: extra parameters for the message display
35 * Default handler for out of context error messages.
38 xsltGenericErrorDefaultFunc(void *ctx, const char *msg, ...) {
41 if (xsltGenericErrorContext == NULL)
42 xsltGenericErrorContext = (void *) stderr;
45 vfprintf((FILE *)xsltGenericErrorContext, msg, args);
49 xmlGenericErrorFunc xsltGenericError = xsltGenericErrorDefaultFunc;
50 void *xsltGenericErrorContext = NULL;
54 * xsltSetGenericErrorFunc:
55 * @ctx: the new error handling context
56 * @handler: the new handler function
58 * Function to reset the handler and the error context for out of
59 * context error messages.
60 * This simply means that @handler will be called for subsequent
61 * error messages while not parsing nor validating. And @ctx will
62 * be passed as first argument to @handler
63 * One can simply force messages to be emitted to another FILE * than
64 * stderr by setting @ctx to this file handle and @handler to NULL.
67 xsltSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler) {
68 xsltGenericErrorContext = ctx;
70 xsltGenericError = handler;
72 xsltGenericError = xsltGenericErrorDefaultFunc;
76 * xsltGenericDebugDefaultFunc:
77 * @ctx: an error context
78 * @msg: the message to display/transmit
79 * @...: extra parameters for the message display
81 * Default handler for out of context error messages.
84 xsltGenericDebugDefaultFunc(void *ctx, const char *msg, ...) {
87 if (xsltGenericDebugContext == NULL)
91 vfprintf((FILE *)xsltGenericDebugContext, msg, args);
95 xmlGenericErrorFunc xsltGenericDebug = xsltGenericDebugDefaultFunc;
96 void *xsltGenericDebugContext = NULL;
100 * xsltSetGenericDebugFunc:
101 * @ctx: the new error handling context
102 * @handler: the new handler function
104 * Function to reset the handler and the error context for out of
105 * context error messages.
106 * This simply means that @handler will be called for subsequent
107 * error messages while not parsing nor validating. And @ctx will
108 * be passed as first argument to @handler
109 * One can simply force messages to be emitted to another FILE * than
110 * stderr by setting @ctx to this file handle and @handler to NULL.
113 xsltSetGenericDebugFunc(void *ctx, xmlGenericErrorFunc handler) {
114 xsltGenericDebugContext = ctx;
116 xsltGenericDebug = handler;
118 xsltGenericDebug = xsltGenericDebugDefaultFunc;