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

Function xmlSearchNsByPrefixStrict

ThirdParty/libxml2/vtklibxml2/tree.c:8409–8456  ·  view source on GitHub ↗

* xmlSearchNsByPrefixStrict: * @doc: the document * @node: the start node * @prefix: the searched namespace prefix * @retNs: the resulting ns-decl * * Dynamically searches for a ns-declaration which matches * the given @nsName in the ancestor-or-self axis of @node. * * Returns 1 if a ns-decl was found, 0 if not and -1 on API * and internal errors. */

Source from the content-addressed store, hash-verified

8407* and internal errors.
8408*/
8409static int
8410xmlSearchNsByPrefixStrict(xmlDocPtr doc, xmlNodePtr node,
8411 const xmlChar* prefix,
8412 xmlNsPtr *retNs)
8413{
8414 xmlNodePtr cur;
8415 xmlNsPtr ns;
8416
8417 if ((doc == NULL) || (node == NULL) || (node->type == XML_NAMESPACE_DECL))
8418 return(-1);
8419
8420 if (retNs)
8421 *retNs = NULL;
8422 if (IS_STR_XML(prefix)) {
8423 if (retNs) {
8424 *retNs = xmlTreeEnsureXMLDecl(doc);
8425 if (*retNs == NULL)
8426 return (-1);
8427 }
8428 return (1);
8429 }
8430 cur = node;
8431 do {
8432 if (cur->type == XML_ELEMENT_NODE) {
8433 if (cur->nsDef != NULL) {
8434 ns = cur->nsDef;
8435 do {
8436 if ((prefix == ns->prefix) ||
8437 xmlStrEqual(prefix, ns->prefix))
8438 {
8439 /*
8440 * Disabled namespaces, e.g. xmlns:abc="".
8441 */
8442 if (ns->href == NULL)
8443 return(0);
8444 if (retNs)
8445 *retNs = ns;
8446 return (1);
8447 }
8448 ns = ns->next;
8449 } while (ns != NULL);
8450 }
8451 } else if (cur->type == XML_ENTITY_DECL)
8452 return (0);
8453 cur = cur->parent;
8454 } while ((cur != NULL) && (cur->doc != (xmlDocPtr) cur));
8455 return (0);
8456}
8457
8458/*
8459* xmlDOMWrapNSNormDeclareNsForced:

Callers 1

Calls 2

xmlTreeEnsureXMLDeclFunction · 0.85
xmlStrEqualFunction · 0.85

Tested by

no test coverage detected