diff options
Diffstat (limited to 'libexslt')
-rw-r--r-- | libexslt/Makefile.am | 3 | ||||
-rw-r--r-- | libexslt/date.c | 6 | ||||
-rw-r--r-- | libexslt/dynamic.c | 96 | ||||
-rw-r--r-- | libexslt/exslt.c | 1 | ||||
-rw-r--r-- | libexslt/exslt.h | 2 |
5 files changed, 103 insertions, 5 deletions
diff --git a/libexslt/Makefile.am b/libexslt/Makefile.am index 059f3e3d..c520580d 100644 --- a/libexslt/Makefile.am +++ b/libexslt/Makefile.am @@ -21,7 +21,8 @@ libexslt_la_SOURCES = \ strings.c \ date.c \ saxon.c \ - libexslt.h + libexslt.h \ + dynamic.c # The following DOES NOT WORK reliably. Sorry no prelinking to uninstalled # yet libraries. diff --git a/libexslt/date.c b/libexslt/date.c index fcd2d2f7..a99c501b 100644 --- a/libexslt/date.c +++ b/libexslt/date.c @@ -39,14 +39,12 @@ #include "exslt.h" +#include <string.h> + #ifdef HAVE_TIME_H #include <time.h> #endif -#ifdef HAVE_STRING_H -#include <string.h> -#endif - #ifdef HAVE_MATH_H #include <math.h> #endif diff --git a/libexslt/dynamic.c b/libexslt/dynamic.c new file mode 100644 index 00000000..c3443dcc --- /dev/null +++ b/libexslt/dynamic.c @@ -0,0 +1,96 @@ +/* + * dynamic.c: Implementation of the EXSLT -- Dynamic module + * + * References: + * http://www.exslt.org/dyn/dyn.html + * + * See Copyright for the status of this software. + * + * Authors: + * Mark Vakoc <mark_vakoc@jdedwards.com> + * Thomas Broyer <tbroyer@ltgt.net> + * + * TODO: + * elements: + * functions: + * min + * max + * sum + * map + * closure + */ + +#define IN_LIBEXSLT +#include "libexslt/libexslt.h" + +#if defined(WIN32) && !defined (__CYGWIN__) +#include <win32config.h> +#else +#include "config.h" +#endif + +#include <libxml/tree.h> +#include <libxml/xpath.h> +#include <libxml/xpathInternals.h> + +#include <libxslt/xsltconfig.h> +#include <libxslt/xsltutils.h> +#include <libxslt/xsltInternals.h> +#include <libxslt/extensions.h> + +#include "exslt.h" + +/** + * exsltDynEvaluateFunction: + * @ctxt: an XPath parser context + * @nargs: the number of arguments + * + * Evaluates the string as an XPath expression and returns the result + * value, which may be a boolean, number, string, node set, result tree + * fragment or external object. + */ + +void +exsltDynEvaluateFunction(xmlXPathParserContextPtr ctxt, int nargs) { + xmlChar *str = NULL; + xmlXPathObjectPtr ret = NULL; + + if (ctxt == NULL) + return; + if (nargs != 1) { + xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL); + xsltGenericError(xsltGenericErrorContext, + "dyn:evalute() : invalid number of args %d\n", nargs); + ctxt->error = XPATH_INVALID_ARITY; + return; + } + str = xmlXPathPopString(ctxt); + /* return an empty node-set if an empty string is passed in */ + if (!str||!xmlStrlen(str)) { + if (str) xmlFree(str); + valuePush(ctxt,xmlXPathNewNodeSet(NULL)); + return; + } + ret = xmlXPathEval(str,ctxt->context); + if (ret) + valuePush(ctxt,ret); + else { + xsltGenericError(xsltGenericErrorContext, + "dyn:evaluate() : unable to evaluate expression '%s'\n",str); + valuePush(ctxt,xmlXPathNewNodeSet(NULL)); + } + xmlFree(str); + return; +} +/** + * exsltDynRegister: + * + * Registers the EXSLT - Dynamic module + */ + +void +exsltDynRegister (void) { + xsltRegisterExtModuleFunction ((const xmlChar *) "evaluate", + EXSLT_DYNAMIC_NAMESPACE, + exsltDynEvaluateFunction); +} diff --git a/libexslt/exslt.c b/libexslt/exslt.c index 9544cb32..d46cefca 100644 --- a/libexslt/exslt.c +++ b/libexslt/exslt.c @@ -38,5 +38,6 @@ exsltRegisterAll (void) { exsltStrRegister(); exsltDateRegister(); exsltSaxonRegister(); + exsltDynRegister(); } diff --git a/libexslt/exslt.h b/libexslt/exslt.h index d858949f..c53d8ff1 100644 --- a/libexslt/exslt.h +++ b/libexslt/exslt.h @@ -21,6 +21,7 @@ LIBEXSLT_PUBLIC extern const int exsltLibxmlVersion; #define EXSLT_STRINGS_NAMESPACE ((const xmlChar *) "http://exslt.org/strings") #define EXSLT_DATE_NAMESPACE ((const xmlChar *) "http://exslt.org/dates-and-times") #define SAXON_NAMESPACE ((const xmlChar *) "http://icl.com/saxon") +#define EXSLT_DYNAMIC_NAMESPACE ((const xmlChar *) "http://exslt.org/dynamic") void LIBEXSLT_PUBLIC exsltCommonRegister (void); void LIBEXSLT_PUBLIC exsltMathRegister (void); @@ -29,6 +30,7 @@ void LIBEXSLT_PUBLIC exsltFuncRegister (void); void LIBEXSLT_PUBLIC exsltStrRegister (void); void LIBEXSLT_PUBLIC exsltDateRegister (void); void LIBEXSLT_PUBLIC exsltSaxonRegister (void); +void LIBEXSLT_PUBLIC exsltDynRegister(void); void LIBEXSLT_PUBLIC exsltRegisterAll (void); |