* xmlXPathCastToString: * @val: an XPath object * * Converts an existing object to its string() equivalent * * Returns the allocated string value of the object, NULL in case of error. * It's up to the caller to free the string memory with xmlFree(). */
| 4763 | * It's up to the caller to free the string memory with xmlFree(). |
| 4764 | */ |
| 4765 | xmlChar * |
| 4766 | xmlXPathCastToString(xmlXPathObjectPtr val) { |
| 4767 | xmlChar *ret = NULL; |
| 4768 | |
| 4769 | if (val == NULL) |
| 4770 | return(xmlStrdup((const xmlChar *) "")); |
| 4771 | switch (val->type) { |
| 4772 | case XPATH_UNDEFINED: |
| 4773 | ret = xmlStrdup((const xmlChar *) ""); |
| 4774 | break; |
| 4775 | case XPATH_NODESET: |
| 4776 | case XPATH_XSLT_TREE: |
| 4777 | ret = xmlXPathCastNodeSetToString(val->nodesetval); |
| 4778 | break; |
| 4779 | case XPATH_STRING: |
| 4780 | return(xmlStrdup(val->stringval)); |
| 4781 | case XPATH_BOOLEAN: |
| 4782 | ret = xmlXPathCastBooleanToString(val->boolval); |
| 4783 | break; |
| 4784 | case XPATH_NUMBER: { |
| 4785 | ret = xmlXPathCastNumberToString(val->floatval); |
| 4786 | break; |
| 4787 | } |
| 4788 | case XPATH_USERS: |
| 4789 | #ifdef LIBXML_XPTR_LOCS_ENABLED |
| 4790 | case XPATH_POINT: |
| 4791 | case XPATH_RANGE: |
| 4792 | case XPATH_LOCATIONSET: |
| 4793 | #endif /* LIBXML_XPTR_LOCS_ENABLED */ |
| 4794 | /* TODO */ |
| 4795 | ret = xmlStrdup((const xmlChar *) ""); |
| 4796 | break; |
| 4797 | } |
| 4798 | return(ret); |
| 4799 | } |
| 4800 | |
| 4801 | /** |
| 4802 | * xmlXPathConvertString: |
no test coverage detected