Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +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 | * |
| 7 | * Daniel.Veillard@w3.org |
| 8 | * |
| 9 | * 14 Nov 2000 ht - added redefinition of xmlBufferWriteChar for VMS |
| 10 | * |
| 11 | */ |
| 12 | |
| 13 | #ifndef __XML_TREE_H__ |
| 14 | #define __XML_TREE_H__ |
| 15 | |
| 16 | #include <stdio.h> |
| 17 | #include <libxml/xmlversion.h> |
Daniel Veillard | 67a2130 | 2001-04-11 14:39:16 +0000 | [diff] [blame] | 18 | #include <libxml/xmlmemory.h> |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 19 | |
| 20 | #ifdef __cplusplus |
| 21 | extern "C" { |
| 22 | #endif |
| 23 | |
| 24 | #define XML_XML_NAMESPACE \ |
| 25 | (const xmlChar *) "http://www.w3.org/XML/1998/namespace" |
| 26 | |
| 27 | /* |
| 28 | * The different element types carried by an XML tree |
| 29 | * |
| 30 | * NOTE: This is synchronized with DOM Level1 values |
| 31 | * See http://www.w3.org/TR/REC-DOM-Level-1/ |
| 32 | * |
| 33 | * Actually this had diverged a bit, and now XML_DOCUMENT_TYPE_NODE should |
| 34 | * be deprecated to use an XML_DTD_NODE. |
| 35 | */ |
| 36 | typedef enum { |
| 37 | XML_ELEMENT_NODE= 1, |
| 38 | XML_ATTRIBUTE_NODE= 2, |
| 39 | XML_TEXT_NODE= 3, |
| 40 | XML_CDATA_SECTION_NODE= 4, |
| 41 | XML_ENTITY_REF_NODE= 5, |
| 42 | XML_ENTITY_NODE= 6, |
| 43 | XML_PI_NODE= 7, |
| 44 | XML_COMMENT_NODE= 8, |
| 45 | XML_DOCUMENT_NODE= 9, |
| 46 | XML_DOCUMENT_TYPE_NODE= 10, |
| 47 | XML_DOCUMENT_FRAG_NODE= 11, |
| 48 | XML_NOTATION_NODE= 12, |
| 49 | XML_HTML_DOCUMENT_NODE= 13, |
| 50 | XML_DTD_NODE= 14, |
| 51 | XML_ELEMENT_DECL= 15, |
| 52 | XML_ATTRIBUTE_DECL= 16, |
| 53 | XML_ENTITY_DECL= 17, |
| 54 | XML_NAMESPACE_DECL= 18, |
| 55 | XML_XINCLUDE_START= 19, |
| 56 | XML_XINCLUDE_END= 20 |
Daniel Veillard | eae522a | 2001-04-23 13:41:34 +0000 | [diff] [blame] | 57 | #ifdef LIBXML_DOCB_ENABLED |
| 58 | ,XML_DOCB_DOCUMENT_NODE= 21 |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 59 | #endif |
| 60 | } xmlElementType; |
| 61 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 62 | /** |
| 63 | * xmlChar: |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 64 | * |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 65 | * This is a basic byte in an UTF-8 encoded string. |
| 66 | * It's unsigned allowing to pinpoint case where char * are assigned |
| 67 | * to xmlChar * (possibly making serialization back impossible). |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 68 | */ |
| 69 | |
| 70 | typedef unsigned char xmlChar; |
| 71 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 72 | /* |
| 73 | * Removed in 2.3.9 ... nobody should still use this |
| 74 | * |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 75 | #ifndef WIN32 |
| 76 | #ifndef CHAR |
| 77 | #define CHAR xmlChar |
| 78 | #endif |
| 79 | #endif |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 80 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 81 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 82 | /** |
| 83 | * BAD_CAST: |
| 84 | * |
| 85 | * Macro to cast a string to an xmlChar * when one know its safe. |
| 86 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 87 | #define BAD_CAST (xmlChar *) |
| 88 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 89 | /** |
| 90 | * xmlNotation: |
| 91 | * |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 92 | * a DTD Notation definition |
| 93 | */ |
| 94 | |
| 95 | typedef struct _xmlNotation xmlNotation; |
| 96 | typedef xmlNotation *xmlNotationPtr; |
| 97 | struct _xmlNotation { |
Daniel Veillard | 9e7160d | 2001-03-18 23:17:47 +0000 | [diff] [blame] | 98 | const xmlChar *name; /* Notation name */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 99 | const xmlChar *PublicID; /* Public identifier, if any */ |
| 100 | const xmlChar *SystemID; /* System identifier, if any */ |
| 101 | }; |
| 102 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 103 | /** |
| 104 | * xmlAttributeType: |
| 105 | * |
| 106 | * a DTD Attribute type definition |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 107 | */ |
| 108 | |
| 109 | typedef enum { |
| 110 | XML_ATTRIBUTE_CDATA = 1, |
| 111 | XML_ATTRIBUTE_ID, |
| 112 | XML_ATTRIBUTE_IDREF , |
| 113 | XML_ATTRIBUTE_IDREFS, |
| 114 | XML_ATTRIBUTE_ENTITY, |
| 115 | XML_ATTRIBUTE_ENTITIES, |
| 116 | XML_ATTRIBUTE_NMTOKEN, |
| 117 | XML_ATTRIBUTE_NMTOKENS, |
| 118 | XML_ATTRIBUTE_ENUMERATION, |
| 119 | XML_ATTRIBUTE_NOTATION |
| 120 | } xmlAttributeType; |
| 121 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 122 | /** |
| 123 | * xmlAttributeDefault: |
| 124 | * |
| 125 | * a DTD Attribute default definition |
| 126 | */ |
| 127 | |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 128 | typedef enum { |
| 129 | XML_ATTRIBUTE_NONE = 1, |
| 130 | XML_ATTRIBUTE_REQUIRED, |
| 131 | XML_ATTRIBUTE_IMPLIED, |
| 132 | XML_ATTRIBUTE_FIXED |
| 133 | } xmlAttributeDefault; |
| 134 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 135 | /** |
| 136 | * xmlEnumeration: |
| 137 | * |
| 138 | * list structure used when there is an enumeration in DTDs |
| 139 | */ |
| 140 | |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 141 | typedef struct _xmlEnumeration xmlEnumeration; |
| 142 | typedef xmlEnumeration *xmlEnumerationPtr; |
| 143 | struct _xmlEnumeration { |
| 144 | struct _xmlEnumeration *next; /* next one */ |
| 145 | const xmlChar *name; /* Enumeration name */ |
| 146 | }; |
| 147 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 148 | /** |
| 149 | * xmlAttribute: |
| 150 | * |
| 151 | * an Attribute declaration in a DTD |
| 152 | */ |
| 153 | |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 154 | typedef struct _xmlAttribute xmlAttribute; |
| 155 | typedef xmlAttribute *xmlAttributePtr; |
| 156 | struct _xmlAttribute { |
| 157 | #ifndef XML_WITHOUT_CORBA |
| 158 | void *_private; /* for Corba, must be first ! */ |
| 159 | #endif |
| 160 | xmlElementType type; /* XML_ATTRIBUTE_DECL, must be second ! */ |
| 161 | const xmlChar *name; /* Attribute name */ |
| 162 | struct _xmlNode *children; /* NULL */ |
| 163 | struct _xmlNode *last; /* NULL */ |
| 164 | struct _xmlDtd *parent; /* -> DTD */ |
| 165 | struct _xmlNode *next; /* next sibling link */ |
| 166 | struct _xmlNode *prev; /* previous sibling link */ |
| 167 | struct _xmlDoc *doc; /* the containing document */ |
| 168 | |
| 169 | struct _xmlAttribute *nexth; /* next in hash table */ |
| 170 | xmlAttributeType atype; /* The attribute type */ |
| 171 | xmlAttributeDefault def; /* the default */ |
| 172 | const xmlChar *defaultValue; /* or the default value */ |
| 173 | xmlEnumerationPtr tree; /* or the enumeration tree if any */ |
| 174 | const xmlChar *prefix; /* the namespace prefix if any */ |
| 175 | const xmlChar *elem; /* Element holding the attribute */ |
| 176 | }; |
| 177 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 178 | /** |
| 179 | * xmlElementContentType: |
| 180 | * |
| 181 | * Possible definitions of element content types |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 182 | */ |
| 183 | typedef enum { |
| 184 | XML_ELEMENT_CONTENT_PCDATA = 1, |
| 185 | XML_ELEMENT_CONTENT_ELEMENT, |
| 186 | XML_ELEMENT_CONTENT_SEQ, |
| 187 | XML_ELEMENT_CONTENT_OR |
| 188 | } xmlElementContentType; |
| 189 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 190 | /** |
| 191 | * xmlElementContentOccur: |
| 192 | * |
| 193 | * Possible definitions of element content occurences |
| 194 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 195 | typedef enum { |
| 196 | XML_ELEMENT_CONTENT_ONCE = 1, |
| 197 | XML_ELEMENT_CONTENT_OPT, |
| 198 | XML_ELEMENT_CONTENT_MULT, |
| 199 | XML_ELEMENT_CONTENT_PLUS |
| 200 | } xmlElementContentOccur; |
| 201 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 202 | /** |
| 203 | * xmlElementContent: |
| 204 | * |
| 205 | * an XML Element content as stored after parsing an element definition |
| 206 | * in a DTD. |
| 207 | */ |
| 208 | |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 209 | typedef struct _xmlElementContent xmlElementContent; |
| 210 | typedef xmlElementContent *xmlElementContentPtr; |
| 211 | struct _xmlElementContent { |
| 212 | xmlElementContentType type; /* PCDATA, ELEMENT, SEQ or OR */ |
| 213 | xmlElementContentOccur ocur; /* ONCE, OPT, MULT or PLUS */ |
| 214 | const xmlChar *name; /* Element name */ |
| 215 | struct _xmlElementContent *c1; /* first child */ |
| 216 | struct _xmlElementContent *c2; /* second child */ |
Daniel Veillard | dab4cb3 | 2001-04-20 13:03:48 +0000 | [diff] [blame] | 217 | struct _xmlElementContent *parent; /* parent */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 218 | }; |
| 219 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 220 | /** |
| 221 | * xmlElementTypeVal: |
| 222 | * |
| 223 | * the differnt possibility for an element content type |
| 224 | */ |
| 225 | |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 226 | typedef enum { |
Daniel Veillard | a10efa8 | 2001-04-18 13:09:01 +0000 | [diff] [blame] | 227 | XML_ELEMENT_TYPE_UNDEFINED = 0, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 228 | XML_ELEMENT_TYPE_EMPTY = 1, |
| 229 | XML_ELEMENT_TYPE_ANY, |
| 230 | XML_ELEMENT_TYPE_MIXED, |
| 231 | XML_ELEMENT_TYPE_ELEMENT |
| 232 | } xmlElementTypeVal; |
| 233 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 234 | /** |
| 235 | * xmlElement: |
| 236 | * |
| 237 | * an XML Element declaration from a DTD |
| 238 | */ |
| 239 | |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 240 | typedef struct _xmlElement xmlElement; |
| 241 | typedef xmlElement *xmlElementPtr; |
| 242 | struct _xmlElement { |
| 243 | #ifndef XML_WITHOUT_CORBA |
| 244 | void *_private; /* for Corba, must be first ! */ |
| 245 | #endif |
| 246 | xmlElementType type; /* XML_ELEMENT_DECL, must be second ! */ |
| 247 | const xmlChar *name; /* Element name */ |
| 248 | struct _xmlNode *children; /* NULL */ |
| 249 | struct _xmlNode *last; /* NULL */ |
| 250 | struct _xmlDtd *parent; /* -> DTD */ |
| 251 | struct _xmlNode *next; /* next sibling link */ |
| 252 | struct _xmlNode *prev; /* previous sibling link */ |
| 253 | struct _xmlDoc *doc; /* the containing document */ |
| 254 | |
| 255 | xmlElementTypeVal etype; /* The type */ |
| 256 | xmlElementContentPtr content; /* the allowed element content */ |
| 257 | xmlAttributePtr attributes; /* List of the declared attributes */ |
| 258 | const xmlChar *prefix; /* the namespace prefix if any */ |
| 259 | }; |
| 260 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 261 | |
| 262 | #define XML_LOCAL_NAMESPACE XML_NAMESPACE_DECL |
| 263 | typedef xmlElementType xmlNsType; |
| 264 | |
| 265 | /** |
| 266 | * xmlNs: |
| 267 | * |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 268 | * An XML namespace. |
| 269 | * Note that prefix == NULL is valid, it defines the default namespace |
| 270 | * within the subtree (until overriden). |
| 271 | * |
| 272 | * XML_GLOBAL_NAMESPACE is now deprecated for good |
| 273 | * xmlNsType is unified with xmlElementType |
| 274 | */ |
| 275 | |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 276 | typedef struct _xmlNs xmlNs; |
| 277 | typedef xmlNs *xmlNsPtr; |
| 278 | struct _xmlNs { |
| 279 | struct _xmlNs *next; /* next Ns link for this node */ |
| 280 | xmlNsType type; /* global or local */ |
| 281 | const xmlChar *href; /* URL for the namespace */ |
| 282 | const xmlChar *prefix; /* prefix for the namespace */ |
| 283 | }; |
| 284 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 285 | /** |
| 286 | * xmlDtd: |
| 287 | * |
| 288 | * An XML DtD, as defined by <!DOCTYPE ... There is actually one for |
| 289 | * the internal subset and for the external subset |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 290 | */ |
| 291 | typedef struct _xmlDtd xmlDtd; |
| 292 | typedef xmlDtd *xmlDtdPtr; |
| 293 | struct _xmlDtd { |
| 294 | #ifndef XML_WITHOUT_CORBA |
| 295 | void *_private; /* for Corba, must be first ! */ |
| 296 | #endif |
| 297 | xmlElementType type; /* XML_DTD_NODE, must be second ! */ |
| 298 | const xmlChar *name; /* Name of the DTD */ |
| 299 | struct _xmlNode *children; /* the value of the property link */ |
| 300 | struct _xmlNode *last; /* last child link */ |
| 301 | struct _xmlDoc *parent; /* child->parent link */ |
| 302 | struct _xmlNode *next; /* next sibling link */ |
| 303 | struct _xmlNode *prev; /* previous sibling link */ |
| 304 | struct _xmlDoc *doc; /* the containing document */ |
| 305 | |
| 306 | /* End of common part */ |
| 307 | void *notations; /* Hash table for notations if any */ |
| 308 | void *elements; /* Hash table for elements if any */ |
| 309 | void *attributes; /* Hash table for attributes if any */ |
| 310 | void *entities; /* Hash table for entities if any */ |
| 311 | const xmlChar *ExternalID; /* External identifier for PUBLIC DTD */ |
| 312 | const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC DTD */ |
| 313 | void *pentities; /* Hash table for param entities if any */ |
| 314 | }; |
| 315 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 316 | /** |
| 317 | * xmlAttr: |
| 318 | * |
| 319 | * A attribute on an XML node. |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 320 | */ |
| 321 | typedef struct _xmlAttr xmlAttr; |
| 322 | typedef xmlAttr *xmlAttrPtr; |
| 323 | struct _xmlAttr { |
| 324 | #ifndef XML_WITHOUT_CORBA |
| 325 | void *_private; /* for Corba, must be first ! */ |
| 326 | #endif |
| 327 | xmlElementType type; /* XML_ATTRIBUTE_NODE, must be second ! */ |
| 328 | const xmlChar *name; /* the name of the property */ |
| 329 | struct _xmlNode *children; /* the value of the property */ |
| 330 | struct _xmlNode *last; /* NULL */ |
| 331 | struct _xmlNode *parent; /* child->parent link */ |
| 332 | struct _xmlAttr *next; /* next sibling link */ |
| 333 | struct _xmlAttr *prev; /* previous sibling link */ |
| 334 | struct _xmlDoc *doc; /* the containing document */ |
| 335 | xmlNs *ns; /* pointer to the associated namespace */ |
| 336 | xmlAttributeType atype; /* the attribute type if validating */ |
| 337 | }; |
| 338 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 339 | /** |
| 340 | * xmlID: |
| 341 | * |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 342 | * An XML ID instance. |
| 343 | */ |
| 344 | |
| 345 | typedef struct _xmlID xmlID; |
| 346 | typedef xmlID *xmlIDPtr; |
| 347 | struct _xmlID { |
| 348 | struct _xmlID *next; /* next ID */ |
| 349 | const xmlChar *value; /* The ID name */ |
| 350 | xmlAttrPtr attr; /* The attribut holding it */ |
| 351 | }; |
| 352 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 353 | /** |
| 354 | * xmlRef: |
| 355 | * |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 356 | * An XML IDREF instance. |
| 357 | */ |
| 358 | |
| 359 | typedef struct _xmlRef xmlRef; |
| 360 | typedef xmlRef *xmlRefPtr; |
| 361 | struct _xmlRef { |
| 362 | struct _xmlRef *next; /* next Ref */ |
| 363 | const xmlChar *value; /* The Ref name */ |
| 364 | xmlAttrPtr attr; /* The attribut holding it */ |
| 365 | }; |
| 366 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 367 | /** |
| 368 | * xmlBufferAllocationScheme: |
| 369 | * |
| 370 | * A buffer allocation scheme can be defined to either match exactly the |
| 371 | * need or double it's allocated size each time it is found too small |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 372 | */ |
| 373 | |
| 374 | typedef enum { |
| 375 | XML_BUFFER_ALLOC_DOUBLEIT, |
| 376 | XML_BUFFER_ALLOC_EXACT |
| 377 | } xmlBufferAllocationScheme; |
| 378 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 379 | /** |
| 380 | * xmlBuffer: |
| 381 | * |
| 382 | * A buffer structure |
| 383 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 384 | typedef struct _xmlBuffer xmlBuffer; |
| 385 | typedef xmlBuffer *xmlBufferPtr; |
| 386 | struct _xmlBuffer { |
| 387 | xmlChar *content; /* The buffer content UTF8 */ |
| 388 | unsigned int use; /* The buffer size used */ |
| 389 | unsigned int size; /* The buffer size */ |
| 390 | xmlBufferAllocationScheme alloc; /* The realloc method */ |
| 391 | }; |
| 392 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 393 | /** |
| 394 | * xmlNode: |
| 395 | * |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 396 | * A node in an XML tree. |
| 397 | */ |
| 398 | typedef struct _xmlNode xmlNode; |
| 399 | typedef xmlNode *xmlNodePtr; |
| 400 | struct _xmlNode { |
| 401 | #ifndef XML_WITHOUT_CORBA |
| 402 | void *_private; /* for Corba, must be first ! */ |
| 403 | #endif |
| 404 | xmlElementType type; /* type number, must be second ! */ |
| 405 | const xmlChar *name; /* the name of the node, or the entity */ |
| 406 | struct _xmlNode *children; /* parent->childs link */ |
| 407 | struct _xmlNode *last; /* last child link */ |
| 408 | struct _xmlNode *parent; /* child->parent link */ |
| 409 | struct _xmlNode *next; /* next sibling link */ |
| 410 | struct _xmlNode *prev; /* previous sibling link */ |
| 411 | struct _xmlDoc *doc; /* the containing document */ |
| 412 | xmlNs *ns; /* pointer to the associated namespace */ |
| 413 | #ifndef XML_USE_BUFFER_CONTENT |
| 414 | xmlChar *content; /* the content */ |
| 415 | #else |
| 416 | xmlBufferPtr content; /* the content in a buffer */ |
| 417 | #endif |
| 418 | |
| 419 | /* End of common part */ |
| 420 | struct _xmlAttr *properties;/* properties list */ |
| 421 | xmlNs *nsDef; /* namespace definitions on this node */ |
| 422 | }; |
| 423 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 424 | /** |
| 425 | * xmlDoc: |
| 426 | * |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 427 | * An XML document. |
| 428 | */ |
| 429 | typedef struct _xmlDoc xmlDoc; |
| 430 | typedef xmlDoc *xmlDocPtr; |
| 431 | struct _xmlDoc { |
| 432 | #ifndef XML_WITHOUT_CORBA |
| 433 | void *_private; /* for Corba, must be first ! */ |
| 434 | #endif |
| 435 | xmlElementType type; /* XML_DOCUMENT_NODE, must be second ! */ |
| 436 | char *name; /* name/filename/URI of the document */ |
| 437 | struct _xmlNode *children; /* the document tree */ |
| 438 | struct _xmlNode *last; /* last child link */ |
| 439 | struct _xmlNode *parent; /* child->parent link */ |
| 440 | struct _xmlNode *next; /* next sibling link */ |
| 441 | struct _xmlNode *prev; /* previous sibling link */ |
| 442 | struct _xmlDoc *doc; /* autoreference to itself */ |
| 443 | |
| 444 | /* End of common part */ |
| 445 | int compression;/* level of zlib compression */ |
| 446 | int standalone; /* standalone document (no external refs) */ |
| 447 | struct _xmlDtd *intSubset; /* the document internal subset */ |
| 448 | struct _xmlDtd *extSubset; /* the document external subset */ |
| 449 | struct _xmlNs *oldNs; /* Global namespace, the old way */ |
| 450 | const xmlChar *version; /* the XML version string */ |
| 451 | const xmlChar *encoding; /* external initial encoding, if any */ |
| 452 | void *ids; /* Hash table for ID attributes if any */ |
| 453 | void *refs; /* Hash table for IDREFs attributes if any */ |
| 454 | const xmlChar *URL; /* The URI for that document */ |
| 455 | int charset; /* encoding of the in-memory content |
| 456 | actually an xmlCharEncoding */ |
| 457 | }; |
| 458 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 459 | /** |
| 460 | * xmlChildrenNode: |
| 461 | * |
| 462 | * Macro for compatibility naming layer with libxml1 |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 463 | */ |
| 464 | #ifndef xmlChildrenNode |
| 465 | #define xmlChildrenNode children |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 466 | #endif |
| 467 | |
| 468 | /** |
| 469 | * xmlRootNode: |
| 470 | * |
| 471 | * Macro for compatibility naming layer with libxml1 |
| 472 | */ |
| 473 | #ifndef xmlRootNode |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 474 | #define xmlRootNode children |
| 475 | #endif |
| 476 | |
| 477 | /* |
| 478 | * Variables. |
| 479 | */ |
| 480 | LIBXML_DLL_IMPORT extern xmlNsPtr baseDTD; |
| 481 | LIBXML_DLL_IMPORT extern int oldXMLWDcompatibility;/* maintain compatibility with old WD */ |
| 482 | LIBXML_DLL_IMPORT extern int xmlIndentTreeOutput; /* try to indent the tree dumps */ |
| 483 | LIBXML_DLL_IMPORT extern xmlBufferAllocationScheme xmlBufferAllocScheme; /* alloc scheme to use */ |
Daniel Veillard | e356c28 | 2001-03-10 12:32:04 +0000 | [diff] [blame] | 484 | LIBXML_DLL_IMPORT extern int xmlSaveNoEmptyTags; /* save empty tags as <empty></empty> */ |
| 485 | LIBXML_DLL_IMPORT extern int xmlDefaultBufferSize; /* default buffer size */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 486 | |
| 487 | /* |
| 488 | * Handling Buffers. |
| 489 | */ |
| 490 | |
Daniel Veillard | 56a4cb8 | 2001-03-24 17:00:36 +0000 | [diff] [blame] | 491 | void xmlSetBufferAllocationScheme(xmlBufferAllocationScheme scheme); |
| 492 | xmlBufferAllocationScheme xmlGetBufferAllocationScheme(void); |
| 493 | |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 494 | xmlBufferPtr xmlBufferCreate (void); |
| 495 | xmlBufferPtr xmlBufferCreateSize (size_t size); |
Daniel Veillard | 56a4cb8 | 2001-03-24 17:00:36 +0000 | [diff] [blame] | 496 | int xmlBufferResize (xmlBufferPtr buf, |
| 497 | unsigned int size); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 498 | void xmlBufferFree (xmlBufferPtr buf); |
| 499 | int xmlBufferDump (FILE *file, |
| 500 | xmlBufferPtr buf); |
| 501 | void xmlBufferAdd (xmlBufferPtr buf, |
| 502 | const xmlChar *str, |
| 503 | int len); |
| 504 | void xmlBufferAddHead (xmlBufferPtr buf, |
| 505 | const xmlChar *str, |
| 506 | int len); |
| 507 | void xmlBufferCat (xmlBufferPtr buf, |
| 508 | const xmlChar *str); |
| 509 | void xmlBufferCCat (xmlBufferPtr buf, |
| 510 | const char *str); |
| 511 | int xmlBufferShrink (xmlBufferPtr buf, |
| 512 | unsigned int len); |
| 513 | int xmlBufferGrow (xmlBufferPtr buf, |
| 514 | unsigned int len); |
| 515 | void xmlBufferEmpty (xmlBufferPtr buf); |
| 516 | const xmlChar* xmlBufferContent (const xmlBufferPtr buf); |
| 517 | int xmlBufferUse (const xmlBufferPtr buf); |
| 518 | void xmlBufferSetAllocationScheme(xmlBufferPtr buf, |
| 519 | xmlBufferAllocationScheme scheme); |
| 520 | int xmlBufferLength (const xmlBufferPtr buf); |
| 521 | |
| 522 | /* |
| 523 | * Creating/freeing new structures |
| 524 | */ |
| 525 | xmlDtdPtr xmlCreateIntSubset (xmlDocPtr doc, |
| 526 | const xmlChar *name, |
| 527 | const xmlChar *ExternalID, |
| 528 | const xmlChar *SystemID); |
| 529 | xmlDtdPtr xmlNewDtd (xmlDocPtr doc, |
| 530 | const xmlChar *name, |
| 531 | const xmlChar *ExternalID, |
| 532 | const xmlChar *SystemID); |
| 533 | xmlDtdPtr xmlGetIntSubset (xmlDocPtr doc); |
| 534 | void xmlFreeDtd (xmlDtdPtr cur); |
| 535 | xmlNsPtr xmlNewGlobalNs (xmlDocPtr doc, |
| 536 | const xmlChar *href, |
| 537 | const xmlChar *prefix); |
| 538 | xmlNsPtr xmlNewNs (xmlNodePtr node, |
| 539 | const xmlChar *href, |
| 540 | const xmlChar *prefix); |
| 541 | void xmlFreeNs (xmlNsPtr cur); |
Daniel Veillard | 56a4cb8 | 2001-03-24 17:00:36 +0000 | [diff] [blame] | 542 | void xmlFreeNsList (xmlNsPtr cur); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 543 | xmlDocPtr xmlNewDoc (const xmlChar *version); |
| 544 | void xmlFreeDoc (xmlDocPtr cur); |
| 545 | xmlAttrPtr xmlNewDocProp (xmlDocPtr doc, |
| 546 | const xmlChar *name, |
| 547 | const xmlChar *value); |
| 548 | xmlAttrPtr xmlNewProp (xmlNodePtr node, |
| 549 | const xmlChar *name, |
| 550 | const xmlChar *value); |
| 551 | xmlAttrPtr xmlNewNsProp (xmlNodePtr node, |
| 552 | xmlNsPtr ns, |
| 553 | const xmlChar *name, |
| 554 | const xmlChar *value); |
| 555 | void xmlFreePropList (xmlAttrPtr cur); |
| 556 | void xmlFreeProp (xmlAttrPtr cur); |
| 557 | xmlAttrPtr xmlCopyProp (xmlNodePtr target, |
| 558 | xmlAttrPtr cur); |
| 559 | xmlAttrPtr xmlCopyPropList (xmlNodePtr target, |
| 560 | xmlAttrPtr cur); |
| 561 | xmlDtdPtr xmlCopyDtd (xmlDtdPtr dtd); |
| 562 | xmlDocPtr xmlCopyDoc (xmlDocPtr doc, |
| 563 | int recursive); |
| 564 | |
| 565 | /* |
| 566 | * Creating new nodes |
| 567 | */ |
| 568 | xmlNodePtr xmlNewDocNode (xmlDocPtr doc, |
| 569 | xmlNsPtr ns, |
| 570 | const xmlChar *name, |
| 571 | const xmlChar *content); |
| 572 | xmlNodePtr xmlNewDocRawNode (xmlDocPtr doc, |
| 573 | xmlNsPtr ns, |
| 574 | const xmlChar *name, |
| 575 | const xmlChar *content); |
| 576 | xmlNodePtr xmlNewNode (xmlNsPtr ns, |
| 577 | const xmlChar *name); |
| 578 | xmlNodePtr xmlNewChild (xmlNodePtr parent, |
| 579 | xmlNsPtr ns, |
| 580 | const xmlChar *name, |
| 581 | const xmlChar *content); |
| 582 | xmlNodePtr xmlNewTextChild (xmlNodePtr parent, |
| 583 | xmlNsPtr ns, |
| 584 | const xmlChar *name, |
| 585 | const xmlChar *content); |
| 586 | xmlNodePtr xmlNewDocText (xmlDocPtr doc, |
| 587 | const xmlChar *content); |
| 588 | xmlNodePtr xmlNewText (const xmlChar *content); |
| 589 | xmlNodePtr xmlNewPI (const xmlChar *name, |
| 590 | const xmlChar *content); |
| 591 | xmlNodePtr xmlNewDocTextLen (xmlDocPtr doc, |
| 592 | const xmlChar *content, |
| 593 | int len); |
| 594 | xmlNodePtr xmlNewTextLen (const xmlChar *content, |
| 595 | int len); |
| 596 | xmlNodePtr xmlNewDocComment (xmlDocPtr doc, |
| 597 | const xmlChar *content); |
| 598 | xmlNodePtr xmlNewComment (const xmlChar *content); |
| 599 | xmlNodePtr xmlNewCDataBlock (xmlDocPtr doc, |
| 600 | const xmlChar *content, |
| 601 | int len); |
| 602 | xmlNodePtr xmlNewCharRef (xmlDocPtr doc, |
| 603 | const xmlChar *name); |
| 604 | xmlNodePtr xmlNewReference (xmlDocPtr doc, |
| 605 | const xmlChar *name); |
| 606 | xmlNodePtr xmlCopyNode (xmlNodePtr node, |
| 607 | int recursive); |
Daniel Veillard | 82daa81 | 2001-04-12 08:55:36 +0000 | [diff] [blame] | 608 | xmlNodePtr xmlDocCopyNode (xmlNodePtr node, |
| 609 | xmlDocPtr doc, |
| 610 | int recursive); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 611 | xmlNodePtr xmlCopyNodeList (xmlNodePtr node); |
| 612 | xmlNodePtr xmlNewDocFragment (xmlDocPtr doc); |
| 613 | |
| 614 | /* |
| 615 | * Navigating |
| 616 | */ |
| 617 | xmlNodePtr xmlDocGetRootElement (xmlDocPtr doc); |
| 618 | xmlNodePtr xmlGetLastChild (xmlNodePtr parent); |
| 619 | int xmlNodeIsText (xmlNodePtr node); |
| 620 | int xmlIsBlankNode (xmlNodePtr node); |
| 621 | |
| 622 | /* |
| 623 | * Changing the structure |
| 624 | */ |
| 625 | xmlNodePtr xmlDocSetRootElement (xmlDocPtr doc, |
| 626 | xmlNodePtr root); |
| 627 | void xmlNodeSetName (xmlNodePtr cur, |
| 628 | const xmlChar *name); |
| 629 | xmlNodePtr xmlAddChild (xmlNodePtr parent, |
| 630 | xmlNodePtr cur); |
| 631 | xmlNodePtr xmlAddChildList (xmlNodePtr parent, |
| 632 | xmlNodePtr cur); |
| 633 | xmlNodePtr xmlReplaceNode (xmlNodePtr old, |
| 634 | xmlNodePtr cur); |
| 635 | xmlNodePtr xmlAddSibling (xmlNodePtr cur, |
| 636 | xmlNodePtr elem); |
| 637 | xmlNodePtr xmlAddPrevSibling (xmlNodePtr cur, |
| 638 | xmlNodePtr elem); |
| 639 | xmlNodePtr xmlAddNextSibling (xmlNodePtr cur, |
| 640 | xmlNodePtr elem); |
| 641 | void xmlUnlinkNode (xmlNodePtr cur); |
| 642 | xmlNodePtr xmlTextMerge (xmlNodePtr first, |
| 643 | xmlNodePtr second); |
| 644 | void xmlTextConcat (xmlNodePtr node, |
| 645 | const xmlChar *content, |
| 646 | int len); |
| 647 | void xmlFreeNodeList (xmlNodePtr cur); |
| 648 | void xmlFreeNode (xmlNodePtr cur); |
| 649 | void xmlSetTreeDoc (xmlNodePtr tree, |
| 650 | xmlDocPtr doc); |
| 651 | void xmlSetListDoc (xmlNodePtr list, |
| 652 | xmlDocPtr doc); |
| 653 | |
| 654 | /* |
| 655 | * Namespaces |
| 656 | */ |
| 657 | xmlNsPtr xmlSearchNs (xmlDocPtr doc, |
| 658 | xmlNodePtr node, |
| 659 | const xmlChar *nameSpace); |
| 660 | xmlNsPtr xmlSearchNsByHref (xmlDocPtr doc, |
| 661 | xmlNodePtr node, |
| 662 | const xmlChar *href); |
| 663 | xmlNsPtr * xmlGetNsList (xmlDocPtr doc, |
| 664 | xmlNodePtr node); |
| 665 | void xmlSetNs (xmlNodePtr node, |
| 666 | xmlNsPtr ns); |
| 667 | xmlNsPtr xmlCopyNamespace (xmlNsPtr cur); |
| 668 | xmlNsPtr xmlCopyNamespaceList (xmlNsPtr cur); |
| 669 | |
| 670 | /* |
| 671 | * Changing the content. |
| 672 | */ |
| 673 | xmlAttrPtr xmlSetProp (xmlNodePtr node, |
| 674 | const xmlChar *name, |
| 675 | const xmlChar *value); |
| 676 | xmlChar * xmlGetProp (xmlNodePtr node, |
| 677 | const xmlChar *name); |
Daniel Veillard | 75bea54 | 2001-05-11 17:41:21 +0000 | [diff] [blame] | 678 | int xmlUnsetProp (xmlNodePtr node, |
| 679 | const xmlChar *name); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 680 | xmlAttrPtr xmlHasProp (xmlNodePtr node, |
| 681 | const xmlChar *name); |
| 682 | xmlAttrPtr xmlSetNsProp (xmlNodePtr node, |
| 683 | xmlNsPtr ns, |
| 684 | const xmlChar *name, |
| 685 | const xmlChar *value); |
| 686 | xmlChar * xmlGetNsProp (xmlNodePtr node, |
| 687 | const xmlChar *name, |
| 688 | const xmlChar *nameSpace); |
Daniel Veillard | 75bea54 | 2001-05-11 17:41:21 +0000 | [diff] [blame] | 689 | int xmlUnsetNsProp (xmlNodePtr node, |
| 690 | xmlNsPtr ns, |
| 691 | const xmlChar *name); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 692 | xmlNodePtr xmlStringGetNodeList (xmlDocPtr doc, |
| 693 | const xmlChar *value); |
| 694 | xmlNodePtr xmlStringLenGetNodeList (xmlDocPtr doc, |
| 695 | const xmlChar *value, |
| 696 | int len); |
| 697 | xmlChar * xmlNodeListGetString (xmlDocPtr doc, |
| 698 | xmlNodePtr list, |
| 699 | int inLine); |
| 700 | xmlChar * xmlNodeListGetRawString (xmlDocPtr doc, |
| 701 | xmlNodePtr list, |
| 702 | int inLine); |
| 703 | void xmlNodeSetContent (xmlNodePtr cur, |
| 704 | const xmlChar *content); |
| 705 | void xmlNodeSetContentLen (xmlNodePtr cur, |
| 706 | const xmlChar *content, |
| 707 | int len); |
| 708 | void xmlNodeAddContent (xmlNodePtr cur, |
| 709 | const xmlChar *content); |
| 710 | void xmlNodeAddContentLen (xmlNodePtr cur, |
| 711 | const xmlChar *content, |
| 712 | int len); |
| 713 | xmlChar * xmlNodeGetContent (xmlNodePtr cur); |
| 714 | xmlChar * xmlNodeGetLang (xmlNodePtr cur); |
| 715 | void xmlNodeSetLang (xmlNodePtr cur, |
| 716 | const xmlChar *lang); |
| 717 | int xmlNodeGetSpacePreserve (xmlNodePtr cur); |
| 718 | void xmlNodeSetSpacePreserve (xmlNodePtr cur, int |
| 719 | val); |
| 720 | xmlChar * xmlNodeGetBase (xmlDocPtr doc, |
| 721 | xmlNodePtr cur); |
| 722 | void xmlNodeSetBase (xmlNodePtr cur, |
| 723 | xmlChar *uri); |
| 724 | |
| 725 | /* |
| 726 | * Removing content. |
| 727 | */ |
| 728 | int xmlRemoveProp (xmlAttrPtr attr); |
| 729 | int xmlRemoveNode (xmlNodePtr node); /* TODO */ |
| 730 | |
| 731 | /* |
| 732 | * Internal, don't use |
| 733 | */ |
| 734 | #ifdef VMS |
| 735 | void xmlBufferWriteXmlCHAR (xmlBufferPtr buf, |
| 736 | const xmlChar *string); |
| 737 | #define xmlBufferWriteCHAR xmlBufferWriteXmlCHAR |
| 738 | #else |
| 739 | void xmlBufferWriteCHAR (xmlBufferPtr buf, |
| 740 | const xmlChar *string); |
| 741 | #endif |
| 742 | void xmlBufferWriteChar (xmlBufferPtr buf, |
| 743 | const char *string); |
| 744 | void xmlBufferWriteQuotedString(xmlBufferPtr buf, |
| 745 | const xmlChar *string); |
| 746 | |
| 747 | /* |
| 748 | * Namespace handling |
| 749 | */ |
| 750 | int xmlReconciliateNs (xmlDocPtr doc, |
| 751 | xmlNodePtr tree); |
| 752 | |
| 753 | /* |
| 754 | * Saving |
| 755 | */ |
| 756 | void xmlDocDumpFormatMemory (xmlDocPtr cur, |
| 757 | xmlChar**mem, |
| 758 | int *size, |
| 759 | int format); |
| 760 | void xmlDocDumpMemory (xmlDocPtr cur, |
| 761 | xmlChar**mem, |
| 762 | int *size); |
| 763 | void xmlDocDumpMemoryEnc (xmlDocPtr out_doc, |
| 764 | xmlChar **doc_txt_ptr, |
| 765 | int * doc_txt_len, |
| 766 | const char *txt_encoding); |
| 767 | void xmlDocDumpFormatMemoryEnc(xmlDocPtr out_doc, |
| 768 | xmlChar **doc_txt_ptr, |
| 769 | int * doc_txt_len, |
| 770 | const char *txt_encoding, |
| 771 | int format); |
| 772 | int xmlDocDump (FILE *f, |
| 773 | xmlDocPtr cur); |
| 774 | void xmlElemDump (FILE *f, |
| 775 | xmlDocPtr doc, |
| 776 | xmlNodePtr cur); |
| 777 | int xmlSaveFile (const char *filename, |
| 778 | xmlDocPtr cur); |
Daniel Veillard | 67fee94 | 2001-04-26 18:59:03 +0000 | [diff] [blame] | 779 | int xmlSaveFormatFile (const char *filename, |
| 780 | xmlDocPtr cur, |
| 781 | int format); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 782 | void xmlNodeDump (xmlBufferPtr buf, |
| 783 | xmlDocPtr doc, |
| 784 | xmlNodePtr cur, |
| 785 | int level, |
| 786 | int format); |
| 787 | |
Daniel Veillard | eefd449 | 2001-04-28 16:55:50 +0000 | [diff] [blame] | 788 | /* These are exported from xmlIO.h |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 789 | |
| 790 | int xmlSaveFileTo (xmlOutputBuffer *buf, |
| 791 | xmlDocPtr cur, |
| 792 | const char *encoding); |
Daniel Veillard | eefd449 | 2001-04-28 16:55:50 +0000 | [diff] [blame] | 793 | int xmlSaveFormatFileTo (xmlOutputBuffer *buf, |
| 794 | xmlDocPtr cur, |
| 795 | const char *encoding, |
| 796 | int format); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 797 | */ |
| 798 | |
| 799 | int xmlSaveFileEnc (const char *filename, |
| 800 | xmlDocPtr cur, |
| 801 | const char *encoding); |
| 802 | |
| 803 | /* |
| 804 | * Compression |
| 805 | */ |
| 806 | int xmlGetDocCompressMode (xmlDocPtr doc); |
| 807 | void xmlSetDocCompressMode (xmlDocPtr doc, |
| 808 | int mode); |
| 809 | int xmlGetCompressMode (void); |
| 810 | void xmlSetCompressMode (int mode); |
| 811 | |
| 812 | #ifdef __cplusplus |
| 813 | } |
| 814 | #endif |
| 815 | |
| 816 | #endif /* __XML_TREE_H__ */ |
| 817 | |