MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlXPathLocalNameFunction

Function xmlXPathLocalNameFunction

ThirdParty/libxml2/vtklibxml2/xpath.c:7630–7671  ·  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

7628 * defaults to the context node.
7629 */
7630void
7631xmlXPathLocalNameFunction(xmlXPathParserContextPtr ctxt, int nargs) {
7632 xmlXPathObjectPtr cur;
7633
7634 if (ctxt == NULL) return;
7635
7636 if (nargs == 0) {
7637 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt, ctxt->context->node));
7638 nargs = 1;
7639 }
7640
7641 CHECK_ARITY(1);
7642 if ((ctxt->value == NULL) ||
7643 ((ctxt->value->type != XPATH_NODESET) &&
7644 (ctxt->value->type != XPATH_XSLT_TREE)))
7645 XP_ERROR(XPATH_INVALID_TYPE);
7646 cur = valuePop(ctxt);
7647
7648 if ((cur->nodesetval == NULL) || (cur->nodesetval->nodeNr == 0)) {
7649 valuePush(ctxt, xmlXPathCacheNewCString(ctxt, ""));
7650 } else {
7651 int i = 0; /* Should be first in document order !!!!! */
7652 switch (cur->nodesetval->nodeTab[i]->type) {
7653 case XML_ELEMENT_NODE:
7654 case XML_ATTRIBUTE_NODE:
7655 case XML_PI_NODE:
7656 if (cur->nodesetval->nodeTab[i]->name[0] == ' ')
7657 valuePush(ctxt, xmlXPathCacheNewCString(ctxt, ""));
7658 else
7659 valuePush(ctxt, xmlXPathCacheNewString(ctxt,
7660 cur->nodesetval->nodeTab[i]->name));
7661 break;
7662 case XML_NAMESPACE_DECL:
7663 valuePush(ctxt, xmlXPathCacheNewString(ctxt,
7664 ((xmlNsPtr)cur->nodesetval->nodeTab[i])->prefix));
7665 break;
7666 default:
7667 valuePush(ctxt, xmlXPathCacheNewCString(ctxt, ""));
7668 }
7669 }
7670 xmlXPathReleaseObject(ctxt->context, cur);
7671}
7672
7673/**
7674 * xmlXPathNamespaceURIFunction:

Callers 1

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

no test coverage detected