ReactOS 0.4.16-dev-2208-g6350669
extensions.c File Reference
#include "libxslt.h"
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <libxml/xmlmemory.h>
#include <libxml/tree.h>
#include <libxml/hash.h>
#include <libxml/xmlerror.h>
#include <libxml/parserInternals.h>
#include <libxml/xpathInternals.h>
#include <libxml/list.h>
#include <libxml/xmlIO.h>
#include <libxml/threads.h>
#include "xslt.h"
#include "xsltInternals.h"
#include "xsltlocale.h"
#include "xsltutils.h"
#include "imports.h"
#include "extensions.h"
Include dependency graph for extensions.c:

Go to the source code of this file.

Classes

struct  _xsltExtDef
 
struct  _xsltExtModule
 
struct  _xsltExtData
 
struct  _xsltExtElement
 
struct  _xsltInitExtCtxt
 

Macros

#define IN_LIBXSLT
 

Typedefs

typedef struct _xsltExtDef xsltExtDef
 
typedef xsltExtDefxsltExtDefPtr
 
typedef struct _xsltExtModule xsltExtModule
 
typedef xsltExtModulexsltExtModulePtr
 
typedef struct _xsltExtData xsltExtData
 
typedef xsltExtDataxsltExtDataPtr
 
typedef struct _xsltExtElement xsltExtElement
 
typedef xsltExtElementxsltExtElementPtr
 

Functions

static xsltExtDefPtr xsltNewExtDef (const xmlChar *prefix, const xmlChar *URI)
 
static void xsltFreeExtDef (xsltExtDefPtr extensiond)
 
static void xsltFreeExtDefList (xsltExtDefPtr extensiond)
 
static xsltExtModulePtr xsltNewExtModule (xsltExtInitFunction initFunc, xsltExtShutdownFunction shutdownFunc, xsltStyleExtInitFunction styleInitFunc, xsltStyleExtShutdownFunction styleShutdownFunc)
 
static void xsltFreeExtModule (xsltExtModulePtr ext)
 
static void xsltFreeExtModuleEntry (void *payload, const xmlChar *name ATTRIBUTE_UNUSED)
 
static xsltExtDataPtr xsltNewExtData (xsltExtModulePtr extModule, void *extData)
 
static void xsltFreeExtData (xsltExtDataPtr ext)
 
static void xsltFreeExtDataEntry (void *payload, const xmlChar *name ATTRIBUTE_UNUSED)
 
static xsltExtElementPtr xsltNewExtElement (xsltPreComputeFunction precomp, xsltTransformFunction transform)
 
static void xsltFreeExtElement (xsltExtElementPtr ext)
 
static void xsltFreeExtElementEntry (void *payload, const xmlChar *name ATTRIBUTE_UNUSED)
 
static int xsltExtModuleRegisterDynamic (const xmlChar *URI ATTRIBUTE_UNUSED)
 
void xsltFreeExts (xsltStylesheetPtr style)
 
int xsltRegisterExtPrefix (xsltStylesheetPtr style, const xmlChar *prefix, const xmlChar *URI)
 
: the function name

xsltUnregisterExtModuleFunction:

@URI: the function namespace URI

Unregisters an extension module function

Returns 0 if successful, -1 in case of error.

int xsltRegisterExtModuleFunction (const xmlChar *name, const xmlChar *URI, xmlXPathFunction function)
 
xmlXPathFunction xsltExtModuleFunctionLookup (const xmlChar *name, const xmlChar *URI)
 
int xsltUnregisterExtModuleFunction (const xmlChar *name, const xmlChar *URI)
 
static void xsltUnregisterAllExtModuleFunction (void)
 
static void xsltFreeElemPreComp (xsltElemPreCompPtr comp)
 
xsltElemPreCompPtr xsltNewElemPreComp (xsltStylesheetPtr style, xmlNodePtr inst, xsltTransformFunction function)
 
void xsltInitElemPreComp (xsltElemPreCompPtr comp, xsltStylesheetPtr style, xmlNodePtr inst, xsltTransformFunction function, xsltElemPreCompDeallocator freeFunc)
 
xsltElemPreCompPtr xsltPreComputeExtModuleElement (xsltStylesheetPtr style, xmlNodePtr inst)
 
: the element name

xsltUnregisterExtModuleElement:

@URI: the element namespace URI

Unregisters an extension module element

Returns 0 if successful, -1 in case of error.

int xsltRegisterExtModuleElement (const xmlChar *name, const xmlChar *URI, xsltPreComputeFunction precomp, xsltTransformFunction transform)
 
xsltTransformFunction xsltExtElementLookup (xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *URI)
 
xsltTransformFunction xsltExtModuleElementLookup (const xmlChar *name, const xmlChar *URI)
 
xsltPreComputeFunction xsltExtModuleElementPreComputeLookup (const xmlChar *name, const xmlChar *URI)
 
int xsltUnregisterExtModuleElement (const xmlChar *name, const xmlChar *URI)
 
static void xsltUnregisterAllExtModuleElement (void)
 

Variables

static xmlHashTablePtr xsltExtensionsHash = NULL
 
static xmlHashTablePtr xsltFunctionsHash = NULL
 
static xmlHashTablePtr xsltElementsHash = NULL
 
static xmlHashTablePtr xsltTopLevelsHash = NULL
 
static xmlHashTablePtr xsltModuleHash = NULL
 
static xmlMutexPtr xsltExtMutex = NULL
 

: the name of the element

xsltRegisterExtElement: @ctxt: an XSLT transformation context

@URI: the URI associated to the element @function: the actual implementation which should be called

Registers an extension element

Returns 0 in case of success, -1 in case of failure

typedef struct _xsltInitExtCtxt xsltInitExtCtxt
 
int xsltRegisterExtFunction (xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *URI, xmlXPathFunction function)
 
int xsltRegisterExtElement (xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *URI, xsltTransformFunction function)
 
void xsltFreeCtxtExts (xsltTransformContextPtr ctxt)
 
static xsltExtDataPtr xsltStyleInitializeStylesheetModule (xsltStylesheetPtr style, const xmlChar *URI)
 
voidxsltStyleGetExtData (xsltStylesheetPtr style, const xmlChar *URI)
 
voidxsltGetExtData (xsltTransformContextPtr ctxt, const xmlChar *URI)
 
static void xsltInitCtxtExt (void *payload, void *data, const xmlChar *URI)
 
int xsltInitCtxtExts (xsltTransformContextPtr ctxt)
 
static void xsltShutdownCtxtExt (void *payload, void *vctxt, const xmlChar *URI)
 
void xsltShutdownCtxtExts (xsltTransformContextPtr ctxt)
 
static void xsltShutdownExt (void *payload, void *vctxt, const xmlChar *URI)
 
void xsltShutdownExts (xsltStylesheetPtr style)
 
int xsltCheckExtPrefix (xsltStylesheetPtr style, const xmlChar *URI)
 
int xsltCheckExtURI (xsltStylesheetPtr style, const xmlChar *URI)
 
int xsltRegisterExtModuleFull (const xmlChar *URI, xsltExtInitFunction initFunc, xsltExtShutdownFunction shutdownFunc, xsltStyleExtInitFunction styleInitFunc, xsltStyleExtShutdownFunction styleShutdownFunc)
 
int xsltRegisterExtModule (const xmlChar *URI, xsltExtInitFunction initFunc, xsltExtShutdownFunction shutdownFunc)
 
int xsltUnregisterExtModule (const xmlChar *URI)
 
static void xsltUnregisterAllExtModules (void)
 
xsltTransformContextPtr xsltXPathGetTransformContext (xmlXPathParserContextPtr ctxt)
 

: the top-level element name

xsltUnregisterExtModuleTopLevel:

@URI: the top-level element namespace URI

Unregisters an extension module top-level element

Returns 0 if successful, -1 in case of error.

static xmlChartestData = NULL
 
static xmlChartestStyleData = NULL
 
int xsltRegisterExtModuleTopLevel (const xmlChar *name, const xmlChar *URI, xsltTopLevelFunction function)
 
xsltTopLevelFunction xsltExtModuleTopLevelLookup (const xmlChar *name, const xmlChar *URI)
 
int xsltUnregisterExtModuleTopLevel (const xmlChar *name, const xmlChar *URI)
 
static void xsltUnregisterAllExtModuleTopLevel (void)
 
xmlHashTablePtr xsltGetExtInfo (xsltStylesheetPtr style, const xmlChar *URI)
 
static void xsltExtFunctionTest (xmlXPathParserContextPtr ctxt, int nargs ATTRIBUTE_UNUSED)
 
static xsltElemPreCompPtr xsltExtElementPreCompTest (xsltStylesheetPtr style, xmlNodePtr inst, xsltTransformFunction function)
 
static void xsltExtElementTest (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr comp ATTRIBUTE_UNUSED)
 
static voidxsltExtInitTest (xsltTransformContextPtr ctxt, const xmlChar *URI)
 
static void xsltExtShutdownTest (xsltTransformContextPtr ctxt, const xmlChar *URI, void *data)
 
static voidxsltExtStyleInitTest (xsltStylesheetPtr style ATTRIBUTE_UNUSED, const xmlChar *URI)
 
static void xsltExtStyleShutdownTest (xsltStylesheetPtr style ATTRIBUTE_UNUSED, const xmlChar *URI, void *data)
 
void xsltRegisterTestModule (void)
 
static void xsltHashScannerModuleFree (void *payload ATTRIBUTE_UNUSED, void *data ATTRIBUTE_UNUSED, const xmlChar *name ATTRIBUTE_UNUSED)
 
void xsltInitGlobals (void)
 
void xsltCleanupGlobals (void)
 
static void xsltDebugDumpExtensionsCallback (void *function ATTRIBUTE_UNUSED, void *data, const xmlChar *name, const xmlChar *URI, const xmlChar *not_used ATTRIBUTE_UNUSED)
 
static void xsltDebugDumpExtModulesCallback (void *function ATTRIBUTE_UNUSED, void *data, const xmlChar *URI, const xmlChar *not_used ATTRIBUTE_UNUSED, const xmlChar *not_used2 ATTRIBUTE_UNUSED)
 
void xsltDebugDumpExtensions (FILE *output)
 

Macro Definition Documentation

◆ IN_LIBXSLT

#define IN_LIBXSLT

Definition at line 12 of file extensions.c.

Typedef Documentation

◆ xsltExtData

Definition at line 73 of file extensions.c.

◆ xsltExtDataPtr

Definition at line 74 of file extensions.c.

◆ xsltExtDef

Definition at line 55 of file extensions.c.

◆ xsltExtDefPtr

Definition at line 56 of file extensions.c.

◆ xsltExtElement

Definition at line 80 of file extensions.c.

◆ xsltExtElementPtr

Definition at line 81 of file extensions.c.

◆ xsltExtModule

Definition at line 64 of file extensions.c.

◆ xsltExtModulePtr

Definition at line 65 of file extensions.c.

◆ xsltInitExtCtxt

Definition at line 942 of file extensions.c.

Function Documentation

◆ xsltCheckExtPrefix()

int xsltCheckExtPrefix ( xsltStylesheetPtr  style,
const xmlChar URI 
)

xsltCheckExtPrefix: @style: the stylesheet @URI: the namespace prefix (possibly NULL)

Check if the given prefix is one of the declared extensions. This is intended to be called only at compile-time. Called by: xsltGetInheritedNsList() (xslt.c) xsltParseTemplateContent (xslt.c)

Returns 1 if this is an extension, 0 otherwise

Definition at line 1183 of file extensions.c.

1184{
1185#ifdef XSLT_REFACTORED
1186 if ((style == NULL) || (style->compCtxt == NULL) ||
1187 (XSLT_CCTXT(style)->inode == NULL) ||
1188 (XSLT_CCTXT(style)->inode->extElemNs == NULL))
1189 return (0);
1190 /*
1191 * Lookup the extension namespaces registered
1192 * at the current node in the stylesheet's tree.
1193 */
1194 if (XSLT_CCTXT(style)->inode->extElemNs != NULL) {
1195 int i;
1196 xsltPointerListPtr list = XSLT_CCTXT(style)->inode->extElemNs;
1197
1198 for (i = 0; i < list->number; i++) {
1199 if (xmlStrEqual((const xmlChar *) list->items[i],
1200 URI))
1201 {
1202 return(1);
1203 }
1204 }
1205 }
1206#else
1208
1209 if ((style == NULL) || (style->nsDefs == NULL))
1210 return (0);
1211 if (URI == NULL)
1212 URI = BAD_CAST "#default";
1213 cur = (xsltExtDefPtr) style->nsDefs;
1214 while (cur != NULL) {
1215 /*
1216 * NOTE: This was change to work on namespace names rather
1217 * than namespace prefixes. This fixes bug #339583.
1218 * TODO: Consider renaming the field "prefix" of xsltExtDef
1219 * to "href".
1220 */
1221 if (xmlStrEqual(URI, cur->prefix))
1222 return (1);
1223 cur = cur->next;
1224 }
1225#endif
1226 return (0);
1227}
xsltExtDef * xsltExtDefPtr
Definition: extensions.c:56
Arabic default style
Definition: afstyles.h:94
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
Definition: list.h:37
#define NULL
Definition: types.h:112
FxCollectionEntry * cur
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
Definition: fs.h:78
#define BAD_CAST
Definition: xmlstring.h:35
XMLPUBFUN int xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:162
unsigned char xmlChar
Definition: xmlstring.h:28

Referenced by xsltGetInheritedNsList(), and xsltParseTemplateContent().

◆ xsltCheckExtURI()

int xsltCheckExtURI ( xsltStylesheetPtr  style,
const xmlChar URI 
)

xsltCheckExtURI: @style: the stylesheet @URI: the namespace URI (possibly NULL)

Check if the given prefix is one of the declared extensions. This is intended to be called only at compile-time. Called by: xsltPrecomputeStylesheet() (xslt.c) xsltParseTemplateContent (xslt.c)

Returns 1 if this is an extension, 0 otherwise

Definition at line 1243 of file extensions.c.

1244{
1246
1247 if ((style == NULL) || (style->nsDefs == NULL))
1248 return (0);
1249 if (URI == NULL)
1250 return (0);
1251 cur = (xsltExtDefPtr) style->nsDefs;
1252 while (cur != NULL) {
1253 if (xmlStrEqual(URI, cur->URI))
1254 return (1);
1255 cur = cur->next;
1256 }
1257 return (0);
1258}

Referenced by xsltPreprocessStylesheet().

◆ xsltCleanupGlobals()

void xsltCleanupGlobals ( void  )

xsltCleanupGlobals:

Unregister all global variables set up by the XSLT library

Definition at line 2295 of file extensions.c.

2296{
2301
2303 /* cleanup dynamic module hash */
2304 if (NULL != xsltModuleHash) {
2308 }
2310
2314 xsltUninit();
2315}
static xmlHashTablePtr xsltModuleHash
Definition: extensions.c:91
static xmlMutexPtr xsltExtMutex
Definition: extensions.c:92
static void xsltUnregisterAllExtModuleElement(void)
Definition: extensions.c:1829
static void xsltUnregisterAllExtModules(void)
Definition: extensions.c:1366
static void xsltUnregisterAllExtModuleFunction(void)
Definition: extensions.c:1501
static void xsltUnregisterAllExtModuleTopLevel(void)
Definition: extensions.c:1940
static void xsltHashScannerModuleFree(void *payload ATTRIBUTE_UNUSED, void *data ATTRIBUTE_UNUSED, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: extensions.c:2267
XMLPUBFUN void xmlMutexLock(xmlMutexPtr tok)
Definition: threads.c:201
XMLPUBFUN void xmlFreeMutex(xmlMutexPtr tok)
Definition: threads.c:185
XMLPUBFUN void xmlMutexUnlock(xmlMutexPtr tok)
Definition: threads.c:225
void xmlHashScan(xmlHashTablePtr hash, xmlHashScanner scan, void *data)
Definition: hash.c:898
void xmlHashFree(xmlHashTablePtr hash, xmlHashDeallocator dealloc)
Definition: hash.c:229
void xsltUninit(void)
Definition: xslt.c:232
void xsltFreeLocales(void)
Definition: xsltlocale.c:93

Referenced by DllMain().

◆ xsltDebugDumpExtensions()

void xsltDebugDumpExtensions ( FILE output)

xsltDebugDumpExtensions: @output: the FILE * for the output, if NULL stdout is used

Dumps a list of the registered XSLT extension functions and elements

Definition at line 2348 of file extensions.c.

2349{
2350 if (output == NULL)
2351 output = stdout;
2352 fprintf(output,
2353 "Registered XSLT Extensions\n--------------------------\n");
2355 if (!xsltFunctionsHash) {
2356 fprintf(output, "No registered extension functions\n");
2357 } else {
2358 fprintf(output, "Registered extension functions:\n");
2360 output);
2361 }
2362 if (!xsltTopLevelsHash) {
2363 fprintf(output, "\nNo registered top-level extension elements\n");
2364 } else {
2365 fprintf(output, "\nRegistered top-level extension elements:\n");
2367 output);
2368 }
2369 if (!xsltElementsHash) {
2370 fprintf(output, "\nNo registered instruction extension elements\n");
2371 } else {
2372 fprintf(output, "\nRegistered instruction extension elements:\n");
2374 output);
2375 }
2376 if (!xsltExtensionsHash) {
2377 fprintf(output, "\nNo registered extension modules\n");
2378 } else {
2379 fprintf(output, "\nRegistered extension modules:\n");
2381 output);
2382 }
2384}
static void xsltDebugDumpExtModulesCallback(void *function ATTRIBUTE_UNUSED, void *data, const xmlChar *URI, const xmlChar *not_used ATTRIBUTE_UNUSED, const xmlChar *not_used2 ATTRIBUTE_UNUSED)
Definition: extensions.c:2330
static xmlHashTablePtr xsltTopLevelsHash
Definition: extensions.c:90
static xmlHashTablePtr xsltFunctionsHash
Definition: extensions.c:88
static xmlHashTablePtr xsltElementsHash
Definition: extensions.c:89
static xmlHashTablePtr xsltExtensionsHash
Definition: extensions.c:87
static void xsltDebugDumpExtensionsCallback(void *function ATTRIBUTE_UNUSED, void *data, const xmlChar *name, const xmlChar *URI, const xmlChar *not_used ATTRIBUTE_UNUSED)
Definition: extensions.c:2318
int WINAPIV fprintf(FILE *file, const char *format,...)
Definition: file.c:5549
#define stdout
void xmlHashScanFull(xmlHashTablePtr hash, xmlHashScannerFull scan, void *data)
Definition: hash.c:914

◆ xsltDebugDumpExtensionsCallback()

static void xsltDebugDumpExtensionsCallback ( void *function  ATTRIBUTE_UNUSED,
void data,
const xmlChar name,
const xmlChar URI,
const xmlChar *not_used  ATTRIBUTE_UNUSED 
)
static

Definition at line 2318 of file extensions.c.

2322{
2323 FILE *output = (FILE *) data;
2324 if (!name || !URI)
2325 return;
2326 fprintf(output, "{%s}%s\n", URI, name);
2327}
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
Definition: name.c:39

Referenced by xsltDebugDumpExtensions().

◆ xsltDebugDumpExtModulesCallback()

static void xsltDebugDumpExtModulesCallback ( void *function  ATTRIBUTE_UNUSED,
void data,
const xmlChar URI,
const xmlChar *not_used  ATTRIBUTE_UNUSED,
const xmlChar *not_used2  ATTRIBUTE_UNUSED 
)
static

Definition at line 2330 of file extensions.c.

2334{
2335 FILE *output = (FILE *) data;
2336 if (!URI)
2337 return;
2338 fprintf(output, "%s\n", URI);
2339}

Referenced by xsltDebugDumpExtensions().

◆ xsltExtElementLookup()

xsltTransformFunction xsltExtElementLookup ( xsltTransformContextPtr  ctxt,
const xmlChar name,
const xmlChar URI 
)

Definition at line 1693 of file extensions.c.

1695{
1697
1698 if ((name == NULL) || (URI == NULL))
1699 return (NULL);
1700
1701 if ((ctxt != NULL) && (ctxt->extElements != NULL)) {
1703 if (ret != NULL) {
1704 return(ret);
1705 }
1706 }
1707
1709
1710 return (ret);
1711}
xsltTransformFunction xsltExtModuleElementLookup(const xmlChar *name, const xmlChar *URI)
Definition: extensions.c:1723
return ret
Definition: mutex.c:146
void * xmlHashLookup2(xmlHashTablePtr hash, const xmlChar *key, const xmlChar *key2)
Definition: hash.c:754
xmlHashTablePtr extElements
#define XML_CAST_FPTR(fptr)
void(* xsltTransformFunction)(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr comp)

Referenced by xsltApplySequenceConstructor(), and xsltElementAvailableFunction().

◆ xsltExtElementPreCompTest()

static xsltElemPreCompPtr xsltExtElementPreCompTest ( xsltStylesheetPtr  style,
xmlNodePtr  inst,
xsltTransformFunction  function 
)
static

xsltExtElementPreCompTest: @style: the stylesheet @inst: the instruction in the stylesheet

Process a libxslt:test node

Definition at line 2046 of file extensions.c.

2048{
2050
2051 if (style == NULL) {
2053 "xsltExtElementTest: no transformation context\n");
2054 return (NULL);
2055 }
2056 if (testStyleData == NULL) {
2058 "xsltExtElementPreCompTest: not initialized,"
2059 " calling xsltStyleGetExtData\n");
2061 if (testStyleData == NULL) {
2063 "xsltExtElementPreCompTest: not initialized\n");
2064 if (style != NULL)
2065 style->errors++;
2066 return (NULL);
2067 }
2068 }
2069 if (inst == NULL) {
2071 "xsltExtElementPreCompTest: no instruction\n");
2072 if (style != NULL)
2073 style->errors++;
2074 return (NULL);
2075 }
2076 ret = xsltNewElemPreComp(style, inst, function);
2077 return (ret);
2078}
static xmlChar * testStyleData
Definition: extensions.c:1986
xsltElemPreCompPtr xsltNewElemPreComp(xsltStylesheetPtr style, xmlNodePtr inst, xsltTransformFunction function)
Definition: extensions.c:1528
void * xsltStyleGetExtData(xsltStylesheetPtr style, const xmlChar *URI)
Definition: extensions.c:781
#define XSLT_DEFAULT_URL
Definition: xslt.h:39
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:762
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:632
void * xsltGenericDebugContext
Definition: xsltutils.c:633

Referenced by xsltRegisterTestModule().

◆ xsltExtElementTest()

static void xsltExtElementTest ( xsltTransformContextPtr  ctxt,
xmlNodePtr  node,
xmlNodePtr  inst,
xsltElemPreCompPtr comp  ATTRIBUTE_UNUSED 
)
static

xsltExtElementTest: @ctxt: an XSLT processing context @node: The current node @inst: the instruction in the stylesheet @comp: precomputed information

Process a libxslt:test node

Definition at line 2090 of file extensions.c.

2093{
2094 xmlNodePtr commentNode;
2095
2096 if (testData == NULL) {
2098 "xsltExtElementTest: not initialized,"
2099 " calling xsltGetExtData\n");
2100 xsltGetExtData(ctxt, (const xmlChar *) XSLT_DEFAULT_URL);
2101 if (testData == NULL) {
2102 xsltTransformError(ctxt, NULL, inst,
2103 "xsltExtElementTest: not initialized\n");
2104 return;
2105 }
2106 }
2107 if (ctxt == NULL) {
2108 xsltTransformError(ctxt, NULL, inst,
2109 "xsltExtElementTest: no transformation context\n");
2110 return;
2111 }
2112 if (node == NULL) {
2113 xsltTransformError(ctxt, NULL, inst,
2114 "xsltExtElementTest: no current node\n");
2115 return;
2116 }
2117 if (inst == NULL) {
2118 xsltTransformError(ctxt, NULL, inst,
2119 "xsltExtElementTest: no instruction\n");
2120 return;
2121 }
2122 if (ctxt->insert == NULL) {
2123 xsltTransformError(ctxt, NULL, inst,
2124 "xsltExtElementTest: no insertion point\n");
2125 return;
2126 }
2127 commentNode = xmlNewComment((const xmlChar *)
2128 "libxslt:test element test worked");
2129 xmlAddChild(ctxt->insert, commentNode);
2130}
static xmlChar * testData
Definition: extensions.c:1985
void * xsltGetExtData(xsltTransformContextPtr ctxt, const xmlChar *URI)
Definition: extensions.c:883
Definition: dlist.c:348

Referenced by xsltRegisterTestModule().

◆ xsltExtFunctionTest()

static void xsltExtFunctionTest ( xmlXPathParserContextPtr  ctxt,
int nargs  ATTRIBUTE_UNUSED 
)
static

xsltExtFunctionTest: @ctxt: the XPath Parser context @nargs: the number of arguments

function libxslt:test() for testing the extensions support.

Definition at line 1996 of file extensions.c.

1998{
2000 void *data = NULL;
2001
2002 tctxt = xsltXPathGetTransformContext(ctxt);
2003
2004 if (testData == NULL) {
2006 "xsltExtFunctionTest: not initialized,"
2007 " calling xsltGetExtData\n");
2008 data = xsltGetExtData(tctxt, (const xmlChar *) XSLT_DEFAULT_URL);
2009 if (data == NULL) {
2011 "xsltExtElementTest: not initialized\n");
2012 return;
2013 }
2014 }
2015 if (tctxt == NULL) {
2017 "xsltExtFunctionTest: failed to get the transformation context\n");
2018 return;
2019 }
2020 if (data == NULL)
2021 data = xsltGetExtData(tctxt, (const xmlChar *) XSLT_DEFAULT_URL);
2022 if (data == NULL) {
2024 "xsltExtFunctionTest: failed to get module data\n");
2025 return;
2026 }
2027 if (data != testData) {
2029 "xsltExtFunctionTest: got wrong module data\n");
2030 return;
2031 }
2032#ifdef WITH_XSLT_DEBUG_FUNCTION
2034 "libxslt:test() called with %d args\n", nargs);
2035#endif
2036}
xsltTransformContextPtr xsltXPathGetTransformContext(xmlXPathParserContextPtr ctxt)
Definition: extensions.c:1392

Referenced by xsltRegisterTestModule().

◆ xsltExtInitTest()

static void * xsltExtInitTest ( xsltTransformContextPtr  ctxt,
const xmlChar URI 
)
static

xsltExtInitTest: @ctxt: an XSLT transformation context @URI: the namespace URI for the extension

A function called at initialization time of an XSLT extension module

Returns a pointer to the module specific data for this transformation

Definition at line 2142 of file extensions.c.

2143{
2144 if (testStyleData == NULL) {
2146 "xsltExtInitTest: not initialized,"
2147 " calling xsltStyleGetExtData\n");
2149 if (testStyleData == NULL) {
2151 "xsltExtInitTest: not initialized\n");
2152 return (NULL);
2153 }
2154 }
2155 if (testData != NULL) {
2157 "xsltExtInitTest: already initialized\n");
2158 return (NULL);
2159 }
2160 testData = (void *) "test data";
2162 "Registered test module : %s\n", URI);
2163 return (testData);
2164}
xsltStylesheetPtr style
void * xsltGenericErrorContext
Definition: xsltutils.c:587

Referenced by xsltRegisterTestModule().

◆ xsltExtModuleElementLookup()

xsltTransformFunction xsltExtModuleElementLookup ( const xmlChar name,
const xmlChar URI 
)

Definition at line 1723 of file extensions.c.

1724{
1726
1727 if ((xsltElementsHash == NULL) || (name == NULL) || (URI == NULL))
1728 return (NULL);
1729
1731
1733
1735
1736 /*
1737 * if function lookup fails, attempt a dynamic load on
1738 * supported platforms
1739 */
1740 if (NULL == ext) {
1741 if (!xsltExtModuleRegisterDynamic(URI)) {
1743
1746
1748 }
1749 }
1750
1751 if (ext == NULL)
1752 return (NULL);
1753 return (ext->transform);
1754}
static int xsltExtModuleRegisterDynamic(const xmlChar *URI ATTRIBUTE_UNUSED)
Definition: extensions.c:481
xsltExtElement * xsltExtElementPtr
Definition: extensions.c:81
static const WCHAR *const ext[]
Definition: module.c:53

Referenced by xsltExtElementLookup().

◆ xsltExtModuleElementPreComputeLookup()

xsltPreComputeFunction xsltExtModuleElementPreComputeLookup ( const xmlChar name,
const xmlChar URI 
)

Definition at line 1766 of file extensions.c.

1768{
1770
1771 if ((xsltElementsHash == NULL) || (name == NULL) || (URI == NULL))
1772 return (NULL);
1773
1775
1777
1779
1780 if (ext == NULL) {
1781 if (!xsltExtModuleRegisterDynamic(URI)) {
1783
1786
1788 }
1789 }
1790
1791 if (ext == NULL)
1792 return (NULL);
1793 return (ext->precomp);
1794}

◆ xsltExtModuleFunctionLookup()

xmlXPathFunction xsltExtModuleFunctionLookup ( const xmlChar name,
const xmlChar URI 
)

Definition at line 1441 of file extensions.c.

1442{
1443 xmlXPathFunction ret;
1444
1445 if ((xsltFunctionsHash == NULL) || (name == NULL) || (URI == NULL))
1446 return (NULL);
1447
1449
1451
1453
1454 /* if lookup fails, attempt a dynamic load on supported platforms */
1455 if (NULL == ret) {
1456 if (!xsltExtModuleRegisterDynamic(URI)) {
1458
1461
1463 }
1464 }
1465
1466 return ret;
1467}

Referenced by xsltXPathFunctionLookup().

◆ xsltExtModuleRegisterDynamic()

static int xsltExtModuleRegisterDynamic ( const xmlChar *URI  ATTRIBUTE_UNUSED)
static

◆ xsltExtModuleTopLevelLookup()

xsltTopLevelFunction xsltExtModuleTopLevelLookup ( const xmlChar name,
const xmlChar URI 
)

Definition at line 1881 of file extensions.c.

1882{
1884
1885 if ((xsltTopLevelsHash == NULL) || (name == NULL) || (URI == NULL))
1886 return (NULL);
1887
1889
1891
1893
1894 /* if lookup fails, attempt a dynamic load on supported platforms */
1895 if (NULL == ret) {
1896 if (!xsltExtModuleRegisterDynamic(URI)) {
1898
1900
1902 }
1903 }
1904
1905 return (ret);
1906}
void(* xsltTopLevelFunction)(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: extensions.h:183

Referenced by xsltParseStylesheetTop().

◆ xsltExtShutdownTest()

static void xsltExtShutdownTest ( xsltTransformContextPtr  ctxt,
const xmlChar URI,
void data 
)
static

xsltExtShutdownTest: @ctxt: an XSLT transformation context @URI: the namespace URI for the extension @data: the data associated to this module

A function called at shutdown time of an XSLT extension module

Definition at line 2176 of file extensions.c.

2178{
2179 if (testData == NULL) {
2181 "xsltExtShutdownTest: not initialized\n");
2182 return;
2183 }
2184 if (data != testData) {
2186 "xsltExtShutdownTest: wrong data\n");
2187 }
2188 testData = NULL;
2190 "Unregistered test module : %s\n", URI);
2191}

Referenced by xsltRegisterTestModule().

◆ xsltExtStyleInitTest()

static void * xsltExtStyleInitTest ( xsltStylesheetPtr style  ATTRIBUTE_UNUSED,
const xmlChar URI 
)
static

xsltExtStyleInitTest: @style: an XSLT stylesheet @URI: the namespace URI for the extension

A function called at initialization time of an XSLT extension module

Returns a pointer to the module specific data for this transformation

Definition at line 2203 of file extensions.c.

2205{
2206 if (testStyleData != NULL) {
2208 "xsltExtInitTest: already initialized\n");
2209 return (NULL);
2210 }
2211 testStyleData = (void *) "test data";
2213 "Registered test module : %s\n", URI);
2214 return (testStyleData);
2215}

Referenced by xsltRegisterTestModule().

◆ xsltExtStyleShutdownTest()

static void xsltExtStyleShutdownTest ( xsltStylesheetPtr style  ATTRIBUTE_UNUSED,
const xmlChar URI,
void data 
)
static

xsltExtStyleShutdownTest: @style: an XSLT stylesheet @URI: the namespace URI for the extension @data: the data associated to this module

A function called at shutdown time of an XSLT extension module

Definition at line 2227 of file extensions.c.

2229{
2230 if (testStyleData == NULL) {
2232 "xsltExtShutdownTest: not initialized\n");
2233 return;
2234 }
2235 if (data != testStyleData) {
2237 "xsltExtShutdownTest: wrong data\n");
2238 }
2241 "Unregistered test module : %s\n", URI);
2242}
xmlGenericErrorFunc xsltGenericError
Definition: xsltutils.c:586

Referenced by xsltRegisterTestModule().

◆ xsltFreeCtxtExts()

void xsltFreeCtxtExts ( xsltTransformContextPtr  ctxt)

xsltFreeCtxtExts: @ctxt: an XSLT transformation context

Free the XSLT extension data

Definition at line 664 of file extensions.c.

665{
666 if (ctxt->extElements != NULL)
668 if (ctxt->extFunctions != NULL)
670}
xmlHashTablePtr extFunctions

Referenced by xsltFreeTransformContext().

◆ xsltFreeElemPreComp()

static void xsltFreeElemPreComp ( xsltElemPreCompPtr  comp)
static

Definition at line 1513 of file extensions.c.

1513 {
1514 xmlFree(comp);
1515}
xmlFreeFunc xmlFree
Definition: globals.c:184

Referenced by xsltNewElemPreComp().

◆ xsltFreeExtData()

static void xsltFreeExtData ( xsltExtDataPtr  ext)
static

xsltFreeExtData: @ext: an XSLT extension module data wrapper

Free up the memory allocated by @ext

Definition at line 249 of file extensions.c.

250{
251 if (ext == NULL)
252 return;
253 xmlFree(ext);
254}

Referenced by xsltFreeExtDataEntry(), xsltGetExtData(), xsltInitCtxtExt(), and xsltStyleInitializeStylesheetModule().

◆ xsltFreeExtDataEntry()

static void xsltFreeExtDataEntry ( void payload,
const xmlChar *name  ATTRIBUTE_UNUSED 
)
static

Definition at line 257 of file extensions.c.

257 {
259}
static void xsltFreeExtData(xsltExtDataPtr ext)
Definition: extensions.c:249

Referenced by xsltShutdownCtxtExts(), and xsltShutdownExts().

◆ xsltFreeExtDef()

static void xsltFreeExtDef ( xsltExtDefPtr  extensiond)
static

xsltFreeExtDef: @extensiond: an XSLT extension definition

Free up the memory allocated by @extensiond

Definition at line 135 of file extensions.c.

136{
137 if (extensiond == NULL)
138 return;
139 if (extensiond->prefix != NULL)
140 xmlFree(extensiond->prefix);
141 if (extensiond->URI != NULL)
142 xmlFree(extensiond->URI);
143 xmlFree(extensiond);
144}
xmlChar * URI
Definition: extensions.c:60
xmlChar * prefix
Definition: extensions.c:59

Referenced by xsltFreeExtDefList().

◆ xsltFreeExtDefList()

static void xsltFreeExtDefList ( xsltExtDefPtr  extensiond)
static

xsltFreeExtDefList: @extensiond: an XSLT extension definition list

Free up the memory allocated by all the elements of @extensiond

Definition at line 153 of file extensions.c.

154{
156
157 while (extensiond != NULL) {
158 cur = extensiond;
159 extensiond = extensiond->next;
161 }
162}
static void xsltFreeExtDef(xsltExtDefPtr extensiond)
Definition: extensions.c:135
struct _xsltExtDef * next
Definition: extensions.c:58

Referenced by xsltFreeExts().

◆ xsltFreeExtElement()

static void xsltFreeExtElement ( xsltExtElementPtr  ext)
static

xsltFreeExtElement: @ext: an XSLT extension element

Frees up the memory allocated by @ext

Definition at line 298 of file extensions.c.

299{
300 if (ext == NULL)
301 return;
302 xmlFree(ext);
303}

Referenced by xsltFreeExtElementEntry().

◆ xsltFreeExtElementEntry()

static void xsltFreeExtElementEntry ( void payload,
const xmlChar *name  ATTRIBUTE_UNUSED 
)
static

Definition at line 306 of file extensions.c.

306 {
308}
static void xsltFreeExtElement(xsltExtElementPtr ext)
Definition: extensions.c:298

Referenced by xsltRegisterExtModuleElement(), xsltUnregisterAllExtModuleElement(), and xsltUnregisterExtModuleElement().

◆ xsltFreeExtModule()

static void xsltFreeExtModule ( xsltExtModulePtr  ext)
static

xsltFreeExtModule: @ext: an XSLT extension module

Free up the memory allocated by @ext

Definition at line 203 of file extensions.c.

204{
205 if (ext == NULL)
206 return;
207 xmlFree(ext);
208}

Referenced by xsltFreeExtModuleEntry().

◆ xsltFreeExtModuleEntry()

static void xsltFreeExtModuleEntry ( void payload,
const xmlChar *name  ATTRIBUTE_UNUSED 
)
static

Definition at line 211 of file extensions.c.

211 {
213}
static void xsltFreeExtModule(xsltExtModulePtr ext)
Definition: extensions.c:203

Referenced by xsltUnregisterAllExtModules(), and xsltUnregisterExtModule().

◆ xsltFreeExts()

void xsltFreeExts ( xsltStylesheetPtr  style)

xsltFreeExts: @style: an XSLT stylesheet

Free up the memory used by XSLT extensions in a stylesheet

Definition at line 501 of file extensions.c.

502{
503 if (style->nsDefs != NULL)
505}
static void xsltFreeExtDefList(xsltExtDefPtr extensiond)
Definition: extensions.c:153

Referenced by xsltFreeStylesheet().

◆ xsltGetExtData()

void * xsltGetExtData ( xsltTransformContextPtr  ctxt,
const xmlChar URI 
)

xsltGetExtData: @ctxt: an XSLT transformation context @URI: the URI associated to the exension module

Retrieve the data associated to the extension module in this given transformation.

Returns the pointer or NULL if not present

Definition at line 883 of file extensions.c.

884{
886
887 if ((ctxt == NULL) || (URI == NULL))
888 return (NULL);
889 if (ctxt->extInfos == NULL) {
890 ctxt->extInfos = xmlHashCreate(10);
891 if (ctxt->extInfos == NULL)
892 return (NULL);
893 data = NULL;
894 } else {
896 }
897 if (data == NULL) {
898 void *extData;
900
902
904
906
907 if (module == NULL) {
908#ifdef WITH_XSLT_DEBUG_EXTENSIONS
910 "Not registered extension module: %s\n", URI);
911#endif
912 return (NULL);
913 } else {
914 if (module->initFunc == NULL)
915 return (NULL);
916
917#ifdef WITH_XSLT_DEBUG_EXTENSIONS
919 "Initializing module: %s\n", URI);
920#endif
921
922 extData = module->initFunc(ctxt, URI);
923 if (extData == NULL)
924 return (NULL);
925
926 data = xsltNewExtData(module, extData);
927 if ((data == NULL) ||
928 (xmlHashAddEntry(ctxt->extInfos, URI, (void *) data) < 0)) {
930 "Failed to register module data: %s\n",
931 URI);
932 if (module->shutdownFunc)
933 module->shutdownFunc(ctxt, URI, extData);
935 return (NULL);
936 }
937 }
938 }
939 return (data->extData);
940}
static xsltExtDataPtr xsltNewExtData(xsltExtModulePtr extModule, void *extData)
Definition: extensions.c:225
xsltExtData * xsltExtDataPtr
Definition: extensions.c:74
void * xmlHashLookup(xmlHashTablePtr hash, const xmlChar *key)
Definition: hash.c:739
int xmlHashAddEntry(xmlHashTablePtr hash, const xmlChar *key, void *payload)
Definition: hash.c:621
xmlHashTablePtr xmlHashCreate(int size)
Definition: hash.c:160
xmlHashTablePtr extInfos

Referenced by xsltExtElementTest(), and xsltExtFunctionTest().

◆ xsltGetExtInfo()

xmlHashTablePtr xsltGetExtInfo ( xsltStylesheetPtr  style,
const xmlChar URI 
)

xsltGetExtInfo: @style: pointer to a stylesheet @URI: the namespace URI desired

looks up URI in extInfos of the stylesheet

returns a pointer to the hash table if found, else NULL

Definition at line 1960 of file extensions.c.

1961{
1963
1964 /*
1965 * TODO: Why do we have a return type of xmlHashTablePtr?
1966 * Is the user-allocated data for extension modules expected
1967 * to be a xmlHashTablePtr only? Or is this intended for
1968 * the EXSLT module only?
1969 */
1970
1971 if (style != NULL && style->extInfos != NULL) {
1972 data = xmlHashLookup(style->extInfos, URI);
1973 if (data != NULL && data->extData != NULL)
1974 return data->extData;
1975 }
1976 return NULL;
1977}

◆ xsltHashScannerModuleFree()

static void xsltHashScannerModuleFree ( void *payload  ATTRIBUTE_UNUSED,
void *data  ATTRIBUTE_UNUSED,
const xmlChar *name  ATTRIBUTE_UNUSED 
)
static

Definition at line 2267 of file extensions.c.

2270{
2271#ifdef WITH_MODULES
2272 xmlModuleClose(payload);
2273#endif
2274}

Referenced by xsltCleanupGlobals().

◆ xsltInitCtxtExt()

static void xsltInitCtxtExt ( void payload,
void data,
const xmlChar URI 
)
static

xsltInitCtxtExt: @styleData: the registered stylesheet data for the module @ctxt: the XSLT transformation context + the return value @URI: the extension URI

Initializes an extension module

Definition at line 957 of file extensions.c.

958{
959 xsltExtDataPtr styleData = (xsltExtDataPtr) payload;
962 xsltExtDataPtr ctxtData;
963 void *extData;
964
965 if ((styleData == NULL) || (ctxt == NULL) || (URI == NULL) ||
966 (ctxt->ret == -1)) {
967#ifdef WITH_XSLT_DEBUG_EXTENSIONS
969 "xsltInitCtxtExt: NULL param or error\n");
970#endif
971 return;
972 }
973 module = styleData->extModule;
974 if ((module == NULL) || (module->initFunc == NULL)) {
975#ifdef WITH_XSLT_DEBUG_EXTENSIONS
977 "xsltInitCtxtExt: no module or no initFunc\n");
978#endif
979 return;
980 }
981
982 ctxtData = (xsltExtDataPtr) xmlHashLookup(ctxt->ctxt->extInfos, URI);
983 if (ctxtData != NULL) {
984#ifdef WITH_XSLT_DEBUG_EXTENSIONS
986 "xsltInitCtxtExt: already initialized\n");
987#endif
988 return;
989 }
990
991 extData = module->initFunc(ctxt->ctxt, URI);
992 if (extData == NULL) {
993#ifdef WITH_XSLT_DEBUG_EXTENSIONS
995 "xsltInitCtxtExt: no extData\n");
996#endif
997 }
998 ctxtData = xsltNewExtData(module, extData);
999 if (ctxtData == NULL) {
1000 if (module->shutdownFunc)
1001 module->shutdownFunc(ctxt->ctxt, URI, extData);
1002 ctxt->ret = -1;
1003 return;
1004 }
1005
1006 if (ctxt->ctxt->extInfos == NULL)
1007 ctxt->ctxt->extInfos = xmlHashCreate(10);
1008 if (ctxt->ctxt->extInfos == NULL) {
1009 if (module->shutdownFunc)
1010 module->shutdownFunc(ctxt->ctxt, URI, extData);
1011 xsltFreeExtData(ctxtData);
1012 ctxt->ret = -1;
1013 return;
1014 }
1015
1016 if (xmlHashAddEntry(ctxt->ctxt->extInfos, URI, ctxtData) < 0) {
1018 "Failed to register module data: %s\n", URI);
1019 if (module->shutdownFunc)
1020 module->shutdownFunc(ctxt->ctxt, URI, extData);
1021 xsltFreeExtData(ctxtData);
1022 ctxt->ret = -1;
1023 return;
1024 }
1025#ifdef WITH_XSLT_DEBUG_EXTENSIONS
1026 xsltGenericDebug(xsltGenericDebugContext, "Registered module %s\n",
1027 URI);
1028#endif
1029 ctxt->ret++;
1030}
xsltExtModulePtr extModule
Definition: extensions.c:76
xsltTransformContextPtr ctxt
Definition: extensions.c:944

Referenced by xsltInitCtxtExts().

◆ xsltInitCtxtExts()

int xsltInitCtxtExts ( xsltTransformContextPtr  ctxt)

xsltInitCtxtExts: @ctxt: an XSLT transformation context

Initialize the set of modules with registered stylesheet data

Returns the number of modules initialized or -1 in case of error

Definition at line 1041 of file extensions.c.

1042{
1045
1046 if (ctxt == NULL)
1047 return (-1);
1048
1049 style = ctxt->style;
1050 if (style == NULL)
1051 return (-1);
1052
1053 ctx.ctxt = ctxt;
1054 ctx.ret = 0;
1055
1056 while (style != NULL) {
1057 if (style->extInfos != NULL) {
1058 xmlHashScan(style->extInfos, xsltInitCtxtExt, &ctx);
1059 if (ctx.ret == -1)
1060 return (-1);
1061 }
1063 }
1064#ifdef WITH_XSLT_DEBUG_EXTENSIONS
1065 xsltGenericDebug(xsltGenericDebugContext, "Registered %d modules\n",
1066 ctx.ret);
1067#endif
1068 return (ctx.ret);
1069}
static void xsltInitCtxtExt(void *payload, void *data, const xmlChar *URI)
Definition: extensions.c:957
xsltStylesheetPtr xsltNextImport(xsltStylesheetPtr cur)
Definition: imports.c:297

Referenced by xsltNewTransformContext().

◆ xsltInitElemPreComp()

void xsltInitElemPreComp ( xsltElemPreCompPtr  comp,
xsltStylesheetPtr  style,
xmlNodePtr  inst,
xsltTransformFunction  function,
xsltElemPreCompDeallocator  freeFunc 
)

xsltInitElemPreComp: @comp: an xsltElemPreComp (or generally a derived structure) @style: the XSLT stylesheet @inst: the element node @function: the transform function @freeFunc: the @comp deallocator

Initializes an existing xsltElemPreComp structure. This is usefull when extending an xsltElemPreComp to store precomputed data. This function MUST be called on any extension element precomputed data struct.

Definition at line 1560 of file extensions.c.

1563{
1564 comp->type = XSLT_FUNC_EXTENSION;
1565 comp->func = function;
1566 comp->inst = inst;
1567 comp->free = freeFunc;
1568
1569 comp->next = style->preComps;
1570 style->preComps = comp;
1571}
xsltElemPreCompDeallocator free
xsltElemPreCompPtr next
xsltStyleType type
xsltTransformFunction func
@ XSLT_FUNC_EXTENSION

Referenced by xsltNewElemPreComp().

◆ xsltInitGlobals()

void xsltInitGlobals ( void  )

xsltInitGlobals:

Initialize the global variables for extensions

Definition at line 2282 of file extensions.c.

2283{
2284 if (xsltExtMutex == NULL) {
2286 }
2287}
XMLPUBFUN xmlMutexPtr xmlNewMutex(void)
Definition: threads.c:149

Referenced by xsltApplyStylesheetInternal(), xsltLoadStylesheetPI(), xsltNewSecurityPrefs(), xsltNewTransformContext(), xsltParseStylesheetDoc(), xsltParseStylesheetFile(), xsltParseStylesheetProcess(), xsltRegisterTestModule(), and xsltSetSecurityPrefs().

◆ xsltNewElemPreComp()

xsltElemPreCompPtr xsltNewElemPreComp ( xsltStylesheetPtr  style,
xmlNodePtr  inst,
xsltTransformFunction  function 
)

xsltNewElemPreComp: @style: the XSLT stylesheet @inst: the element node @function: the transform function

Creates and initializes an xsltElemPreComp

Returns the new and initialized xsltElemPreComp

Definition at line 1528 of file extensions.c.

1530{
1532
1534 if (cur == NULL) {
1536 "xsltNewExtElement : malloc failed\n");
1537 return (NULL);
1538 }
1539 memset(cur, 0, sizeof(xsltElemPreComp));
1540
1542
1543 return (cur);
1544}
static void xsltFreeElemPreComp(xsltElemPreCompPtr comp)
Definition: extensions.c:1513
void xsltInitElemPreComp(xsltElemPreCompPtr comp, xsltStylesheetPtr style, xmlNodePtr inst, xsltTransformFunction function, xsltElemPreCompDeallocator freeFunc)
Definition: extensions.c:1560
xmlMallocFunc xmlMalloc
Definition: globals.c:193
#define memset(x, y, z)
Definition: compat.h:39
xsltElemPreComp * xsltElemPreCompPtr

Referenced by xsltExtElementPreCompTest(), and xsltPreComputeExtModuleElement().

◆ xsltNewExtData()

static xsltExtDataPtr xsltNewExtData ( xsltExtModulePtr  extModule,
void extData 
)
static

xsltNewExtData: @extModule: the module @extData: the associated data

Create a new XSLT extension module data wrapper

Returns the newly allocated xsltExtDataPtr or NULL in case of error

Definition at line 225 of file extensions.c.

226{
228
229 if (extModule == NULL)
230 return (NULL);
232 if (cur == NULL) {
234 "xsltNewExtData : malloc failed\n");
235 return (NULL);
236 }
237 cur->extModule = extModule;
238 cur->extData = extData;
239 return (cur);
240}

Referenced by xsltGetExtData(), xsltInitCtxtExt(), and xsltStyleInitializeStylesheetModule().

◆ xsltNewExtDef()

static xsltExtDefPtr xsltNewExtDef ( const xmlChar prefix,
const xmlChar URI 
)
static

xsltNewExtDef: @prefix: the extension prefix @URI: the namespace URI

Create a new XSLT ExtDef

Returns the newly allocated xsltExtDefPtr or NULL in case of error

Definition at line 110 of file extensions.c.

111{
113
115 if (cur == NULL) {
117 "xsltNewExtDef : malloc failed\n");
118 return (NULL);
119 }
120 memset(cur, 0, sizeof(xsltExtDef));
121 if (prefix != NULL)
122 cur->prefix = xmlStrdup(prefix);
123 if (URI != NULL)
124 cur->URI = xmlStrdup(URI);
125 return (cur);
126}
Character const *const prefix
Definition: tempnam.cpp:195
XMLPUBFUN xmlChar * xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:69

Referenced by xsltRegisterExtPrefix().

◆ xsltNewExtElement()

static xsltExtElementPtr xsltNewExtElement ( xsltPreComputeFunction  precomp,
xsltTransformFunction  transform 
)
static

xsltNewExtElement: @precomp: the pre-computation function @transform: the transformation function

Create a new XSLT extension element

Returns the newly allocated xsltExtElementPtr or NULL in case of error

Definition at line 272 of file extensions.c.

274{
276
277 if (transform == NULL)
278 return (NULL);
279
281 if (cur == NULL) {
283 "xsltNewExtElement : malloc failed\n");
284 return (NULL);
285 }
286 cur->precomp = precomp;
287 cur->transform = transform;
288 return (cur);
289}
GLuint GLenum GLenum transform
Definition: glext.h:9407

Referenced by xsltRegisterExtModuleElement().

◆ xsltNewExtModule()

static xsltExtModulePtr xsltNewExtModule ( xsltExtInitFunction  initFunc,
xsltExtShutdownFunction  shutdownFunc,
xsltStyleExtInitFunction  styleInitFunc,
xsltStyleExtShutdownFunction  styleShutdownFunc 
)
static

xsltNewExtModule: @initFunc: the module initialization function @shutdownFunc: the module shutdown function @styleInitFunc: the stylesheet module data allocator function @styleShutdownFunc: the stylesheet module data free function

Create a new XSLT extension module

Returns the newly allocated xsltExtModulePtr or NULL in case of error

Definition at line 176 of file extensions.c.

180{
182
184 if (cur == NULL) {
186 "xsltNewExtModule : malloc failed\n");
187 return (NULL);
188 }
189 cur->initFunc = initFunc;
190 cur->shutdownFunc = shutdownFunc;
191 cur->styleInitFunc = styleInitFunc;
192 cur->styleShutdownFunc = styleShutdownFunc;
193 return (cur);
194}
xsltExtModule * xsltExtModulePtr
Definition: extensions.c:65

Referenced by xsltRegisterExtModuleFull().

◆ xsltPreComputeExtModuleElement()

xsltElemPreCompPtr xsltPreComputeExtModuleElement ( xsltStylesheetPtr  style,
xmlNodePtr  inst 
)

xsltPreComputeExtModuleElement: @style: the stylesheet @inst: the element node

Precomputes an extension module element

Returns the precomputed data

Definition at line 1583 of file extensions.c.

1584{
1586 xsltElemPreCompPtr comp = NULL;
1587
1588 if ((style == NULL) || (inst == NULL) ||
1589 (inst->type != XML_ELEMENT_NODE) || (inst->ns == NULL))
1590 return (NULL);
1591
1593
1595 xmlHashLookup2(xsltElementsHash, inst->name, inst->ns->href);
1596
1598
1599 /*
1600 * EXT TODO: Now what?
1601 */
1602 if (ext == NULL)
1603 return (NULL);
1604
1605 if (ext->precomp != NULL) {
1606 /*
1607 * REVISIT TODO: Check if the text below is correct.
1608 * This will return a xsltElemPreComp structure or NULL.
1609 * 1) If the the author of the extension needs a
1610 * custom structure to hold the specific values of
1611 * this extension, he will derive a structure based on
1612 * xsltElemPreComp; thus we obviously *cannot* refactor
1613 * the xsltElemPreComp structure, since all already derived
1614 * user-defined strucures will break.
1615 * Example: For the extension xsl:document,
1616 * in xsltDocumentComp() (preproc.c), the structure
1617 * xsltStyleItemDocument is allocated, filled with
1618 * specific values and returned.
1619 * 2) If the author needs no values to be stored in
1620 * this structure, then he'll return NULL;
1621 */
1622 comp = ext->precomp(style, inst, ext->transform);
1623 }
1624 if (comp == NULL) {
1625 /*
1626 * Default creation of a xsltElemPreComp structure, if
1627 * the author of this extension did not create a custom
1628 * structure.
1629 */
1630 comp = xsltNewElemPreComp(style, inst, ext->transform);
1631 }
1632
1633 return (comp);
1634}

Referenced by xsltStylePreCompute().

◆ xsltRegisterExtElement()

int xsltRegisterExtElement ( xsltTransformContextPtr  ctxt,
const xmlChar name,
const xmlChar URI,
xsltTransformFunction  function 
)

Definition at line 643 of file extensions.c.

645{
646 if ((ctxt == NULL) || (name == NULL) ||
647 (URI == NULL) || (function == NULL))
648 return (-1);
649 if (ctxt->extElements == NULL)
650 ctxt->extElements = xmlHashCreate(10);
651 if (ctxt->extElements == NULL)
652 return (-1);
653 return (xmlHashAddEntry2
654 (ctxt->extElements, name, URI, XML_CAST_FPTR(function)));
655}
int xmlHashAddEntry2(xmlHashTablePtr hash, const xmlChar *key, const xmlChar *key2, void *payload)
Definition: hash.c:639

Referenced by xsltRegisterAllElement().

◆ xsltRegisterExtFunction()

int xsltRegisterExtFunction ( xsltTransformContextPtr  ctxt,
const xmlChar name,
const xmlChar URI,
xmlXPathFunction  function 
)

Definition at line 609 of file extensions.c.

611{
612 int ret;
613
614 if ((ctxt == NULL) || (name == NULL) ||
615 (URI == NULL) || (function == NULL))
616 return (-1);
617 if (ctxt->xpathCtxt != NULL) {
618 xmlXPathRegisterFuncNS(ctxt->xpathCtxt, name, URI, function);
619 }
620 if (ctxt->extFunctions == NULL)
621 ctxt->extFunctions = xmlHashCreate(10);
622 if (ctxt->extFunctions == NULL)
623 return (-1);
624
626 XML_CAST_FPTR(function));
627
628 return(ret);
629}
xmlXPathContextPtr xpathCtxt

◆ xsltRegisterExtModule()

int xsltRegisterExtModule ( const xmlChar URI,
xsltExtInitFunction  initFunc,
xsltExtShutdownFunction  shutdownFunc 
)

xsltRegisterExtModule: @URI: URI associated to this module @initFunc: the module initialization function @shutdownFunc: the module shutdown function

Register an XSLT extension module to the library.

Returns 0 if sucessful, -1 in case of error

Definition at line 1325 of file extensions.c.

1328{
1329 return xsltRegisterExtModuleFull(URI, initFunc, shutdownFunc,
1330 NULL, NULL);
1331}
int xsltRegisterExtModuleFull(const xmlChar *URI, xsltExtInitFunction initFunc, xsltExtShutdownFunction shutdownFunc, xsltStyleExtInitFunction styleInitFunc, xsltStyleExtShutdownFunction styleShutdownFunc)
Definition: extensions.c:1273

◆ xsltRegisterExtModuleElement()

int xsltRegisterExtModuleElement ( const xmlChar name,
const xmlChar URI,
xsltPreComputeFunction  precomp,
xsltTransformFunction  transform 
)

Definition at line 1648 of file extensions.c.

1651{
1652 int ret = 0;
1653
1655
1656 if ((name == NULL) || (URI == NULL) || (transform == NULL))
1657 return (-1);
1658
1659 if (xsltElementsHash == NULL)
1661 if (xsltElementsHash == NULL)
1662 return (-1);
1663
1665
1666 ext = xsltNewExtElement(precomp, transform);
1667 if (ext == NULL) {
1668 ret = -1;
1669 goto done;
1670 }
1671
1674
1675done:
1677
1678 return (ret);
1679}
static xsltExtElementPtr xsltNewExtElement(xsltPreComputeFunction precomp, xsltTransformFunction transform)
Definition: extensions.c:272
static void xsltFreeExtElementEntry(void *payload, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: extensions.c:306
int xmlHashUpdateEntry2(xmlHashTablePtr hash, const xmlChar *key, const xmlChar *key2, void *payload, xmlHashDeallocator dealloc)
Definition: hash.c:699

Referenced by xsltRegisterAllExtras(), and xsltRegisterTestModule().

◆ xsltRegisterExtModuleFull()

int xsltRegisterExtModuleFull ( const xmlChar URI,
xsltExtInitFunction  initFunc,
xsltExtShutdownFunction  shutdownFunc,
xsltStyleExtInitFunction  styleInitFunc,
xsltStyleExtShutdownFunction  styleShutdownFunc 
)

xsltRegisterExtModuleFull: @URI: URI associated to this module @initFunc: the module initialization function @shutdownFunc: the module shutdown function @styleInitFunc: the module initialization function @styleShutdownFunc: the module shutdown function

Register an XSLT extension module to the library.

Returns 0 if sucessful, -1 in case of error

Definition at line 1273 of file extensions.c.

1278{
1279 int ret;
1281
1282 if ((URI == NULL) || (initFunc == NULL))
1283 return (-1);
1284 if (xsltExtensionsHash == NULL)
1286
1287 if (xsltExtensionsHash == NULL)
1288 return (-1);
1289
1291
1293 if (module != NULL) {
1294 if ((module->initFunc == initFunc) &&
1295 (module->shutdownFunc == shutdownFunc))
1296 ret = 0;
1297 else
1298 ret = -1;
1299 goto done;
1300 }
1301 module = xsltNewExtModule(initFunc, shutdownFunc,
1302 styleInitFunc, styleShutdownFunc);
1303 if (module == NULL) {
1304 ret = -1;
1305 goto done;
1306 }
1307 ret = xmlHashAddEntry(xsltExtensionsHash, URI, (void *) module);
1308
1309done:
1311 return (ret);
1312}
static xsltExtModulePtr xsltNewExtModule(xsltExtInitFunction initFunc, xsltExtShutdownFunction shutdownFunc, xsltStyleExtInitFunction styleInitFunc, xsltStyleExtShutdownFunction styleShutdownFunc)
Definition: extensions.c:176

Referenced by xsltRegisterExtModule(), and xsltRegisterTestModule().

◆ xsltRegisterExtModuleFunction()

int xsltRegisterExtModuleFunction ( const xmlChar name,
const xmlChar URI,
xmlXPathFunction  function 
)

Definition at line 1410 of file extensions.c.

1412{
1413 if ((name == NULL) || (URI == NULL) || (function == NULL))
1414 return (-1);
1415
1416 if (xsltFunctionsHash == NULL)
1418 if (xsltFunctionsHash == NULL)
1419 return (-1);
1420
1422
1424 XML_CAST_FPTR(function), NULL);
1425
1427
1428 return (0);
1429}

Referenced by init_libxslt(), xsltRegisterAllExtras(), and xsltRegisterTestModule().

◆ xsltRegisterExtModuleTopLevel()

int xsltRegisterExtModuleTopLevel ( const xmlChar name,
const xmlChar URI,
xsltTopLevelFunction  function 
)

Definition at line 1850 of file extensions.c.

1852{
1853 if ((name == NULL) || (URI == NULL) || (function == NULL))
1854 return (-1);
1855
1856 if (xsltTopLevelsHash == NULL)
1858 if (xsltTopLevelsHash == NULL)
1859 return (-1);
1860
1862
1864 XML_CAST_FPTR(function), NULL);
1865
1867
1868 return (0);
1869}

◆ xsltRegisterExtPrefix()

int xsltRegisterExtPrefix ( xsltStylesheetPtr  style,
const xmlChar prefix,
const xmlChar URI 
)

xsltRegisterExtPrefix: @style: an XSLT stylesheet @prefix: the prefix used (optional) @URI: the URI associated to the extension

Registers an extension namespace This is called from xslt.c during compile-time. The given prefix is not needed. Called by: xsltParseExtElemPrefixes() (new function) xsltRegisterExtPrefix() (old function)

Returns 0 in case of success, 1 if the @URI was already registered as an extension namespace and -1 in case of failure

Definition at line 525 of file extensions.c.

527{
528 xsltExtDefPtr def, ret;
529
530 if ((style == NULL) || (URI == NULL))
531 return (-1);
532
533#ifdef WITH_XSLT_DEBUG_EXTENSIONS
535 "Registering extension namespace '%s'.\n", URI);
536#endif
537 def = (xsltExtDefPtr) style->nsDefs;
538#ifdef XSLT_REFACTORED
539 /*
540 * The extension is associated with a namespace name.
541 */
542 while (def != NULL) {
543 if (xmlStrEqual(URI, def->URI))
544 return (1);
545 def = def->next;
546 }
547#else
548 while (def != NULL) {
549 if (xmlStrEqual(prefix, def->prefix))
550 return (-1);
551 def = def->next;
552 }
553#endif
554 ret = xsltNewExtDef(prefix, URI);
555 if (ret == NULL)
556 return (-1);
557 ret->next = (xsltExtDefPtr) style->nsDefs;
558 style->nsDefs = ret;
559
560 /*
561 * check whether there is an extension module with a stylesheet
562 * initialization function.
563 */
564#ifdef XSLT_REFACTORED
565 /*
566 * Don't initialize modules based on specified namespaces via
567 * the attribute "[xsl:]extension-element-prefixes".
568 */
569#else
572
576 if (NULL == module) {
581 }
582 }
583 if (module != NULL) {
585 }
586 }
587#endif
588 return (0);
589}
static xsltExtDefPtr xsltNewExtDef(const xmlChar *prefix, const xmlChar *URI)
Definition: extensions.c:110
if(dx< 0)
Definition: linetemp.h:194

Referenced by xsltParseStylesheetExtPrefix().

◆ xsltRegisterTestModule()

void xsltRegisterTestModule ( void  )

xsltRegisterTestModule:

Registers the test module

Definition at line 2250 of file extensions.c.

2251{
2257 xsltRegisterExtModuleFunction((const xmlChar *) "test",
2258 (const xmlChar *) XSLT_DEFAULT_URL,
2260 xsltRegisterExtModuleElement((const xmlChar *) "test",
2261 (const xmlChar *) XSLT_DEFAULT_URL,
2264}
static void xsltExtStyleShutdownTest(xsltStylesheetPtr style ATTRIBUTE_UNUSED, const xmlChar *URI, void *data)
Definition: extensions.c:2227
static void xsltExtFunctionTest(xmlXPathParserContextPtr ctxt, int nargs ATTRIBUTE_UNUSED)
Definition: extensions.c:1996
static void * xsltExtInitTest(xsltTransformContextPtr ctxt, const xmlChar *URI)
Definition: extensions.c:2142
static void * xsltExtStyleInitTest(xsltStylesheetPtr style ATTRIBUTE_UNUSED, const xmlChar *URI)
Definition: extensions.c:2203
int xsltRegisterExtModuleElement(const xmlChar *name, const xmlChar *URI, xsltPreComputeFunction precomp, xsltTransformFunction transform)
Definition: extensions.c:1648
static xsltElemPreCompPtr xsltExtElementPreCompTest(xsltStylesheetPtr style, xmlNodePtr inst, xsltTransformFunction function)
Definition: extensions.c:2046
static void xsltExtElementTest(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst, xsltElemPreCompPtr comp ATTRIBUTE_UNUSED)
Definition: extensions.c:2090
static void xsltExtShutdownTest(xsltTransformContextPtr ctxt, const xmlChar *URI, void *data)
Definition: extensions.c:2176
void xsltInitGlobals(void)
Definition: extensions.c:2282
int xsltRegisterExtModuleFunction(const xmlChar *name, const xmlChar *URI, xmlXPathFunction function)
Definition: extensions.c:1410

◆ xsltShutdownCtxtExt()

static void xsltShutdownCtxtExt ( void payload,
void vctxt,
const xmlChar URI 
)
static

xsltShutdownCtxtExt: @data: the registered data for the module @ctxt: the XSLT transformation context @URI: the extension URI

Shutdown an extension module loaded

Definition at line 1080 of file extensions.c.

1081{
1085
1086 if ((data == NULL) || (ctxt == NULL) || (URI == NULL))
1087 return;
1088 module = data->extModule;
1089 if ((module == NULL) || (module->shutdownFunc == NULL))
1090 return;
1091
1092#ifdef WITH_XSLT_DEBUG_EXTENSIONS
1094 "Shutting down module : %s\n", URI);
1095#endif
1096 module->shutdownFunc(ctxt, URI, data->extData);
1097}
xsltTransformContext * xsltTransformContextPtr

Referenced by xsltShutdownCtxtExts().

◆ xsltShutdownCtxtExts()

void xsltShutdownCtxtExts ( xsltTransformContextPtr  ctxt)

xsltShutdownCtxtExts: @ctxt: an XSLT transformation context

Shutdown the set of modules loaded

Definition at line 1106 of file extensions.c.

1107{
1108 if (ctxt == NULL)
1109 return;
1110 if (ctxt->extInfos == NULL)
1111 return;
1114 ctxt->extInfos = NULL;
1115}
static void xsltShutdownCtxtExt(void *payload, void *vctxt, const xmlChar *URI)
Definition: extensions.c:1080
static void xsltFreeExtDataEntry(void *payload, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: extensions.c:257

Referenced by xsltApplyStylesheetInternal(), and xsltFreeTransformContext().

◆ xsltShutdownExt()

static void xsltShutdownExt ( void payload,
void vctxt,
const xmlChar URI 
)
static

xsltShutdownExt: @data: the registered data for the module @ctxt: the XSLT stylesheet @URI: the extension URI

Shutdown an extension module loaded

Definition at line 1126 of file extensions.c.

1127{
1131
1132 if ((data == NULL) || (style == NULL) || (URI == NULL))
1133 return;
1134 module = data->extModule;
1135 if ((module == NULL) || (module->styleShutdownFunc == NULL))
1136 return;
1137
1138#ifdef WITH_XSLT_DEBUG_EXTENSIONS
1140 "Shutting down module : %s\n", URI);
1141#endif
1142 module->styleShutdownFunc(style, URI, data->extData);
1143 /*
1144 * Don't remove the entry from the hash table here, since
1145 * this will produce segfaults - this fixes bug #340624.
1146 *
1147 * xmlHashRemoveEntry(style->extInfos, URI, xsltFreeExtDataEntry);
1148 */
1149}
xsltStylesheet * xsltStylesheetPtr

Referenced by xsltShutdownExts().

◆ xsltShutdownExts()

void xsltShutdownExts ( xsltStylesheetPtr  style)

xsltShutdownExts: @style: an XSLT stylesheet

Shutdown the set of modules loaded

Definition at line 1158 of file extensions.c.

1159{
1160 if (style == NULL)
1161 return;
1162 if (style->extInfos == NULL)
1163 return;
1166 style->extInfos = NULL;
1167}
static void xsltShutdownExt(void *payload, void *vctxt, const xmlChar *URI)
Definition: extensions.c:1126

Referenced by xsltFreeStylesheet().

◆ xsltStyleGetExtData()

void * xsltStyleGetExtData ( xsltStylesheetPtr  style,
const xmlChar URI 
)

xsltStyleGetExtData: @style: an XSLT stylesheet @URI: the URI associated to the exension module

Retrieve the data associated to the extension module in this given stylesheet. Called by: xsltRegisterExtPrefix(), ( xsltExtElementPreCompTest(), xsltExtInitTest )

Returns the pointer or NULL if not present

Definition at line 781 of file extensions.c.

782{
783 xsltExtDataPtr dataContainer = NULL;
784 xsltStylesheetPtr tmpStyle;
785
786 if ((style == NULL) || (URI == NULL) ||
788 return (NULL);
789
790
791#ifdef XSLT_REFACTORED
792 /*
793 * This is intended for global storage, so only the main
794 * stylesheet will hold the data.
795 */
796 tmpStyle = style;
797 while (tmpStyle->parent != NULL)
798 tmpStyle = tmpStyle->parent;
799 if (tmpStyle->extInfos != NULL) {
800 dataContainer =
801 (xsltExtDataPtr) xmlHashLookup(tmpStyle->extInfos, URI);
802 if (dataContainer != NULL) {
803 /*
804 * The module was already initialized in the context
805 * of this stylesheet; just return the user-data that
806 * comes with it.
807 */
808 return(dataContainer->extData);
809 }
810 }
811#else
812 /*
813 * Old behaviour.
814 */
815 tmpStyle = style;
816 if (tmpStyle->extInfos != NULL) {
817 dataContainer =
818 (xsltExtDataPtr) xmlHashLookup(tmpStyle->extInfos, URI);
819 if (dataContainer != NULL) {
820 return(dataContainer->extData);
821 }
822 }
823#endif
824
825 dataContainer =
827 if (dataContainer != NULL)
828 return (dataContainer->extData);
829 return(NULL);
830}
static xsltExtDataPtr xsltStyleInitializeStylesheetModule(xsltStylesheetPtr style, const xmlChar *URI)
Definition: extensions.c:685
void * extData
Definition: extensions.c:77
struct _xsltStylesheet * parent
xmlHashTablePtr extInfos

Referenced by xsltExtElementPreCompTest(), xsltExtInitTest(), and xsltRegisterExtPrefix().

◆ xsltStyleInitializeStylesheetModule()

static xsltExtDataPtr xsltStyleInitializeStylesheetModule ( xsltStylesheetPtr  style,
const xmlChar URI 
)
static

xsltStyleGetStylesheetExtData: @style: an XSLT stylesheet @URI: the URI associated to the exension module

Fires the compile-time initialization callback of an extension module and returns a container holding the user-data (retrieved via the callback).

Returns the create module-data container or NULL if such a module was not registered.

Definition at line 685 of file extensions.c.

687{
688 xsltExtDataPtr dataContainer;
689 void *userData = NULL;
691
692 if ((style == NULL) || (URI == NULL))
693 return(NULL);
694
695 if (xsltExtensionsHash == NULL) {
696#ifdef WITH_XSLT_DEBUG_EXTENSIONS
698 "Not registered extension module: %s\n", URI);
699#endif
700 return(NULL);
701 }
702
704
706
708
709 if (module == NULL) {
710#ifdef WITH_XSLT_DEBUG_EXTENSIONS
712 "Not registered extension module: %s\n", URI);
713#endif
714 return (NULL);
715 }
716 /*
717 * The specified module was registered so initialize it.
718 */
719 if (style->extInfos == NULL) {
720 style->extInfos = xmlHashCreate(10);
721 if (style->extInfos == NULL)
722 return (NULL);
723 }
724 /*
725 * Fire the initialization callback if available.
726 */
727 if (module->styleInitFunc == NULL) {
728#ifdef WITH_XSLT_DEBUG_EXTENSIONS
730 "Initializing module with *no* callback: %s\n", URI);
731#endif
732 } else {
733#ifdef WITH_XSLT_DEBUG_EXTENSIONS
735 "Initializing module with callback: %s\n", URI);
736#endif
737 /*
738 * Fire the initialization callback.
739 */
740 userData = module->styleInitFunc(style, URI);
741 }
742 /*
743 * Store the user-data in the context of the given stylesheet.
744 */
745 dataContainer = xsltNewExtData(module, userData);
746 if (dataContainer == NULL) {
747 if (module->styleShutdownFunc)
748 module->styleShutdownFunc(style, URI, userData);
749 return (NULL);
750 }
751
752 if (xmlHashAddEntry(style->extInfos, URI,
753 (void *) dataContainer) < 0)
754 {
756 "Failed to register module '%s'.\n", URI);
757 style->errors++;
758 if (module->styleShutdownFunc)
759 module->styleShutdownFunc(style, URI, userData);
760 xsltFreeExtData(dataContainer);
761 return (NULL);
762 }
763
764 return(dataContainer);
765}

Referenced by xsltStyleGetExtData().

◆ xsltUnregisterAllExtModuleElement()

static void xsltUnregisterAllExtModuleElement ( void  )
static

xsltUnregisterAllExtModuleElement:

Unregisters all extension module element

Definition at line 1829 of file extensions.c.

Referenced by xsltCleanupGlobals().

◆ xsltUnregisterAllExtModuleFunction()

static void xsltUnregisterAllExtModuleFunction ( void  )
static

xsltUnregisterAllExtModuleFunction:

Unregisters all extension module function

Definition at line 1501 of file extensions.c.

Referenced by xsltCleanupGlobals().

◆ xsltUnregisterAllExtModules()

static void xsltUnregisterAllExtModules ( void  )
static

xsltUnregisterAllExtModules:

Unregister all the XSLT extension module from the library.

Definition at line 1366 of file extensions.c.

1367{
1368 if (xsltExtensionsHash == NULL)
1369 return;
1370
1372
1375
1377}
static void xsltFreeExtModuleEntry(void *payload, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: extensions.c:211

Referenced by xsltCleanupGlobals().

◆ xsltUnregisterAllExtModuleTopLevel()

static void xsltUnregisterAllExtModuleTopLevel ( void  )
static

xsltUnregisterAllExtModuleTopLevel:

Unregisters all extension module function

Definition at line 1940 of file extensions.c.

Referenced by xsltCleanupGlobals().

◆ xsltUnregisterExtModule()

int xsltUnregisterExtModule ( const xmlChar URI)

xsltUnregisterExtModule: @URI: URI associated to this module

Unregister an XSLT extension module from the library.

Returns 0 if sucessful, -1 in case of error

Definition at line 1342 of file extensions.c.

1343{
1344 int ret;
1345
1346 if (URI == NULL)
1347 return (-1);
1348 if (xsltExtensionsHash == NULL)
1349 return (-1);
1350
1352
1354
1356
1357 return (ret);
1358}
int xmlHashRemoveEntry(xmlHashTablePtr hash, const xmlChar *key, xmlHashDeallocator dealloc)
Definition: hash.c:1102

◆ xsltUnregisterExtModuleElement()

int xsltUnregisterExtModuleElement ( const xmlChar name,
const xmlChar URI 
)

Definition at line 1806 of file extensions.c.

1807{
1808 int ret;
1809
1810 if ((xsltElementsHash == NULL) || (name == NULL) || (URI == NULL))
1811 return (-1);
1812
1814
1817
1819
1820 return(ret);
1821}
int xmlHashRemoveEntry2(xmlHashTablePtr hash, const xmlChar *key, const xmlChar *key2, xmlHashDeallocator dealloc)
Definition: hash.c:1121

◆ xsltUnregisterExtModuleFunction()

int xsltUnregisterExtModuleFunction ( const xmlChar name,
const xmlChar URI 
)

Definition at line 1479 of file extensions.c.

1480{
1481 int ret;
1482
1483 if ((xsltFunctionsHash == NULL) || (name == NULL) || (URI == NULL))
1484 return (-1);
1485
1487
1489
1491
1492 return(ret);
1493}

◆ xsltUnregisterExtModuleTopLevel()

int xsltUnregisterExtModuleTopLevel ( const xmlChar name,
const xmlChar URI 
)

Definition at line 1918 of file extensions.c.

1919{
1920 int ret;
1921
1922 if ((xsltTopLevelsHash == NULL) || (name == NULL) || (URI == NULL))
1923 return (-1);
1924
1926
1928
1930
1931 return(ret);
1932}

◆ xsltXPathGetTransformContext()

xsltTransformContextPtr xsltXPathGetTransformContext ( xmlXPathParserContextPtr  ctxt)

xsltXPathGetTransformContext: @ctxt: an XPath transformation context

Provides the XSLT transformation context from the XPath transformation context. This is useful when an XPath function in the extension module is called by the XPath interpreter and that the XSLT context is needed for example to retrieve the associated data pertaining to this XSLT transformation.

Returns the XSLT transformation context or NULL in case of error.

Definition at line 1392 of file extensions.c.

1393{
1394 if ((ctxt == NULL) || (ctxt->context == NULL))
1395 return (NULL);
1396 return (ctxt->context->extra);
1397}

Referenced by xsltCurrentFunction(), xsltDocumentFunction(), xsltDocumentFunctionLoadDocument(), xsltElementAvailableFunction(), xsltExtFunctionTest(), xsltFormatNumberFunction(), xsltFunctionAvailableFunction(), xsltFunctionNodeSet(), xsltGenerateIdFunction(), xsltKeyFunction(), and xsltSystemPropertyFunction().

Variable Documentation

◆ testData

xmlChar* testData = NULL
static

◆ testStyleData

xmlChar* testStyleData = NULL
static

◆ xsltElementsHash

◆ xsltExtensionsHash

◆ xsltExtMutex

◆ xsltFunctionsHash

◆ xsltModuleHash

xmlHashTablePtr xsltModuleHash = NULL
static

Definition at line 91 of file extensions.c.

Referenced by xsltCleanupGlobals().

◆ xsltTopLevelsHash