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>
* xmlschemas.c: Fixed SAX2 validation: grow of internal
......
......@@ -1964,11 +1964,8 @@ xmlFreeProp(xmlAttrPtr cur) {
xmlDeregisterNodeDefaultValue((xmlNodePtr)cur);
/* Check for ID removal -> leading to invalid references ! */
if ((cur->parent != NULL) && (cur->parent->doc != NULL) &&
((cur->parent->doc->intSubset != NULL) ||
(cur->parent->doc->extSubset != NULL))) {
if (xmlIsID(cur->parent->doc, cur->parent, cur))
xmlRemoveID(cur->parent->doc, cur);
if ((cur->doc != NULL) && (cur->atype == XML_ATTRIBUTE_ID)) {
xmlRemoveID(cur->doc, cur);
}
if (cur->children != NULL) xmlFreeNodeList(cur->children);
DICT_FREE(cur->name)
......@@ -3408,6 +3405,11 @@ xmlUnlinkNode(xmlNodePtr cur) {
xmlNodePtr parent;
parent = cur->parent;
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)
parent->properties = ((xmlAttrPtr) cur)->next;
} else {
......@@ -3481,6 +3483,12 @@ xmlReplaceNode(xmlNodePtr old, xmlNodePtr cur) {
if (cur->type == XML_ATTRIBUTE_NODE) {
if (cur->parent->properties == (xmlAttrPtr)old)
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 {
if (cur->parent->children == old)
cur->parent->children = cur;
......
......@@ -2772,6 +2772,7 @@ xmlRemoveID(xmlDocPtr doc, xmlAttrPtr attr) {
}
xmlHashRemoveEntry(table, ID, (xmlHashDeallocator) xmlFreeID);
xmlFree(ID);
attr->atype = 0;
return(0);
}
......
......@@ -1612,9 +1612,34 @@ xmlTextReaderNext(xmlTextReaderPtr reader) {
* string must be deallocated by the caller.
*/
xmlChar *
xmlTextReaderReadInnerXml(xmlTextReaderPtr reader ATTRIBUTE_UNUSED) {
TODO
return(NULL);
xmlTextReaderReadInnerXml(xmlTextReaderPtr reader ATTRIBUTE_UNUSED)
{
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) {
* string must be deallocated by the caller.
*/
xmlChar *
xmlTextReaderReadOuterXml(xmlTextReaderPtr reader ATTRIBUTE_UNUSED) {
TODO
return(NULL);
xmlTextReaderReadOuterXml(xmlTextReaderPtr reader ATTRIBUTE_UNUSED)
{
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