* 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
| 8774 | * context node as its only member. |
| 8775 | */ |
| 8776 | void |
| 8777 | xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs) { |
| 8778 | xmlXPathObjectPtr cur; |
| 8779 | |
| 8780 | if (ctxt == NULL) return; |
| 8781 | if (nargs == 0) { |
| 8782 | valuePush(ctxt, |
| 8783 | xmlXPathCacheWrapString(ctxt->context, |
| 8784 | xmlXPathCastNodeToString(ctxt->context->node))); |
| 8785 | return; |
| 8786 | } |
| 8787 | |
| 8788 | CHECK_ARITY(1); |
| 8789 | cur = valuePop(ctxt); |
| 8790 | if (cur == NULL) XP_ERROR(XPATH_INVALID_OPERAND); |
| 8791 | valuePush(ctxt, xmlXPathCacheConvertString(ctxt->context, cur)); |
| 8792 | } |
| 8793 | |
| 8794 | /** |
| 8795 | * xmlXPathStringLengthFunction: |