mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-08-07 06:43:02 +03:00
added a function lookup framework
* xpath.c include/libxml/xpath{,Internals}.h: added a function lookup framework
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
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>
|
Fri Jul 27 01:50:20 EDT 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
||||||
|
|
||||||
* tree.c: fixed xmlCopyNode() for documents
|
* tree.c: fixed xmlCopyNode() for documents
|
||||||
|
@@ -231,6 +231,10 @@ struct _xmlXPathContext {
|
|||||||
/* The function name and URI when calling a function */
|
/* The function name and URI when calling a function */
|
||||||
const xmlChar *function;
|
const xmlChar *function;
|
||||||
const xmlChar *functionURI;
|
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,
|
xmlXPathVariableLookupFunc f,
|
||||||
void *varCtxt);
|
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
|
* Error reporting
|
||||||
*/
|
*/
|
||||||
|
43
xpath.c
43
xpath.c
@@ -2309,6 +2309,24 @@ xmlXPathRegisterFuncNS(xmlXPathContextPtr ctxt, const xmlChar *name,
|
|||||||
return(xmlHashAddEntry2(ctxt->funcHash, name, ns_uri, (void *) f));
|
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:
|
* xmlXPathFunctionLookup:
|
||||||
* @ctxt: the XPath context
|
* @ctxt: the XPath context
|
||||||
@@ -2321,6 +2339,17 @@ xmlXPathRegisterFuncNS(xmlXPathContextPtr ctxt, const xmlChar *name,
|
|||||||
*/
|
*/
|
||||||
xmlXPathFunction
|
xmlXPathFunction
|
||||||
xmlXPathFunctionLookup(xmlXPathContextPtr ctxt, const xmlChar *name) {
|
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));
|
return(xmlXPathFunctionLookupNS(ctxt, name, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2340,11 +2369,21 @@ xmlXPathFunctionLookupNS(xmlXPathContextPtr ctxt, const xmlChar *name,
|
|||||||
const xmlChar *ns_uri) {
|
const xmlChar *ns_uri) {
|
||||||
if (ctxt == NULL)
|
if (ctxt == NULL)
|
||||||
return(NULL);
|
return(NULL);
|
||||||
if (ctxt->funcHash == NULL)
|
|
||||||
return(NULL);
|
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
return(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));
|
return((xmlXPathFunction) xmlHashLookup2(ctxt->funcHash, name, ns_uri));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user