diff --git a/ChangeLog b/ChangeLog index b3c5ea08..40566c46 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Jan 19 06:30:38 CET 2001 Daniel Veillard + + * xpath.[ch] xpathInternals.h: added xmlXPathRegisterVariableLookup() + for XSLT + Thu Jan 18 16:19:47 CET 2001 Daniel Veillard * xmlIO.c: Gary Pennington fix diff --git a/include/libxml/xpath.h b/include/libxml/xpath.h index 6f820d4a..ccd2606b 100644 --- a/include/libxml/xpath.h +++ b/include/libxml/xpath.h @@ -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 */ }; /* diff --git a/include/libxml/xpathInternals.h b/include/libxml/xpathInternals.h index 5126dc7d..e277ad05 100644 --- a/include/libxml/xpathInternals.h +++ b/include/libxml/xpathInternals.h @@ -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); diff --git a/xpath.c b/xpath.c index c63266b7..a1d407b5 100644 --- a/xpath.c +++ b/xpath.c @@ -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) diff --git a/xpath.h b/xpath.h index 6f820d4a..ccd2606b 100644 --- a/xpath.h +++ b/xpath.h @@ -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 */ }; /* diff --git a/xpathInternals.h b/xpathInternals.h index 5126dc7d..e277ad05 100644 --- a/xpathInternals.h +++ b/xpathInternals.h @@ -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);