Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 1 | /* |
| 2 | * tree.h : describes the structures found in an tree resulting |
| 3 | * from an XML parsing. |
| 4 | * |
| 5 | * See Copyright for the status of this software. |
| 6 | * |
Daniel Veillard | 39a1f9a | 1999-01-17 19:11:59 +0000 | [diff] [blame] | 7 | * Daniel.Veillard@w3.org |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #ifndef __XML_TREE_H__ |
| 11 | #define __XML_TREE_H__ |
| 12 | |
| 13 | |
| 14 | #ifdef __cplusplus |
| 15 | extern "C" { |
| 16 | #endif |
| 17 | |
Daniel Veillard | 39a1f9a | 1999-01-17 19:11:59 +0000 | [diff] [blame] | 18 | #include <stdio.h> |
| 19 | |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 20 | /* |
Daniel Veillard | ccb0963 | 1998-10-27 06:21:04 +0000 | [diff] [blame] | 21 | * The different element types carried by an XML tree |
| 22 | * |
| 23 | * NOTE: This is synchronized with DOM Level1 values |
| 24 | * See http://www.w3.org/TR/REC-DOM-Level-1/ |
| 25 | */ |
| 26 | typedef enum { |
| 27 | XML_ELEMENT_NODE= 1, |
| 28 | XML_ATTRIBUTE_NODE= 2, |
| 29 | XML_TEXT_NODE= 3, |
| 30 | XML_CDATA_SECTION_NODE= 4, |
| 31 | XML_ENTITY_REF_NODE= 5, |
| 32 | XML_ENTITY_NODE= 6, |
| 33 | XML_PI_NODE= 7, |
| 34 | XML_COMMENT_NODE= 8, |
| 35 | XML_DOCUMENT_NODE= 9, |
| 36 | XML_DOCUMENT_TYPE_NODE= 10, |
| 37 | XML_DOCUMENT_FRAG_NODE= 11, |
Daniel Veillard | 7c1206f | 1999-10-14 09:10:25 +0000 | [diff] [blame^] | 38 | XML_NOTATION_NODE= 12, |
| 39 | XML_HTML_DOCUMENT_NODE= 13 |
Daniel Veillard | ccb0963 | 1998-10-27 06:21:04 +0000 | [diff] [blame] | 40 | } xmlElementType; |
| 41 | |
| 42 | /* |
Daniel Veillard | 0ba4d53 | 1998-11-01 19:34:31 +0000 | [diff] [blame] | 43 | * Size of an internal character representation. |
| 44 | * |
| 45 | * Currently we use 8bit chars internal representation for memory efficiency, |
| 46 | * but the parser is not tied to that, just define UNICODE to switch to |
| 47 | * a 16 bits internal representation. Note that with 8 bits wide |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 48 | * xmlChars one can still use UTF-8 to handle correctly non ISO-Latin |
Daniel Veillard | 0ba4d53 | 1998-11-01 19:34:31 +0000 | [diff] [blame] | 49 | * input. |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 50 | */ |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 51 | |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 52 | #ifdef UNICODE |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 53 | typedef unsigned short xmlChar; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 54 | #else |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 55 | typedef unsigned char xmlChar; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 56 | #endif |
| 57 | |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 58 | #ifndef WIN32 |
| 59 | #ifndef CHAR |
| 60 | #define CHAR xmlChar |
| 61 | #endif |
| 62 | #endif |
| 63 | |
| 64 | #define BAD_CAST (xmlChar *) |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 65 | |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 66 | /* |
| 67 | * a DTD Notation definition |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 68 | */ |
| 69 | |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 70 | typedef struct xmlNotation { |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 71 | const xmlChar *name; /* Notation name */ |
| 72 | const xmlChar *PublicID; /* Public identifier, if any */ |
| 73 | const xmlChar *SystemID; /* System identifier, if any */ |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 74 | } xmlNotation; |
| 75 | typedef xmlNotation *xmlNotationPtr; |
| 76 | |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 77 | /* |
| 78 | * a DTD Attribute definition |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 79 | */ |
| 80 | |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 81 | typedef enum { |
| 82 | XML_ATTRIBUTE_CDATA = 1, |
| 83 | XML_ATTRIBUTE_ID, |
| 84 | XML_ATTRIBUTE_IDREF , |
| 85 | XML_ATTRIBUTE_IDREFS, |
| 86 | XML_ATTRIBUTE_ENTITY, |
| 87 | XML_ATTRIBUTE_ENTITIES, |
| 88 | XML_ATTRIBUTE_NMTOKEN, |
| 89 | XML_ATTRIBUTE_NMTOKENS, |
| 90 | XML_ATTRIBUTE_ENUMERATION, |
| 91 | XML_ATTRIBUTE_NOTATION |
| 92 | } xmlAttributeType; |
Daniel Veillard | 39a1f9a | 1999-01-17 19:11:59 +0000 | [diff] [blame] | 93 | |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 94 | typedef enum { |
| 95 | XML_ATTRIBUTE_NONE = 1, |
| 96 | XML_ATTRIBUTE_REQUIRED, |
| 97 | XML_ATTRIBUTE_IMPLIED, |
| 98 | XML_ATTRIBUTE_FIXED |
| 99 | } xmlAttributeDefault; |
| 100 | |
| 101 | typedef struct xmlEnumeration { |
| 102 | struct xmlEnumeration *next; /* next one */ |
Daniel Veillard | 6077d03 | 1999-10-09 09:11:45 +0000 | [diff] [blame] | 103 | const xmlChar *name; /* Enumeration name */ |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 104 | } xmlEnumeration; |
| 105 | typedef xmlEnumeration *xmlEnumerationPtr; |
| 106 | |
| 107 | typedef struct xmlAttribute { |
Daniel Veillard | 6077d03 | 1999-10-09 09:11:45 +0000 | [diff] [blame] | 108 | const xmlChar *elem; /* Element holding the attribute */ |
| 109 | const xmlChar *name; /* Attribute name */ |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 110 | struct xmlAttribute *next; /* list of attributes of an element */ |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 111 | xmlAttributeType type; /* The type */ |
| 112 | xmlAttributeDefault def; /* the default */ |
Daniel Veillard | 6077d03 | 1999-10-09 09:11:45 +0000 | [diff] [blame] | 113 | const xmlChar *defaultValue;/* or the default value */ |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 114 | xmlEnumerationPtr tree; /* or the enumeration tree if any */ |
| 115 | } xmlAttribute; |
| 116 | typedef xmlAttribute *xmlAttributePtr; |
Daniel Veillard | 39a1f9a | 1999-01-17 19:11:59 +0000 | [diff] [blame] | 117 | |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 118 | /* |
| 119 | * a DTD Element definition. |
| 120 | */ |
Daniel Veillard | 1899e85 | 1999-02-01 12:18:54 +0000 | [diff] [blame] | 121 | typedef enum { |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 122 | XML_ELEMENT_CONTENT_PCDATA = 1, |
Daniel Veillard | 1899e85 | 1999-02-01 12:18:54 +0000 | [diff] [blame] | 123 | XML_ELEMENT_CONTENT_ELEMENT, |
| 124 | XML_ELEMENT_CONTENT_SEQ, |
| 125 | XML_ELEMENT_CONTENT_OR |
| 126 | } xmlElementContentType; |
Daniel Veillard | 39a1f9a | 1999-01-17 19:11:59 +0000 | [diff] [blame] | 127 | |
Daniel Veillard | 1899e85 | 1999-02-01 12:18:54 +0000 | [diff] [blame] | 128 | typedef enum { |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 129 | XML_ELEMENT_CONTENT_ONCE = 1, |
Daniel Veillard | 1899e85 | 1999-02-01 12:18:54 +0000 | [diff] [blame] | 130 | XML_ELEMENT_CONTENT_OPT, |
| 131 | XML_ELEMENT_CONTENT_MULT, |
| 132 | XML_ELEMENT_CONTENT_PLUS |
| 133 | } xmlElementContentOccur; |
Daniel Veillard | 39a1f9a | 1999-01-17 19:11:59 +0000 | [diff] [blame] | 134 | |
| 135 | typedef struct xmlElementContent { |
Daniel Veillard | 1899e85 | 1999-02-01 12:18:54 +0000 | [diff] [blame] | 136 | xmlElementContentType type; /* PCDATA, ELEMENT, SEQ or OR */ |
| 137 | xmlElementContentOccur ocur; /* ONCE, OPT, MULT or PLUS */ |
Daniel Veillard | 6077d03 | 1999-10-09 09:11:45 +0000 | [diff] [blame] | 138 | const xmlChar *name; /* Element name */ |
Daniel Veillard | 39a1f9a | 1999-01-17 19:11:59 +0000 | [diff] [blame] | 139 | struct xmlElementContent *c1; /* first child */ |
| 140 | struct xmlElementContent *c2; /* second child */ |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 141 | } xmlElementContent; |
| 142 | typedef xmlElementContent *xmlElementContentPtr; |
Daniel Veillard | 39a1f9a | 1999-01-17 19:11:59 +0000 | [diff] [blame] | 143 | |
Daniel Veillard | 1899e85 | 1999-02-01 12:18:54 +0000 | [diff] [blame] | 144 | typedef enum { |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 145 | XML_ELEMENT_TYPE_EMPTY = 1, |
Daniel Veillard | 1899e85 | 1999-02-01 12:18:54 +0000 | [diff] [blame] | 146 | XML_ELEMENT_TYPE_ANY, |
| 147 | XML_ELEMENT_TYPE_MIXED, |
| 148 | XML_ELEMENT_TYPE_ELEMENT |
| 149 | } xmlElementTypeVal; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 150 | |
| 151 | typedef struct xmlElement { |
Daniel Veillard | 6077d03 | 1999-10-09 09:11:45 +0000 | [diff] [blame] | 152 | const xmlChar *name; /* Element name */ |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 153 | xmlElementTypeVal type; /* The type */ |
Daniel Veillard | 39a1f9a | 1999-01-17 19:11:59 +0000 | [diff] [blame] | 154 | xmlElementContentPtr content; /* the allowed element content */ |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 155 | xmlAttributePtr attributes; /* List of the declared attributes */ |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 156 | } xmlElement; |
| 157 | typedef xmlElement *xmlElementPtr; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 158 | |
| 159 | /* |
| 160 | * An XML namespace. |
| 161 | * Note that prefix == NULL is valid, it defines the default namespace |
| 162 | * within the subtree (until overriden). |
| 163 | */ |
| 164 | |
Daniel Veillard | 1899e85 | 1999-02-01 12:18:54 +0000 | [diff] [blame] | 165 | typedef enum { |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 166 | XML_GLOBAL_NAMESPACE = 1, /* old style global namespace */ |
Daniel Veillard | 1899e85 | 1999-02-01 12:18:54 +0000 | [diff] [blame] | 167 | XML_LOCAL_NAMESPACE /* new style local scoping */ |
| 168 | } xmlNsType; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 169 | |
| 170 | typedef struct xmlNs { |
| 171 | struct xmlNs *next; /* next Ns link for this node */ |
Daniel Veillard | 1899e85 | 1999-02-01 12:18:54 +0000 | [diff] [blame] | 172 | xmlNsType type; /* global or local */ |
Daniel Veillard | 6077d03 | 1999-10-09 09:11:45 +0000 | [diff] [blame] | 173 | const xmlChar *href; /* URL for the namespace */ |
| 174 | const xmlChar *prefix; /* prefix for the namespace */ |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 175 | } xmlNs; |
| 176 | typedef xmlNs *xmlNsPtr; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 177 | |
| 178 | /* |
| 179 | * An XML DtD, as defined by <!DOCTYPE. |
| 180 | */ |
| 181 | typedef struct xmlDtd { |
Daniel Veillard | 6077d03 | 1999-10-09 09:11:45 +0000 | [diff] [blame] | 182 | const xmlChar *name; /* Name of the DTD */ |
| 183 | const xmlChar *ExternalID; /* External identifier for PUBLIC DTD */ |
| 184 | const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC DTD */ |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 185 | void *notations; /* Hash table for notations if any */ |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 186 | void *elements; /* Hash table for elements if any */ |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 187 | void *attributes; /* Hash table for attributes if any */ |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 188 | void *entities; /* Hash table for entities if any */ |
| 189 | /* struct xmlDtd *next; * next link for this document */ |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 190 | } xmlDtd; |
| 191 | typedef xmlDtd *xmlDtdPtr; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 192 | |
| 193 | /* |
| 194 | * A attribute of an XML node. |
| 195 | */ |
| 196 | typedef struct xmlAttr { |
Daniel Veillard | 27fb075 | 1998-10-17 06:47:46 +0000 | [diff] [blame] | 197 | #ifndef XML_WITHOUT_CORBA |
| 198 | void *_private; /* for Corba, must be first ! */ |
| 199 | void *vepv; /* for Corba, must be next ! */ |
| 200 | #endif |
Daniel Veillard | ccb0963 | 1998-10-27 06:21:04 +0000 | [diff] [blame] | 201 | xmlElementType type; /* XML_ATTRIBUTE_NODE, must be third ! */ |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 202 | struct xmlNode *node; /* attr->node link */ |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 203 | struct xmlAttr *next; /* attribute list link */ |
Daniel Veillard | 6077d03 | 1999-10-09 09:11:45 +0000 | [diff] [blame] | 204 | const xmlChar *name; /* the name of the property */ |
Daniel Veillard | ccb0963 | 1998-10-27 06:21:04 +0000 | [diff] [blame] | 205 | struct xmlNode *val; /* the value of the property */ |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 206 | xmlNs *ns; /* pointer to the associated namespace */ |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 207 | } xmlAttr; |
| 208 | typedef xmlAttr *xmlAttrPtr; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 209 | |
| 210 | /* |
Daniel Veillard | 991e63d | 1999-08-15 23:32:28 +0000 | [diff] [blame] | 211 | * An XML ID instance. |
| 212 | */ |
| 213 | |
| 214 | typedef struct xmlID { |
| 215 | struct xmlID *next; /* next ID */ |
Daniel Veillard | 6077d03 | 1999-10-09 09:11:45 +0000 | [diff] [blame] | 216 | const xmlChar *value; /* The ID name */ |
Daniel Veillard | 991e63d | 1999-08-15 23:32:28 +0000 | [diff] [blame] | 217 | xmlAttrPtr attr; /* The attribut holding it */ |
| 218 | } xmlID; |
| 219 | typedef xmlID *xmlIDPtr; |
| 220 | |
| 221 | /* |
Daniel Veillard | c08a2c6 | 1999-09-08 21:35:25 +0000 | [diff] [blame] | 222 | * An XML IDREF instance. |
| 223 | */ |
| 224 | |
| 225 | typedef struct xmlRef { |
| 226 | struct xmlRef *next; /* next Ref */ |
Daniel Veillard | 6077d03 | 1999-10-09 09:11:45 +0000 | [diff] [blame] | 227 | const xmlChar *value; /* The Ref name */ |
Daniel Veillard | c08a2c6 | 1999-09-08 21:35:25 +0000 | [diff] [blame] | 228 | xmlAttrPtr attr; /* The attribut holding it */ |
| 229 | } xmlRef; |
| 230 | typedef xmlRef *xmlRefPtr; |
| 231 | |
| 232 | /* |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 233 | * A node in an XML tree. |
| 234 | */ |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 235 | typedef struct xmlNode { |
Daniel Veillard | 27fb075 | 1998-10-17 06:47:46 +0000 | [diff] [blame] | 236 | #ifndef XML_WITHOUT_CORBA |
| 237 | void *_private; /* for Corba, must be first ! */ |
| 238 | void *vepv; /* for Corba, must be next ! */ |
| 239 | #endif |
Daniel Veillard | ccb0963 | 1998-10-27 06:21:04 +0000 | [diff] [blame] | 240 | xmlElementType type; /* type number in the DTD, must be third ! */ |
Daniel Veillard | 0bef131 | 1998-10-14 02:36:47 +0000 | [diff] [blame] | 241 | struct xmlDoc *doc; /* the containing document */ |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 242 | struct xmlNode *parent; /* child->parent link */ |
| 243 | struct xmlNode *next; /* next sibling link */ |
Daniel Veillard | 0bef131 | 1998-10-14 02:36:47 +0000 | [diff] [blame] | 244 | struct xmlNode *prev; /* previous sibling link */ |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 245 | struct xmlNode *childs; /* parent->childs link */ |
Daniel Veillard | 39a1f9a | 1999-01-17 19:11:59 +0000 | [diff] [blame] | 246 | struct xmlNode *last; /* last child link */ |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 247 | struct xmlAttr *properties; /* properties list */ |
Daniel Veillard | 6077d03 | 1999-10-09 09:11:45 +0000 | [diff] [blame] | 248 | const xmlChar *name; /* the name of the node, or the entity */ |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 249 | xmlNs *ns; /* pointer to the associated namespace */ |
| 250 | xmlNs *nsDef; /* namespace definitions on this node */ |
Daniel Veillard | 6077d03 | 1999-10-09 09:11:45 +0000 | [diff] [blame] | 251 | xmlChar *content; /* the content */ |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 252 | } _xmlNode; |
| 253 | typedef _xmlNode xmlNode; |
| 254 | typedef _xmlNode *xmlNodePtr; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 255 | |
| 256 | /* |
| 257 | * An XML document. |
| 258 | */ |
| 259 | typedef struct xmlDoc { |
Daniel Veillard | 27fb075 | 1998-10-17 06:47:46 +0000 | [diff] [blame] | 260 | #ifndef XML_WITHOUT_CORBA |
| 261 | void *_private; /* for Corba, must be first ! */ |
| 262 | void *vepv; /* for Corba, must be next ! */ |
| 263 | #endif |
Daniel Veillard | ccb0963 | 1998-10-27 06:21:04 +0000 | [diff] [blame] | 264 | xmlElementType type; /* XML_DOCUMENT_NODE, must be second ! */ |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 265 | char *name; /* name/filename/URI of the document */ |
Daniel Veillard | 6077d03 | 1999-10-09 09:11:45 +0000 | [diff] [blame] | 266 | const xmlChar *version; /* the XML version string */ |
| 267 | const xmlChar *encoding; /* encoding, if any */ |
Daniel Veillard | 15a8df4 | 1998-09-24 19:15:06 +0000 | [diff] [blame] | 268 | int compression;/* level of zlib compression */ |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 269 | int standalone; /* standalone document (no external refs) */ |
Daniel Veillard | 39a1f9a | 1999-01-17 19:11:59 +0000 | [diff] [blame] | 270 | struct xmlDtd *intSubset; /* the document internal subset */ |
| 271 | struct xmlDtd *extSubset; /* the document external subset */ |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 272 | struct xmlNs *oldNs; /* Global namespace, the old way */ |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 273 | struct xmlNode *root; /* the document tree */ |
Daniel Veillard | 991e63d | 1999-08-15 23:32:28 +0000 | [diff] [blame] | 274 | void *ids; /* Hash table for ID attributes if any */ |
Daniel Veillard | c08a2c6 | 1999-09-08 21:35:25 +0000 | [diff] [blame] | 275 | void *refs; /* Hash table for IDREFs attributes if any */ |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 276 | } _xmlDoc; |
| 277 | typedef _xmlDoc xmlDoc; |
| 278 | typedef xmlDoc *xmlDocPtr; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 279 | |
| 280 | /* |
Daniel Veillard | 5099ae8 | 1999-04-21 20:12:07 +0000 | [diff] [blame] | 281 | * A buffer structure |
| 282 | */ |
| 283 | |
| 284 | typedef struct xmlBuffer { |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 285 | xmlChar *content; /* The buffer content UTF8 */ |
Daniel Veillard | 5099ae8 | 1999-04-21 20:12:07 +0000 | [diff] [blame] | 286 | unsigned int use; /* The buffer size used */ |
| 287 | unsigned int size; /* The buffer size */ |
| 288 | } _xmlBuffer; |
| 289 | typedef _xmlBuffer xmlBuffer; |
| 290 | typedef xmlBuffer *xmlBufferPtr; |
| 291 | |
| 292 | /* |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 293 | * Variables. |
| 294 | */ |
| 295 | extern xmlNsPtr baseDTD; |
| 296 | extern int oldXMLWDcompatibility;/* maintain compatibility with old WD */ |
| 297 | extern int xmlIndentTreeOutput; /* try to indent the tree dumps */ |
| 298 | |
| 299 | /* |
Daniel Veillard | 5099ae8 | 1999-04-21 20:12:07 +0000 | [diff] [blame] | 300 | * Handling Buffers. |
| 301 | */ |
| 302 | |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 303 | xmlBufferPtr xmlBufferCreate (void); |
| 304 | void xmlBufferFree (xmlBufferPtr buf); |
| 305 | int xmlBufferDump (FILE *file, |
| 306 | xmlBufferPtr buf); |
| 307 | void xmlBufferAdd (xmlBufferPtr buf, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 308 | const xmlChar *str, |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 309 | int len); |
| 310 | void xmlBufferCat (xmlBufferPtr buf, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 311 | const xmlChar *str); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 312 | void xmlBufferCCat (xmlBufferPtr buf, |
| 313 | const char *str); |
| 314 | int xmlBufferShrink (xmlBufferPtr buf, |
| 315 | int len); |
| 316 | void xmlBufferEmpty (xmlBufferPtr buf); |
Daniel Veillard | 5099ae8 | 1999-04-21 20:12:07 +0000 | [diff] [blame] | 317 | |
| 318 | /* |
Daniel Veillard | 1625364 | 1998-10-28 22:58:05 +0000 | [diff] [blame] | 319 | * Creating/freeing new structures |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 320 | */ |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 321 | xmlDtdPtr xmlCreateIntSubset (xmlDocPtr doc, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 322 | const xmlChar *name, |
| 323 | const xmlChar *ExternalID, |
| 324 | const xmlChar *SystemID); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 325 | xmlDtdPtr xmlNewDtd (xmlDocPtr doc, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 326 | const xmlChar *name, |
| 327 | const xmlChar *ExternalID, |
| 328 | const xmlChar *SystemID); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 329 | void xmlFreeDtd (xmlDtdPtr cur); |
| 330 | xmlNsPtr xmlNewGlobalNs (xmlDocPtr doc, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 331 | const xmlChar *href, |
| 332 | const xmlChar *prefix); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 333 | xmlNsPtr xmlNewNs (xmlNodePtr node, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 334 | const xmlChar *href, |
| 335 | const xmlChar *prefix); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 336 | void xmlFreeNs (xmlNsPtr cur); |
Daniel Veillard | 6077d03 | 1999-10-09 09:11:45 +0000 | [diff] [blame] | 337 | xmlDocPtr xmlNewDoc (const xmlChar *version); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 338 | void xmlFreeDoc (xmlDocPtr cur); |
| 339 | xmlAttrPtr xmlNewDocProp (xmlDocPtr doc, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 340 | const xmlChar *name, |
| 341 | const xmlChar *value); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 342 | xmlAttrPtr xmlNewProp (xmlNodePtr node, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 343 | const xmlChar *name, |
| 344 | const xmlChar *value); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 345 | xmlAttrPtr xmlNewNsProp (xmlNodePtr node, |
| 346 | xmlNsPtr ns, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 347 | const xmlChar *name, |
| 348 | const xmlChar *value); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 349 | void xmlFreePropList (xmlAttrPtr cur); |
| 350 | void xmlFreeProp (xmlAttrPtr cur); |
| 351 | xmlAttrPtr xmlCopyProp (xmlNodePtr target, |
| 352 | xmlAttrPtr cur); |
| 353 | xmlAttrPtr xmlCopyPropList (xmlNodePtr target, |
| 354 | xmlAttrPtr cur); |
| 355 | xmlDtdPtr xmlCopyDtd (xmlDtdPtr dtd); |
| 356 | xmlDocPtr xmlCopyDoc (xmlDocPtr doc, |
| 357 | int recursive); |
Daniel Veillard | 1625364 | 1998-10-28 22:58:05 +0000 | [diff] [blame] | 358 | |
| 359 | /* |
| 360 | * Creating new nodes |
| 361 | */ |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 362 | xmlNodePtr xmlNewDocNode (xmlDocPtr doc, |
| 363 | xmlNsPtr ns, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 364 | const xmlChar *name, |
| 365 | const xmlChar *content); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 366 | xmlNodePtr xmlNewNode (xmlNsPtr ns, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 367 | const xmlChar *name); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 368 | xmlNodePtr xmlNewChild (xmlNodePtr parent, |
| 369 | xmlNsPtr ns, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 370 | const xmlChar *name, |
| 371 | const xmlChar *content); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 372 | xmlNodePtr xmlNewDocText (xmlDocPtr doc, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 373 | const xmlChar *content); |
| 374 | xmlNodePtr xmlNewText (const xmlChar *content); |
| 375 | xmlNodePtr xmlNewPI (const xmlChar *name, |
| 376 | const xmlChar *content); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 377 | xmlNodePtr xmlNewDocTextLen (xmlDocPtr doc, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 378 | const xmlChar *content, |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 379 | int len); |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 380 | xmlNodePtr xmlNewTextLen (const xmlChar *content, |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 381 | int len); |
| 382 | xmlNodePtr xmlNewDocComment (xmlDocPtr doc, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 383 | const xmlChar *content); |
| 384 | xmlNodePtr xmlNewComment (const xmlChar *content); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 385 | xmlNodePtr xmlNewCDataBlock (xmlDocPtr doc, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 386 | const xmlChar *content, |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 387 | int len); |
| 388 | xmlNodePtr xmlNewReference (xmlDocPtr doc, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 389 | const xmlChar *name); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 390 | xmlNodePtr xmlCopyNode (xmlNodePtr node, |
| 391 | int recursive); |
| 392 | xmlNodePtr xmlCopyNodeList (xmlNodePtr node); |
Daniel Veillard | 1625364 | 1998-10-28 22:58:05 +0000 | [diff] [blame] | 393 | |
| 394 | /* |
| 395 | * Navigating |
| 396 | */ |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 397 | xmlNodePtr xmlGetLastChild (xmlNodePtr parent); |
| 398 | int xmlNodeIsText (xmlNodePtr node); |
Daniel Veillard | 1625364 | 1998-10-28 22:58:05 +0000 | [diff] [blame] | 399 | |
| 400 | /* |
| 401 | * Changing the structure |
| 402 | */ |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 403 | xmlNodePtr xmlAddChild (xmlNodePtr parent, |
| 404 | xmlNodePtr cur); |
| 405 | xmlNodePtr xmlAddSibling (xmlNodePtr cur, |
| 406 | xmlNodePtr elem); |
| 407 | void xmlUnlinkNode (xmlNodePtr cur); |
| 408 | xmlNodePtr xmlTextMerge (xmlNodePtr first, |
| 409 | xmlNodePtr second); |
| 410 | void xmlTextConcat (xmlNodePtr node, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 411 | const xmlChar *content, |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 412 | int len); |
| 413 | void xmlFreeNodeList (xmlNodePtr cur); |
| 414 | void xmlFreeNode (xmlNodePtr cur); |
Daniel Veillard | 1625364 | 1998-10-28 22:58:05 +0000 | [diff] [blame] | 415 | |
| 416 | /* |
| 417 | * Namespaces |
| 418 | */ |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 419 | xmlNsPtr xmlSearchNs (xmlDocPtr doc, |
| 420 | xmlNodePtr node, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 421 | const xmlChar *nameSpace); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 422 | xmlNsPtr xmlSearchNsByHref (xmlDocPtr doc, |
| 423 | xmlNodePtr node, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 424 | const xmlChar *href); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 425 | xmlNsPtr * xmlGetNsList (xmlDocPtr doc, |
| 426 | xmlNodePtr node); |
| 427 | void xmlSetNs (xmlNodePtr node, |
| 428 | xmlNsPtr ns); |
| 429 | xmlNsPtr xmlCopyNamespace (xmlNsPtr cur); |
| 430 | xmlNsPtr xmlCopyNamespaceList (xmlNsPtr cur); |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 431 | |
Daniel Veillard | 1625364 | 1998-10-28 22:58:05 +0000 | [diff] [blame] | 432 | /* |
| 433 | * Changing the content. |
| 434 | */ |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 435 | xmlAttrPtr xmlSetProp (xmlNodePtr node, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 436 | const xmlChar *name, |
| 437 | const xmlChar *value); |
Daniel Veillard | 6077d03 | 1999-10-09 09:11:45 +0000 | [diff] [blame] | 438 | xmlChar * xmlGetProp (xmlNodePtr node, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 439 | const xmlChar *name); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 440 | xmlNodePtr xmlStringGetNodeList (xmlDocPtr doc, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 441 | const xmlChar *value); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 442 | xmlNodePtr xmlStringLenGetNodeList (xmlDocPtr doc, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 443 | const xmlChar *value, |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 444 | int len); |
Daniel Veillard | 6077d03 | 1999-10-09 09:11:45 +0000 | [diff] [blame] | 445 | xmlChar * xmlNodeListGetString (xmlDocPtr doc, |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 446 | xmlNodePtr list, |
| 447 | int inLine); |
| 448 | void xmlNodeSetContent (xmlNodePtr cur, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 449 | const xmlChar *content); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 450 | void xmlNodeSetContentLen (xmlNodePtr cur, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 451 | const xmlChar *content, |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 452 | int len); |
| 453 | void xmlNodeAddContent (xmlNodePtr cur, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 454 | const xmlChar *content); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 455 | void xmlNodeAddContentLen (xmlNodePtr cur, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 456 | const xmlChar *content, |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 457 | int len); |
Daniel Veillard | 6077d03 | 1999-10-09 09:11:45 +0000 | [diff] [blame] | 458 | xmlChar * xmlNodeGetContent (xmlNodePtr cur); |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 459 | const xmlChar * xmlNodeGetLang (xmlNodePtr cur); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 460 | void xmlNodeSetLang (xmlNodePtr cur, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 461 | const xmlChar *lang); |
Daniel Veillard | 1625364 | 1998-10-28 22:58:05 +0000 | [diff] [blame] | 462 | |
| 463 | /* |
Daniel Veillard | c08a2c6 | 1999-09-08 21:35:25 +0000 | [diff] [blame] | 464 | * Removing content. |
| 465 | */ |
| 466 | int xmlRemoveProp (xmlAttrPtr attr); /* TODO */ |
| 467 | int xmlRemoveNode (xmlNodePtr node); /* TODO */ |
| 468 | |
| 469 | /* |
Daniel Veillard | 1625364 | 1998-10-28 22:58:05 +0000 | [diff] [blame] | 470 | * Internal, don't use |
| 471 | */ |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 472 | void xmlBufferWriteCHAR (xmlBufferPtr buf, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 473 | const xmlChar *string); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 474 | void xmlBufferWriteChar (xmlBufferPtr buf, |
| 475 | const char *string); |
| 476 | void xmlBufferWriteQuotedString(xmlBufferPtr buf, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 477 | const xmlChar *string); |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 478 | |
Daniel Veillard | 1625364 | 1998-10-28 22:58:05 +0000 | [diff] [blame] | 479 | /* |
| 480 | * Saving |
| 481 | */ |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 482 | void xmlDocDumpMemory (xmlDocPtr cur, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 483 | xmlChar**mem, |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 484 | int *size); |
| 485 | void xmlDocDump (FILE *f, |
| 486 | xmlDocPtr cur); |
| 487 | int xmlSaveFile (const char *filename, |
| 488 | xmlDocPtr cur); |
Daniel Veillard | 151b1b0 | 1998-09-23 00:49:46 +0000 | [diff] [blame] | 489 | |
Daniel Veillard | 1625364 | 1998-10-28 22:58:05 +0000 | [diff] [blame] | 490 | /* |
| 491 | * Compression |
| 492 | */ |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 493 | int xmlGetDocCompressMode (xmlDocPtr doc); |
| 494 | void xmlSetDocCompressMode (xmlDocPtr doc, |
| 495 | int mode); |
| 496 | int xmlGetCompressMode (void); |
| 497 | void xmlSetCompressMode (int mode); |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 498 | |
| 499 | #ifdef __cplusplus |
| 500 | } |
| 501 | #endif |
| 502 | |
| 503 | #endif /* __XML_TREE_H__ */ |
| 504 | |