MCPcopy Create free account
hub / github.com/KhronosGroup/OpenCOLLADA / xmlXPathLocalNameFunction

Function xmlXPathLocalNameFunction

Externals/LibXML/xpath.c:8562–8605  ·  view source on GitHub ↗

* xmlXPathLocalNameFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the local-name() XPath function * string local-name(node-set?) * The local-name function returns a string containing the local part * of the name of the node in the argument node-set that is first in * document order. If the node-set is empty or the first node has no * name,

Source from the content-addressed store, hash-verified

8560 * defaults to the context node.
8561 */
8562void
8563xmlXPathLocalNameFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8564 xmlXPathObjectPtr cur;
8565
8566 if (ctxt == NULL) return;
8567
8568 if (nargs == 0) {
8569 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,
8570 ctxt->context->node));
8571 nargs = 1;
8572 }
8573
8574 CHECK_ARITY(1);
8575 if ((ctxt->value == NULL) ||
8576 ((ctxt->value->type != XPATH_NODESET) &&
8577 (ctxt->value->type != XPATH_XSLT_TREE)))
8578 XP_ERROR(XPATH_INVALID_TYPE);
8579 cur = valuePop(ctxt);
8580
8581 if ((cur->nodesetval == NULL) || (cur->nodesetval->nodeNr == 0)) {
8582 valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, ""));
8583 } else {
8584 int i = 0; /* Should be first in document order !!!!! */
8585 switch (cur->nodesetval->nodeTab[i]->type) {
8586 case XML_ELEMENT_NODE:
8587 case XML_ATTRIBUTE_NODE:
8588 case XML_PI_NODE:
8589 if (cur->nodesetval->nodeTab[i]->name[0] == ' ')
8590 valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, ""));
8591 else
8592 valuePush(ctxt,
8593 xmlXPathCacheNewString(ctxt->context,
8594 cur->nodesetval->nodeTab[i]->name));
8595 break;
8596 case XML_NAMESPACE_DECL:
8597 valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,
8598 ((xmlNsPtr)cur->nodesetval->nodeTab[i])->prefix));
8599 break;
8600 default:
8601 valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, ""));
8602 }
8603 }
8604 xmlXPathReleaseObject(ctxt->context, cur);
8605}
8606
8607/**
8608 * xmlXPathNamespaceURIFunction:

Callers 2

xmlXPathNameFunctionFunction · 0.85

Calls 6

valuePushFunction · 0.85
xmlXPathCacheNewNodeSetFunction · 0.85
valuePopFunction · 0.85
xmlXPathCacheNewCStringFunction · 0.85
xmlXPathCacheNewStringFunction · 0.85
xmlXPathReleaseObjectFunction · 0.85

Tested by 1