xmlNode *frag = xmlNewDocFragment(node->doc);
xmlReplaceNode(node, frag);
frag->children = node->children;
+ frag->last = node->last;
}
}
if (child->type == XML_ELEMENT_NODE) {
// Find the ID, if any.
string id;
+ xmlAttr *id_attr = NULL;
for (xmlAttr *attr = child->properties; attr != NULL; attr = attr->next) {
if (strcmp(reinterpret_cast<const char *>(attr->ns->href), "http://template.sesse.net/") == 0 &&
strcmp(reinterpret_cast<const char *>(attr->name), "id") == 0) {
id = reinterpret_cast<const char *>(xmlNodeGetContent(attr->children));
-
- if (clean) {
- if (attr->prev == NULL) {
- child->properties = attr->next;
- } else {
- attr->prev->next = attr->next;
- }
- }
+ id_attr = attr;
}
}
+ if (clean && id_attr != NULL) {
+ xmlRemoveProp(id_attr);
+ }
// Check all substitutions to see if we found anything appropriate.
for (auto it : substitution_map) {