#define IS_TZO_CHAR(c) \
((c == 0) || (c == 'Z') || (c == '+') || (c == '-'))
-#define TZO_SECS(tm) (tm->tm_isdst > 0 ? 3600 : 0)
-
#define VALID_YEAR(yr) (yr != 0)
-/* months are stored as 0 - 11 */
#define VALID_MONTH(mon) ((mon >= 1) && (mon <= 12))
/* VALID_DAY should only be used when month is unknown */
#define VALID_DAY(day) ((day >= 1) && (day <= 31))
static exsltDatePtr
exsltDateCurrent (void) {
struct tm *localTm, *gmTm;
- time_t tzSecs, secs;
+ time_t secs;
exsltDatePtr ret;
ret = exsltDateCreateDate();
if (ret == NULL)
- return NULL;
+ return NULL;
/* get current time */
secs = time(NULL);
/* get real year, not years since 1900 */
ret->year = localTm->tm_year + 1900;
- ret->mon = localTm->tm_mon + 1;
- ret->day = localTm->tm_mday;
+ ret->mon = localTm->tm_mon + 1;
+ ret->day = localTm->tm_mday;
ret->hour = localTm->tm_hour;
- ret->min = localTm->tm_min;
+ ret->min = localTm->tm_min;
/* floating point seconds */
- ret->sec = (double) localTm->tm_sec;
+ ret->sec = (double) localTm->tm_sec;
/* determine the time zone offset from local to gm time */
gmTm = gmtime(&secs);
- tzSecs = mktime(gmTm) - secs;
ret->tz_flag = 0;
- ret->tzo = -(tzSecs - TZO_SECS(localTm)) / 60;
+ ret->tzo = -(((ret->day - gmTm->tm_mday) * 1440) +
+ ((ret->hour - gmTm->tm_hour) * 60) +
+ (ret->min - gmTm->tm_min));
return ret;
}
}
}
-/**
- * xsltFunctionEvaluate:
- * @ctxt: the XPath Parser context
- * @nargs: the number of arguments
- *
- * Implement the evaluate() XSLT function
- * node-set evaluate(string)
- *
- * This function is available in libxslt or saxon namespace.
- */
-void
-xsltFunctionEvaluate(xmlXPathParserContextPtr ctxt, int nargs){
- xsltTransformContextPtr tctxt;
- xmlXPathObjectPtr obj, ret;
- xmlXPathCompExprPtr comp;
-
- if (nargs != 1) {
- xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
- "evaluate() : expects one string arg\n");
- ctxt->error = XPATH_INVALID_ARITY;
- return;
- }
-
- obj = valuePop(ctxt);
- if (obj->type != XPATH_STRING) {
- obj = xmlXPathConvertString(obj);
- }
-
- if (obj->stringval == NULL) {
- valuePush(ctxt, xmlXPathNewNodeSet(NULL));
- }
- else {
- tctxt = xsltXPathGetTransformContext(ctxt);
- comp = xmlXPathCompile(obj->stringval);
- ret = xmlXPathCompiledEval(comp,
- tctxt->xpathCtxt);
- valuePush(ctxt, ret);
- xmlXPathFreeCompExpr(comp);
- }
- xmlXPathFreeObject(obj);
-}
-
-/**
- * xsltFunctionExpression:
- * @ctxt: the XPath Parser context
- * @nargs: the number of arguments
- *
- * Implement the evaluate() XSLT function
- * stored-expression expression(string)
- *
- * This function is available in libxslt or saxon namespace.
- */
-void
-xsltFunctionExpression(xmlXPathParserContextPtr ctxt, int nargs){
- xsltTransformContextPtr tctxt;
- xmlXPathObjectPtr obj, ret;
- xmlXPathCompExprPtr comp;
-
- if (nargs != 1) {
- xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
- "expression() : expects one string arg\n");
- ctxt->error = XPATH_INVALID_ARITY;
- return;
- }
-
- obj = valuePop(ctxt);
- if (obj->type != XPATH_STRING) {
- obj = xmlXPathConvertString(obj);
- }
-
- if (obj->stringval == NULL) {
- xsltGenericError(xsltGenericErrorContext,
- "expression() : invalid string arg\n");
- ctxt->error = XPATH_INVALID_TYPE;
- return;
- }
- else {
- tctxt = xsltXPathGetTransformContext(ctxt);
- comp = xmlXPathCompile(obj->stringval);
- if(comp != NULL) {
- ret = xmlXPathNewString(obj->stringval);
- ret->user = comp;
- valuePush(ctxt, ret);
- }
- }
- xmlXPathFreeObject(obj);
-}
-
-/**
- * xsltFunctionEval:
- * @ctxt: the XPath Parser context
- * @nargs: the number of arguments
- *
- * Implement the eval() XSLT function
- * node-set eval(stored-expression)
- *
- * This function is available in libxslt or saxon namespace.
- */
-void
-xsltFunctionEval(xmlXPathParserContextPtr ctxt, int nargs){
- xsltTransformContextPtr tctxt;
- xmlXPathObjectPtr obj, ret;
- xmlXPathCompExprPtr comp;
-
- if (nargs != 1) {
- xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
- "eval() : expects one compiled xpath expr\n");
- ctxt->error = XPATH_INVALID_ARITY;
- return;
- }
-
- obj = valuePop(ctxt);
- if (obj->type != XPATH_STRING ||
- obj->user == NULL) {
- xsltGenericError(xsltGenericErrorContext,
- "eval() : invalid arg expecting compiled xpath expr\n");
- ctxt->error = XPATH_INVALID_ARITY;
- }
-
- tctxt = xsltXPathGetTransformContext(ctxt);
- comp = obj->user;
- ret = xmlXPathCompiledEval(comp,
- tctxt->xpathCtxt);
- valuePush(ctxt, ret);
- xmlXPathFreeObject(obj);
-}
-
-
/*
* Okay the following really seems unportable and since it's not
xsltRegisterExtModuleFunction((const xmlChar *) "node-set",
XSLT_XT_NAMESPACE,
xsltFunctionNodeSet);
- xsltRegisterExtModuleFunction((const xmlChar *) "evaluate",
- XSLT_LIBXSLT_NAMESPACE,
- xsltFunctionEvaluate);
- xsltRegisterExtModuleFunction((const xmlChar *) "evaluate",
- XSLT_SAXON_NAMESPACE,
- xsltFunctionEvaluate);
- xsltRegisterExtModuleFunction((const xmlChar *) "expression",
- XSLT_LIBXSLT_NAMESPACE,
- xsltFunctionExpression);
- xsltRegisterExtModuleFunction((const xmlChar *) "expression",
- XSLT_SAXON_NAMESPACE,
- xsltFunctionExpression);
- xsltRegisterExtModuleFunction((const xmlChar *) "eval",
- XSLT_LIBXSLT_NAMESPACE,
- xsltFunctionEval);
- xsltRegisterExtModuleFunction((const xmlChar *) "eval",
- XSLT_SAXON_NAMESPACE,
- xsltFunctionEval);
#ifdef WITH_LOCALTIME
xsltRegisterExtModuleFunction((const xmlChar *) "localTime",
XSLT_NORM_SAXON_NAMESPACE,