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

Function xmlXPathNamespaceURIFunction

ThirdParty/libxml2/vtklibxml2/xpath.c:7687–7722  ·  view source on GitHub ↗

* xmlXPathNamespaceURIFunction: * @ctxt: the XPath Parser context * @nargs: the number of arguments * * Implement the namespace-uri() XPath function * string namespace-uri(node-set?) * The namespace-uri function returns a string containing the * namespace URI of the expanded name of the node in the argument * node-set that is first in document order. If the node-set is empty, * the f

Source from the content-addressed store, hash-verified

7685 * defaults to the context node.
7686 */
7687void
7688xmlXPathNamespaceURIFunction(xmlXPathParserContextPtr ctxt, int nargs) {
7689 xmlXPathObjectPtr cur;
7690
7691 if (ctxt == NULL) return;
7692
7693 if (nargs == 0) {
7694 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt, ctxt->context->node));
7695 nargs = 1;
7696 }
7697 CHECK_ARITY(1);
7698 if ((ctxt->value == NULL) ||
7699 ((ctxt->value->type != XPATH_NODESET) &&
7700 (ctxt->value->type != XPATH_XSLT_TREE)))
7701 XP_ERROR(XPATH_INVALID_TYPE);
7702 cur = valuePop(ctxt);
7703
7704 if ((cur->nodesetval == NULL) || (cur->nodesetval->nodeNr == 0)) {
7705 valuePush(ctxt, xmlXPathCacheNewCString(ctxt, ""));
7706 } else {
7707 int i = 0; /* Should be first in document order !!!!! */
7708 switch (cur->nodesetval->nodeTab[i]->type) {
7709 case XML_ELEMENT_NODE:
7710 case XML_ATTRIBUTE_NODE:
7711 if (cur->nodesetval->nodeTab[i]->ns == NULL)
7712 valuePush(ctxt, xmlXPathCacheNewCString(ctxt, ""));
7713 else
7714 valuePush(ctxt, xmlXPathCacheNewString(ctxt,
7715 cur->nodesetval->nodeTab[i]->ns->href));
7716 break;
7717 default:
7718 valuePush(ctxt, xmlXPathCacheNewCString(ctxt, ""));
7719 }
7720 }
7721 xmlXPathReleaseObject(ctxt->context, cur);
7722}
7723
7724/**
7725 * xmlXPathNameFunction:

Callers

nothing calls this directly

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