Skip to content
Snippets Groups Projects
Commit 8a82ca1ea487 authored by Martin's avatar Martin
Browse files

Allow use of EXSLT outside XSLT

* libexslt/exslt.h libexslt/date.c libexslt/math.c libexslt/sets.c
  libexslt/strings.c: provide registration function for an XPath
  context directly
parent 299bdfa74a2b
No related branches found
No related tags found
No related merge requests found
...@@ -3792,3 +3792,123 @@ ...@@ -3792,3 +3792,123 @@
(const xmlChar *) EXSLT_DATE_NAMESPACE, (const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateYearFunction); exsltDateYearFunction);
} }
/**
* exsltDateXpathCtxtRegister:
*
* Registers the EXSLT - Dates and Times module for use outside XSLT
*/
int
exsltDateXpathCtxtRegister (xmlXPathContextPtr ctxt, const xmlChar *prefix)
{
if (ctxt
&& prefix
&& !xmlXPathRegisterNs(ctxt,
prefix,
(const xmlChar *) EXSLT_DATE_NAMESPACE)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "add",
(const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateAddFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "add-duration",
(const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateAddDurationFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "date",
(const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateDateFunction)
#ifdef WITH_TIME
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "date-time",
(const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateDateTimeFunction)
#endif
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "day-abbreviation",
(const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateDayAbbreviationFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "day-in-month",
(const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateDayInMonthFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "day-in-week",
(const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateDayInWeekFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "day-in-year",
(const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateDayInYearFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "day-name",
(const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateDayNameFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "day-of-week-in-month",
(const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateDayOfWeekInMonthFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "difference",
(const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateDifferenceFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "duration",
(const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateDurationFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "hour-in-day",
(const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateHourInDayFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "leap-year",
(const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateLeapYearFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "minute-in-hour",
(const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateMinuteInHourFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "month-abbreviation",
(const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateMonthAbbreviationFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "month-in-year",
(const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateMonthInYearFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "month-name",
(const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateMonthNameFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "second-in-minute",
(const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateSecondInMinuteFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "seconds",
(const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateSecondsFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "sum",
(const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateSumFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "time",
(const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateTimeFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "week-in-month",
(const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateWeekInMonthFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "week-in-year",
(const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateWeekInYearFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "year",
(const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateYearFunction)) {
return 0;
}
return -1;
}
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#define __EXSLT_H__ #define __EXSLT_H__
#include <libxml/tree.h> #include <libxml/tree.h>
#include <libxml/xpath.h>
#include "exsltexports.h" #include "exsltexports.h"
#include <libexslt/exsltconfig.h> #include <libexslt/exsltconfig.h>
...@@ -85,6 +86,15 @@ ...@@ -85,6 +86,15 @@
EXSLTPUBFUN void EXSLTCALL exsltRegisterAll (void); EXSLTPUBFUN void EXSLTCALL exsltRegisterAll (void);
EXSLTPUBFUN int EXSLTCALL exsltDateXpathCtxtRegister (xmlXPathContextPtr ctxt,
const xmlChar *prefix);
EXSLTPUBFUN int EXSLTCALL exsltMathXpathCtxtRegister (xmlXPathContextPtr ctxt,
const xmlChar *prefix);
EXSLTPUBFUN int EXSLTCALL exsltSetsXpathCtxtRegister (xmlXPathContextPtr ctxt,
const xmlChar *prefix);
EXSLTPUBFUN int EXSLTCALL exsltStrXpathCtxtRegister (xmlXPathContextPtr ctxt,
const xmlChar *prefix);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -1106,3 +1106,97 @@ ...@@ -1106,3 +1106,97 @@
exsltMathExpFunction); exsltMathExpFunction);
#endif #endif
} }
/**
* exsltMathXpathCtxtRegister:
*
* Registers the EXSLT - Math module for use outside XSLT
*/
int
exsltMathXpathCtxtRegister (xmlXPathContextPtr ctxt, const xmlChar *prefix)
{
if (ctxt
&& prefix
&& !xmlXPathRegisterNs(ctxt,
prefix,
(const xmlChar *) EXSLT_MATH_NAMESPACE)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "min",
(const xmlChar *) EXSLT_MATH_NAMESPACE,
exsltMathMinFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "max",
(const xmlChar *) EXSLT_MATH_NAMESPACE,
exsltMathMaxFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "highest",
(const xmlChar *) EXSLT_MATH_NAMESPACE,
exsltMathHighestFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "lowest",
(const xmlChar *) EXSLT_MATH_NAMESPACE,
exsltMathLowestFunction)
#ifdef HAVE_STDLIB_H
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "random",
(const xmlChar *) EXSLT_MATH_NAMESPACE,
exsltMathRandomFunction)
#endif
#if HAVE_MATH_H
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "abs",
(const xmlChar *) EXSLT_MATH_NAMESPACE,
exsltMathAbsFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "sqrt",
(const xmlChar *) EXSLT_MATH_NAMESPACE,
exsltMathSqrtFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "power",
(const xmlChar *) EXSLT_MATH_NAMESPACE,
exsltMathPowerFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "log",
(const xmlChar *) EXSLT_MATH_NAMESPACE,
exsltMathLogFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "sin",
(const xmlChar *) EXSLT_MATH_NAMESPACE,
exsltMathSinFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "cos",
(const xmlChar *) EXSLT_MATH_NAMESPACE,
exsltMathCosFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "tan",
(const xmlChar *) EXSLT_MATH_NAMESPACE,
exsltMathTanFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "asin",
(const xmlChar *) EXSLT_MATH_NAMESPACE,
exsltMathAsinFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "acos",
(const xmlChar *) EXSLT_MATH_NAMESPACE,
exsltMathAcosFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "atan",
(const xmlChar *) EXSLT_MATH_NAMESPACE,
exsltMathAtanFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "atan2",
(const xmlChar *) EXSLT_MATH_NAMESPACE,
exsltMathAtan2Function)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "exp",
(const xmlChar *) EXSLT_MATH_NAMESPACE,
exsltMathExpFunction)
#endif
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "constant",
(const xmlChar *) EXSLT_MATH_NAMESPACE,
exsltMathConstantFunction)) {
return 0;
}
return -1;
}
...@@ -290,3 +290,45 @@ ...@@ -290,3 +290,45 @@
EXSLT_SETS_NAMESPACE, EXSLT_SETS_NAMESPACE,
exsltSetsTrailingFunction); exsltSetsTrailingFunction);
} }
/**
* exsltSetsXpathCtxtRegister:
*
* Registers the EXSLT - Sets module for use outside XSLT
*/
int
exsltSetsXpathCtxtRegister (xmlXPathContextPtr ctxt, const xmlChar *prefix)
{
if (ctxt
&& prefix
&& !xmlXPathRegisterNs(ctxt,
prefix,
(const xmlChar *) EXSLT_SETS_NAMESPACE)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "difference",
(const xmlChar *) EXSLT_SETS_NAMESPACE,
exsltSetsDifferenceFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "intersection",
(const xmlChar *) EXSLT_SETS_NAMESPACE,
exsltSetsIntersectionFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "distinct",
(const xmlChar *) EXSLT_SETS_NAMESPACE,
exsltSetsDistinctFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "has-same-node",
(const xmlChar *) EXSLT_SETS_NAMESPACE,
exsltSetsHasSameNodesFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "leading",
(const xmlChar *) EXSLT_SETS_NAMESPACE,
exsltSetsLeadingFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "trailing",
(const xmlChar *) EXSLT_SETS_NAMESPACE,
exsltSetsTrailingFunction)) {
return 0;
}
return -1;
}
...@@ -673,3 +673,45 @@ ...@@ -673,3 +673,45 @@
EXSLT_STRINGS_NAMESPACE, EXSLT_STRINGS_NAMESPACE,
exsltStrReplaceFunction); exsltStrReplaceFunction);
} }
/**
* exsltStrXpathCtxtRegister:
*
* Registers the EXSLT - Strings module for use outside XSLT
*/
int
exsltStrXpathCtxtRegister (xmlXPathContextPtr ctxt, const xmlChar *prefix)
{
if (ctxt
&& prefix
&& !xmlXPathRegisterNs(ctxt,
prefix,
(const xmlChar *) EXSLT_STRINGS_NAMESPACE)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "encode-uri",
(const xmlChar *) EXSLT_STRINGS_NAMESPACE,
exsltStrEncodeUriFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "decode-uri",
(const xmlChar *) EXSLT_STRINGS_NAMESPACE,
exsltStrDecodeUriFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "padding",
(const xmlChar *) EXSLT_STRINGS_NAMESPACE,
exsltStrPaddingFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "align",
(const xmlChar *) EXSLT_STRINGS_NAMESPACE,
exsltStrAlignFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "concat",
(const xmlChar *) EXSLT_STRINGS_NAMESPACE,
exsltStrConcatFunction)
&& !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "replace",
(const xmlChar *) EXSLT_STRINGS_NAMESPACE,
exsltStrReplaceFunction)) {
return 0;
}
return -1;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment