1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-08-01 10:06:59 +03:00

added a function lookup framework

* xpath.c include/libxml/xpath{,Internals}.h: added a function
	  lookup framework
This commit is contained in:
Thomas Broyer
2001-07-26 16:55:21 +00:00
parent 1d0bfab330
commit ba4ad3263b
4 changed files with 62 additions and 2 deletions

43
xpath.c
View File

@ -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));
}