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

Function xmlSearchNsSafe

ThirdParty/libxml2/vtklibxml2/tree.c:6045–6115  ·  view source on GitHub ↗

* xmlSearchNsSafe: * @node: a node * @prefix: a namespace prefix * @out: pointer to resulting namespace * * Search a namespace with @prefix in scope of @node. * * Returns 0 on success, -1 if a memory allocation failed, 1 on * other errors. */

Source from the content-addressed store, hash-verified

6043 * other errors.
6044 */
6045int
6046xmlSearchNsSafe(xmlNodePtr node, const xmlChar *prefix,
6047 xmlNsPtr *out) {
6048 xmlNsPtr cur;
6049 xmlDocPtr doc;
6050 xmlNodePtr orig = node;
6051 xmlNodePtr parent;
6052
6053 if (out == NULL)
6054 return(1);
6055 *out = NULL;
6056 if ((node == NULL) || (node->type == XML_NAMESPACE_DECL))
6057 return(1);
6058
6059 doc = node->doc;
6060
6061 if ((doc != NULL) && (IS_STR_XML(prefix))) {
6062 cur = xmlTreeEnsureXMLDecl(doc);
6063 if (cur == NULL)
6064 return(-1);
6065 *out = cur;
6066 return(0);
6067 }
6068
6069 while (node->type != XML_ELEMENT_NODE) {
6070 node = node->parent;
6071 if (node == NULL)
6072 return(0);
6073 }
6074
6075 parent = node;
6076
6077 while ((node != NULL) && (node->type == XML_ELEMENT_NODE)) {
6078 cur = node->nsDef;
6079 while (cur != NULL) {
6080 if ((xmlStrEqual(cur->prefix, prefix)) &&
6081 (cur->href != NULL)) {
6082 *out = cur;
6083 return(0);
6084 }
6085 cur = cur->next;
6086 }
6087 if (orig != node) {
6088 cur = node->ns;
6089 if ((cur != NULL) &&
6090 (xmlStrEqual(cur->prefix, prefix)) &&
6091 (cur->href != NULL)) {
6092 *out = cur;
6093 return(0);
6094 }
6095 }
6096
6097 node = node->parent;
6098 }
6099
6100 /*
6101 * The XML-1.0 namespace is normally held on the document
6102 * element. In this case exceptionally create it on the

Callers 11

SAX2.cFile · 0.85
xmlSAX2StartElementFunction · 0.85
xmlSAX2AttributeNsFunction · 0.85
xmlSAX2StartElementNsFunction · 0.85
xmlCopyPropInternalFunction · 0.85
xmlStaticCopyNodeFunction · 0.85
xmlSearchNsFunction · 0.85
xmlNewReconciledNsFunction · 0.85
xmlSetPropFunction · 0.85

Calls 3

xmlTreeEnsureXMLDeclFunction · 0.85
xmlStrEqualFunction · 0.85
xmlNewXmlNsFunction · 0.85

Tested by

no test coverage detected