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
diff --git a/ChangeLog b/ChangeLog
index 53ddf2c..b19bc0a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+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
diff --git a/tree.c b/tree.c
index a040ba3..7a2b01c 100644
--- a/tree.c
+++ b/tree.c
@@ -1964,11 +1964,8 @@
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 @@
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 @@
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;
diff --git a/valid.c b/valid.c
index 82ca7fc..f9daada 100644
--- a/valid.c
+++ b/valid.c
@@ -2772,6 +2772,7 @@
}
xmlHashRemoveEntry(table, ID, (xmlHashDeallocator) xmlFreeID);
xmlFree(ID);
+ attr->atype = 0;
return(0);
}
diff --git a/xmlreader.c b/xmlreader.c
index 54a6bf8..c3cadb0 100644
--- a/xmlreader.c
+++ b/xmlreader.c
@@ -1612,9 +1612,34 @@
* 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 @@
* 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;
}
/**