summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2002-05-30 21:36:59 +0000
committerDaniel Veillard <veillard@src.gnome.org>2002-05-30 21:36:59 +0000
commit765957430fd4b748c2d8f70ee546308fad4359f8 (patch)
tree0bfb731b03dab66fedac30a14387f416d3b75699
parent52a0b2ad40bcde4926878b6260f02d052944b61f (diff)
downloadlibxslt-765957430fd4b748c2d8f70ee546308fad4359f8.tar.gz
libxslt-765957430fd4b748c2d8f70ee546308fad4359f8.tar.bz2
libxslt-765957430fd4b748c2d8f70ee546308fad4359f8.zip
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
-rw-r--r--ChangeLog8
-rw-r--r--libexslt/Makefile.am3
-rw-r--r--libexslt/date.c6
-rw-r--r--libexslt/dynamic.c96
-rw-r--r--libexslt/exslt.c1
-rw-r--r--libexslt/exslt.h2
-rw-r--r--win32/Makefile.msvc5
7 files changed, 115 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index b70ce945..8c640753 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Thu May 30 23:35:47 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+ * 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 <daniel@veillard.com>
* configure.in: preparing 1.0.18
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);
diff --git a/win32/Makefile.msvc b/win32/Makefile.msvc
index 6bf5f49a..06deaec8 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 :-)