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

Function xmlC14NVisibleNsStackFind

ThirdParty/libxml2/vtklibxml2/c14n.c:395–427  ·  view source on GitHub ↗

* xmlC14NVisibleNsStackFind: * @ctx: the C14N context * @ns: the namespace to check * * Checks whether the given namespace was already rendered or not * * Returns 1 if we already wrote this namespace or 0 otherwise */

Source from the content-addressed store, hash-verified

393 * Returns 1 if we already wrote this namespace or 0 otherwise
394 */
395static int
396xmlC14NVisibleNsStackFind(xmlC14NVisibleNsStackPtr cur, xmlNsPtr ns)
397{
398 int i;
399 const xmlChar *prefix;
400 const xmlChar *href;
401 int has_empty_ns;
402
403 if(cur == NULL) {
404 xmlC14NErrParam(NULL);
405 return (0);
406 }
407
408 /*
409 * if the default namespace xmlns="" is not defined yet then
410 * we do not want to print it out
411 */
412 prefix = ((ns == NULL) || (ns->prefix == NULL)) ? BAD_CAST "" : ns->prefix;
413 href = ((ns == NULL) || (ns->href == NULL)) ? BAD_CAST "" : ns->href;
414 has_empty_ns = (xmlC14NStrEqual(prefix, NULL) && xmlC14NStrEqual(href, NULL));
415
416 if (cur->nsTab != NULL) {
417 int start = (has_empty_ns) ? 0 : cur->nsPrevStart;
418 for (i = cur->nsCurEnd - 1; i >= start; --i) {
419 xmlNsPtr ns1 = cur->nsTab[i];
420
421 if(xmlC14NStrEqual(prefix, (ns1 != NULL) ? ns1->prefix : NULL)) {
422 return(xmlC14NStrEqual(href, (ns1 != NULL) ? ns1->href : NULL));
423 }
424 }
425 }
426 return(has_empty_ns);
427}
428
429static int
430xmlExcC14NVisibleNsStackFind(xmlC14NVisibleNsStackPtr cur, xmlNsPtr ns, xmlC14NCtxPtr ctx) {

Callers 2

Calls 2

xmlC14NErrParamFunction · 0.85
xmlC14NStrEqualFunction · 0.85

Tested by

no test coverage detected