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

Function xmlDOMWrapNSNormGatherInScopeNs

ThirdParty/libxml2/vtklibxml2/tree.c:8073–8124  ·  view source on GitHub ↗

* * xmlDOMWrapNSNormGatherInScopeNs: * @map: the namespace map * @node: the node to start with * * Puts in-scope namespaces into the ns-map. * * Returns 0 on success, -1 on API or internal errors. */

Source from the content-addressed store, hash-verified

8071* Returns 0 on success, -1 on API or internal errors.
8072*/
8073static int
8074xmlDOMWrapNSNormGatherInScopeNs(xmlNsMapPtr *map,
8075 xmlNodePtr node)
8076{
8077 xmlNodePtr cur;
8078 xmlNsPtr ns;
8079 xmlNsMapItemPtr mi;
8080 int shadowed;
8081
8082 if ((map == NULL) || (*map != NULL))
8083 return (-1);
8084 if ((node == NULL) || (node->type == XML_NAMESPACE_DECL))
8085 return (-1);
8086 /*
8087 * Get in-scope ns-decls of @parent.
8088 */
8089 cur = node;
8090 while ((cur != NULL) && (cur != (xmlNodePtr) cur->doc)) {
8091 if (cur->type == XML_ELEMENT_NODE) {
8092 if (cur->nsDef != NULL) {
8093 ns = cur->nsDef;
8094 do {
8095 shadowed = 0;
8096 if (XML_NSMAP_NOTEMPTY(*map)) {
8097 /*
8098 * Skip shadowed prefixes.
8099 */
8100 XML_NSMAP_FOREACH(*map, mi) {
8101 if ((ns->prefix == mi->newNs->prefix) ||
8102 xmlStrEqual(ns->prefix, mi->newNs->prefix)) {
8103 shadowed = 1;
8104 break;
8105 }
8106 }
8107 }
8108 /*
8109 * Insert mapping.
8110 */
8111 mi = xmlDOMWrapNsMapAddItem(map, 0, NULL,
8112 ns, XML_TREE_NSMAP_PARENT);
8113 if (mi == NULL)
8114 return (-1);
8115 if (shadowed)
8116 mi->shadowDepth = 0;
8117 ns = ns->next;
8118 } while (ns != NULL);
8119 }
8120 }
8121 cur = cur->parent;
8122 }
8123 return (0);
8124}
8125
8126/*
8127* xmlDOMWrapNSNormAddNsMapItem2:

Callers 3

xmlDOMWrapAdoptBranchFunction · 0.85
xmlDOMWrapCloneNodeFunction · 0.85

Calls 2

xmlStrEqualFunction · 0.85
xmlDOMWrapNsMapAddItemFunction · 0.85

Tested by

no test coverage detected