From 765957430fd4b748c2d8f70ee546308fad4359f8 Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Thu, 30 May 2002 21:36:59 +0000 Subject: [PATCH] applied a patch from Mark Vakoc to implement the EXSLT object * win32/Makefile.msvc libexslt/Makefile.am libexslt/date.c libexslt/dynamic.c libexslt/exslt.c libexslt/exslt.h: applied a patch from Mark Vakoc to implement the EXSLT object dyn:evaluate(string) extension function, and a small fix to date.c Daniel --- ChangeLog | 8 +++++ libexslt/Makefile.am | 3 +- libexslt/date.c | 6 ++-- libexslt/dynamic.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++ libexslt/exslt.c | 1 + libexslt/exslt.h | 2 ++ win32/Makefile.msvc | 5 ++- 7 files changed, 115 insertions(+), 6 deletions(-) create mode 100644 libexslt/dynamic.c diff --git a/ChangeLog b/ChangeLog index b70ce94..8c64075 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Thu May 30 23:35:47 CEST 2002 Daniel Veillard + + * win32/Makefile.msvc libexslt/Makefile.am libexslt/date.c + libexslt/dynamic.c libexslt/exslt.c libexslt/exslt.h: applied + a patch from Mark Vakoc to implement the EXSLT + object dyn:evaluate(string) extension function, and a small fix + to date.c + Mon May 27 23:24:57 CEST 2002 Daniel Veillard * configure.in: preparing 1.0.18 diff --git a/libexslt/Makefile.am b/libexslt/Makefile.am index 059f3e3..c520580 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 fcd2d2f..a99c501 100644 --- a/libexslt/date.c +++ b/libexslt/date.c @@ -39,14 +39,12 @@ #include "exslt.h" +#include + #ifdef HAVE_TIME_H #include #endif -#ifdef HAVE_STRING_H -#include -#endif - #ifdef HAVE_MATH_H #include #endif diff --git a/libexslt/dynamic.c b/libexslt/dynamic.c new file mode 100644 index 0000000..c3443dc --- /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 + * Thomas Broyer + * + * TODO: + * elements: + * functions: + * min + * max + * sum + * map + * closure + */ + +#define IN_LIBEXSLT +#include "libexslt/libexslt.h" + +#if defined(WIN32) && !defined (__CYGWIN__) +#include +#else +#include "config.h" +#endif + +#include +#include +#include + +#include +#include +#include +#include + +#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 9544cb3..d46cefc 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 d858949..c53d8ff 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); diff --git a/win32/Makefile.msvc b/win32/Makefile.msvc index 6bf5f49..06deaec 100644 --- a/win32/Makefile.msvc +++ b/win32/Makefile.msvc @@ -125,7 +125,9 @@ EXSLT_OBJS = $(EXSLT_INTDIR)\common.obj\ $(EXSLT_INTDIR)\math.obj\ $(EXSLT_INTDIR)\saxon.obj\ $(EXSLT_INTDIR)\sets.obj\ - $(EXSLT_INTDIR)\strings.obj + $(EXSLT_INTDIR)\strings.obj\ + $(EXSLT_INTDIR)\dynamic.obj + # Xsltproc and friends executables. UTILS = $(BINDIR)\xsltproc.exe @@ -160,6 +162,7 @@ install : all copy $(BINDIR)\$(EXSLT_A) $(LIBPREFIX) copy $(BINDIR)\$(EXSLT_IMP) $(LIBPREFIX) copy $(BINDIR)\*.exe $(BINPREFIX) + copy $(BINDIR)\*.pdb $(BINPREFIX) # This is a target for me, to make a binary distribution. Not for the public use, # keep your hands off :-) -- 2.7.4