mirror of
https://gitlab.gnome.org/GNOME/libxslt
synced 2025-08-10 09:03:02 +03:00
fixed bug 114812
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
|
Wed Jul 9 21:27:43 HKT 2003 William Brack <wbrack@mmm.com.hk>
|
||||||
|
|
||||||
|
* fixed bug 114812, trouble with imported exslt functions
|
||||||
|
added lookup function in libxslt/extension.c
|
||||||
|
enhanced exsltInitFunc in libexslt/functions.c to take
|
||||||
|
better care of imports
|
||||||
|
|
||||||
Wed Jul 9 12:19:34 CEST 2003 Daniel Veillard <daniel@veillard.com>
|
Wed Jul 9 12:19:34 CEST 2003 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* python/generator.py python/libxslt-python-api.xml python/libxslt.c
|
* python/generator.py python/libxslt-python-api.xml python/libxslt.c
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
#include <libxslt/xsltInternals.h>
|
#include <libxslt/xsltInternals.h>
|
||||||
#include <libxslt/extensions.h>
|
#include <libxslt/extensions.h>
|
||||||
#include <libxslt/transform.h>
|
#include <libxslt/transform.h>
|
||||||
|
#include <libxslt/imports.h>
|
||||||
|
|
||||||
#include "exslt.h"
|
#include "exslt.h"
|
||||||
|
|
||||||
@@ -42,8 +43,16 @@ struct _exsltFuncResultPreComp {
|
|||||||
xmlXPathCompExprPtr select;
|
xmlXPathCompExprPtr select;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Used for callback function in exsltInitFunc */
|
||||||
|
typedef struct _exsltFuncImportRegData exsltFuncImportRegData;
|
||||||
|
struct _exsltFuncImportRegData {
|
||||||
|
xsltTransformContextPtr ctxt;
|
||||||
|
xmlHashTablePtr hash;
|
||||||
|
};
|
||||||
|
|
||||||
static void exsltFuncFunctionFunction (xmlXPathParserContextPtr ctxt,
|
static void exsltFuncFunctionFunction (xmlXPathParserContextPtr ctxt,
|
||||||
int nargs);
|
int nargs);
|
||||||
|
static exsltFuncFunctionData *exsltFuncNewFunctionData(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* exsltFuncRegisterFunc:
|
* exsltFuncRegisterFunc:
|
||||||
@@ -68,6 +77,48 @@ exsltFuncRegisterFunc (exsltFuncFunctionData *data,
|
|||||||
exsltFuncFunctionFunction);
|
exsltFuncFunctionFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* exsltFuncRegisterImportFunc
|
||||||
|
* @data: the exsltFuncFunctionData for the function
|
||||||
|
* @ch: structure containing context and hash table
|
||||||
|
* @URI: the function namespace URI
|
||||||
|
* @name: the function name
|
||||||
|
*
|
||||||
|
* Checks if imported function is already registered in top-level
|
||||||
|
* stylesheet. If not, copies function data and registers function
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
exsltFuncRegisterImportFunc (exsltFuncFunctionData *data,
|
||||||
|
exsltFuncImportRegData *ch,
|
||||||
|
const xmlChar *URI, const xmlChar *name) {
|
||||||
|
exsltFuncFunctionData *func=NULL;
|
||||||
|
|
||||||
|
if ((data == NULL) || (ch == NULL) || (URI == NULL) || (name == NULL))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (ch->ctxt == NULL || ch->hash == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Check if already present */
|
||||||
|
func = (exsltFuncFunctionData*)xmlHashLookup2(ch->hash,
|
||||||
|
URI, name);
|
||||||
|
if (func == NULL) { /* Not yet present - copy it in */
|
||||||
|
func = exsltFuncNewFunctionData();
|
||||||
|
memcpy(func, data, sizeof(exsltFuncFunctionData));
|
||||||
|
if (xmlHashAddEntry2(ch->hash, URI, name, func) < 0) {
|
||||||
|
xsltGenericError(xsltGenericErrorContext,
|
||||||
|
"Failed to register function {%s}%s\n",
|
||||||
|
URI, name);
|
||||||
|
} else { /* Do the registration */
|
||||||
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
|
"exsltFuncRegisterImportFunc: register {%s}%s\n",
|
||||||
|
URI, name);
|
||||||
|
xsltRegisterExtFunction(ch->ctxt, name, URI,
|
||||||
|
exsltFuncFunctionFunction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* exsltFuncInit:
|
* exsltFuncInit:
|
||||||
* @ctxt: an XSLT transformation context
|
* @ctxt: an XSLT transformation context
|
||||||
@@ -79,9 +130,11 @@ exsltFuncRegisterFunc (exsltFuncFunctionData *data,
|
|||||||
*/
|
*/
|
||||||
static exsltFuncData *
|
static exsltFuncData *
|
||||||
exsltFuncInit (xsltTransformContextPtr ctxt, const xmlChar *URI) {
|
exsltFuncInit (xsltTransformContextPtr ctxt, const xmlChar *URI) {
|
||||||
xmlHashTablePtr hash;
|
|
||||||
exsltFuncData *ret;
|
exsltFuncData *ret;
|
||||||
|
xsltStylesheetPtr tmp;
|
||||||
|
exsltFuncImportRegData ch;
|
||||||
|
xmlHashTablePtr hash;
|
||||||
|
|
||||||
ret = (exsltFuncData *) xmlMalloc (sizeof(exsltFuncData));
|
ret = (exsltFuncData *) xmlMalloc (sizeof(exsltFuncData));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericError(xsltGenericErrorContext,
|
||||||
@@ -93,10 +146,18 @@ exsltFuncInit (xsltTransformContextPtr ctxt, const xmlChar *URI) {
|
|||||||
ret->result = NULL;
|
ret->result = NULL;
|
||||||
ret->error = 0;
|
ret->error = 0;
|
||||||
|
|
||||||
hash = (xmlHashTablePtr) xsltStyleGetExtData(ctxt->style, URI);
|
ch.hash = (xmlHashTablePtr) xsltStyleGetExtData(ctxt->style, URI);
|
||||||
xmlHashScanFull(hash, (xmlHashScannerFull) exsltFuncRegisterFunc, ctxt);
|
ret->funcs = ch.hash;
|
||||||
|
xmlHashScanFull(ch.hash, (xmlHashScannerFull) exsltFuncRegisterFunc, ctxt);
|
||||||
ret->funcs = hash;
|
tmp = ctxt->style;
|
||||||
|
ch.ctxt = ctxt;
|
||||||
|
while ((tmp=xsltNextImport(tmp))!=NULL) {
|
||||||
|
hash = xsltGetExtInfo(tmp, URI);
|
||||||
|
if (hash != NULL) {
|
||||||
|
xmlHashScanFull(hash,
|
||||||
|
(xmlHashScannerFull) exsltFuncRegisterImportFunc, &ch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
@@ -128,8 +189,8 @@ exsltFuncShutdown (xsltTransformContextPtr ctxt ATTRIBUTE_UNUSED,
|
|||||||
* Returns the allocated data
|
* Returns the allocated data
|
||||||
*/
|
*/
|
||||||
static xmlHashTablePtr
|
static xmlHashTablePtr
|
||||||
exsltFuncStyleInit (xsltStylesheetPtr style ATTRIBUTE_UNUSED,
|
exsltFuncStyleInit (xsltStylesheetPtr style,
|
||||||
const xmlChar *URI ATTRIBUTE_UNUSED) {
|
const xmlChar *URI) {
|
||||||
return xmlHashCreate(1);
|
return xmlHashCreate(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1296,6 +1296,26 @@ xsltUnregisterAllExtModuleTopLevel (void) {
|
|||||||
xsltTopLevelsHash = NULL;
|
xsltTopLevelsHash = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
xmlHashTablePtr
|
||||||
|
xsltGetExtInfo (xsltStylesheetPtr style, const xmlChar *URI) {
|
||||||
|
xsltExtDataPtr data;
|
||||||
|
|
||||||
|
if (style != NULL && style->extInfos != NULL) {
|
||||||
|
data = xmlHashLookup(style->extInfos, URI);
|
||||||
|
if (data != NULL && data->extData != NULL)
|
||||||
|
return data->extData;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* *
|
* *
|
||||||
|
@@ -181,6 +181,12 @@ void xsltFreeExts (xsltStylesheetPtr style);
|
|||||||
|
|
||||||
xsltElemPreCompPtr xsltPreComputeExtModuleElement(xsltStylesheetPtr style,
|
xsltElemPreCompPtr xsltPreComputeExtModuleElement(xsltStylesheetPtr style,
|
||||||
xmlNodePtr inst);
|
xmlNodePtr inst);
|
||||||
|
/*
|
||||||
|
* Extension Infos access.
|
||||||
|
* Used by exslt initialisation
|
||||||
|
*/
|
||||||
|
|
||||||
|
xmlHashTablePtr xsltGetExtInfo (xsltStylesheetPtr style, const xmlChar *URI);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test module http://xmlsoft.org/XSLT/
|
* Test module http://xmlsoft.org/XSLT/
|
||||||
|
Reference in New Issue
Block a user