| 3040 | } |
| 3041 | |
| 3042 | static xmlNodePtr |
| 3043 | xmlInsertProp(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 | |
| 3084 | static xmlNodePtr |
| 3085 | xmlInsertNode(xmlDocPtr doc, xmlNodePtr cur, xmlNodePtr parent, |
no test coverage detected