* xmlXPathEvaluatePredicateResult: * @ctxt: the XPath Parser context * @res: the Predicate Expression evaluation result * * Evaluate a predicate result for the current node. * A PredicateExpr is evaluated by evaluating the Expr and converting * the result to a boolean. If the result is a number, the result will * be converted to true if the number is equal to the position of the * contex
| 12820 | * Returns 1 if predicate is true, 0 otherwise |
| 12821 | */ |
| 12822 | int |
| 12823 | xmlXPathEvaluatePredicateResult(xmlXPathParserContextPtr ctxt, |
| 12824 | xmlXPathObjectPtr res) { |
| 12825 | if ((ctxt == NULL) || (res == NULL)) return(0); |
| 12826 | switch (res->type) { |
| 12827 | case XPATH_BOOLEAN: |
| 12828 | return(res->boolval); |
| 12829 | case XPATH_NUMBER: |
| 12830 | #if defined(__BORLANDC__) || (defined(_MSC_VER) && (_MSC_VER == 1200)) |
| 12831 | return((res->floatval == ctxt->context->proximityPosition) && |
| 12832 | (!xmlXPathIsNaN(res->floatval))); /* MSC pbm Mark Vakoc !*/ |
| 12833 | #else |
| 12834 | return(res->floatval == ctxt->context->proximityPosition); |
| 12835 | #endif |
| 12836 | case XPATH_NODESET: |
| 12837 | case XPATH_XSLT_TREE: |
| 12838 | if (res->nodesetval == NULL) |
| 12839 | return(0); |
| 12840 | return(res->nodesetval->nodeNr != 0); |
| 12841 | case XPATH_STRING: |
| 12842 | return((res->stringval != NULL) && (res->stringval[0] != 0)); |
| 12843 | #ifdef LIBXML_XPTR_LOCS_ENABLED |
| 12844 | case XPATH_LOCATIONSET:{ |
| 12845 | xmlLocationSetPtr ptr = res->user; |
| 12846 | if (ptr == NULL) |
| 12847 | return(0); |
| 12848 | return (ptr->locNr != 0); |
| 12849 | } |
| 12850 | #endif |
| 12851 | default: |
| 12852 | break; |
| 12853 | } |
| 12854 | return(0); |
| 12855 | } |
| 12856 | |
| 12857 | #ifdef XPATH_STREAMING |
| 12858 | /** |
no test coverage detected