Commit ba4ad326 authored by Thomas Broyer's avatar Thomas Broyer

added a function lookup framework


	* xpath.c include/libxml/xpath{,Internals}.h: added a function
	  lookup framework
parent 1d0bfab3
Thu Jul 26 18:55:52 CEST 2001 Thomas Broyer <tbroyer@ltgt.net>
* xpath.c include/libxml/xpath{,Internals}.h: added a function
lookup framework
Fri Jul 27 01:50:20 EDT 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* tree.c: fixed xmlCopyNode() for documents
......
......@@ -231,6 +231,10 @@ struct _xmlXPathContext {
/* The function name and URI when calling a function */
const xmlChar *function;
const xmlChar *functionURI;
/* function lookup function and data */
void *funcLookupFunc; /* function lookup func */
void *funcLookupData; /* function lookup data */
};
/*
......
......@@ -319,6 +319,18 @@ void xmlXPathRegisterVariableLookup (xmlXPathContextPtr ctxt,
xmlXPathVariableLookupFunc f,
void *varCtxt);
/*
* Function Lookup forwarding
*/
typedef xmlXPathFunction
(*xmlXPathFuncLookupFunc) (void *ctxt,
const xmlChar *name,
const xmlChar *ns_uri);
void xmlXPathRegisterFuncLookup (xmlXPathContextPtr ctxt,
xmlXPathFuncLookupFunc f,
void *funcCtxt);
/*
* Error reporting
*/
......
......@@ -2309,6 +2309,24 @@ xmlXPathRegisterFuncNS(xmlXPathContextPtr ctxt, const xmlChar *name,
return(xmlHashAddEntry2(ctxt->funcHash, name, ns_uri, (void *) f));
}
/**
* xmlXPathRegisterFuncLookup:
* @ctxt: the XPath context
* @f: the lookup function
* @data: the lookup data
*
* Registers an external mecanism to do function lookup.
*/
void
xmlXPathRegisterFuncLookup (xmlXPathContextPtr ctxt,
xmlXPathFuncLookupFunc f,
void *funcCtxt) {
if (ctxt == NULL)
return;
ctxt->funcLookupFunc = (void *) f;
ctxt->funcLookupData = funcCtxt;
}
/**
* xmlXPathFunctionLookup:
* @ctxt: the XPath context
......@@ -2321,6 +2339,17 @@ xmlXPathRegisterFuncNS(xmlXPathContextPtr ctxt, const xmlChar *name,
*/
xmlXPathFunction
xmlXPathFunctionLookup(xmlXPathContextPtr ctxt, const xmlChar *name) {
if (ctxt == NULL)
return (NULL);
if (ctxt->funcLookupFunc != NULL) {
xmlXPathFunction ret;
ret = ((xmlXPathFuncLookupFunc) ctxt->funcLookupFunc)
(ctxt->funcLookupData, name, NULL);
if (ret != NULL)
return(ret);
}
return(xmlXPathFunctionLookupNS(ctxt, name, NULL));
}
......@@ -2340,11 +2369,21 @@ xmlXPathFunctionLookupNS(xmlXPathContextPtr ctxt, const xmlChar *name,
const xmlChar *ns_uri) {
if (ctxt == NULL)
return(NULL);
if (ctxt->funcHash == NULL)
return(NULL);
if (name == NULL)
return(NULL);
if (ctxt->funcLookupFunc != NULL) {
xmlXPathFunction ret;
ret = ((xmlXPathFuncLookupFunc) ctxt->funcLookupFunc)
(ctxt->funcLookupData, name, ns_uri);
if (ret != NULL)
return(ret);
}
if (ctxt->funcHash == NULL)
return(NULL);
return((xmlXPathFunction) xmlHashLookup2(ctxt->funcHash, name, ns_uri));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment