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

Function xmlInsertProp

ThirdParty/libxml2/vtklibxml2/tree.c:3042–3082  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3040}
3041
3042static xmlNodePtr
3043xmlInsertProp(xmlDocPtr doc, xmlNodePtr cur, xmlNodePtr parent,
3044 xmlNodePtr prev, xmlNodePtr next) {
3045 xmlAttrPtr attr;
3046
3047 if (((prev != NULL) && (prev->type != XML_ATTRIBUTE_NODE)) ||
3048 ((next != NULL) && (next->type != XML_ATTRIBUTE_NODE)))
3049 return(NULL);
3050
3051 /* check if an attribute with the same name exists */
3052 attr = xmlGetPropNodeInternal(parent, cur->name,
3053 cur->ns ? cur->ns->href : NULL, 0);
3054
3055 xmlUnlinkNodeInternal(cur);
3056
3057 if (cur->doc != doc) {
3058 if (xmlSetTreeDoc(cur, doc) < 0)
3059 return(NULL);
3060 }
3061
3062 cur->parent = parent;
3063 cur->prev = prev;
3064 cur->next = next;
3065
3066 if (prev == NULL) {
3067 if (parent != NULL)
3068 parent->properties = (xmlAttrPtr) cur;
3069 } else {
3070 prev->next = cur;
3071 }
3072 if (next != NULL) {
3073 next->prev = cur;
3074 }
3075
3076 if ((attr != NULL) && (attr != (xmlAttrPtr) cur)) {
3077 /* different instance, destroy it (attributes must be unique) */
3078 xmlRemoveProp((xmlAttrPtr) attr);
3079 }
3080
3081 return cur;
3082}
3083
3084static xmlNodePtr
3085xmlInsertNode(xmlDocPtr doc, xmlNodePtr cur, xmlNodePtr parent,

Callers 1

xmlInsertNodeFunction · 0.85

Calls 4

xmlGetPropNodeInternalFunction · 0.85
xmlUnlinkNodeInternalFunction · 0.85
xmlSetTreeDocFunction · 0.85
xmlRemovePropFunction · 0.85

Tested by

no test coverage detected