Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:19:34

0001 /*
0002  * Summary: set of utilities for the XSLT engine
0003  * Description: interfaces for the utilities module of the XSLT engine.
0004  *              things like message handling, profiling, and other
0005  *              generally useful routines.
0006  *
0007  * Copy: See Copyright for the status of this software.
0008  *
0009  * Author: Daniel Veillard
0010  */
0011 
0012 #ifndef __XML_XSLTUTILS_H__
0013 #define __XML_XSLTUTILS_H__
0014 
0015 #include <libxslt/xsltconfig.h>
0016 #include <libxml/xpath.h>
0017 #include <libxml/dict.h>
0018 #include <libxml/xmlerror.h>
0019 #include "xsltexports.h"
0020 #include "xsltInternals.h"
0021 
0022 #ifdef __cplusplus
0023 extern "C" {
0024 #endif
0025 
0026 /**
0027  * XSLT_TODO:
0028  *
0029  * Macro to flag unimplemented blocks.
0030  */
0031 #define XSLT_TODO                           \
0032     xsltGenericError(xsltGenericErrorContext,               \
0033         "Unimplemented block at %s:%d\n",               \
0034             __FILE__, __LINE__);
0035 
0036 /**
0037  * XSLT_STRANGE:
0038  *
0039  * Macro to flag that a problem was detected internally.
0040  */
0041 #define XSLT_STRANGE                            \
0042     xsltGenericError(xsltGenericErrorContext,               \
0043         "Internal error at %s:%d\n",                \
0044             __FILE__, __LINE__);
0045 
0046 /**
0047  * IS_XSLT_ELEM:
0048  *
0049  * Checks that the element pertains to XSLT namespace.
0050  */
0051 #define IS_XSLT_ELEM(n)                         \
0052     (((n) != NULL) && ((n)->type == XML_ELEMENT_NODE) &&                \
0053      ((n)->ns != NULL) && (xmlStrEqual((n)->ns->href, XSLT_NAMESPACE)))
0054 
0055 /**
0056  * IS_XSLT_NAME:
0057  *
0058  * Checks the value of an element in XSLT namespace.
0059  */
0060 #define IS_XSLT_NAME(n, val)                        \
0061     (xmlStrEqual((n)->name, (const xmlChar *) (val)))
0062 
0063 /**
0064  * IS_XSLT_REAL_NODE:
0065  *
0066  * Check that a node is a 'real' one: document, element, text or attribute.
0067  */
0068 #define IS_XSLT_REAL_NODE(n)                        \
0069     (((n) != NULL) &&                           \
0070      (((n)->type == XML_ELEMENT_NODE) ||                \
0071       ((n)->type == XML_TEXT_NODE) ||                   \
0072       ((n)->type == XML_CDATA_SECTION_NODE) ||              \
0073       ((n)->type == XML_ATTRIBUTE_NODE) ||              \
0074       ((n)->type == XML_DOCUMENT_NODE) ||               \
0075       ((n)->type == XML_HTML_DOCUMENT_NODE) ||              \
0076       ((n)->type == XML_COMMENT_NODE) ||                \
0077       ((n)->type == XML_PI_NODE)))
0078 
0079 /*
0080  * Our own version of namespaced attributes lookup.
0081  */
0082 XSLTPUBFUN xmlChar * XSLTCALL
0083         xsltGetNsProp   (xmlNodePtr node,
0084                  const xmlChar *name,
0085                  const xmlChar *nameSpace);
0086 XSLTPUBFUN const xmlChar * XSLTCALL
0087         xsltGetCNsProp  (xsltStylesheetPtr style,
0088                  xmlNodePtr node,
0089                  const xmlChar *name,
0090                  const xmlChar *nameSpace);
0091 XSLTPUBFUN int XSLTCALL
0092         xsltGetUTF8Char (const unsigned char *utf,
0093                  int *len);
0094 #ifdef IN_LIBXSLT
0095 /** DOC_DISABLE */
0096 XSLTPUBFUN int XSLTCALL
0097         xsltGetUTF8CharZ (const unsigned char *utf,
0098                   int *len);
0099 /** DOC_ENABLE */
0100 #endif
0101 
0102 /*
0103  * XSLT Debug Tracing Tracing Types
0104  */
0105 typedef enum {
0106     XSLT_TRACE_ALL =        -1,
0107     XSLT_TRACE_NONE =       0,
0108     XSLT_TRACE_COPY_TEXT =      1<<0,
0109     XSLT_TRACE_PROCESS_NODE =   1<<1,
0110     XSLT_TRACE_APPLY_TEMPLATE = 1<<2,
0111     XSLT_TRACE_COPY =       1<<3,
0112     XSLT_TRACE_COMMENT =        1<<4,
0113     XSLT_TRACE_PI =         1<<5,
0114     XSLT_TRACE_COPY_OF =        1<<6,
0115     XSLT_TRACE_VALUE_OF =       1<<7,
0116     XSLT_TRACE_CALL_TEMPLATE =  1<<8,
0117     XSLT_TRACE_APPLY_TEMPLATES =    1<<9,
0118     XSLT_TRACE_CHOOSE =     1<<10,
0119     XSLT_TRACE_IF =         1<<11,
0120     XSLT_TRACE_FOR_EACH =       1<<12,
0121     XSLT_TRACE_STRIP_SPACES =   1<<13,
0122     XSLT_TRACE_TEMPLATES =      1<<14,
0123     XSLT_TRACE_KEYS =       1<<15,
0124     XSLT_TRACE_VARIABLES =      1<<16
0125 } xsltDebugTraceCodes;
0126 
0127 /**
0128  * XSLT_TRACE:
0129  *
0130  * Control the type of xsl debugtrace messages emitted.
0131  */
0132 #define XSLT_TRACE(ctxt,code,call)  \
0133     if (ctxt->traceCode && (*(ctxt->traceCode) & code)) \
0134         call
0135 
0136 XSLTPUBFUN void XSLTCALL
0137         xsltDebugSetDefaultTrace(xsltDebugTraceCodes val);
0138 XSLTPUBFUN xsltDebugTraceCodes XSLTCALL
0139         xsltDebugGetDefaultTrace(void);
0140 
0141 /*
0142  * XSLT specific error and debug reporting functions.
0143  */
0144 XSLTPUBVAR xmlGenericErrorFunc xsltGenericError;
0145 XSLTPUBVAR void *xsltGenericErrorContext;
0146 XSLTPUBVAR xmlGenericErrorFunc xsltGenericDebug;
0147 XSLTPUBVAR void *xsltGenericDebugContext;
0148 
0149 XSLTPUBFUN void XSLTCALL
0150         xsltPrintErrorContext       (xsltTransformContextPtr ctxt,
0151                                              xsltStylesheetPtr style,
0152                          xmlNodePtr node);
0153 XSLTPUBFUN void XSLTCALL
0154         xsltMessage         (xsltTransformContextPtr ctxt,
0155                          xmlNodePtr node,
0156                          xmlNodePtr inst);
0157 XSLTPUBFUN void XSLTCALL
0158         xsltSetGenericErrorFunc     (void *ctx,
0159                          xmlGenericErrorFunc handler);
0160 XSLTPUBFUN void XSLTCALL
0161         xsltSetGenericDebugFunc     (void *ctx,
0162                          xmlGenericErrorFunc handler);
0163 XSLTPUBFUN void XSLTCALL
0164         xsltSetTransformErrorFunc   (xsltTransformContextPtr ctxt,
0165                          void *ctx,
0166                          xmlGenericErrorFunc handler);
0167 XSLTPUBFUN void XSLTCALL
0168         xsltTransformError      (xsltTransformContextPtr ctxt,
0169                          xsltStylesheetPtr style,
0170                          xmlNodePtr node,
0171                          const char *msg,
0172                          ...) LIBXSLT_ATTR_FORMAT(4,5);
0173 
0174 XSLTPUBFUN int XSLTCALL
0175         xsltSetCtxtParseOptions     (xsltTransformContextPtr ctxt,
0176                          int options);
0177 /*
0178  * Sorting.
0179  */
0180 
0181 XSLTPUBFUN void XSLTCALL
0182         xsltDocumentSortFunction    (xmlNodeSetPtr list);
0183 XSLTPUBFUN void XSLTCALL
0184         xsltSetSortFunc         (xsltSortFunc handler);
0185 XSLTPUBFUN void XSLTCALL
0186         xsltSetCtxtSortFunc     (xsltTransformContextPtr ctxt,
0187                          xsltSortFunc handler);
0188 XSLTPUBFUN void XSLTCALL
0189         xsltSetCtxtLocaleHandlers   (xsltTransformContextPtr ctxt,
0190                          xsltNewLocaleFunc newLocale,
0191                          xsltFreeLocaleFunc freeLocale,
0192                          xsltGenSortKeyFunc genSortKey);
0193 XSLTPUBFUN void XSLTCALL
0194         xsltDefaultSortFunction     (xsltTransformContextPtr ctxt,
0195                          xmlNodePtr *sorts,
0196                          int nbsorts);
0197 XSLTPUBFUN void XSLTCALL
0198         xsltDoSortFunction      (xsltTransformContextPtr ctxt,
0199                          xmlNodePtr * sorts,
0200                          int nbsorts);
0201 XSLTPUBFUN xmlXPathObjectPtr * XSLTCALL
0202         xsltComputeSortResult       (xsltTransformContextPtr ctxt,
0203                          xmlNodePtr sort);
0204 
0205 /*
0206  * QNames handling.
0207  */
0208 
0209 XSLTPUBFUN const xmlChar * XSLTCALL
0210         xsltSplitQName          (xmlDictPtr dict,
0211                          const xmlChar *name,
0212                          const xmlChar **prefix);
0213 XSLTPUBFUN const xmlChar * XSLTCALL
0214         xsltGetQNameURI         (xmlNodePtr node,
0215                          xmlChar **name);
0216 
0217 XSLTPUBFUN const xmlChar * XSLTCALL
0218         xsltGetQNameURI2        (xsltStylesheetPtr style,
0219                          xmlNodePtr node,
0220                          const xmlChar **name);
0221 
0222 /*
0223  * Output, reuse libxml I/O buffers.
0224  */
0225 XSLTPUBFUN int XSLTCALL
0226         xsltSaveResultTo        (xmlOutputBufferPtr buf,
0227                          xmlDocPtr result,
0228                          xsltStylesheetPtr style);
0229 XSLTPUBFUN int XSLTCALL
0230         xsltSaveResultToFilename    (const char *URI,
0231                          xmlDocPtr result,
0232                          xsltStylesheetPtr style,
0233                          int compression);
0234 XSLTPUBFUN int XSLTCALL
0235         xsltSaveResultToFile        (FILE *file,
0236                          xmlDocPtr result,
0237                          xsltStylesheetPtr style);
0238 XSLTPUBFUN int XSLTCALL
0239         xsltSaveResultToFd      (int fd,
0240                          xmlDocPtr result,
0241                          xsltStylesheetPtr style);
0242 XSLTPUBFUN int XSLTCALL
0243         xsltSaveResultToString          (xmlChar **doc_txt_ptr,
0244                                                  int * doc_txt_len,
0245                                                  xmlDocPtr result,
0246                                                  xsltStylesheetPtr style);
0247 
0248 /*
0249  * XPath interface
0250  */
0251 XSLTPUBFUN xmlXPathCompExprPtr XSLTCALL
0252         xsltXPathCompile        (xsltStylesheetPtr style,
0253                          const xmlChar *str);
0254 XSLTPUBFUN xmlXPathCompExprPtr XSLTCALL
0255         xsltXPathCompileFlags       (xsltStylesheetPtr style,
0256                          const xmlChar *str,
0257                          int flags);
0258 
0259 #ifdef IN_LIBXSLT
0260 /** DOC_DISABLE */
0261 #define XSLT_SOURCE_NODE_MASK       15u
0262 #define XSLT_SOURCE_NODE_HAS_KEY    1u
0263 #define XSLT_SOURCE_NODE_HAS_ID     2u
0264 int
0265 xsltGetSourceNodeFlags(xmlNodePtr node);
0266 int
0267 xsltSetSourceNodeFlags(xsltTransformContextPtr ctxt, xmlNodePtr node,
0268                        int flags);
0269 int
0270 xsltClearSourceNodeFlags(xmlNodePtr node, int flags);
0271 void **
0272 xsltGetPSVIPtr(xmlNodePtr cur);
0273 /** DOC_ENABLE */
0274 #endif
0275 
0276 #ifdef WITH_PROFILER
0277 /*
0278  * Profiling.
0279  */
0280 XSLTPUBFUN void XSLTCALL
0281         xsltSaveProfiling       (xsltTransformContextPtr ctxt,
0282                          FILE *output);
0283 XSLTPUBFUN xmlDocPtr XSLTCALL
0284         xsltGetProfileInformation   (xsltTransformContextPtr ctxt);
0285 
0286 XSLTPUBFUN long XSLTCALL
0287         xsltTimestamp           (void);
0288 XSLTPUBFUN void XSLTCALL
0289         xsltCalibrateAdjust     (long delta);
0290 #endif
0291 
0292 /**
0293  * XSLT_TIMESTAMP_TICS_PER_SEC:
0294  *
0295  * Sampling precision for profiling
0296  */
0297 #define XSLT_TIMESTAMP_TICS_PER_SEC 100000l
0298 
0299 /*
0300  * Hooks for the debugger.
0301  */
0302 
0303 typedef enum {
0304     XSLT_DEBUG_NONE = 0, /* no debugging allowed */
0305     XSLT_DEBUG_INIT,
0306     XSLT_DEBUG_STEP,
0307     XSLT_DEBUG_STEPOUT,
0308     XSLT_DEBUG_NEXT,
0309     XSLT_DEBUG_STOP,
0310     XSLT_DEBUG_CONT,
0311     XSLT_DEBUG_RUN,
0312     XSLT_DEBUG_RUN_RESTART,
0313     XSLT_DEBUG_QUIT
0314 } xsltDebugStatusCodes;
0315 
0316 XSLTPUBVAR int xslDebugStatus;
0317 
0318 typedef void (*xsltHandleDebuggerCallback) (xmlNodePtr cur, xmlNodePtr node,
0319             xsltTemplatePtr templ, xsltTransformContextPtr ctxt);
0320 typedef int (*xsltAddCallCallback) (xsltTemplatePtr templ, xmlNodePtr source);
0321 typedef void (*xsltDropCallCallback) (void);
0322 
0323 XSLTPUBFUN int XSLTCALL
0324         xsltGetDebuggerStatus       (void);
0325 #ifdef WITH_DEBUGGER
0326 XSLTPUBFUN void XSLTCALL
0327         xsltSetDebuggerStatus       (int value);
0328 XSLTPUBFUN int XSLTCALL
0329         xsltSetDebuggerCallbacks    (int no, void *block);
0330 XSLTPUBFUN int XSLTCALL
0331         xslAddCall          (xsltTemplatePtr templ,
0332                          xmlNodePtr source);
0333 XSLTPUBFUN void XSLTCALL
0334         xslDropCall         (void);
0335 #endif
0336 
0337 #ifdef __cplusplus
0338 }
0339 #endif
0340 
0341 #endif /* __XML_XSLTUTILS_H__ */
0342 
0343