* xmlXPathCountFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the count() XPath function * number count(node-set) */
| 7465 | * number count(node-set) |
| 7466 | */ |
| 7467 | void |
| 7468 | xmlXPathCountFunction(xmlXPathParserContextPtr ctxt, int nargs) { |
| 7469 | xmlXPathObjectPtr cur; |
| 7470 | |
| 7471 | CHECK_ARITY(1); |
| 7472 | if ((ctxt->value == NULL) || |
| 7473 | ((ctxt->value->type != XPATH_NODESET) && |
| 7474 | (ctxt->value->type != XPATH_XSLT_TREE))) |
| 7475 | XP_ERROR(XPATH_INVALID_TYPE); |
| 7476 | cur = valuePop(ctxt); |
| 7477 | |
| 7478 | if ((cur == NULL) || (cur->nodesetval == NULL)) |
| 7479 | valuePush(ctxt, xmlXPathCacheNewFloat(ctxt, 0.0)); |
| 7480 | else |
| 7481 | valuePush(ctxt, xmlXPathCacheNewFloat(ctxt, |
| 7482 | (double) cur->nodesetval->nodeNr)); |
| 7483 | xmlXPathReleaseObject(ctxt->context, cur); |
| 7484 | } |
| 7485 | |
| 7486 | /** |
| 7487 | * xmlXPathGetElementsByIds: |
nothing calls this directly
no test coverage detected