diff options
author | Martin <gzlist@googlemail.com> | 2009-09-17 16:54:18 +0200 |
---|---|---|
committer | Daniel Veillard <veillard@redhat.com> | 2009-09-17 16:54:18 +0200 |
commit | ce169a52f485dbf5522c0668e2975201b179add7 (patch) | |
tree | bf54bf74a0e518855b6502e6deb5a8cfb78ca554 /libexslt | |
parent | 3d435b25cf2e8112d87cb133c00b94d5924ec75c (diff) | |
download | libxslt-ce169a52f485dbf5522c0668e2975201b179add7.tar.gz libxslt-ce169a52f485dbf5522c0668e2975201b179add7.tar.bz2 libxslt-ce169a52f485dbf5522c0668e2975201b179add7.zip |
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
Diffstat (limited to 'libexslt')
-rw-r--r-- | libexslt/date.c | 120 | ||||
-rw-r--r-- | libexslt/exslt.h | 10 | ||||
-rw-r--r-- | libexslt/math.c | 94 | ||||
-rw-r--r-- | libexslt/sets.c | 42 | ||||
-rw-r--r-- | libexslt/strings.c | 42 |
5 files changed, 308 insertions, 0 deletions
diff --git a/libexslt/date.c b/libexslt/date.c index 47856699..cefbdd83 100644 --- a/libexslt/date.c +++ b/libexslt/date.c @@ -3792,3 +3792,123 @@ exsltDateRegister (void) (const xmlChar *) EXSLT_DATE_NAMESPACE, 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; +} diff --git a/libexslt/exslt.h b/libexslt/exslt.h index 52d09cfc..21473080 100644 --- a/libexslt/exslt.h +++ b/libexslt/exslt.h @@ -3,6 +3,7 @@ #define __EXSLT_H__ #include <libxml/tree.h> +#include <libxml/xpath.h> #include "exsltexports.h" #include <libexslt/exsltconfig.h> @@ -85,6 +86,15 @@ EXSLTPUBFUN void EXSLTCALL exsltDynRegister(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 } #endif diff --git a/libexslt/math.c b/libexslt/math.c index e56709bd..a1971e05 100644 --- a/libexslt/math.c +++ b/libexslt/math.c @@ -1106,3 +1106,97 @@ exsltMathRegister (void) { exsltMathExpFunction); #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; +} diff --git a/libexslt/sets.c b/libexslt/sets.c index 6739b5d1..a5a79130 100644 --- a/libexslt/sets.c +++ b/libexslt/sets.c @@ -290,3 +290,45 @@ exsltSetsRegister (void) { EXSLT_SETS_NAMESPACE, 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; +} diff --git a/libexslt/strings.c b/libexslt/strings.c index 192d0c4a..1a11976c 100644 --- a/libexslt/strings.c +++ b/libexslt/strings.c @@ -673,3 +673,45 @@ exsltStrRegister (void) { EXSLT_STRINGS_NAMESPACE, 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; +} |