1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-08-07 06:43:02 +03:00

added xmlXPathRegisterVariableLookup() for XSLT Daniel

* xpath.[ch] xpathInternals.h: added xmlXPathRegisterVariableLookup() for XSLT
Daniel
This commit is contained in:
Daniel Veillard
2001-01-19 05:32:34 +00:00
parent d8aa7cbd18
commit 8f4d97579a
6 changed files with 77 additions and 0 deletions

View File

@@ -1,3 +1,8 @@
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

View File

@@ -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 */
};
/*

View File

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

36
xpath.c
View File

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

View File

@@ -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 */
};
/*

View File

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