Commit 8f4d9757 authored by Daniel Veillard's avatar Daniel Veillard
Browse files

added xmlXPathRegisterVariableLookup() for XSLT Daniel

* xpath.[ch] xpathInternals.h: added xmlXPathRegisterVariableLookup() for XSLT
Daniel
parent d8aa7cbd
Fri Jan 19 06:30:38 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* xpath.[ch] xpathInternals.h: added xmlXPathRegisterVariableLookup()
for XSLT
Thu Jan 18 16:19:47 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* xmlIO.c: Gary Pennington <Gary.Pennington@uk.sun.com> fix
......
......@@ -212,6 +212,8 @@ struct _xmlXPathContext {
/* the set of namespace declarations in scope for the expression */
xmlHashTablePtr nsHash; /* The namespaces hash table */
void *varLookupFunc; /* variable lookup func */
void *varLookupData; /* variable lookup data */
};
/*
......
......@@ -56,6 +56,21 @@ extern "C" {
if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_BOOLEAN)) \
xmlXPathBooleanFunction(ctxt, 1);
/*
* Varibale Lookup forwarding
*/
typedef xmlXPathObjectPtr
(*xmlXPathVariableLookupFunc) (void *ctxt,
const xmlChar *name,
const xmlChar *ns_uri);
void xmlXPathRegisterVariableLookup (xmlXPathContextPtr ctxt,
xmlXPathVariableLookupFunc f,
void *varCtxt);
/*
* Error reporting
*/
void xmlXPatherror (xmlXPathParserContextPtr ctxt,
const char *file,
int line,
......@@ -68,6 +83,7 @@ void xmlXPathDebugDumpObject (FILE *output,
/**
* Extending a context
*/
int xmlXPathRegisterNs (xmlXPathContextPtr ctxt,
const xmlChar *prefix,
const xmlChar *ns_uri);
......
......@@ -1011,6 +1011,23 @@ xmlXPathRegisterVariableNS(xmlXPathContextPtr ctxt, const xmlChar *name,
(xmlHashDeallocator)xmlXPathFreeObject));
}
/**
* xmlXPathRegisterVariableLookup:
* @ctxt: the XPath context
* @f: the lookup function
* @data: the lookup data
*
* register an external mechanism to do variable lookup
*/
void
xmlXPathRegisterVariableLookup(xmlXPathContextPtr ctxt,
xmlXPathVariableLookupFunc f, void *data) {
if (ctxt == NULL)
return;
ctxt->varLookupFunc = (void *) f;
ctxt->varLookupData = data;
}
/**
* xmlXPathVariableLookup:
* @ctxt: the XPath context
......@@ -1023,6 +1040,16 @@ xmlXPathRegisterVariableNS(xmlXPathContextPtr ctxt, const xmlChar *name,
*/
xmlXPathObjectPtr
xmlXPathVariableLookup(xmlXPathContextPtr ctxt, const xmlChar *name) {
if (ctxt == NULL)
return(NULL);
if (ctxt->varLookupFunc != NULL) {
xmlXPathObjectPtr ret;
ret = ((xmlXPathVariableLookupFunc)ctxt->varLookupFunc)
(ctxt->varLookupData, name, NULL);
if (ret != NULL) return(ret);
}
return(xmlXPathVariableLookupNS(ctxt, name, NULL));
}
......@@ -1042,6 +1069,15 @@ xmlXPathVariableLookupNS(xmlXPathContextPtr ctxt, const xmlChar *name,
const xmlChar *ns_uri) {
if (ctxt == NULL)
return(NULL);
if (ctxt->varLookupFunc != NULL) {
xmlXPathObjectPtr ret;
ret = ((xmlXPathVariableLookupFunc)ctxt->varLookupFunc)
(ctxt->varLookupData, name, ns_uri);
if (ret != NULL) return(ret);
}
if (ctxt->varHash == NULL)
return(NULL);
if (name == NULL)
......
......@@ -212,6 +212,8 @@ struct _xmlXPathContext {
/* the set of namespace declarations in scope for the expression */
xmlHashTablePtr nsHash; /* The namespaces hash table */
void *varLookupFunc; /* variable lookup func */
void *varLookupData; /* variable lookup data */
};
/*
......
......@@ -56,6 +56,21 @@ extern "C" {
if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_BOOLEAN)) \
xmlXPathBooleanFunction(ctxt, 1);
/*
* Varibale Lookup forwarding
*/
typedef xmlXPathObjectPtr
(*xmlXPathVariableLookupFunc) (void *ctxt,
const xmlChar *name,
const xmlChar *ns_uri);
void xmlXPathRegisterVariableLookup (xmlXPathContextPtr ctxt,
xmlXPathVariableLookupFunc f,
void *varCtxt);
/*
* Error reporting
*/
void xmlXPatherror (xmlXPathParserContextPtr ctxt,
const char *file,
int line,
......@@ -68,6 +83,7 @@ void xmlXPathDebugDumpObject (FILE *output,
/**
* Extending a context
*/
int xmlXPathRegisterNs (xmlXPathContextPtr ctxt,
const xmlChar *prefix,
const xmlChar *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