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

Function xmlDOMWrapRemoveNode

ThirdParty/libxml2/vtklibxml2/tree.c:8172–8292  ·  view source on GitHub ↗

* xmlDOMWrapRemoveNode: * @ctxt: a DOM wrapper context * @doc: the doc * @node: the node to be removed. * @options: set of options, unused at the moment * * Unlinks the given node from its owner. * This will substitute ns-references to node->nsDef for * ns-references to doc->oldNs, thus ensuring the removed * branch to be autark wrt ns-references. * * NOTE: This function was not intensively tested

Source from the content-addressed store, hash-verified

8170* -1 on API and internal errors.
8171*/
8172int
8173xmlDOMWrapRemoveNode(xmlDOMWrapCtxtPtr ctxt, xmlDocPtr doc,
8174 xmlNodePtr node, int options ATTRIBUTE_UNUSED)
8175{
8176 xmlNsPtr *list = NULL;
8177 int sizeList = 0, nbList = 0, ret = 0, i, j;
8178 xmlNsPtr ns;
8179
8180 if ((node == NULL) || (doc == NULL) || (node->doc != doc))
8181 return (-1);
8182
8183 /* TODO: 0 or -1 ? */
8184 if (node->parent == NULL)
8185 return (0);
8186
8187 switch (node->type) {
8188 case XML_TEXT_NODE:
8189 case XML_CDATA_SECTION_NODE:
8190 case XML_ENTITY_REF_NODE:
8191 case XML_PI_NODE:
8192 case XML_COMMENT_NODE:
8193 xmlUnlinkNodeInternal(node);
8194 return (0);
8195 case XML_ELEMENT_NODE:
8196 case XML_ATTRIBUTE_NODE:
8197 break;
8198 default:
8199 return (1);
8200 }
8201 xmlUnlinkNodeInternal(node);
8202 /*
8203 * Save out-of-scope ns-references in doc->oldNs.
8204 */
8205 do {
8206 switch (node->type) {
8207 case XML_ELEMENT_NODE:
8208 if ((ctxt == NULL) && (node->nsDef != NULL)) {
8209 ns = node->nsDef;
8210 do {
8211 if (xmlDOMWrapNSNormAddNsMapItem2(&list, &sizeList,
8212 &nbList, ns, ns) == -1)
8213 ret = -1;
8214 ns = ns->next;
8215 } while (ns != NULL);
8216 }
8217 /* Falls through. */
8218 case XML_ATTRIBUTE_NODE:
8219 if (node->ns != NULL) {
8220 /*
8221 * Find a mapping.
8222 */
8223 if (list != NULL) {
8224 for (i = 0, j = 0; i < nbList; i++, j += 2) {
8225 if (node->ns == list[j]) {
8226 node->ns = list[++j];
8227 goto next_node;
8228 }
8229 }

Callers

nothing calls this directly

Calls 3

xmlUnlinkNodeInternalFunction · 0.85
xmlDOMWrapStoreNsFunction · 0.85

Tested by

no test coverage detected