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:
@@ -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>
|
Thu Jan 18 16:19:47 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
||||||
|
|
||||||
* xmlIO.c: Gary Pennington <Gary.Pennington@uk.sun.com> fix
|
* 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 */
|
/* the set of namespace declarations in scope for the expression */
|
||||||
xmlHashTablePtr nsHash; /* The namespaces hash table */
|
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)) \
|
if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_BOOLEAN)) \
|
||||||
xmlXPathBooleanFunction(ctxt, 1);
|
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,
|
void xmlXPatherror (xmlXPathParserContextPtr ctxt,
|
||||||
const char *file,
|
const char *file,
|
||||||
int line,
|
int line,
|
||||||
@@ -68,6 +83,7 @@ void xmlXPathDebugDumpObject (FILE *output,
|
|||||||
/**
|
/**
|
||||||
* Extending a context
|
* Extending a context
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int xmlXPathRegisterNs (xmlXPathContextPtr ctxt,
|
int xmlXPathRegisterNs (xmlXPathContextPtr ctxt,
|
||||||
const xmlChar *prefix,
|
const xmlChar *prefix,
|
||||||
const xmlChar *ns_uri);
|
const xmlChar *ns_uri);
|
||||||
|
36
xpath.c
36
xpath.c
@@ -1011,6 +1011,23 @@ xmlXPathRegisterVariableNS(xmlXPathContextPtr ctxt, const xmlChar *name,
|
|||||||
(xmlHashDeallocator)xmlXPathFreeObject));
|
(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:
|
* xmlXPathVariableLookup:
|
||||||
* @ctxt: the XPath context
|
* @ctxt: the XPath context
|
||||||
@@ -1023,6 +1040,16 @@ xmlXPathRegisterVariableNS(xmlXPathContextPtr ctxt, const xmlChar *name,
|
|||||||
*/
|
*/
|
||||||
xmlXPathObjectPtr
|
xmlXPathObjectPtr
|
||||||
xmlXPathVariableLookup(xmlXPathContextPtr ctxt, const xmlChar *name) {
|
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));
|
return(xmlXPathVariableLookupNS(ctxt, name, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1042,6 +1069,15 @@ xmlXPathVariableLookupNS(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->varLookupFunc != NULL) {
|
||||||
|
xmlXPathObjectPtr ret;
|
||||||
|
|
||||||
|
ret = ((xmlXPathVariableLookupFunc)ctxt->varLookupFunc)
|
||||||
|
(ctxt->varLookupData, name, ns_uri);
|
||||||
|
if (ret != NULL) return(ret);
|
||||||
|
}
|
||||||
|
|
||||||
if (ctxt->varHash == NULL)
|
if (ctxt->varHash == NULL)
|
||||||
return(NULL);
|
return(NULL);
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
|
2
xpath.h
2
xpath.h
@@ -212,6 +212,8 @@ struct _xmlXPathContext {
|
|||||||
|
|
||||||
/* the set of namespace declarations in scope for the expression */
|
/* the set of namespace declarations in scope for the expression */
|
||||||
xmlHashTablePtr nsHash; /* The namespaces hash table */
|
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)) \
|
if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_BOOLEAN)) \
|
||||||
xmlXPathBooleanFunction(ctxt, 1);
|
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,
|
void xmlXPatherror (xmlXPathParserContextPtr ctxt,
|
||||||
const char *file,
|
const char *file,
|
||||||
int line,
|
int line,
|
||||||
@@ -68,6 +83,7 @@ void xmlXPathDebugDumpObject (FILE *output,
|
|||||||
/**
|
/**
|
||||||
* Extending a context
|
* Extending a context
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int xmlXPathRegisterNs (xmlXPathContextPtr ctxt,
|
int xmlXPathRegisterNs (xmlXPathContextPtr ctxt,
|
||||||
const xmlChar *prefix,
|
const xmlChar *prefix,
|
||||||
const xmlChar *ns_uri);
|
const xmlChar *ns_uri);
|
||||||
|
Reference in New Issue
Block a user