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