MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlXPathSumFunction

Function xmlXPathSumFunction

ThirdParty/libxml2/vtklibxml2/xpath.c:8569–8590  ·  view source on GitHub ↗

* xmlXPathSumFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the sum() XPath function * number sum(node-set) * The sum function returns the sum of the values of the nodes in * the argument node-set. */

Source from the content-addressed store, hash-verified

8567 * the argument node-set.
8568 */
8569void
8570xmlXPathSumFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8571 xmlXPathObjectPtr cur;
8572 int i;
8573 double res = 0.0;
8574
8575 CHECK_ARITY(1);
8576 if ((ctxt->value == NULL) ||
8577 ((ctxt->value->type != XPATH_NODESET) &&
8578 (ctxt->value->type != XPATH_XSLT_TREE)))
8579 XP_ERROR(XPATH_INVALID_TYPE);
8580 cur = valuePop(ctxt);
8581
8582 if ((cur->nodesetval != NULL) && (cur->nodesetval->nodeNr != 0)) {
8583 for (i = 0; i < cur->nodesetval->nodeNr; i++) {
8584 res += xmlXPathNodeToNumberInternal(ctxt,
8585 cur->nodesetval->nodeTab[i]);
8586 }
8587 }
8588 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt, res));
8589 xmlXPathReleaseObject(ctxt->context, cur);
8590}
8591
8592/**
8593 * xmlXPathFloorFunction:

Callers

nothing calls this directly

Calls 5

valuePopFunction · 0.85
valuePushFunction · 0.85
xmlXPathCacheNewFloatFunction · 0.85
xmlXPathReleaseObjectFunction · 0.85

Tested by

no test coverage detected