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