+Tue Aug 14 05:01:30 CEST 2001 Thomas Broyer <tbroyer@ltgt.net>
+
+ * libxslt/xslt.c libxslt/xsltInternals.h libxslt/transform.c
+ libxslt/extra.[ch] libxslt/extensions.c libxslt/preproc.[ch]:
+ fixed compilation warnings due to recent changes to the extension
+ framework.
+ * libxslt/preproc.[ch] libexslt/common.c
+ fixed the precomputation of *:document elements
+ * libxslt/functions.h: fixed a compilation warning
+
Mon Aug 13 11:41:02 CEST 2001 Daniel Veillard <daniel@veillard.com>
* libxslt/xsltutils.c: applied fix suggested by Tom Moog
#include <libxslt/extensions.h>
#include <libxslt/transform.h>
#include <libxslt/extra.h>
+#include <libxslt/preproc.h>
#include "exslt.h"
exsltObjectTypeFunction);
xsltRegisterExtModuleElement((const xmlChar *) "document",
EXSLT_COMMON_NAMESPACE,
- NULL, xsltDocumentElem);
+ (xsltPreComputeFunction) xsltDocumentComp,
+ (xsltTransformFunction) xsltDocumentElem);
}
xsltPrintErrorContext(NULL, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsltExtElementTest: no transformation context\n");
- return;
+ return (NULL);
}
if (testStyleData == NULL) {
xsltGenericDebug(xsltGenericDebugContext,
" calling xsltStyleGetExtData\n");
xsltStyleGetExtData(style, (const xmlChar *) XSLT_DEFAULT_URL);
if (testStyleData == NULL) {
- xsltPrintErrorContext(NULL, NULL, inst);
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsltExtElementPreCompTest: not initialized\n");
style->errors++;
- return;
+ return (NULL);
}
}
if (inst == NULL) {
- xsltPrintErrorContext(NULL, NULL, inst);
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsltExtElementPreCompTest: no instruction\n");
style->errors++;
- return;
+ return (NULL);
}
ret = xsltNewElemPreComp (style, inst, function);
return (ret);
#include "variables.h"
#include "transform.h"
#include "extra.h"
+#include "preproc.h"
#ifdef WITH_XSLT_DEBUG
#define WITH_XSLT_DEBUG_EXTRA
* xsltRegisterExtras:
* @ctxt: a XSLT process context
*
+ * Registers the built-in extensions. This function is deprecated, use
+ * xsltRegisterAllExtras instead.
+ */
+void
+xsltRegisterExtras(xsltTransformContextPtr ctxt ATTRIBUTE_UNUSED) {
+ xsltRegisterAllExtras();
+}
+
+/**
+ * xsltRegisterAllExtras:
+ *
* Registers the built-in extensions
*/
void
-xsltRegisterExtras(xsltTransformContextPtr ctxt) {
- xsltRegisterExtFunction(ctxt, (const xmlChar *) "node-set",
- XSLT_LIBXSLT_NAMESPACE, xsltFunctionNodeSet);
- xsltRegisterExtFunction(ctxt, (const xmlChar *) "node-set",
- XSLT_SAXON_NAMESPACE, xsltFunctionNodeSet);
- xsltRegisterExtFunction(ctxt, (const xmlChar *) "node-set",
- XSLT_XT_NAMESPACE, xsltFunctionNodeSet);
+xsltRegisterAllExtras (void) {
+ xsltRegisterExtModuleFunction((const xmlChar *) "node-set",
+ XSLT_LIBXSLT_NAMESPACE,
+ xsltFunctionNodeSet);
+ xsltRegisterExtModuleFunction((const xmlChar *) "node-set",
+ XSLT_SAXON_NAMESPACE,
+ xsltFunctionNodeSet);
+ xsltRegisterExtModuleFunction((const xmlChar *) "node-set",
+ XSLT_XT_NAMESPACE,
+ xsltFunctionNodeSet);
#ifdef WITH_LOCALTIME
- xsltRegisterExtFunction(ctxt, (const xmlChar *) "localTime",
- XSLT_NORM_SAXON_NAMESPACE, xsltFunctionLocalTime);
+ xsltRegisterExtModuleFunction((const xmlChar *) "localTime",
+ XSLT_NORM_SAXON_NAMESPACE,
+ xsltFunctionLocalTime);
#endif
- xsltRegisterExtElement(ctxt, (const xmlChar *) "debug",
- XSLT_LIBXSLT_NAMESPACE, xsltDebug);
- xsltRegisterExtElement(ctxt, (const xmlChar *) "output",
- XSLT_SAXON_NAMESPACE, xsltDocumentElem);
- xsltRegisterExtElement(ctxt, (const xmlChar *) "write",
- XSLT_XALAN_NAMESPACE, xsltDocumentElem);
- xsltRegisterExtElement(ctxt, (const xmlChar *) "document",
- XSLT_XT_NAMESPACE, xsltDocumentElem);
- xsltRegisterExtElement(ctxt, (const xmlChar *) "document",
- XSLT_NAMESPACE, xsltDocumentElem);
+ xsltRegisterExtModuleElement((const xmlChar *) "debug",
+ XSLT_LIBXSLT_NAMESPACE,
+ NULL,
+ (xsltTransformFunction) xsltDebug);
+ xsltRegisterExtModuleElement((const xmlChar *) "output",
+ XSLT_SAXON_NAMESPACE,
+ xsltDocumentComp,
+ (xsltTransformFunction) xsltDocumentElem);
+ xsltRegisterExtModuleElement((const xmlChar *) "write",
+ XSLT_XALAN_NAMESPACE,
+ xsltDocumentComp,
+ (xsltTransformFunction) xsltDocumentElem);
+ xsltRegisterExtModuleElement((const xmlChar *) "document",
+ XSLT_XT_NAMESPACE,
+ xsltDocumentComp,
+ (xsltTransformFunction) xsltDocumentElem);
+ xsltRegisterExtModuleElement((const xmlChar *) "document",
+ XSLT_NAMESPACE,
+ xsltDocumentComp,
+ (xsltTransformFunction) xsltDocumentElem);
}
void xsltFunctionNodeSet (xmlXPathParserContextPtr ctxt,
int nargs);
-
-void xsltRegisterExtras (xsltTransformContextPtr ctxt);
-
-
void xsltDebug (xsltTransformContextPtr ctxt,
xmlNodePtr node,
xmlNodePtr inst,
xsltStylePreCompPtr comp);
+
+
+void xsltRegisterExtras (xsltTransformContextPtr ctxt);
+void xsltRegisterAllExtras (void);
+
#ifdef __cplusplus
}
#endif
*/
#define XSLT_REGISTER_FUNCTION_LOOKUP(ctxt) \
xmlXPathRegisterFuncLookup((ctxt)->xpathCtxt, \
- xsltXPathFunctionLookup, (void *)(ctxt->xpathCtxt));
+ (xmlXPathFuncLookupFunc) xsltXPathFunctionLookup, \
+ (void *)(ctxt->xpathCtxt));
xmlXPathFunction
xsltXPathFunctionLookup (xmlXPathContextPtr ctxt,
cur->type = type;
switch (cur->type) {
case XSLT_FUNC_COPY:
- cur->func = xsltCopy;break;
+ cur->func = (xsltTransformFunction) xsltCopy;break;
case XSLT_FUNC_SORT:
- cur->func = xsltSort;break;
+ cur->func = (xsltTransformFunction) xsltSort;break;
case XSLT_FUNC_TEXT:
- cur->func = xsltText;break;
+ cur->func = (xsltTransformFunction) xsltText;break;
case XSLT_FUNC_ELEMENT:
- cur->func = xsltElement;break;
+ cur->func = (xsltTransformFunction) xsltElement;break;
case XSLT_FUNC_ATTRIBUTE:
- cur->func = xsltAttribute;break;
+ cur->func = (xsltTransformFunction) xsltAttribute;break;
case XSLT_FUNC_COMMENT:
- cur->func = xsltComment;break;
+ cur->func = (xsltTransformFunction) xsltComment;break;
case XSLT_FUNC_PI:
- cur->func = xsltProcessingInstruction;break;
+ cur->func = (xsltTransformFunction) xsltProcessingInstruction;
+ break;
case XSLT_FUNC_COPYOF:
- cur->func = xsltCopyOf;break;
+ cur->func = (xsltTransformFunction) xsltCopyOf;break;
case XSLT_FUNC_VALUEOF:
- cur->func = xsltValueOf;break;
+ cur->func = (xsltTransformFunction) xsltValueOf;break;
case XSLT_FUNC_NUMBER:
- cur->func = xsltNumber;break;
+ cur->func = (xsltTransformFunction) xsltNumber;break;
case XSLT_FUNC_APPLYIMPORTS:
- cur->func = xsltApplyImports;break;
+ cur->func = (xsltTransformFunction) xsltApplyImports;break;
case XSLT_FUNC_CALLTEMPLATE:
- cur->func = xsltCallTemplate;break;
+ cur->func = (xsltTransformFunction) xsltCallTemplate;break;
case XSLT_FUNC_APPLYTEMPLATES:
- cur->func = xsltApplyTemplates;break;
+ cur->func = (xsltTransformFunction) xsltApplyTemplates;break;
case XSLT_FUNC_CHOOSE:
- cur->func = xsltChoose;break;
+ cur->func = (xsltTransformFunction) xsltChoose;break;
case XSLT_FUNC_IF:
- cur->func = xsltIf;break;
+ cur->func = (xsltTransformFunction) xsltIf;break;
case XSLT_FUNC_FOREACH:
- cur->func = xsltForEach;break;
+ cur->func = (xsltTransformFunction) xsltForEach;break;
case XSLT_FUNC_DOCUMENT:
- cur->func = xsltDocumentElem;break;
+ cur->func = (xsltTransformFunction) xsltDocumentElem;break;
case XSLT_FUNC_WITHPARAM:
cur->func = NULL;break;
case XSLT_FUNC_PARAM:
}
}
cur->next = style->preComps;
- style->preComps = cur;
+ style->preComps = (xsltElemPreCompPtr) cur;
return(cur);
}
*
* Pre process an XSLT-1.1 document element
*/
-static void
-xsltDocumentComp(xsltStylesheetPtr style, xmlNodePtr inst) {
+xsltElemPreCompPtr
+xsltDocumentComp(xsltStylesheetPtr style, xmlNodePtr inst,
+ xsltTransformFunction function ATTRIBUTE_UNUSED) {
xsltStylePreCompPtr comp;
xmlChar *filename = NULL;
xmlChar *base = NULL;
comp = xsltNewStylePreComp(style, XSLT_FUNC_DOCUMENT);
if (comp == NULL)
- return;
- inst->_private = comp;
+ return (NULL);
comp->inst = inst;
comp->ver11 = 0;
xmlFree(base);
if (filename != NULL)
xmlFree(filename);
+
+ return ((xsltElemPreCompPtr) comp);
}
/************************************************************************
*/
void
xsltFreeStylePreComps(xsltStylesheetPtr style) {
- xsltStylePreCompPtr cur, next;
+ xsltElemPreCompPtr cur, next;
if (style == NULL)
return;
while (cur != NULL) {
next = cur->next;
if (cur->type == XSLT_FUNC_EXTENSION)
- ((xsltElemPreCompPtr)cur)->free(cur);
+ cur->free(cur);
else
- xsltFreeStylePreComp(cur);
+ xsltFreeStylePreComp((xsltStylePreCompPtr) cur);
cur = next;
}
}
/* no computation needed */
return;
} else if (IS_XSLT_NAME(inst, "document")) {
- xsltDocumentComp(style, inst);
+ inst->_private = (void *) xsltDocumentComp(style, inst,
+ (xsltTransformFunction) xsltDocumentElem);
} else {
xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericDebugContext,
* Add the namespace lookup here, this code can be shared by
* all precomputations.
*/
- cur = inst->_private;
+ cur = (xsltStylePreCompPtr) inst->_private;
if (cur != NULL) {
int i = 0;
cur->nsNr = i;
}
} else {
- /* FIXME */
- if (IS_XSLT_NAME(inst, "document")) {
- xsltDocumentComp(style, inst);
- } else {
- inst->_private =
- (void *) xsltPreComputeExtModuleElement(style, inst);
-
- /*
- * Unknown element, maybe registered at the context
- * level. Mark it for later recognition.
- */
- if (inst->_private == NULL)
- inst->_private = (void *) xsltExtMarker;
- }
+ inst->_private =
+ (void *) xsltPreComputeExtModuleElement(style, inst);
+
+ /*
+ * Unknown element, maybe registered at the context
+ * level. Mark it for later recognition.
+ */
+ if (inst->_private == NULL)
+ inst->_private = (void *) xsltExtMarker;
}
}
*/
extern const xmlChar *xsltExtMarker;
+xsltElemPreCompPtr
+ xsltDocumentComp (xsltStylesheetPtr style,
+ xmlNodePtr inst,
+ xsltTransformFunction function);
+
void xsltStylePreCompute (xsltStylesheetPtr style,
xmlNodePtr inst);
void xsltFreeStylePreComps (xsltStylesheetPtr style);
if (info->func != NULL) {
ctxt->insert = insert;
- info->func(ctxt, node, cur, info);
+ info->func(ctxt, node, cur, (xsltElemPreCompPtr) info);
ctxt->insert = oldInsert;
goto skip_children;
}
if (profile != NULL)
ctxt->profile = 1;
- xsltRegisterExtras(ctxt);
if (output != NULL)
ctxt->outputFile = output;
else
xsltRegisterAllElement(xsltTransformContextPtr ctxt)
{
xsltRegisterExtElement(ctxt, (const xmlChar *) "apply-templates",
- XSLT_NAMESPACE, xsltApplyTemplates);
+ XSLT_NAMESPACE,
+ (xsltTransformFunction) xsltApplyTemplates);
xsltRegisterExtElement(ctxt, (const xmlChar *) "apply-imports",
- XSLT_NAMESPACE, xsltApplyImports);
+ XSLT_NAMESPACE,
+ (xsltTransformFunction) xsltApplyImports);
xsltRegisterExtElement(ctxt, (const xmlChar *) "call-template",
- XSLT_NAMESPACE, xsltCallTemplate);
+ XSLT_NAMESPACE,
+ (xsltTransformFunction) xsltCallTemplate);
xsltRegisterExtElement(ctxt, (const xmlChar *) "element",
- XSLT_NAMESPACE, xsltElement);
+ XSLT_NAMESPACE,
+ (xsltTransformFunction) xsltElement);
xsltRegisterExtElement(ctxt, (const xmlChar *) "attribute",
- XSLT_NAMESPACE, xsltAttribute);
+ XSLT_NAMESPACE,
+ (xsltTransformFunction) xsltAttribute);
xsltRegisterExtElement(ctxt, (const xmlChar *) "text",
- XSLT_NAMESPACE, xsltText);
+ XSLT_NAMESPACE,
+ (xsltTransformFunction) xsltText);
xsltRegisterExtElement(ctxt, (const xmlChar *) "processing-instruction",
- XSLT_NAMESPACE, xsltProcessingInstruction);
+ XSLT_NAMESPACE,
+ (xsltTransformFunction) xsltProcessingInstruction);
xsltRegisterExtElement(ctxt, (const xmlChar *) "comment",
- XSLT_NAMESPACE, xsltComment);
+ XSLT_NAMESPACE,
+ (xsltTransformFunction) xsltComment);
xsltRegisterExtElement(ctxt, (const xmlChar *) "copy",
- XSLT_NAMESPACE, xsltCopy);
+ XSLT_NAMESPACE,
+ (xsltTransformFunction) xsltCopy);
xsltRegisterExtElement(ctxt, (const xmlChar *) "value-of",
- XSLT_NAMESPACE, xsltValueOf);
+ XSLT_NAMESPACE,
+ (xsltTransformFunction) xsltValueOf);
xsltRegisterExtElement(ctxt, (const xmlChar *) "number",
- XSLT_NAMESPACE, xsltNumber);
+ XSLT_NAMESPACE,
+ (xsltTransformFunction) xsltNumber);
xsltRegisterExtElement(ctxt, (const xmlChar *) "for-each",
- XSLT_NAMESPACE, xsltForEach);
+ XSLT_NAMESPACE,
+ (xsltTransformFunction) xsltForEach);
xsltRegisterExtElement(ctxt, (const xmlChar *) "if",
- XSLT_NAMESPACE, xsltIf);
+ XSLT_NAMESPACE,
+ (xsltTransformFunction) xsltIf);
xsltRegisterExtElement(ctxt, (const xmlChar *) "choose",
- XSLT_NAMESPACE, xsltChoose);
+ XSLT_NAMESPACE,
+ (xsltTransformFunction) xsltChoose);
xsltRegisterExtElement(ctxt, (const xmlChar *) "sort",
- XSLT_NAMESPACE, xsltSort);
+ XSLT_NAMESPACE,
+ (xsltTransformFunction) xsltSort);
xsltRegisterExtElement(ctxt, (const xmlChar *) "copy-of",
- XSLT_NAMESPACE, xsltCopyOf);
+ XSLT_NAMESPACE,
+ (xsltTransformFunction) xsltCopyOf);
xsltRegisterExtElement(ctxt, (const xmlChar *) "message",
XSLT_NAMESPACE,
(xsltTransformFunction) xsltMessage);
* Those don't have callable entry points but are registered anyway
*/
xsltRegisterExtElement(ctxt, (const xmlChar *) "variable",
- XSLT_NAMESPACE, xsltDebug);
+ XSLT_NAMESPACE,
+ (xsltTransformFunction) xsltDebug);
xsltRegisterExtElement(ctxt, (const xmlChar *) "param",
- XSLT_NAMESPACE, xsltDebug);
+ XSLT_NAMESPACE,
+ (xsltTransformFunction) xsltDebug);
xsltRegisterExtElement(ctxt, (const xmlChar *) "with-param",
- XSLT_NAMESPACE, xsltDebug);
+ XSLT_NAMESPACE,
+ (xsltTransformFunction) xsltDebug);
xsltRegisterExtElement(ctxt, (const xmlChar *) "decimal-format",
- XSLT_NAMESPACE, xsltDebug);
+ XSLT_NAMESPACE,
+ (xsltTransformFunction) xsltDebug);
xsltRegisterExtElement(ctxt, (const xmlChar *) "when",
- XSLT_NAMESPACE, xsltDebug);
+ XSLT_NAMESPACE,
+ (xsltTransformFunction) xsltDebug);
xsltRegisterExtElement(ctxt, (const xmlChar *) "otherwise",
- XSLT_NAMESPACE, xsltDebug);
+ XSLT_NAMESPACE,
+ (xsltTransformFunction) xsltDebug);
xsltRegisterExtElement(ctxt, (const xmlChar *) "fallback",
- XSLT_NAMESPACE, xsltDebug);
+ XSLT_NAMESPACE,
+ (xsltTransformFunction) xsltDebug);
}
#include "documents.h"
#include "extensions.h"
#include "preproc.h"
+#include "extra.h"
#ifdef WITH_XSLT_DEBUG
#define WITH_XSLT_DEBUG_PARSING
************************************************************************/
/**
+ * xsltInit:
+ *
+ * Initializes the processor (e.g. registers built-in extensions,
+ * etc.)
+ */
+static void
+xsltInit (void) {
+ static int initialized = 0;
+
+ if (initialized == 0) {
+ initialized = 1;
+ xsltRegisterAllExtras();
+ }
+}
+
+/**
* xsltIsBlank:
* @str: a string
*
cur->exclPrefixMax = 0;
cur->exclPrefixTab = NULL;
cur->extInfos = NULL;
+
+ xsltInit();
+
return(cur);
}
}
return(ret);
}
-
/*
* Precomputed blocks
*/
- xsltStylePreCompPtr preComps; /* list of precomputed blocks */
+ xsltElemPreCompPtr preComps;/* list of precomputed blocks */
int warnings; /* number of warnings found at compilation */
int errors; /* number of errors found at compilation */