* xmlXPathStringFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the string() XPath function * string string(object?) * The string function converts an object to a string as follows: * - A node-set is converted to a string by returning the value of * the node in the node-set that is first in document order. * If the node-set is
| 7835 | * context node as its only member. |
| 7836 | */ |
| 7837 | void |
| 7838 | xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs) { |
| 7839 | xmlXPathObjectPtr cur; |
| 7840 | xmlChar *stringval; |
| 7841 | |
| 7842 | if (ctxt == NULL) return; |
| 7843 | if (nargs == 0) { |
| 7844 | stringval = xmlXPathCastNodeToString(ctxt->context->node); |
| 7845 | if (stringval == NULL) |
| 7846 | xmlXPathPErrMemory(ctxt); |
| 7847 | valuePush(ctxt, xmlXPathCacheWrapString(ctxt, stringval)); |
| 7848 | return; |
| 7849 | } |
| 7850 | |
| 7851 | CHECK_ARITY(1); |
| 7852 | cur = valuePop(ctxt); |
| 7853 | if (cur == NULL) XP_ERROR(XPATH_INVALID_OPERAND); |
| 7854 | if (cur->type != XPATH_STRING) { |
| 7855 | stringval = xmlXPathCastToString(cur); |
| 7856 | if (stringval == NULL) |
| 7857 | xmlXPathPErrMemory(ctxt); |
| 7858 | xmlXPathReleaseObject(ctxt->context, cur); |
| 7859 | cur = xmlXPathCacheWrapString(ctxt, stringval); |
| 7860 | } |
| 7861 | valuePush(ctxt, cur); |
| 7862 | } |
| 7863 | |
| 7864 | /** |
| 7865 | * xmlXPathStringLengthFunction: |
nothing calls this directly
no test coverage detected