blob: de7cf7965e1f9b607a6fc3c2699af8561b7b7536 [file] [log] [blame]
Daniel Veillard260a68f1998-08-13 03:39:55 +00001/*
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 Veillard39a1f9a1999-01-17 19:11:59 +00007 * Daniel.Veillard@w3.org
Daniel Veillardce6e98d2000-11-25 09:54:49 +00008 *
9 * 14 Nov 2000 ht - added redefinition of xmlBufferWriteChar for VMS
10 *
Daniel Veillard260a68f1998-08-13 03:39:55 +000011 */
12
13#ifndef __XML_TREE_H__
14#define __XML_TREE_H__
15
Daniel Veillard82c305b1999-12-15 19:08:23 +000016#include <stdio.h>
Daniel Veillard361d8452000-04-03 19:48:13 +000017#include <libxml/xmlversion.h>
Daniel Veillard82c305b1999-12-15 19:08:23 +000018
Daniel Veillard260a68f1998-08-13 03:39:55 +000019#ifdef __cplusplus
20extern "C" {
21#endif
22
23/*
Daniel Veillardccb09631998-10-27 06:21:04 +000024 * The different element types carried by an XML tree
25 *
26 * NOTE: This is synchronized with DOM Level1 values
27 * See http://www.w3.org/TR/REC-DOM-Level-1/
Daniel Veillard4a6845d2001-01-03 13:32:39 +000028 *
29 * Actually this had diverged a bit, and now XML_DOCUMENT_TYPE_NODE should
30 * be deprecated to use an XML_DTD_NODE.
Daniel Veillardccb09631998-10-27 06:21:04 +000031 */
32typedef enum {
33 XML_ELEMENT_NODE= 1,
34 XML_ATTRIBUTE_NODE= 2,
35 XML_TEXT_NODE= 3,
36 XML_CDATA_SECTION_NODE= 4,
37 XML_ENTITY_REF_NODE= 5,
38 XML_ENTITY_NODE= 6,
39 XML_PI_NODE= 7,
40 XML_COMMENT_NODE= 8,
41 XML_DOCUMENT_NODE= 9,
42 XML_DOCUMENT_TYPE_NODE= 10,
43 XML_DOCUMENT_FRAG_NODE= 11,
Daniel Veillard7c1206f1999-10-14 09:10:25 +000044 XML_NOTATION_NODE= 12,
Daniel Veillardcf461992000-03-14 18:30:20 +000045 XML_HTML_DOCUMENT_NODE= 13,
46 XML_DTD_NODE= 14,
47 XML_ELEMENT_DECL= 15,
48 XML_ATTRIBUTE_DECL= 16,
Daniel Veillard39c7d712000-09-10 16:14:55 +000049 XML_ENTITY_DECL= 17,
Daniel Veillard9e8bfae2000-11-06 16:43:11 +000050 XML_NAMESPACE_DECL= 18,
51 XML_XINCLUDE_START= 19,
52 XML_XINCLUDE_END= 20
Daniel Veillarda4964b72000-10-31 18:23:44 +000053#ifdef LIBXML_SGML_ENABLED
Daniel Veillard9e8bfae2000-11-06 16:43:11 +000054 ,XML_SGML_DOCUMENT_NODE= 21
Daniel Veillard39c7d712000-09-10 16:14:55 +000055#endif
Daniel Veillardccb09631998-10-27 06:21:04 +000056} xmlElementType;
57
58/*
Daniel Veillard0ba4d531998-11-01 19:34:31 +000059 * Size of an internal character representation.
60 *
Daniel Veillardcf461992000-03-14 18:30:20 +000061 * We use 8bit chars internal representation for memory efficiency,
62 * Note that with 8 bits wide xmlChars one can still use UTF-8 to handle
63 * correctly non ISO-Latin input.
Daniel Veillard260a68f1998-08-13 03:39:55 +000064 */
Daniel Veillarddd6b3671999-09-23 22:19:22 +000065
Daniel Veillarddd6b3671999-09-23 22:19:22 +000066typedef unsigned char xmlChar;
Daniel Veillard260a68f1998-08-13 03:39:55 +000067
Daniel Veillarddd6b3671999-09-23 22:19:22 +000068#ifndef WIN32
69#ifndef CHAR
70#define CHAR xmlChar
71#endif
72#endif
73
74#define BAD_CAST (xmlChar *)
Daniel Veillardb96e6431999-08-29 21:02:19 +000075
Daniel Veillard260a68f1998-08-13 03:39:55 +000076/*
77 * a DTD Notation definition
Daniel Veillard260a68f1998-08-13 03:39:55 +000078 */
79
Daniel Veillard71b656e2000-01-05 14:46:17 +000080typedef struct _xmlNotation xmlNotation;
81typedef xmlNotation *xmlNotationPtr;
82struct _xmlNotation {
Daniel Veillarddd6b3671999-09-23 22:19:22 +000083 const xmlChar *name; /* Notation name */
84 const xmlChar *PublicID; /* Public identifier, if any */
85 const xmlChar *SystemID; /* System identifier, if any */
Daniel Veillard71b656e2000-01-05 14:46:17 +000086};
Daniel Veillard1e346af1999-02-22 10:33:01 +000087
Daniel Veillard260a68f1998-08-13 03:39:55 +000088/*
89 * a DTD Attribute definition
Daniel Veillard260a68f1998-08-13 03:39:55 +000090 */
91
Daniel Veillard1e346af1999-02-22 10:33:01 +000092typedef enum {
93 XML_ATTRIBUTE_CDATA = 1,
94 XML_ATTRIBUTE_ID,
95 XML_ATTRIBUTE_IDREF ,
96 XML_ATTRIBUTE_IDREFS,
97 XML_ATTRIBUTE_ENTITY,
98 XML_ATTRIBUTE_ENTITIES,
99 XML_ATTRIBUTE_NMTOKEN,
100 XML_ATTRIBUTE_NMTOKENS,
101 XML_ATTRIBUTE_ENUMERATION,
102 XML_ATTRIBUTE_NOTATION
103} xmlAttributeType;
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000104
Daniel Veillard1e346af1999-02-22 10:33:01 +0000105typedef enum {
106 XML_ATTRIBUTE_NONE = 1,
107 XML_ATTRIBUTE_REQUIRED,
108 XML_ATTRIBUTE_IMPLIED,
109 XML_ATTRIBUTE_FIXED
110} xmlAttributeDefault;
111
Daniel Veillard71b656e2000-01-05 14:46:17 +0000112typedef struct _xmlEnumeration xmlEnumeration;
Daniel Veillard1e346af1999-02-22 10:33:01 +0000113typedef xmlEnumeration *xmlEnumerationPtr;
Daniel Veillard71b656e2000-01-05 14:46:17 +0000114struct _xmlEnumeration {
115 struct _xmlEnumeration *next; /* next one */
116 const xmlChar *name; /* Enumeration name */
117};
Daniel Veillard1e346af1999-02-22 10:33:01 +0000118
Daniel Veillard71b656e2000-01-05 14:46:17 +0000119typedef struct _xmlAttribute xmlAttribute;
120typedef xmlAttribute *xmlAttributePtr;
121struct _xmlAttribute {
Daniel Veillardcf461992000-03-14 18:30:20 +0000122#ifndef XML_WITHOUT_CORBA
123 void *_private; /* for Corba, must be first ! */
124#endif
125 xmlElementType type; /* XML_ATTRIBUTE_DECL, must be second ! */
126 const xmlChar *name; /* Attribute name */
127 struct _xmlNode *children; /* NULL */
128 struct _xmlNode *last; /* NULL */
129 struct _xmlDtd *parent; /* -> DTD */
130 struct _xmlNode *next; /* next sibling link */
131 struct _xmlNode *prev; /* previous sibling link */
132 struct _xmlDoc *doc; /* the containing document */
133
134 struct _xmlAttribute *nexth; /* next in hash table */
135 xmlAttributeType atype; /* The attribute type */
136 xmlAttributeDefault def; /* the default */
137 const xmlChar *defaultValue; /* or the default value */
138 xmlEnumerationPtr tree; /* or the enumeration tree if any */
139 const xmlChar *prefix; /* the namespace prefix if any */
140 const xmlChar *elem; /* Element holding the attribute */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000141};
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000142
Daniel Veillard260a68f1998-08-13 03:39:55 +0000143/*
144 * a DTD Element definition.
145 */
Daniel Veillard1899e851999-02-01 12:18:54 +0000146typedef enum {
Daniel Veillard1e346af1999-02-22 10:33:01 +0000147 XML_ELEMENT_CONTENT_PCDATA = 1,
Daniel Veillard1899e851999-02-01 12:18:54 +0000148 XML_ELEMENT_CONTENT_ELEMENT,
149 XML_ELEMENT_CONTENT_SEQ,
150 XML_ELEMENT_CONTENT_OR
151} xmlElementContentType;
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000152
Daniel Veillard1899e851999-02-01 12:18:54 +0000153typedef enum {
Daniel Veillard1e346af1999-02-22 10:33:01 +0000154 XML_ELEMENT_CONTENT_ONCE = 1,
Daniel Veillard1899e851999-02-01 12:18:54 +0000155 XML_ELEMENT_CONTENT_OPT,
156 XML_ELEMENT_CONTENT_MULT,
157 XML_ELEMENT_CONTENT_PLUS
158} xmlElementContentOccur;
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000159
Daniel Veillard71b656e2000-01-05 14:46:17 +0000160typedef struct _xmlElementContent xmlElementContent;
161typedef xmlElementContent *xmlElementContentPtr;
162struct _xmlElementContent {
Daniel Veillard1899e851999-02-01 12:18:54 +0000163 xmlElementContentType type; /* PCDATA, ELEMENT, SEQ or OR */
164 xmlElementContentOccur ocur; /* ONCE, OPT, MULT or PLUS */
Daniel Veillard6077d031999-10-09 09:11:45 +0000165 const xmlChar *name; /* Element name */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000166 struct _xmlElementContent *c1; /* first child */
167 struct _xmlElementContent *c2; /* second child */
168};
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000169
Daniel Veillard1899e851999-02-01 12:18:54 +0000170typedef enum {
Daniel Veillard1e346af1999-02-22 10:33:01 +0000171 XML_ELEMENT_TYPE_EMPTY = 1,
Daniel Veillard1899e851999-02-01 12:18:54 +0000172 XML_ELEMENT_TYPE_ANY,
173 XML_ELEMENT_TYPE_MIXED,
174 XML_ELEMENT_TYPE_ELEMENT
175} xmlElementTypeVal;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000176
Daniel Veillard71b656e2000-01-05 14:46:17 +0000177typedef struct _xmlElement xmlElement;
178typedef xmlElement *xmlElementPtr;
179struct _xmlElement {
Daniel Veillardcf461992000-03-14 18:30:20 +0000180#ifndef XML_WITHOUT_CORBA
181 void *_private; /* for Corba, must be first ! */
182#endif
183 xmlElementType type; /* XML_ELEMENT_DECL, must be second ! */
Daniel Veillard6077d031999-10-09 09:11:45 +0000184 const xmlChar *name; /* Element name */
Daniel Veillardcf461992000-03-14 18:30:20 +0000185 struct _xmlNode *children; /* NULL */
186 struct _xmlNode *last; /* NULL */
187 struct _xmlDtd *parent; /* -> DTD */
188 struct _xmlNode *next; /* next sibling link */
189 struct _xmlNode *prev; /* previous sibling link */
190 struct _xmlDoc *doc; /* the containing document */
191
192 xmlElementTypeVal etype; /* The type */
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000193 xmlElementContentPtr content; /* the allowed element content */
Daniel Veillardb05deb71999-08-10 19:04:08 +0000194 xmlAttributePtr attributes; /* List of the declared attributes */
Daniel Veillardbe803962000-06-28 23:40:59 +0000195 const xmlChar *prefix; /* the namespace prefix if any */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000196};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000197
198/*
199 * An XML namespace.
200 * Note that prefix == NULL is valid, it defines the default namespace
201 * within the subtree (until overriden).
Daniel Veillarda4964b72000-10-31 18:23:44 +0000202 *
203 * XML_GLOBAL_NAMESPACE is now deprecated for good
204 * xmlNsType is unified with xmlElementType
Daniel Veillard260a68f1998-08-13 03:39:55 +0000205 */
206
Daniel Veillarda4964b72000-10-31 18:23:44 +0000207#define XML_LOCAL_NAMESPACE XML_NAMESPACE_DECL
208typedef xmlElementType xmlNsType;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000209
Daniel Veillard71b656e2000-01-05 14:46:17 +0000210typedef struct _xmlNs xmlNs;
211typedef xmlNs *xmlNsPtr;
212struct _xmlNs {
213 struct _xmlNs *next; /* next Ns link for this node */
Daniel Veillard1899e851999-02-01 12:18:54 +0000214 xmlNsType type; /* global or local */
Daniel Veillard6077d031999-10-09 09:11:45 +0000215 const xmlChar *href; /* URL for the namespace */
216 const xmlChar *prefix; /* prefix for the namespace */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000217};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000218
219/*
220 * An XML DtD, as defined by <!DOCTYPE.
221 */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000222typedef struct _xmlDtd xmlDtd;
223typedef xmlDtd *xmlDtdPtr;
224struct _xmlDtd {
Daniel Veillardcf461992000-03-14 18:30:20 +0000225#ifndef XML_WITHOUT_CORBA
226 void *_private; /* for Corba, must be first ! */
227#endif
228 xmlElementType type; /* XML_DTD_NODE, must be second ! */
Daniel Veillard6077d031999-10-09 09:11:45 +0000229 const xmlChar *name; /* Name of the DTD */
Daniel Veillardcf461992000-03-14 18:30:20 +0000230 struct _xmlNode *children; /* the value of the property link */
231 struct _xmlNode *last; /* last child link */
232 struct _xmlDoc *parent; /* child->parent link */
233 struct _xmlNode *next; /* next sibling link */
234 struct _xmlNode *prev; /* previous sibling link */
235 struct _xmlDoc *doc; /* the containing document */
236
237 /* End of common part */
Daniel Veillard1e346af1999-02-22 10:33:01 +0000238 void *notations; /* Hash table for notations if any */
Daniel Veillard260a68f1998-08-13 03:39:55 +0000239 void *elements; /* Hash table for elements if any */
Daniel Veillard1e346af1999-02-22 10:33:01 +0000240 void *attributes; /* Hash table for attributes if any */
Daniel Veillard260a68f1998-08-13 03:39:55 +0000241 void *entities; /* Hash table for entities if any */
Daniel Veillardcf461992000-03-14 18:30:20 +0000242 const xmlChar *ExternalID; /* External identifier for PUBLIC DTD */
243 const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC DTD */
Daniel Veillard52afe802000-10-22 16:56:02 +0000244 void *pentities; /* Hash table for param entities if any */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000245};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000246
247/*
248 * A attribute of an XML node.
249 */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000250typedef struct _xmlAttr xmlAttr;
251typedef xmlAttr *xmlAttrPtr;
252struct _xmlAttr {
Daniel Veillard27fb0751998-10-17 06:47:46 +0000253#ifndef XML_WITHOUT_CORBA
254 void *_private; /* for Corba, must be first ! */
Daniel Veillard27fb0751998-10-17 06:47:46 +0000255#endif
Daniel Veillardcf461992000-03-14 18:30:20 +0000256 xmlElementType type; /* XML_ATTRIBUTE_NODE, must be second ! */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000257 const xmlChar *name; /* the name of the property */
Daniel Veillardcf461992000-03-14 18:30:20 +0000258 struct _xmlNode *children; /* the value of the property */
259 struct _xmlNode *last; /* NULL */
260 struct _xmlNode *parent; /* child->parent link */
261 struct _xmlAttr *next; /* next sibling link */
262 struct _xmlAttr *prev; /* previous sibling link */
263 struct _xmlDoc *doc; /* the containing document */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000264 xmlNs *ns; /* pointer to the associated namespace */
Daniel Veillardcf461992000-03-14 18:30:20 +0000265 xmlAttributeType atype; /* the attribute type if validating */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000266};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000267
268/*
Daniel Veillard991e63d1999-08-15 23:32:28 +0000269 * An XML ID instance.
270 */
271
Daniel Veillard71b656e2000-01-05 14:46:17 +0000272typedef struct _xmlID xmlID;
273typedef xmlID *xmlIDPtr;
274struct _xmlID {
275 struct _xmlID *next; /* next ID */
Daniel Veillard6077d031999-10-09 09:11:45 +0000276 const xmlChar *value; /* The ID name */
Daniel Veillard991e63d1999-08-15 23:32:28 +0000277 xmlAttrPtr attr; /* The attribut holding it */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000278};
Daniel Veillard991e63d1999-08-15 23:32:28 +0000279
280/*
Daniel Veillardc08a2c61999-09-08 21:35:25 +0000281 * An XML IDREF instance.
282 */
283
Daniel Veillard71b656e2000-01-05 14:46:17 +0000284typedef struct _xmlRef xmlRef;
285typedef xmlRef *xmlRefPtr;
286struct _xmlRef {
287 struct _xmlRef *next; /* next Ref */
Daniel Veillard6077d031999-10-09 09:11:45 +0000288 const xmlChar *value; /* The Ref name */
Daniel Veillardc08a2c61999-09-08 21:35:25 +0000289 xmlAttrPtr attr; /* The attribut holding it */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000290};
Daniel Veillardc08a2c61999-09-08 21:35:25 +0000291
292/*
Daniel Veillardf5c2c871999-12-01 09:51:45 +0000293 * A buffer structure
294 */
295
296typedef enum {
297 XML_BUFFER_ALLOC_DOUBLEIT,
298 XML_BUFFER_ALLOC_EXACT
299} xmlBufferAllocationScheme;
300
Daniel Veillard71b656e2000-01-05 14:46:17 +0000301typedef struct _xmlBuffer xmlBuffer;
302typedef xmlBuffer *xmlBufferPtr;
303struct _xmlBuffer {
Daniel Veillardf5c2c871999-12-01 09:51:45 +0000304 xmlChar *content; /* The buffer content UTF8 */
305 unsigned int use; /* The buffer size used */
306 unsigned int size; /* The buffer size */
307 xmlBufferAllocationScheme alloc; /* The realloc method */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000308};
Daniel Veillardf5c2c871999-12-01 09:51:45 +0000309
310/*
Daniel Veillard260a68f1998-08-13 03:39:55 +0000311 * A node in an XML tree.
312 */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000313typedef struct _xmlNode xmlNode;
314typedef xmlNode *xmlNodePtr;
315struct _xmlNode {
Daniel Veillard27fb0751998-10-17 06:47:46 +0000316#ifndef XML_WITHOUT_CORBA
317 void *_private; /* for Corba, must be first ! */
Daniel Veillard27fb0751998-10-17 06:47:46 +0000318#endif
Daniel Veillardcf461992000-03-14 18:30:20 +0000319 xmlElementType type; /* type number, must be second ! */
320 const xmlChar *name; /* the name of the node, or the entity */
321 struct _xmlNode *children; /* parent->childs link */
322 struct _xmlNode *last; /* last child link */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000323 struct _xmlNode *parent; /* child->parent link */
324 struct _xmlNode *next; /* next sibling link */
325 struct _xmlNode *prev; /* previous sibling link */
Daniel Veillardcf461992000-03-14 18:30:20 +0000326 struct _xmlDoc *doc; /* the containing document */
327 xmlNs *ns; /* pointer to the associated namespace */
Daniel Veillardf5c2c871999-12-01 09:51:45 +0000328#ifndef XML_USE_BUFFER_CONTENT
Daniel Veillardcf461992000-03-14 18:30:20 +0000329 xmlChar *content; /* the content */
Daniel Veillardf5c2c871999-12-01 09:51:45 +0000330#else
Daniel Veillardcf461992000-03-14 18:30:20 +0000331 xmlBufferPtr content; /* the content in a buffer */
Daniel Veillardf5c2c871999-12-01 09:51:45 +0000332#endif
Daniel Veillardcf461992000-03-14 18:30:20 +0000333
334 /* End of common part */
335 struct _xmlAttr *properties;/* properties list */
336 xmlNs *nsDef; /* namespace definitions on this node */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000337};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000338
339/*
340 * An XML document.
341 */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000342typedef struct _xmlDoc xmlDoc;
343typedef xmlDoc *xmlDocPtr;
344struct _xmlDoc {
Daniel Veillard27fb0751998-10-17 06:47:46 +0000345#ifndef XML_WITHOUT_CORBA
346 void *_private; /* for Corba, must be first ! */
Daniel Veillard27fb0751998-10-17 06:47:46 +0000347#endif
Daniel Veillardccb09631998-10-27 06:21:04 +0000348 xmlElementType type; /* XML_DOCUMENT_NODE, must be second ! */
Daniel Veillard260a68f1998-08-13 03:39:55 +0000349 char *name; /* name/filename/URI of the document */
Daniel Veillardcf461992000-03-14 18:30:20 +0000350 struct _xmlNode *children; /* the document tree */
351 struct _xmlNode *last; /* last child link */
352 struct _xmlNode *parent; /* child->parent link */
353 struct _xmlNode *next; /* next sibling link */
354 struct _xmlNode *prev; /* previous sibling link */
355 struct _xmlDoc *doc; /* autoreference to itself */
356
357 /* End of common part */
Daniel Veillard15a8df41998-09-24 19:15:06 +0000358 int compression;/* level of zlib compression */
Daniel Veillard260a68f1998-08-13 03:39:55 +0000359 int standalone; /* standalone document (no external refs) */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000360 struct _xmlDtd *intSubset; /* the document internal subset */
361 struct _xmlDtd *extSubset; /* the document external subset */
362 struct _xmlNs *oldNs; /* Global namespace, the old way */
Daniel Veillardcf461992000-03-14 18:30:20 +0000363 const xmlChar *version; /* the XML version string */
Daniel Veillardbe803962000-06-28 23:40:59 +0000364 const xmlChar *encoding; /* external initial encoding, if any */
Daniel Veillard991e63d1999-08-15 23:32:28 +0000365 void *ids; /* Hash table for ID attributes if any */
Daniel Veillardc08a2c61999-09-08 21:35:25 +0000366 void *refs; /* Hash table for IDREFs attributes if any */
Daniel Veillardcf461992000-03-14 18:30:20 +0000367 const xmlChar *URL; /* The URI for that document */
Daniel Veillardbe803962000-06-28 23:40:59 +0000368 int charset; /* encoding of the in-memory content
369 actually an xmlCharEncoding */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000370};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000371
372/*
Daniel Veillardbe803962000-06-28 23:40:59 +0000373 * Compatibility naming layer with libxml1
374 */
375#ifndef xmlChildrenNode
376#define xmlChildrenNode children
377#define xmlRootNode children
378#endif
379
380/*
Daniel Veillard260a68f1998-08-13 03:39:55 +0000381 * Variables.
382 */
Daniel Veillardc2def842000-11-07 14:21:01 +0000383LIBXML_DLL_IMPORT extern xmlNsPtr baseDTD;
384LIBXML_DLL_IMPORT extern int oldXMLWDcompatibility;/* maintain compatibility with old WD */
385LIBXML_DLL_IMPORT extern int xmlIndentTreeOutput; /* try to indent the tree dumps */
386LIBXML_DLL_IMPORT extern xmlBufferAllocationScheme xmlBufferAllocScheme; /* alloc scheme to use */
387LIBXML_DLL_IMPORT extern int xmlSaveNoEmptyTags; /* save empty tags as <empty></empty> */
Daniel Veillard260a68f1998-08-13 03:39:55 +0000388
389/*
Daniel Veillard5099ae81999-04-21 20:12:07 +0000390 * Handling Buffers.
391 */
392
Daniel Veillardb96e6431999-08-29 21:02:19 +0000393xmlBufferPtr xmlBufferCreate (void);
Daniel Veillardf5c2c871999-12-01 09:51:45 +0000394xmlBufferPtr xmlBufferCreateSize (size_t size);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000395void xmlBufferFree (xmlBufferPtr buf);
396int xmlBufferDump (FILE *file,
397 xmlBufferPtr buf);
398void xmlBufferAdd (xmlBufferPtr buf,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000399 const xmlChar *str,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000400 int len);
Daniel Veillardbe803962000-06-28 23:40:59 +0000401void xmlBufferAddHead (xmlBufferPtr buf,
402 const xmlChar *str,
403 int len);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000404void xmlBufferCat (xmlBufferPtr buf,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000405 const xmlChar *str);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000406void xmlBufferCCat (xmlBufferPtr buf,
407 const char *str);
408int xmlBufferShrink (xmlBufferPtr buf,
Daniel Veillard4b0755c2000-09-25 14:26:28 +0000409 unsigned int len);
Daniel Veillard496a1cf2000-05-03 14:20:55 +0000410int xmlBufferGrow (xmlBufferPtr buf,
Daniel Veillard4b0755c2000-09-25 14:26:28 +0000411 unsigned int len);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000412void xmlBufferEmpty (xmlBufferPtr buf);
Daniel Veillardf5c2c871999-12-01 09:51:45 +0000413const xmlChar* xmlBufferContent (const xmlBufferPtr buf);
414int xmlBufferUse (const xmlBufferPtr buf);
415void xmlBufferSetAllocationScheme(xmlBufferPtr buf,
416 xmlBufferAllocationScheme scheme);
417int xmlBufferLength (const xmlBufferPtr buf);
Daniel Veillard5099ae81999-04-21 20:12:07 +0000418
419/*
Daniel Veillard16253641998-10-28 22:58:05 +0000420 * Creating/freeing new structures
Daniel Veillard260a68f1998-08-13 03:39:55 +0000421 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000422xmlDtdPtr xmlCreateIntSubset (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000423 const xmlChar *name,
424 const xmlChar *ExternalID,
425 const xmlChar *SystemID);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000426xmlDtdPtr xmlNewDtd (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000427 const xmlChar *name,
428 const xmlChar *ExternalID,
429 const xmlChar *SystemID);
Daniel Veillardd83eb822000-06-30 18:39:56 +0000430xmlDtdPtr xmlGetIntSubset (xmlDocPtr doc);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000431void xmlFreeDtd (xmlDtdPtr cur);
432xmlNsPtr xmlNewGlobalNs (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000433 const xmlChar *href,
434 const xmlChar *prefix);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000435xmlNsPtr xmlNewNs (xmlNodePtr node,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000436 const xmlChar *href,
437 const xmlChar *prefix);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000438void xmlFreeNs (xmlNsPtr cur);
Daniel Veillard6077d031999-10-09 09:11:45 +0000439xmlDocPtr xmlNewDoc (const xmlChar *version);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000440void xmlFreeDoc (xmlDocPtr cur);
441xmlAttrPtr xmlNewDocProp (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000442 const xmlChar *name,
443 const xmlChar *value);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000444xmlAttrPtr xmlNewProp (xmlNodePtr node,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000445 const xmlChar *name,
446 const xmlChar *value);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000447xmlAttrPtr xmlNewNsProp (xmlNodePtr node,
448 xmlNsPtr ns,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000449 const xmlChar *name,
450 const xmlChar *value);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000451void xmlFreePropList (xmlAttrPtr cur);
452void xmlFreeProp (xmlAttrPtr cur);
453xmlAttrPtr xmlCopyProp (xmlNodePtr target,
454 xmlAttrPtr cur);
455xmlAttrPtr xmlCopyPropList (xmlNodePtr target,
456 xmlAttrPtr cur);
457xmlDtdPtr xmlCopyDtd (xmlDtdPtr dtd);
458xmlDocPtr xmlCopyDoc (xmlDocPtr doc,
459 int recursive);
Daniel Veillard16253641998-10-28 22:58:05 +0000460
461/*
462 * Creating new nodes
463 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000464xmlNodePtr xmlNewDocNode (xmlDocPtr doc,
465 xmlNsPtr ns,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000466 const xmlChar *name,
467 const xmlChar *content);
Daniel Veillard11a48ec1999-11-23 10:40:46 +0000468xmlNodePtr xmlNewDocRawNode (xmlDocPtr doc,
469 xmlNsPtr ns,
470 const xmlChar *name,
471 const xmlChar *content);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000472xmlNodePtr xmlNewNode (xmlNsPtr ns,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000473 const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000474xmlNodePtr xmlNewChild (xmlNodePtr parent,
475 xmlNsPtr ns,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000476 const xmlChar *name,
477 const xmlChar *content);
Daniel Veillard11a48ec1999-11-23 10:40:46 +0000478xmlNodePtr xmlNewTextChild (xmlNodePtr parent,
479 xmlNsPtr ns,
480 const xmlChar *name,
481 const xmlChar *content);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000482xmlNodePtr xmlNewDocText (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000483 const xmlChar *content);
484xmlNodePtr xmlNewText (const xmlChar *content);
485xmlNodePtr xmlNewPI (const xmlChar *name,
486 const xmlChar *content);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000487xmlNodePtr xmlNewDocTextLen (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000488 const xmlChar *content,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000489 int len);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000490xmlNodePtr xmlNewTextLen (const xmlChar *content,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000491 int len);
492xmlNodePtr xmlNewDocComment (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000493 const xmlChar *content);
494xmlNodePtr xmlNewComment (const xmlChar *content);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000495xmlNodePtr xmlNewCDataBlock (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000496 const xmlChar *content,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000497 int len);
Daniel Veillardcf461992000-03-14 18:30:20 +0000498xmlNodePtr xmlNewCharRef (xmlDocPtr doc,
499 const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000500xmlNodePtr xmlNewReference (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000501 const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000502xmlNodePtr xmlCopyNode (xmlNodePtr node,
503 int recursive);
504xmlNodePtr xmlCopyNodeList (xmlNodePtr node);
Daniel Veillard2eac5032000-01-09 21:08:56 +0000505xmlNodePtr xmlNewDocFragment (xmlDocPtr doc);
Daniel Veillard16253641998-10-28 22:58:05 +0000506
507/*
508 * Navigating
509 */
Daniel Veillard3dbfdca1999-12-15 19:08:23 +0000510xmlNodePtr xmlDocGetRootElement (xmlDocPtr doc);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000511xmlNodePtr xmlGetLastChild (xmlNodePtr parent);
512int xmlNodeIsText (xmlNodePtr node);
Daniel Veillard3e6d2372000-03-04 11:39:43 +0000513int xmlIsBlankNode (xmlNodePtr node);
Daniel Veillard16253641998-10-28 22:58:05 +0000514
515/*
516 * Changing the structure
517 */
Daniel Veillard5cb5ab81999-12-21 15:35:29 +0000518xmlNodePtr xmlDocSetRootElement (xmlDocPtr doc,
519 xmlNodePtr root);
520void xmlNodeSetName (xmlNodePtr cur,
521 const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000522xmlNodePtr xmlAddChild (xmlNodePtr parent,
523 xmlNodePtr cur);
Daniel Veillard87b95392000-08-12 21:12:04 +0000524xmlNodePtr xmlAddChildList (xmlNodePtr parent,
525 xmlNodePtr cur);
Daniel Veillard5cb5ab81999-12-21 15:35:29 +0000526xmlNodePtr xmlReplaceNode (xmlNodePtr old,
527 xmlNodePtr cur);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000528xmlNodePtr xmlAddSibling (xmlNodePtr cur,
529 xmlNodePtr elem);
Daniel Veillard5cb5ab81999-12-21 15:35:29 +0000530xmlNodePtr xmlAddPrevSibling (xmlNodePtr cur,
531 xmlNodePtr elem);
532xmlNodePtr xmlAddNextSibling (xmlNodePtr cur,
533 xmlNodePtr elem);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000534void xmlUnlinkNode (xmlNodePtr cur);
535xmlNodePtr xmlTextMerge (xmlNodePtr first,
536 xmlNodePtr second);
537void xmlTextConcat (xmlNodePtr node,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000538 const xmlChar *content,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000539 int len);
540void xmlFreeNodeList (xmlNodePtr cur);
541void xmlFreeNode (xmlNodePtr cur);
Daniel Veillardc2def842000-11-07 14:21:01 +0000542void xmlSetTreeDoc (xmlNodePtr tree,
543 xmlDocPtr doc);
544void xmlSetListDoc (xmlNodePtr list,
545 xmlDocPtr doc);
Daniel Veillard16253641998-10-28 22:58:05 +0000546
547/*
548 * Namespaces
549 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000550xmlNsPtr xmlSearchNs (xmlDocPtr doc,
551 xmlNodePtr node,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000552 const xmlChar *nameSpace);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000553xmlNsPtr xmlSearchNsByHref (xmlDocPtr doc,
554 xmlNodePtr node,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000555 const xmlChar *href);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000556xmlNsPtr * xmlGetNsList (xmlDocPtr doc,
557 xmlNodePtr node);
558void xmlSetNs (xmlNodePtr node,
559 xmlNsPtr ns);
560xmlNsPtr xmlCopyNamespace (xmlNsPtr cur);
561xmlNsPtr xmlCopyNamespaceList (xmlNsPtr cur);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000562
Daniel Veillard16253641998-10-28 22:58:05 +0000563/*
564 * Changing the content.
565 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000566xmlAttrPtr xmlSetProp (xmlNodePtr node,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000567 const xmlChar *name,
568 const xmlChar *value);
Daniel Veillard6077d031999-10-09 09:11:45 +0000569xmlChar * xmlGetProp (xmlNodePtr node,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000570 const xmlChar *name);
Daniel Veillard32bc74e2000-07-14 14:49:25 +0000571xmlAttrPtr xmlHasProp (xmlNodePtr node,
572 const xmlChar *name);
Daniel Veillard5a2b6972001-01-20 21:15:50 +0000573xmlAttrPtr xmlSetNsProp (xmlNodePtr node,
574 xmlNsPtr ns,
575 const xmlChar *name,
576 const xmlChar *value);
Daniel Veillard10a2c651999-12-12 13:03:50 +0000577xmlChar * xmlGetNsProp (xmlNodePtr node,
578 const xmlChar *name,
Ramiro Estrugobfce3771999-12-15 04:32:07 +0000579 const xmlChar *nameSpace);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000580xmlNodePtr xmlStringGetNodeList (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000581 const xmlChar *value);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000582xmlNodePtr xmlStringLenGetNodeList (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000583 const xmlChar *value,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000584 int len);
Daniel Veillard6077d031999-10-09 09:11:45 +0000585xmlChar * xmlNodeListGetString (xmlDocPtr doc,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000586 xmlNodePtr list,
587 int inLine);
Daniel Veillardbe803962000-06-28 23:40:59 +0000588xmlChar * xmlNodeListGetRawString (xmlDocPtr doc,
589 xmlNodePtr list,
590 int inLine);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000591void xmlNodeSetContent (xmlNodePtr cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000592 const xmlChar *content);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000593void xmlNodeSetContentLen (xmlNodePtr cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000594 const xmlChar *content,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000595 int len);
596void xmlNodeAddContent (xmlNodePtr cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000597 const xmlChar *content);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000598void xmlNodeAddContentLen (xmlNodePtr cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000599 const xmlChar *content,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000600 int len);
Daniel Veillard6077d031999-10-09 09:11:45 +0000601xmlChar * xmlNodeGetContent (xmlNodePtr cur);
Daniel Veillarda819dac1999-11-24 18:04:22 +0000602xmlChar * xmlNodeGetLang (xmlNodePtr cur);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000603void xmlNodeSetLang (xmlNodePtr cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000604 const xmlChar *lang);
Daniel Veillardcf461992000-03-14 18:30:20 +0000605int xmlNodeGetSpacePreserve (xmlNodePtr cur);
Daniel Veillardbe9ec4b2000-10-25 11:01:53 +0000606void xmlNodeSetSpacePreserve (xmlNodePtr cur, int
607 val);
Daniel Veillard10a2c651999-12-12 13:03:50 +0000608xmlChar * xmlNodeGetBase (xmlDocPtr doc,
609 xmlNodePtr cur);
Daniel Veillardbe9ec4b2000-10-25 11:01:53 +0000610void xmlNodeSetBase (xmlNodePtr cur,
611 xmlChar *uri);
Daniel Veillard16253641998-10-28 22:58:05 +0000612
613/*
Daniel Veillardc08a2c61999-09-08 21:35:25 +0000614 * Removing content.
615 */
Daniel Veillardcf461992000-03-14 18:30:20 +0000616int xmlRemoveProp (xmlAttrPtr attr);
Daniel Veillardc08a2c61999-09-08 21:35:25 +0000617int xmlRemoveNode (xmlNodePtr node); /* TODO */
618
619/*
Daniel Veillard16253641998-10-28 22:58:05 +0000620 * Internal, don't use
621 */
Daniel Veillardce6e98d2000-11-25 09:54:49 +0000622#ifdef VMS
623void xmlBufferWriteXmlCHAR (xmlBufferPtr buf,
624 const xmlChar *string);
625#define xmlBufferWriteCHAR xmlBufferWriteXmlCHAR
626#else
Daniel Veillardb96e6431999-08-29 21:02:19 +0000627void xmlBufferWriteCHAR (xmlBufferPtr buf,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000628 const xmlChar *string);
Daniel Veillardce6e98d2000-11-25 09:54:49 +0000629#endif
Daniel Veillardb96e6431999-08-29 21:02:19 +0000630void xmlBufferWriteChar (xmlBufferPtr buf,
631 const char *string);
632void xmlBufferWriteQuotedString(xmlBufferPtr buf,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000633 const xmlChar *string);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000634
Daniel Veillard16253641998-10-28 22:58:05 +0000635/*
Daniel Veillardcf461992000-03-14 18:30:20 +0000636 * Namespace handling
637 */
638int xmlReconciliateNs (xmlDocPtr doc,
639 xmlNodePtr tree);
640
641/*
Daniel Veillard16253641998-10-28 22:58:05 +0000642 * Saving
643 */
Daniel Veillarda6d8eb62000-12-27 10:46:47 +0000644void xmlDocDumpFormatMemory (xmlDocPtr cur,
645 xmlChar**mem,
646 int *size,
647 int format);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000648void xmlDocDumpMemory (xmlDocPtr cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000649 xmlChar**mem,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000650 int *size);
Daniel Veillard58770e72000-11-25 00:48:47 +0000651void xmlDocDumpMemoryEnc (xmlDocPtr out_doc,
652 xmlChar **doc_txt_ptr,
653 int * doc_txt_len,
654 const char *txt_encoding);
Daniel Veillarda6d8eb62000-12-27 10:46:47 +0000655void xmlDocDumpFormatMemoryEnc(xmlDocPtr out_doc,
656 xmlChar **doc_txt_ptr,
657 int * doc_txt_len,
658 const char *txt_encoding,
659 int format);
Daniel Veillardbe803962000-06-28 23:40:59 +0000660int xmlDocDump (FILE *f,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000661 xmlDocPtr cur);
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000662void xmlElemDump (FILE *f,
Daniel Veillard06047432000-04-24 11:33:38 +0000663 xmlDocPtr doc,
664 xmlNodePtr cur);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000665int xmlSaveFile (const char *filename,
666 xmlDocPtr cur);
Daniel Veillardb656ebe2000-09-22 13:51:48 +0000667void xmlNodeDump (xmlBufferPtr buf,
668 xmlDocPtr doc,
669 xmlNodePtr cur,
670 int level,
671 int format);
Daniel Veillard151b1b01998-09-23 00:49:46 +0000672
Daniel Veillardbe803962000-06-28 23:40:59 +0000673/* This one is exported from xmlIO.h
674
675int xmlSaveFileTo (xmlOutputBuffer *buf,
676 xmlDocPtr cur,
677 const char *encoding);
678 */
679
680int xmlSaveFileEnc (const char *filename,
681 xmlDocPtr cur,
682 const char *encoding);
683
Daniel Veillard16253641998-10-28 22:58:05 +0000684/*
685 * Compression
686 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000687int xmlGetDocCompressMode (xmlDocPtr doc);
688void xmlSetDocCompressMode (xmlDocPtr doc,
689 int mode);
690int xmlGetCompressMode (void);
691void xmlSetCompressMode (int mode);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000692
693#ifdef __cplusplus
694}
695#endif
696
697#endif /* __XML_TREE_H__ */
698