2 #include "libexslt/libexslt.h"
4 #if defined(WIN32) && !defined (__CYGWIN__) && (!__MINGW32__)
5 #include <win32config.h>
10 #include <libxml/tree.h>
11 #include <libxml/xpath.h>
12 #include <libxml/xpathInternals.h>
14 #include <libxslt/xsltconfig.h>
15 #include <libxslt/xsltutils.h>
16 #include <libxslt/xsltInternals.h>
17 #include <libxslt/extensions.h>
33 * Implements the EXSLT - Math min() function:
34 * number math:min (node-set)
36 * Returns the minimum value of the nodes passed as the argument, or
37 * xmlXPathNAN if @ns is NULL or empty or if one of the nodes
41 exsltMathMin (xmlNodeSetPtr ns
) {
45 if ((ns
== NULL
) || (ns
->nodeNr
== 0))
47 ret
= xmlXPathCastNodeToNumber(ns
->nodeTab
[0]);
48 if (xmlXPathIsNaN(ret
))
50 for (i
= 1; i
< ns
->nodeNr
; i
++) {
51 cur
= xmlXPathCastNodeToNumber(ns
->nodeTab
[i
]);
52 if (xmlXPathIsNaN(cur
))
61 * exsltMathMinFunction:
62 * @ctxt: an XPath parser context
63 * @nargs: the number of arguments
65 * Wraps #exsltMathMin for use by the XPath processor.
68 exsltMathMinFunction (xmlXPathParserContextPtr ctxt
, int nargs
) {
74 xsltGenericError(xsltGenericErrorContext
,
75 "math:min: invalid number of arguments\n");
76 ctxt
->error
= XPATH_INVALID_ARITY
;
79 /* We need to delay the freeing of value->user */
80 if ((ctxt
->value
!= NULL
) && (ctxt
->value
->boolval
!= 0)) {
81 user
= ctxt
->value
->user
;
82 ctxt
->value
->boolval
= 0;
83 ctxt
->value
->user
= NULL
;
85 ns
= xmlXPathPopNodeSet(ctxt
);
86 if (xmlXPathCheckError(ctxt
))
89 ret
= exsltMathMin(ns
);
91 xmlXPathFreeNodeSet(ns
);
93 xmlFreeNodeList((xmlNodePtr
)user
);
95 xmlXPathReturnNumber(ctxt
, ret
);
102 * Implements the EXSLT - Math max() function:
103 * number math:max (node-set)
105 * Returns the maximum value of the nodes passed as arguments, or
106 * xmlXPathNAN if @ns is NULL or empty or if one of the nodes
110 exsltMathMax (xmlNodeSetPtr ns
) {
114 if ((ns
== NULL
) || (ns
->nodeNr
== 0))
116 ret
= xmlXPathCastNodeToNumber(ns
->nodeTab
[0]);
117 if (xmlXPathIsNaN(ret
))
119 for (i
= 1; i
< ns
->nodeNr
; i
++) {
120 cur
= xmlXPathCastNodeToNumber(ns
->nodeTab
[i
]);
121 if (xmlXPathIsNaN(cur
))
130 * exsltMathMaxFunction:
131 * @ctxt: an XPath parser context
132 * @nargs: the number of arguments
134 * Wraps #exsltMathMax for use by the XPath processor.
137 exsltMathMaxFunction (xmlXPathParserContextPtr ctxt
, int nargs
) {
143 xmlXPathSetArityError(ctxt
);
147 /* We need to delay the freeing of value->user */
148 if ((ctxt
->value
!= NULL
) && (ctxt
->value
->boolval
!= 0)) {
149 user
= ctxt
->value
->user
;
150 ctxt
->value
->boolval
= 0;
151 ctxt
->value
->user
= 0;
153 ns
= xmlXPathPopNodeSet(ctxt
);
154 if (xmlXPathCheckError(ctxt
))
157 ret
= exsltMathMax(ns
);
159 xmlXPathFreeNodeSet(ns
);
162 xmlFreeNodeList((xmlNodePtr
)user
);
163 xmlXPathReturnNumber(ctxt
, ret
);
170 * Implements the EXSLT - Math highest() function:
171 * node-set math:highest (node-set)
173 * Returns the nodes in the node-set whose value is the maximum value
177 exsltMathHighest (xmlNodeSetPtr ns
) {
178 xmlNodeSetPtr ret
= xmlXPathNodeSetCreate(NULL
);
182 if ((ns
== NULL
) || (ns
->nodeNr
== 0))
185 max
= xmlXPathCastNodeToNumber(ns
->nodeTab
[0]);
186 if (xmlXPathIsNaN(max
))
189 xmlXPathNodeSetAddUnique(ret
, ns
->nodeTab
[0]);
191 for (i
= 1; i
< ns
->nodeNr
; i
++) {
192 cur
= xmlXPathCastNodeToNumber(ns
->nodeTab
[i
]);
193 if (xmlXPathIsNaN(cur
)) {
194 xmlXPathEmptyNodeSet(ret
);
201 xmlXPathEmptyNodeSet(ret
);
202 xmlXPathNodeSetAddUnique(ret
, ns
->nodeTab
[i
]);
205 xmlXPathNodeSetAddUnique(ret
, ns
->nodeTab
[i
]);
211 * exsltMathHighestFunction:
212 * @ctxt: an XPath parser context
213 * @nargs: the number of arguments
215 * Wraps #exsltMathHighest for use by the XPath processor
218 exsltMathHighestFunction (xmlXPathParserContextPtr ctxt
, int nargs
) {
219 xmlNodeSetPtr ns
, ret
;
223 xmlXPathSetArityError(ctxt
);
227 /* We need to delay the freeing of value->user */
228 if ((ctxt
->value
!= NULL
) && ctxt
->value
->boolval
!= 0) {
229 user
= ctxt
->value
->user
;
230 ctxt
->value
->boolval
= 0;
231 ctxt
->value
->user
= NULL
;
233 ns
= xmlXPathPopNodeSet(ctxt
);
234 if (xmlXPathCheckError(ctxt
))
237 ret
= exsltMathHighest(ns
);
239 xmlXPathFreeNodeSet(ns
);
241 xmlFreeNodeList((xmlNodePtr
)user
);
243 xmlXPathReturnNodeSet(ctxt
, ret
);
250 * Implements the EXSLT - Math lowest() function
251 * node-set math:lowest (node-set)
253 * Returns the nodes in the node-set whose value is the minimum value
257 exsltMathLowest (xmlNodeSetPtr ns
) {
258 xmlNodeSetPtr ret
= xmlXPathNodeSetCreate(NULL
);
262 if ((ns
== NULL
) || (ns
->nodeNr
== 0))
265 min
= xmlXPathCastNodeToNumber(ns
->nodeTab
[0]);
266 if (xmlXPathIsNaN(min
))
269 xmlXPathNodeSetAddUnique(ret
, ns
->nodeTab
[0]);
271 for (i
= 1; i
< ns
->nodeNr
; i
++) {
272 cur
= xmlXPathCastNodeToNumber(ns
->nodeTab
[i
]);
273 if (xmlXPathIsNaN(cur
)) {
274 xmlXPathEmptyNodeSet(ret
);
281 xmlXPathEmptyNodeSet(ret
);
282 xmlXPathNodeSetAddUnique(ret
, ns
->nodeTab
[i
]);
285 xmlXPathNodeSetAddUnique(ret
, ns
->nodeTab
[i
]);
291 * exsltMathLowestFunction:
292 * @ctxt: an XPath parser context
293 * @nargs: the number of arguments
295 * Wraps #exsltMathLowest for use by the XPath processor
298 exsltMathLowestFunction (xmlXPathParserContextPtr ctxt
, int nargs
) {
299 xmlNodeSetPtr ns
, ret
;
304 xmlXPathSetArityError(ctxt
);
308 /* We need to delay the freeing of value->user */
309 if ((ctxt
->value
!= NULL
) && (ctxt
->value
->boolval
!= 0)) {
310 user
= ctxt
->value
->user
;
311 ctxt
->value
->boolval
= 0;
312 ctxt
->value
->user
= NULL
;
314 ns
= xmlXPathPopNodeSet(ctxt
);
315 if (xmlXPathCheckError(ctxt
))
318 ret
= exsltMathLowest(ns
);
320 xmlXPathFreeNodeSet(ns
);
322 xmlFreeNodeList((xmlNodePtr
)user
);
324 xmlXPathReturnNodeSet(ctxt
, ret
);
327 /* math other functions */
329 /* constant values */
330 #define EXSLT_PI (const xmlChar *) \
331 "3.1415926535897932384626433832795028841971693993751"
332 #define EXSLT_E (const xmlChar *) \
333 "2.71828182845904523536028747135266249775724709369996"
334 #define EXSLT_SQRRT2 (const xmlChar *) \
335 "1.41421356237309504880168872420969807856967187537694"
336 #define EXSLT_LN2 (const xmlChar *) \
337 "0.69314718055994530941723212145817656807550013436025"
338 #define EXSLT_LN10 (const xmlChar *) \
339 "2.30258509299404568402"
340 #define EXSLT_LOG2E (const xmlChar *) \
341 "1.4426950408889634074"
342 #define EXSLT_SQRT1_2 (const xmlChar *) \
343 "0.70710678118654752440"
350 * Implements the EXSLT - Math constant function:
351 * number math:constant(string, number)
353 * Returns a number value of the given constant with the given precision or
354 * xmlXPathNAN if name is unknown.
355 * The constants are PI, E, SQRRT2, LN2, LN10, LOG2E, and SQRT1_2
358 exsltMathConstant (xmlChar
*name
, double precision
) {
362 if ((name
== NULL
) || (xmlXPathIsNaN(precision
)) || (precision
< 1.0)) {
366 if (xmlStrEqual(name
, BAD_CAST
"PI")) {
367 int len
= xmlStrlen(EXSLT_PI
);
369 if (precision
<= len
)
370 len
= (int)precision
;
372 str
= xmlStrsub(EXSLT_PI
, 0, len
);
374 } else if (xmlStrEqual(name
, BAD_CAST
"E")) {
375 int len
= xmlStrlen(EXSLT_E
);
377 if (precision
<= len
)
378 len
= (int)precision
;
380 str
= xmlStrsub(EXSLT_E
, 0, len
);
382 } else if (xmlStrEqual(name
, BAD_CAST
"SQRRT2")) {
383 int len
= xmlStrlen(EXSLT_SQRRT2
);
385 if (precision
<= len
)
386 len
= (int)precision
;
388 str
= xmlStrsub(EXSLT_SQRRT2
, 0, len
);
390 } else if (xmlStrEqual(name
, BAD_CAST
"LN2")) {
391 int len
= xmlStrlen(EXSLT_LN2
);
393 if (precision
<= len
)
394 len
= (int)precision
;
396 str
= xmlStrsub(EXSLT_LN2
, 0, len
);
398 } else if (xmlStrEqual(name
, BAD_CAST
"LN10")) {
399 int len
= xmlStrlen(EXSLT_LN10
);
401 if (precision
<= len
)
402 len
= (int)precision
;
404 str
= xmlStrsub(EXSLT_LN10
, 0, len
);
406 } else if (xmlStrEqual(name
, BAD_CAST
"LOG2E")) {
407 int len
= xmlStrlen(EXSLT_LOG2E
);
409 if (precision
<= len
)
410 len
= (int)precision
;
412 str
= xmlStrsub(EXSLT_LOG2E
, 0, len
);
414 } else if (xmlStrEqual(name
, BAD_CAST
"SQRT1_2")) {
415 int len
= xmlStrlen(EXSLT_SQRT1_2
);
417 if (precision
<= len
)
418 len
= (int)precision
;
420 str
= xmlStrsub(EXSLT_SQRT1_2
, 0, len
);
427 ret
= xmlXPathCastStringToNumber(str
);
433 * exsltMathConstantFunction:
434 * @ctxt: an XPath parser context
435 * @nargs: the number of arguments
437 * Wraps #exsltMathConstant for use by the XPath processor.
440 exsltMathConstantFunction (xmlXPathParserContextPtr ctxt
, int nargs
) {
445 xmlXPathSetArityError(ctxt
);
448 ret
= xmlXPathPopNumber(ctxt
);
449 if (xmlXPathCheckError(ctxt
))
452 name
= xmlXPathPopString(ctxt
);
453 if (xmlXPathCheckError(ctxt
))
456 ret
= exsltMathConstant(name
, ret
);
460 xmlXPathReturnNumber(ctxt
, ret
);
463 #if defined(HAVE_STDLIB_H) && defined(RAND_MAX)
468 * Implements the EXSLT - Math random() function:
469 * number math:random ()
471 * Returns a random number between 0 and 1 inclusive.
474 exsltMathRandom (void) {
479 ret
= (double)num
/ (double)RAND_MAX
;
484 * exsltMathRandomFunction:
485 * @ctxt: an XPath parser context
486 * @nargs: the number of arguments
488 * Wraps #exsltMathRandom for use by the XPath processor.
491 exsltMathRandomFunction (xmlXPathParserContextPtr ctxt
, int nargs
) {
495 xmlXPathSetArityError(ctxt
);
499 ret
= exsltMathRandom();
501 xmlXPathReturnNumber(ctxt
, ret
);
504 #endif /* defined(HAVE_STDLIB_H) && defined(RAND_MAX) */
512 * Implements the EXSLT - Math abs() function:
513 * number math:abs (number)
515 * Returns the absolute value of the argument, or xmlXPathNAN if @num is Nan.
518 exsltMathAbs (double num
) {
521 if (xmlXPathIsNaN(num
))
528 * exsltMathAbsFunction:
529 * @ctxt: an XPath parser context
530 * @nargs: the number of arguments
532 * Wraps #exsltMathAbs for use by the XPath processor.
535 exsltMathAbsFunction (xmlXPathParserContextPtr ctxt
, int nargs
) {
539 xmlXPathSetArityError(ctxt
);
542 ret
= xmlXPathPopNumber(ctxt
);
543 if (xmlXPathCheckError(ctxt
))
546 ret
= exsltMathAbs(ret
);
548 xmlXPathReturnNumber(ctxt
, ret
);
555 * Implements the EXSLT - Math sqrt() function:
556 * number math:sqrt (number)
558 * Returns the square root of the argument, or xmlXPathNAN if @num is Nan.
561 exsltMathSqrt (double num
) {
564 if (xmlXPathIsNaN(num
))
571 * exsltMathSqrtFunction:
572 * @ctxt: an XPath parser context
573 * @nargs: the number of arguments
575 * Wraps #exsltMathSqrt for use by the XPath processor.
578 exsltMathSqrtFunction (xmlXPathParserContextPtr ctxt
, int nargs
) {
582 xmlXPathSetArityError(ctxt
);
585 ret
= xmlXPathPopNumber(ctxt
);
586 if (xmlXPathCheckError(ctxt
))
589 ret
= exsltMathSqrt(ret
);
591 xmlXPathReturnNumber(ctxt
, ret
);
599 * Implements the EXSLT - Math power() function:
600 * number math:power (number, number)
602 * Returns the power base and power arguments, or xmlXPathNAN
603 * if either @base or @power is Nan.
606 exsltMathPower (double base
, double power
) {
609 if ((xmlXPathIsNaN(base
) || xmlXPathIsNaN(power
)))
611 ret
= pow(base
, power
);
617 * @ctxt: an XPath parser context
618 * @nargs: the number of arguments
620 * Wraps #exsltMathPower for use by the XPath processor.
623 exsltMathPowerFunction (xmlXPathParserContextPtr ctxt
, int nargs
) {
627 xmlXPathSetArityError(ctxt
);
630 ret
= xmlXPathPopNumber(ctxt
);
631 if (xmlXPathCheckError(ctxt
))
635 base
= xmlXPathPopNumber(ctxt
);
636 if (xmlXPathCheckError(ctxt
))
639 ret
= exsltMathPower(base
, ret
);
641 xmlXPathReturnNumber(ctxt
, ret
);
648 * Implements the EXSLT - Math log() function:
649 * number math:log (number)
651 * Returns the natural log of the argument, or xmlXPathNAN if @num is Nan.
654 exsltMathLog (double num
) {
657 if (xmlXPathIsNaN(num
))
664 * exsltMathLogFunction:
665 * @ctxt: an XPath parser context
666 * @nargs: the number of arguments
668 * Wraps #exsltMathLog for use by the XPath processor.
671 exsltMathLogFunction (xmlXPathParserContextPtr ctxt
, int nargs
) {
675 xmlXPathSetArityError(ctxt
);
678 ret
= xmlXPathPopNumber(ctxt
);
679 if (xmlXPathCheckError(ctxt
))
682 ret
= exsltMathLog(ret
);
684 xmlXPathReturnNumber(ctxt
, ret
);
691 * Implements the EXSLT - Math sin() function:
692 * number math:sin (number)
694 * Returns the sine of the argument, or xmlXPathNAN if @num is Nan.
697 exsltMathSin (double num
) {
700 if (xmlXPathIsNaN(num
))
707 * exsltMathSinFunction:
708 * @ctxt: an XPath parser context
709 * @nargs: the number of arguments
711 * Wraps #exsltMathSin for use by the XPath processor.
714 exsltMathSinFunction (xmlXPathParserContextPtr ctxt
, int nargs
) {
718 xmlXPathSetArityError(ctxt
);
721 ret
= xmlXPathPopNumber(ctxt
);
722 if (xmlXPathCheckError(ctxt
))
725 ret
= exsltMathSin(ret
);
727 xmlXPathReturnNumber(ctxt
, ret
);
734 * Implements the EXSLT - Math cos() function:
735 * number math:cos (number)
737 * Returns the cosine of the argument, or xmlXPathNAN if @num is Nan.
740 exsltMathCos (double num
) {
743 if (xmlXPathIsNaN(num
))
750 * exsltMathCosFunction:
751 * @ctxt: an XPath parser context
752 * @nargs: the number of arguments
754 * Wraps #exsltMathCos for use by the XPath processor.
757 exsltMathCosFunction (xmlXPathParserContextPtr ctxt
, int nargs
) {
761 xmlXPathSetArityError(ctxt
);
764 ret
= xmlXPathPopNumber(ctxt
);
765 if (xmlXPathCheckError(ctxt
))
768 ret
= exsltMathCos(ret
);
770 xmlXPathReturnNumber(ctxt
, ret
);
777 * Implements the EXSLT - Math tan() function:
778 * number math:tan (number)
780 * Returns the tangent of the argument, or xmlXPathNAN if @num is Nan.
783 exsltMathTan (double num
) {
786 if (xmlXPathIsNaN(num
))
793 * exsltMathTanFunction:
794 * @ctxt: an XPath parser context
795 * @nargs: the number of arguments
797 * Wraps #exsltMathTan for use by the XPath processor.
800 exsltMathTanFunction (xmlXPathParserContextPtr ctxt
, int nargs
) {
804 xmlXPathSetArityError(ctxt
);
807 ret
= xmlXPathPopNumber(ctxt
);
808 if (xmlXPathCheckError(ctxt
))
811 ret
= exsltMathTan(ret
);
813 xmlXPathReturnNumber(ctxt
, ret
);
820 * Implements the EXSLT - Math asin() function:
821 * number math:asin (number)
823 * Returns the arc sine of the argument, or xmlXPathNAN if @num is Nan.
826 exsltMathAsin (double num
) {
829 if (xmlXPathIsNaN(num
))
836 * exsltMathAsinFunction:
837 * @ctxt: an XPath parser context
838 * @nargs: the number of arguments
840 * Wraps #exsltMathAsin for use by the XPath processor.
843 exsltMathAsinFunction (xmlXPathParserContextPtr ctxt
, int nargs
) {
847 xmlXPathSetArityError(ctxt
);
850 ret
= xmlXPathPopNumber(ctxt
);
851 if (xmlXPathCheckError(ctxt
))
854 ret
= exsltMathAsin(ret
);
856 xmlXPathReturnNumber(ctxt
, ret
);
863 * Implements the EXSLT - Math acos() function:
864 * number math:acos (number)
866 * Returns the arc cosine of the argument, or xmlXPathNAN if @num is Nan.
869 exsltMathAcos (double num
) {
872 if (xmlXPathIsNaN(num
))
879 * exsltMathAcosFunction:
880 * @ctxt: an XPath parser context
881 * @nargs: the number of arguments
883 * Wraps #exsltMathAcos for use by the XPath processor.
886 exsltMathAcosFunction (xmlXPathParserContextPtr ctxt
, int nargs
) {
890 xmlXPathSetArityError(ctxt
);
893 ret
= xmlXPathPopNumber(ctxt
);
894 if (xmlXPathCheckError(ctxt
))
897 ret
= exsltMathAcos(ret
);
899 xmlXPathReturnNumber(ctxt
, ret
);
906 * Implements the EXSLT - Math atan() function:
907 * number math:atan (number)
909 * Returns the arc tangent of the argument, or xmlXPathNAN if @num is Nan.
912 exsltMathAtan (double num
) {
915 if (xmlXPathIsNaN(num
))
922 * exsltMathAtanFunction:
923 * @ctxt: an XPath parser context
924 * @nargs: the number of arguments
926 * Wraps #exsltMathAtan for use by the XPath processor.
929 exsltMathAtanFunction (xmlXPathParserContextPtr ctxt
, int nargs
) {
933 xmlXPathSetArityError(ctxt
);
936 ret
= xmlXPathPopNumber(ctxt
);
937 if (xmlXPathCheckError(ctxt
))
940 ret
= exsltMathAtan(ret
);
942 xmlXPathReturnNumber(ctxt
, ret
);
950 * Implements the EXSLT - Math atan2() function:
951 * number math:atan2 (number, number)
953 * Returns the arc tangent function of the y/x arguments, or xmlXPathNAN
954 * if either @y or @x is Nan.
957 exsltMathAtan2 (double y
, double x
) {
960 if ((xmlXPathIsNaN(y
) || xmlXPathIsNaN(x
)))
967 * exsltMathAtan2Function:
968 * @ctxt: an XPath parser context
969 * @nargs: the number of arguments
971 * Wraps #exsltMathAtan2 for use by the XPath processor.
974 exsltMathAtan2Function (xmlXPathParserContextPtr ctxt
, int nargs
) {
978 xmlXPathSetArityError(ctxt
);
981 x
= xmlXPathPopNumber(ctxt
);
982 if (xmlXPathCheckError(ctxt
))
986 ret
= xmlXPathPopNumber(ctxt
);
987 if (xmlXPathCheckError(ctxt
))
990 ret
= exsltMathAtan2(ret
, x
);
992 xmlXPathReturnNumber(ctxt
, ret
);
999 * Implements the EXSLT - Math exp() function:
1000 * number math:exp (number)
1002 * Returns the exponential function of the argument, or xmlXPathNAN if
1006 exsltMathExp (double num
) {
1009 if (xmlXPathIsNaN(num
))
1010 return(xmlXPathNAN
);
1016 * exsltMathExpFunction:
1017 * @ctxt: an XPath parser context
1018 * @nargs: the number of arguments
1020 * Wraps #exsltMathExp for use by the XPath processor.
1023 exsltMathExpFunction (xmlXPathParserContextPtr ctxt
, int nargs
) {
1027 xmlXPathSetArityError(ctxt
);
1030 ret
= xmlXPathPopNumber(ctxt
);
1031 if (xmlXPathCheckError(ctxt
))
1034 ret
= exsltMathExp(ret
);
1036 xmlXPathReturnNumber(ctxt
, ret
);
1039 #endif /* HAVE_MATH_H */
1042 * exsltMathRegister:
1044 * Registers the EXSLT - Math module
1048 exsltMathRegister (void) {
1049 xsltRegisterExtModuleFunction ((const xmlChar
*) "min",
1050 EXSLT_MATH_NAMESPACE
,
1051 exsltMathMinFunction
);
1052 xsltRegisterExtModuleFunction ((const xmlChar
*) "max",
1053 EXSLT_MATH_NAMESPACE
,
1054 exsltMathMaxFunction
);
1055 xsltRegisterExtModuleFunction ((const xmlChar
*) "highest",
1056 EXSLT_MATH_NAMESPACE
,
1057 exsltMathHighestFunction
);
1058 xsltRegisterExtModuleFunction ((const xmlChar
*) "lowest",
1059 EXSLT_MATH_NAMESPACE
,
1060 exsltMathLowestFunction
);
1061 /* register other math functions */
1062 xsltRegisterExtModuleFunction ((const xmlChar
*) "constant",
1063 EXSLT_MATH_NAMESPACE
,
1064 exsltMathConstantFunction
);
1065 #ifdef HAVE_STDLIB_H
1066 xsltRegisterExtModuleFunction ((const xmlChar
*) "random",
1067 EXSLT_MATH_NAMESPACE
,
1068 exsltMathRandomFunction
);
1071 xsltRegisterExtModuleFunction ((const xmlChar
*) "abs",
1072 EXSLT_MATH_NAMESPACE
,
1073 exsltMathAbsFunction
);
1074 xsltRegisterExtModuleFunction ((const xmlChar
*) "sqrt",
1075 EXSLT_MATH_NAMESPACE
,
1076 exsltMathSqrtFunction
);
1077 xsltRegisterExtModuleFunction ((const xmlChar
*) "power",
1078 EXSLT_MATH_NAMESPACE
,
1079 exsltMathPowerFunction
);
1080 xsltRegisterExtModuleFunction ((const xmlChar
*) "log",
1081 EXSLT_MATH_NAMESPACE
,
1082 exsltMathLogFunction
);
1083 xsltRegisterExtModuleFunction ((const xmlChar
*) "sin",
1084 EXSLT_MATH_NAMESPACE
,
1085 exsltMathSinFunction
);
1086 xsltRegisterExtModuleFunction ((const xmlChar
*) "cos",
1087 EXSLT_MATH_NAMESPACE
,
1088 exsltMathCosFunction
);
1089 xsltRegisterExtModuleFunction ((const xmlChar
*) "tan",
1090 EXSLT_MATH_NAMESPACE
,
1091 exsltMathTanFunction
);
1092 xsltRegisterExtModuleFunction ((const xmlChar
*) "asin",
1093 EXSLT_MATH_NAMESPACE
,
1094 exsltMathAsinFunction
);
1095 xsltRegisterExtModuleFunction ((const xmlChar
*) "acos",
1096 EXSLT_MATH_NAMESPACE
,
1097 exsltMathAcosFunction
);
1098 xsltRegisterExtModuleFunction ((const xmlChar
*) "atan",
1099 EXSLT_MATH_NAMESPACE
,
1100 exsltMathAtanFunction
);
1101 xsltRegisterExtModuleFunction ((const xmlChar
*) "atan2",
1102 EXSLT_MATH_NAMESPACE
,
1103 exsltMathAtan2Function
);
1104 xsltRegisterExtModuleFunction ((const xmlChar
*) "exp",
1105 EXSLT_MATH_NAMESPACE
,
1106 exsltMathExpFunction
);
1111 * exsltMathXpathCtxtRegister:
1113 * Registers the EXSLT - Math module for use outside XSLT
1116 exsltMathXpathCtxtRegister (xmlXPathContextPtr ctxt
, const xmlChar
*prefix
)
1120 && !xmlXPathRegisterNs(ctxt
,
1122 (const xmlChar
*) EXSLT_MATH_NAMESPACE
)
1123 && !xmlXPathRegisterFuncNS(ctxt
,
1124 (const xmlChar
*) "min",
1125 (const xmlChar
*) EXSLT_MATH_NAMESPACE
,
1126 exsltMathMinFunction
)
1127 && !xmlXPathRegisterFuncNS(ctxt
,
1128 (const xmlChar
*) "max",
1129 (const xmlChar
*) EXSLT_MATH_NAMESPACE
,
1130 exsltMathMaxFunction
)
1131 && !xmlXPathRegisterFuncNS(ctxt
,
1132 (const xmlChar
*) "highest",
1133 (const xmlChar
*) EXSLT_MATH_NAMESPACE
,
1134 exsltMathHighestFunction
)
1135 && !xmlXPathRegisterFuncNS(ctxt
,
1136 (const xmlChar
*) "lowest",
1137 (const xmlChar
*) EXSLT_MATH_NAMESPACE
,
1138 exsltMathLowestFunction
)
1139 #ifdef HAVE_STDLIB_H
1140 && !xmlXPathRegisterFuncNS(ctxt
,
1141 (const xmlChar
*) "random",
1142 (const xmlChar
*) EXSLT_MATH_NAMESPACE
,
1143 exsltMathRandomFunction
)
1146 && !xmlXPathRegisterFuncNS(ctxt
,
1147 (const xmlChar
*) "abs",
1148 (const xmlChar
*) EXSLT_MATH_NAMESPACE
,
1149 exsltMathAbsFunction
)
1150 && !xmlXPathRegisterFuncNS(ctxt
,
1151 (const xmlChar
*) "sqrt",
1152 (const xmlChar
*) EXSLT_MATH_NAMESPACE
,
1153 exsltMathSqrtFunction
)
1154 && !xmlXPathRegisterFuncNS(ctxt
,
1155 (const xmlChar
*) "power",
1156 (const xmlChar
*) EXSLT_MATH_NAMESPACE
,
1157 exsltMathPowerFunction
)
1158 && !xmlXPathRegisterFuncNS(ctxt
,
1159 (const xmlChar
*) "log",
1160 (const xmlChar
*) EXSLT_MATH_NAMESPACE
,
1161 exsltMathLogFunction
)
1162 && !xmlXPathRegisterFuncNS(ctxt
,
1163 (const xmlChar
*) "sin",
1164 (const xmlChar
*) EXSLT_MATH_NAMESPACE
,
1165 exsltMathSinFunction
)
1166 && !xmlXPathRegisterFuncNS(ctxt
,
1167 (const xmlChar
*) "cos",
1168 (const xmlChar
*) EXSLT_MATH_NAMESPACE
,
1169 exsltMathCosFunction
)
1170 && !xmlXPathRegisterFuncNS(ctxt
,
1171 (const xmlChar
*) "tan",
1172 (const xmlChar
*) EXSLT_MATH_NAMESPACE
,
1173 exsltMathTanFunction
)
1174 && !xmlXPathRegisterFuncNS(ctxt
,
1175 (const xmlChar
*) "asin",
1176 (const xmlChar
*) EXSLT_MATH_NAMESPACE
,
1177 exsltMathAsinFunction
)
1178 && !xmlXPathRegisterFuncNS(ctxt
,
1179 (const xmlChar
*) "acos",
1180 (const xmlChar
*) EXSLT_MATH_NAMESPACE
,
1181 exsltMathAcosFunction
)
1182 && !xmlXPathRegisterFuncNS(ctxt
,
1183 (const xmlChar
*) "atan",
1184 (const xmlChar
*) EXSLT_MATH_NAMESPACE
,
1185 exsltMathAtanFunction
)
1186 && !xmlXPathRegisterFuncNS(ctxt
,
1187 (const xmlChar
*) "atan2",
1188 (const xmlChar
*) EXSLT_MATH_NAMESPACE
,
1189 exsltMathAtan2Function
)
1190 && !xmlXPathRegisterFuncNS(ctxt
,
1191 (const xmlChar
*) "exp",
1192 (const xmlChar
*) EXSLT_MATH_NAMESPACE
,
1193 exsltMathExpFunction
)
1195 && !xmlXPathRegisterFuncNS(ctxt
,
1196 (const xmlChar
*) "constant",
1197 (const xmlChar
*) EXSLT_MATH_NAMESPACE
,
1198 exsltMathConstantFunction
)) {