Commit da6f4af3 authored by Daniel Veillard's avatar Daniel Veillard
Browse files

applied patch from Rob Richards for removal of ID (and xml:id) applied

* tree.c valid.c: applied patch from Rob Richards for removal
  of ID (and xml:id)
* xmlreader.c: applied patch from James Wert implementing
  xmlTextReaderReadInnerXml and xmlTextReaderReadOuterXml
Daniel
parent 84a56e31
Mon Jun 20 18:11:32 CEST 2005 Daniel Veillard <daniel@veillard.com>
* tree.c valid.c: applied patch from Rob Richards for removal
of ID (and xml:id)
* xmlreader.c: applied patch from James Wert implementing
xmlTextReaderReadInnerXml and xmlTextReaderReadOuterXml
Thu Jun 16 14:38:22 CEST 2005 Kasimier Buchcik <libxml2-cvs@cazic.net> Thu Jun 16 14:38:22 CEST 2005 Kasimier Buchcik <libxml2-cvs@cazic.net>
* xmlschemas.c: Fixed SAX2 validation: grow of internal * xmlschemas.c: Fixed SAX2 validation: grow of internal
......
...@@ -1964,11 +1964,8 @@ xmlFreeProp(xmlAttrPtr cur) { ...@@ -1964,11 +1964,8 @@ xmlFreeProp(xmlAttrPtr cur) {
xmlDeregisterNodeDefaultValue((xmlNodePtr)cur); xmlDeregisterNodeDefaultValue((xmlNodePtr)cur);
/* Check for ID removal -> leading to invalid references ! */ /* Check for ID removal -> leading to invalid references ! */
if ((cur->parent != NULL) && (cur->parent->doc != NULL) && if ((cur->doc != NULL) && (cur->atype == XML_ATTRIBUTE_ID)) {
((cur->parent->doc->intSubset != NULL) || xmlRemoveID(cur->doc, cur);
(cur->parent->doc->extSubset != NULL))) {
if (xmlIsID(cur->parent->doc, cur->parent, cur))
xmlRemoveID(cur->parent->doc, cur);
} }
if (cur->children != NULL) xmlFreeNodeList(cur->children); if (cur->children != NULL) xmlFreeNodeList(cur->children);
DICT_FREE(cur->name) DICT_FREE(cur->name)
...@@ -3408,6 +3405,11 @@ xmlUnlinkNode(xmlNodePtr cur) { ...@@ -3408,6 +3405,11 @@ xmlUnlinkNode(xmlNodePtr cur) {
xmlNodePtr parent; xmlNodePtr parent;
parent = cur->parent; parent = cur->parent;
if (cur->type == XML_ATTRIBUTE_NODE) { if (cur->type == XML_ATTRIBUTE_NODE) {
/* If attribute is an ID from subset then remove it */
if ((((xmlAttrPtr) cur)->atype == XML_ATTRIBUTE_ID) &&
xmlIsID(parent->doc, parent, (xmlAttrPtr) cur)) {
xmlRemoveID(cur->doc, (xmlAttrPtr) cur);
}
if (parent->properties == (xmlAttrPtr) cur) if (parent->properties == (xmlAttrPtr) cur)
parent->properties = ((xmlAttrPtr) cur)->next; parent->properties = ((xmlAttrPtr) cur)->next;
} else { } else {
...@@ -3481,6 +3483,12 @@ xmlReplaceNode(xmlNodePtr old, xmlNodePtr cur) { ...@@ -3481,6 +3483,12 @@ xmlReplaceNode(xmlNodePtr old, xmlNodePtr cur) {
if (cur->type == XML_ATTRIBUTE_NODE) { if (cur->type == XML_ATTRIBUTE_NODE) {
if (cur->parent->properties == (xmlAttrPtr)old) if (cur->parent->properties == (xmlAttrPtr)old)
cur->parent->properties = ((xmlAttrPtr) cur); cur->parent->properties = ((xmlAttrPtr) cur);
/* If old attribute is ID and defined in DTD then remove ID */
if ((((xmlAttrPtr) old)->atype == XML_ATTRIBUTE_ID) &&
xmlIsID(old->doc, old->parent, (xmlAttrPtr) old)) {
xmlRemoveID(old->doc, (xmlAttrPtr) old);
}
} else { } else {
if (cur->parent->children == old) if (cur->parent->children == old)
cur->parent->children = cur; cur->parent->children = cur;
......
...@@ -2772,6 +2772,7 @@ xmlRemoveID(xmlDocPtr doc, xmlAttrPtr attr) { ...@@ -2772,6 +2772,7 @@ xmlRemoveID(xmlDocPtr doc, xmlAttrPtr attr) {
} }
xmlHashRemoveEntry(table, ID, (xmlHashDeallocator) xmlFreeID); xmlHashRemoveEntry(table, ID, (xmlHashDeallocator) xmlFreeID);
xmlFree(ID); xmlFree(ID);
attr->atype = 0;
return(0); return(0);
} }
......
...@@ -1612,9 +1612,34 @@ xmlTextReaderNext(xmlTextReaderPtr reader) { ...@@ -1612,9 +1612,34 @@ xmlTextReaderNext(xmlTextReaderPtr reader) {
* string must be deallocated by the caller. * string must be deallocated by the caller.
*/ */
xmlChar * xmlChar *
xmlTextReaderReadInnerXml(xmlTextReaderPtr reader ATTRIBUTE_UNUSED) { xmlTextReaderReadInnerXml(xmlTextReaderPtr reader ATTRIBUTE_UNUSED)
TODO {
return(NULL); xmlChar *resbuf;
xmlNodePtr node, cur_node;
xmlBufferPtr buff, buff2;
xmlDocPtr doc;
if (xmlTextReaderExpand(reader) == NULL) {
return NULL;
}
doc = reader->doc;
buff = xmlBufferCreate();
for (cur_node = reader->node->children; cur_node != NULL;
cur_node = cur_node->next) {
node = xmlDocCopyNode(cur_node, doc, 1);
buff2 = xmlBufferCreate();
if (xmlNodeDump(buff2, doc, node, 0, 0) == -1) {
xmlFreeNode(node);
xmlBufferFree(buff2);
xmlBufferFree(buff);
return NULL;
}
xmlBufferCat(buff, buff2->content);
xmlFreeNode(node);
xmlBufferFree(buff2);
}
resbuf = buff->content;
return resbuf;
} }
/** /**
...@@ -1628,9 +1653,32 @@ xmlTextReaderReadInnerXml(xmlTextReaderPtr reader ATTRIBUTE_UNUSED) { ...@@ -1628,9 +1653,32 @@ xmlTextReaderReadInnerXml(xmlTextReaderPtr reader ATTRIBUTE_UNUSED) {
* string must be deallocated by the caller. * string must be deallocated by the caller.
*/ */
xmlChar * xmlChar *
xmlTextReaderReadOuterXml(xmlTextReaderPtr reader ATTRIBUTE_UNUSED) { xmlTextReaderReadOuterXml(xmlTextReaderPtr reader ATTRIBUTE_UNUSED)
TODO {
return(NULL); xmlChar *resbuf;
xmlNodePtr node;
xmlBufferPtr buff;
xmlDocPtr doc;
node = reader->node;
doc = reader->doc;
if (xmlTextReaderExpand(reader) == NULL) {
return NULL;
}
node = xmlDocCopyNode(node, doc, 1);
buff = xmlBufferCreate();
if (xmlNodeDump(buff, doc, node, 0, 0) == -1) {
xmlFreeNode(node);
xmlBufferFree(buff);
return NULL;
}
resbuf = buff->content;
buff->content = NULL;
xmlFreeNode(node);
xmlBufferFree(buff);
return resbuf;
} }
/** /**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment