diff options
author | Daniel Veillard <veillard@src.gnome.org> | 2002-01-26 21:42:58 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 2002-01-26 21:42:58 +0000 |
commit | 8ee9c8f6c4ac1d1865cd5fcdc02e59a0c8de2d8a (patch) | |
tree | 90e819b069392d047a18c459e7bfb988a3f0ae04 | |
parent | a42f25f939a92818e689cbf15ec806c8363cd65f (diff) | |
download | android_external_libxml2-8ee9c8f6c4ac1d1865cd5fcdc02e59a0c8de2d8a.tar.gz android_external_libxml2-8ee9c8f6c4ac1d1865cd5fcdc02e59a0c8de2d8a.tar.bz2 android_external_libxml2-8ee9c8f6c4ac1d1865cd5fcdc02e59a0c8de2d8a.zip |
applied patch from Anthony Jones to implement copy of DTD subtree too. Had
* entities.c tree.c include/libxml/entities.h: applied patch
from Anthony Jones to implement copy of DTD subtree too. Had
just to keep 2 function private which really ought to become
public ones.
Daniel
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | entities.c | 2 | ||||
-rw-r--r-- | include/libxml/entities.h | 4 | ||||
-rw-r--r-- | tree.c | 112 |
4 files changed, 120 insertions, 5 deletions
@@ -1,3 +1,10 @@ +Sat Jan 26 22:41:13 CET 2002 Daniel Veillard <daniel@veillard.com> + + * entities.c tree.c include/libxml/entities.h: applied patch + from Anthony Jones to implement copy of DTD subtree too. Had + just to keep 2 function private which really ought to become + public ones. + Fri Jan 25 15:14:55 CET 2002 Daniel Veillard <daniel@veillard.com> * xmllint.c: added pointers to the web pages in the usage() @@ -883,6 +883,8 @@ xmlCopyEntity(xmlEntityPtr ent) { cur->content = xmlStrdup(ent->content); if (ent->orig != NULL) cur->orig = xmlStrdup(ent->orig); + if (ent->URI != NULL) + cur->URI = xmlStrdup(ent->URI); return(cur); } diff --git a/include/libxml/entities.h b/include/libxml/entities.h index 4ce07519..4bd11a3f 100644 --- a/include/libxml/entities.h +++ b/include/libxml/entities.h @@ -38,8 +38,8 @@ struct _xmlEntity { void *_private; /* application data */ xmlElementType type; /* XML_ENTITY_DECL, must be second ! */ const xmlChar *name; /* Attribute name */ - struct _xmlNode *children; /* NULL */ - struct _xmlNode *last; /* NULL */ + struct _xmlNode *children; /* First child link */ + struct _xmlNode *last; /* Last child link */ struct _xmlDtd *parent; /* -> DTD */ struct _xmlNode *next; /* next sibling link */ struct _xmlNode *prev; /* previous sibling link */ @@ -71,6 +71,57 @@ static int xmlCheckDTD = 1; /************************************************************************ * * + * Functions to move to entities.c once the * + * API freeze is smoothen and they can be made public. * + * * + ************************************************************************/ +#include <libxml/hash.h> + +/** + * xmlGetEntityFromDtd: + * @dtd: A pointer to the DTD to search + * @name: The entity name + * + * Do an entity lookup in the DTD entity hash table and + * return the corresponding entity, if found. + * + * Returns A pointer to the entity structure or NULL if not found. + */ +static xmlEntityPtr +xmlGetEntityFromDtd(xmlDtdPtr dtd, const xmlChar *name) { + xmlEntitiesTablePtr table; + + if((dtd != NULL) && (dtd->entities != NULL)) { + table = (xmlEntitiesTablePtr) dtd->entities; + return((xmlEntityPtr) xmlHashLookup(table, name)); + /* return(xmlGetEntityFromTable(table, name)); */ + } + return(NULL); +} +/** + * xmlGetParameterEntityFromDtd: + * @dtd: A pointer to the DTD to search + * @name: The entity name + * + * Do an entity lookup in the DTD pararmeter entity hash table and + * return the corresponding entity, if found. + * + * Returns A pointer to the entity structure or NULL if not found. + */ +static xmlEntityPtr +xmlGetParameterEntityFromDtd(xmlDtdPtr dtd, const xmlChar *name) { + xmlEntitiesTablePtr table; + + if ((dtd != NULL) && (dtd->pentities != NULL)) { + table = (xmlEntitiesTablePtr) dtd->pentities; + return((xmlEntityPtr) xmlHashLookup(table, name)); + /* return(xmlGetEntityFromTable(table, name)); */ + } + return(NULL); +} + +/************************************************************************ + * * * Allocation and deallocation of basic structures * * * ************************************************************************/ @@ -1821,8 +1872,6 @@ xmlSetTreeDoc(xmlNodePtr tree, xmlDocPtr doc) { if (tree == NULL) return; - if (tree->type == XML_ENTITY_DECL) - return; if (tree->doc != doc) { if(tree->type == XML_ELEMENT_NODE) { prop = tree->properties; @@ -2989,8 +3038,10 @@ xmlStaticCopyNodeList(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent) { q->doc = doc; q->parent = parent; doc->intSubset = (xmlDtdPtr) q; + xmlAddChild(parent, q); } else { q = (xmlNodePtr) doc->intSubset; + xmlAddChild(parent, q); } } else q = xmlStaticCopyNode(node, doc, parent, 1); @@ -3067,6 +3118,7 @@ xmlNodePtr xmlCopyNodeList(const xmlNodePtr node) { xmlDtdPtr xmlCopyDtd(xmlDtdPtr dtd) { xmlDtdPtr ret; + xmlNodePtr cur, p = NULL, q; if (dtd == NULL) return(NULL); ret = xmlNewDtd(NULL, dtd->name, dtd->ExternalID, dtd->SystemID); @@ -3083,6 +3135,60 @@ xmlCopyDtd(xmlDtdPtr dtd) { if (dtd->attributes != NULL) ret->attributes = (void *) xmlCopyAttributeTable( (xmlAttributeTablePtr) dtd->attributes); + if (dtd->pentities != NULL) + ret->pentities = (void *) xmlCopyEntitiesTable( + (xmlEntitiesTablePtr) dtd->pentities); + + cur = dtd->children; + while (cur != NULL) { + q = NULL; + + if (cur->type == XML_ENTITY_DECL) { + xmlEntityPtr tmp = (xmlEntityPtr) cur; + switch (tmp->etype) { + case XML_INTERNAL_GENERAL_ENTITY: + case XML_EXTERNAL_GENERAL_PARSED_ENTITY: + case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY: + q = (xmlNodePtr) xmlGetEntityFromDtd(ret, tmp->name); + break; + case XML_INTERNAL_PARAMETER_ENTITY: + case XML_EXTERNAL_PARAMETER_ENTITY: + q = (xmlNodePtr) + xmlGetParameterEntityFromDtd(ret, tmp->name); + break; + case XML_INTERNAL_PREDEFINED_ENTITY: + break; + } + } else if (cur->type == XML_ELEMENT_DECL) { + xmlElementPtr tmp = (xmlElementPtr) cur; + q = (xmlNodePtr) + xmlGetDtdQElementDesc(ret, tmp->name, tmp->prefix); + } else if (cur->type == XML_ATTRIBUTE_DECL) { + xmlAttributePtr tmp = (xmlAttributePtr) cur; + q = (xmlNodePtr) + xmlGetDtdQAttrDesc(ret, tmp->elem, tmp->name, tmp->prefix); + } else if (cur->type == XML_COMMENT_NODE) { + q = xmlCopyNode(cur, 0); + } + + if (q == NULL) { + cur = cur->next; + continue; + } + + if (p == NULL) + ret->children = q; + else + p->next = q; + + q->prev = p; + q->parent = (xmlNodePtr) ret; + q->next = NULL; + ret->last = q; + p = q; + cur = cur->next; + } + return(ret); } @@ -3116,7 +3222,7 @@ xmlCopyDoc(xmlDocPtr doc, int recursive) { ret->children = NULL; if (doc->intSubset != NULL) { ret->intSubset = xmlCopyDtd(doc->intSubset); - ret->intSubset->doc = ret; + xmlSetTreeDoc((xmlNodePtr)ret->intSubset, ret); ret->intSubset->parent = ret; } if (doc->oldNs != NULL) |