blob: a3ae15fd84e69484fe86bd61de8f2c608d4cfb90 [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 Veillard260a68f1998-08-13 03:39:55 +00008 */
9
10#ifndef __XML_TREE_H__
11#define __XML_TREE_H__
12
Daniel Veillard82c305b1999-12-15 19:08:23 +000013#include <stdio.h>
Daniel Veillard361d8452000-04-03 19:48:13 +000014#include <libxml/xmlversion.h>
Daniel Veillard82c305b1999-12-15 19:08:23 +000015
Daniel Veillard260a68f1998-08-13 03:39:55 +000016
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21/*
Daniel Veillardccb09631998-10-27 06:21:04 +000022 * The different element types carried by an XML tree
23 *
24 * NOTE: This is synchronized with DOM Level1 values
25 * See http://www.w3.org/TR/REC-DOM-Level-1/
26 */
27typedef enum {
28 XML_ELEMENT_NODE= 1,
29 XML_ATTRIBUTE_NODE= 2,
30 XML_TEXT_NODE= 3,
31 XML_CDATA_SECTION_NODE= 4,
32 XML_ENTITY_REF_NODE= 5,
33 XML_ENTITY_NODE= 6,
34 XML_PI_NODE= 7,
35 XML_COMMENT_NODE= 8,
36 XML_DOCUMENT_NODE= 9,
37 XML_DOCUMENT_TYPE_NODE= 10,
38 XML_DOCUMENT_FRAG_NODE= 11,
Daniel Veillard7c1206f1999-10-14 09:10:25 +000039 XML_NOTATION_NODE= 12,
Daniel Veillardcf461992000-03-14 18:30:20 +000040 XML_HTML_DOCUMENT_NODE= 13,
41 XML_DTD_NODE= 14,
42 XML_ELEMENT_DECL= 15,
43 XML_ATTRIBUTE_DECL= 16,
44 XML_ENTITY_DECL= 17
Daniel Veillardccb09631998-10-27 06:21:04 +000045} xmlElementType;
46
47/*
Daniel Veillard0ba4d531998-11-01 19:34:31 +000048 * Size of an internal character representation.
49 *
Daniel Veillardcf461992000-03-14 18:30:20 +000050 * We use 8bit chars internal representation for memory efficiency,
51 * Note that with 8 bits wide xmlChars one can still use UTF-8 to handle
52 * correctly non ISO-Latin input.
Daniel Veillard260a68f1998-08-13 03:39:55 +000053 */
Daniel Veillarddd6b3671999-09-23 22:19:22 +000054
Daniel Veillarddd6b3671999-09-23 22:19:22 +000055typedef unsigned char xmlChar;
Daniel Veillard260a68f1998-08-13 03:39:55 +000056
Daniel Veillarddd6b3671999-09-23 22:19:22 +000057#ifndef WIN32
58#ifndef CHAR
59#define CHAR xmlChar
60#endif
61#endif
62
63#define BAD_CAST (xmlChar *)
Daniel Veillardb96e6431999-08-29 21:02:19 +000064
Daniel Veillard260a68f1998-08-13 03:39:55 +000065/*
66 * a DTD Notation definition
Daniel Veillard260a68f1998-08-13 03:39:55 +000067 */
68
Daniel Veillard71b656e2000-01-05 14:46:17 +000069typedef struct _xmlNotation xmlNotation;
70typedef xmlNotation *xmlNotationPtr;
71struct _xmlNotation {
Daniel Veillarddd6b3671999-09-23 22:19:22 +000072 const xmlChar *name; /* Notation name */
73 const xmlChar *PublicID; /* Public identifier, if any */
74 const xmlChar *SystemID; /* System identifier, if any */
Daniel Veillard71b656e2000-01-05 14:46:17 +000075};
Daniel Veillard1e346af1999-02-22 10:33:01 +000076
Daniel Veillard260a68f1998-08-13 03:39:55 +000077/*
78 * a DTD Attribute definition
Daniel Veillard260a68f1998-08-13 03:39:55 +000079 */
80
Daniel Veillard1e346af1999-02-22 10:33:01 +000081typedef enum {
82 XML_ATTRIBUTE_CDATA = 1,
83 XML_ATTRIBUTE_ID,
84 XML_ATTRIBUTE_IDREF ,
85 XML_ATTRIBUTE_IDREFS,
86 XML_ATTRIBUTE_ENTITY,
87 XML_ATTRIBUTE_ENTITIES,
88 XML_ATTRIBUTE_NMTOKEN,
89 XML_ATTRIBUTE_NMTOKENS,
90 XML_ATTRIBUTE_ENUMERATION,
91 XML_ATTRIBUTE_NOTATION
92} xmlAttributeType;
Daniel Veillard39a1f9a1999-01-17 19:11:59 +000093
Daniel Veillard1e346af1999-02-22 10:33:01 +000094typedef enum {
95 XML_ATTRIBUTE_NONE = 1,
96 XML_ATTRIBUTE_REQUIRED,
97 XML_ATTRIBUTE_IMPLIED,
98 XML_ATTRIBUTE_FIXED
99} xmlAttributeDefault;
100
Daniel Veillard71b656e2000-01-05 14:46:17 +0000101typedef struct _xmlEnumeration xmlEnumeration;
Daniel Veillard1e346af1999-02-22 10:33:01 +0000102typedef xmlEnumeration *xmlEnumerationPtr;
Daniel Veillard71b656e2000-01-05 14:46:17 +0000103struct _xmlEnumeration {
104 struct _xmlEnumeration *next; /* next one */
105 const xmlChar *name; /* Enumeration name */
106};
Daniel Veillard1e346af1999-02-22 10:33:01 +0000107
Daniel Veillard71b656e2000-01-05 14:46:17 +0000108typedef struct _xmlAttribute xmlAttribute;
109typedef xmlAttribute *xmlAttributePtr;
110struct _xmlAttribute {
Daniel Veillardcf461992000-03-14 18:30:20 +0000111#ifndef XML_WITHOUT_CORBA
112 void *_private; /* for Corba, must be first ! */
113#endif
114 xmlElementType type; /* XML_ATTRIBUTE_DECL, must be second ! */
115 const xmlChar *name; /* Attribute name */
116 struct _xmlNode *children; /* NULL */
117 struct _xmlNode *last; /* NULL */
118 struct _xmlDtd *parent; /* -> DTD */
119 struct _xmlNode *next; /* next sibling link */
120 struct _xmlNode *prev; /* previous sibling link */
121 struct _xmlDoc *doc; /* the containing document */
122
123 struct _xmlAttribute *nexth; /* next in hash table */
124 xmlAttributeType atype; /* The attribute type */
125 xmlAttributeDefault def; /* the default */
126 const xmlChar *defaultValue; /* or the default value */
127 xmlEnumerationPtr tree; /* or the enumeration tree if any */
128 const xmlChar *prefix; /* the namespace prefix if any */
129 const xmlChar *elem; /* Element holding the attribute */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000130};
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000131
Daniel Veillard260a68f1998-08-13 03:39:55 +0000132/*
133 * a DTD Element definition.
134 */
Daniel Veillard1899e851999-02-01 12:18:54 +0000135typedef enum {
Daniel Veillard1e346af1999-02-22 10:33:01 +0000136 XML_ELEMENT_CONTENT_PCDATA = 1,
Daniel Veillard1899e851999-02-01 12:18:54 +0000137 XML_ELEMENT_CONTENT_ELEMENT,
138 XML_ELEMENT_CONTENT_SEQ,
139 XML_ELEMENT_CONTENT_OR
140} xmlElementContentType;
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000141
Daniel Veillard1899e851999-02-01 12:18:54 +0000142typedef enum {
Daniel Veillard1e346af1999-02-22 10:33:01 +0000143 XML_ELEMENT_CONTENT_ONCE = 1,
Daniel Veillard1899e851999-02-01 12:18:54 +0000144 XML_ELEMENT_CONTENT_OPT,
145 XML_ELEMENT_CONTENT_MULT,
146 XML_ELEMENT_CONTENT_PLUS
147} xmlElementContentOccur;
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000148
Daniel Veillard71b656e2000-01-05 14:46:17 +0000149typedef struct _xmlElementContent xmlElementContent;
150typedef xmlElementContent *xmlElementContentPtr;
151struct _xmlElementContent {
Daniel Veillard1899e851999-02-01 12:18:54 +0000152 xmlElementContentType type; /* PCDATA, ELEMENT, SEQ or OR */
153 xmlElementContentOccur ocur; /* ONCE, OPT, MULT or PLUS */
Daniel Veillard6077d031999-10-09 09:11:45 +0000154 const xmlChar *name; /* Element name */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000155 struct _xmlElementContent *c1; /* first child */
156 struct _xmlElementContent *c2; /* second child */
157};
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000158
Daniel Veillard1899e851999-02-01 12:18:54 +0000159typedef enum {
Daniel Veillard1e346af1999-02-22 10:33:01 +0000160 XML_ELEMENT_TYPE_EMPTY = 1,
Daniel Veillard1899e851999-02-01 12:18:54 +0000161 XML_ELEMENT_TYPE_ANY,
162 XML_ELEMENT_TYPE_MIXED,
163 XML_ELEMENT_TYPE_ELEMENT
164} xmlElementTypeVal;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000165
Daniel Veillard71b656e2000-01-05 14:46:17 +0000166typedef struct _xmlElement xmlElement;
167typedef xmlElement *xmlElementPtr;
168struct _xmlElement {
Daniel Veillardcf461992000-03-14 18:30:20 +0000169#ifndef XML_WITHOUT_CORBA
170 void *_private; /* for Corba, must be first ! */
171#endif
172 xmlElementType type; /* XML_ELEMENT_DECL, must be second ! */
Daniel Veillard6077d031999-10-09 09:11:45 +0000173 const xmlChar *name; /* Element name */
Daniel Veillardcf461992000-03-14 18:30:20 +0000174 struct _xmlNode *children; /* NULL */
175 struct _xmlNode *last; /* NULL */
176 struct _xmlDtd *parent; /* -> DTD */
177 struct _xmlNode *next; /* next sibling link */
178 struct _xmlNode *prev; /* previous sibling link */
179 struct _xmlDoc *doc; /* the containing document */
180
181 xmlElementTypeVal etype; /* The type */
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000182 xmlElementContentPtr content; /* the allowed element content */
Daniel Veillardb05deb71999-08-10 19:04:08 +0000183 xmlAttributePtr attributes; /* List of the declared attributes */
Daniel Veillardbe803962000-06-28 23:40:59 +0000184 const xmlChar *prefix; /* the namespace prefix if any */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000185};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000186
187/*
188 * An XML namespace.
189 * Note that prefix == NULL is valid, it defines the default namespace
190 * within the subtree (until overriden).
191 */
192
Daniel Veillard1899e851999-02-01 12:18:54 +0000193typedef enum {
Daniel Veillard1e346af1999-02-22 10:33:01 +0000194 XML_GLOBAL_NAMESPACE = 1, /* old style global namespace */
Daniel Veillard1899e851999-02-01 12:18:54 +0000195 XML_LOCAL_NAMESPACE /* new style local scoping */
196} xmlNsType;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000197
Daniel Veillard71b656e2000-01-05 14:46:17 +0000198typedef struct _xmlNs xmlNs;
199typedef xmlNs *xmlNsPtr;
200struct _xmlNs {
201 struct _xmlNs *next; /* next Ns link for this node */
Daniel Veillard1899e851999-02-01 12:18:54 +0000202 xmlNsType type; /* global or local */
Daniel Veillard6077d031999-10-09 09:11:45 +0000203 const xmlChar *href; /* URL for the namespace */
204 const xmlChar *prefix; /* prefix for the namespace */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000205};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000206
207/*
208 * An XML DtD, as defined by <!DOCTYPE.
209 */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000210typedef struct _xmlDtd xmlDtd;
211typedef xmlDtd *xmlDtdPtr;
212struct _xmlDtd {
Daniel Veillardcf461992000-03-14 18:30:20 +0000213#ifndef XML_WITHOUT_CORBA
214 void *_private; /* for Corba, must be first ! */
215#endif
216 xmlElementType type; /* XML_DTD_NODE, must be second ! */
Daniel Veillard6077d031999-10-09 09:11:45 +0000217 const xmlChar *name; /* Name of the DTD */
Daniel Veillardcf461992000-03-14 18:30:20 +0000218 struct _xmlNode *children; /* the value of the property link */
219 struct _xmlNode *last; /* last child link */
220 struct _xmlDoc *parent; /* child->parent link */
221 struct _xmlNode *next; /* next sibling link */
222 struct _xmlNode *prev; /* previous sibling link */
223 struct _xmlDoc *doc; /* the containing document */
224
225 /* End of common part */
Daniel Veillard1e346af1999-02-22 10:33:01 +0000226 void *notations; /* Hash table for notations if any */
Daniel Veillard260a68f1998-08-13 03:39:55 +0000227 void *elements; /* Hash table for elements if any */
Daniel Veillard1e346af1999-02-22 10:33:01 +0000228 void *attributes; /* Hash table for attributes if any */
Daniel Veillard260a68f1998-08-13 03:39:55 +0000229 void *entities; /* Hash table for entities if any */
Daniel Veillardcf461992000-03-14 18:30:20 +0000230 const xmlChar *ExternalID; /* External identifier for PUBLIC DTD */
231 const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC DTD */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000232};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000233
234/*
235 * A attribute of an XML node.
236 */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000237typedef struct _xmlAttr xmlAttr;
238typedef xmlAttr *xmlAttrPtr;
239struct _xmlAttr {
Daniel Veillard27fb0751998-10-17 06:47:46 +0000240#ifndef XML_WITHOUT_CORBA
241 void *_private; /* for Corba, must be first ! */
Daniel Veillard27fb0751998-10-17 06:47:46 +0000242#endif
Daniel Veillardcf461992000-03-14 18:30:20 +0000243 xmlElementType type; /* XML_ATTRIBUTE_NODE, must be second ! */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000244 const xmlChar *name; /* the name of the property */
Daniel Veillardcf461992000-03-14 18:30:20 +0000245 struct _xmlNode *children; /* the value of the property */
246 struct _xmlNode *last; /* NULL */
247 struct _xmlNode *parent; /* child->parent link */
248 struct _xmlAttr *next; /* next sibling link */
249 struct _xmlAttr *prev; /* previous sibling link */
250 struct _xmlDoc *doc; /* the containing document */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000251 xmlNs *ns; /* pointer to the associated namespace */
Daniel Veillardcf461992000-03-14 18:30:20 +0000252 xmlAttributeType atype; /* the attribute type if validating */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000253};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000254
255/*
Daniel Veillard991e63d1999-08-15 23:32:28 +0000256 * An XML ID instance.
257 */
258
Daniel Veillard71b656e2000-01-05 14:46:17 +0000259typedef struct _xmlID xmlID;
260typedef xmlID *xmlIDPtr;
261struct _xmlID {
262 struct _xmlID *next; /* next ID */
Daniel Veillard6077d031999-10-09 09:11:45 +0000263 const xmlChar *value; /* The ID name */
Daniel Veillard991e63d1999-08-15 23:32:28 +0000264 xmlAttrPtr attr; /* The attribut holding it */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000265};
Daniel Veillard991e63d1999-08-15 23:32:28 +0000266
267/*
Daniel Veillardc08a2c61999-09-08 21:35:25 +0000268 * An XML IDREF instance.
269 */
270
Daniel Veillard71b656e2000-01-05 14:46:17 +0000271typedef struct _xmlRef xmlRef;
272typedef xmlRef *xmlRefPtr;
273struct _xmlRef {
274 struct _xmlRef *next; /* next Ref */
Daniel Veillard6077d031999-10-09 09:11:45 +0000275 const xmlChar *value; /* The Ref name */
Daniel Veillardc08a2c61999-09-08 21:35:25 +0000276 xmlAttrPtr attr; /* The attribut holding it */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000277};
Daniel Veillardc08a2c61999-09-08 21:35:25 +0000278
279/*
Daniel Veillardf5c2c871999-12-01 09:51:45 +0000280 * A buffer structure
281 */
282
283typedef enum {
284 XML_BUFFER_ALLOC_DOUBLEIT,
285 XML_BUFFER_ALLOC_EXACT
286} xmlBufferAllocationScheme;
287
Daniel Veillard71b656e2000-01-05 14:46:17 +0000288typedef struct _xmlBuffer xmlBuffer;
289typedef xmlBuffer *xmlBufferPtr;
290struct _xmlBuffer {
Daniel Veillardf5c2c871999-12-01 09:51:45 +0000291 xmlChar *content; /* The buffer content UTF8 */
292 unsigned int use; /* The buffer size used */
293 unsigned int size; /* The buffer size */
294 xmlBufferAllocationScheme alloc; /* The realloc method */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000295};
Daniel Veillardf5c2c871999-12-01 09:51:45 +0000296
297/*
Daniel Veillard260a68f1998-08-13 03:39:55 +0000298 * A node in an XML tree.
299 */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000300typedef struct _xmlNode xmlNode;
301typedef xmlNode *xmlNodePtr;
302struct _xmlNode {
Daniel Veillard27fb0751998-10-17 06:47:46 +0000303#ifndef XML_WITHOUT_CORBA
304 void *_private; /* for Corba, must be first ! */
Daniel Veillard27fb0751998-10-17 06:47:46 +0000305#endif
Daniel Veillardcf461992000-03-14 18:30:20 +0000306 xmlElementType type; /* type number, must be second ! */
307 const xmlChar *name; /* the name of the node, or the entity */
308 struct _xmlNode *children; /* parent->childs link */
309 struct _xmlNode *last; /* last child link */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000310 struct _xmlNode *parent; /* child->parent link */
311 struct _xmlNode *next; /* next sibling link */
312 struct _xmlNode *prev; /* previous sibling link */
Daniel Veillardcf461992000-03-14 18:30:20 +0000313 struct _xmlDoc *doc; /* the containing document */
314 xmlNs *ns; /* pointer to the associated namespace */
Daniel Veillardf5c2c871999-12-01 09:51:45 +0000315#ifndef XML_USE_BUFFER_CONTENT
Daniel Veillardcf461992000-03-14 18:30:20 +0000316 xmlChar *content; /* the content */
Daniel Veillardf5c2c871999-12-01 09:51:45 +0000317#else
Daniel Veillardcf461992000-03-14 18:30:20 +0000318 xmlBufferPtr content; /* the content in a buffer */
Daniel Veillardf5c2c871999-12-01 09:51:45 +0000319#endif
Daniel Veillardcf461992000-03-14 18:30:20 +0000320
321 /* End of common part */
322 struct _xmlAttr *properties;/* properties list */
323 xmlNs *nsDef; /* namespace definitions on this node */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000324};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000325
326/*
327 * An XML document.
328 */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000329typedef struct _xmlDoc xmlDoc;
330typedef xmlDoc *xmlDocPtr;
331struct _xmlDoc {
Daniel Veillard27fb0751998-10-17 06:47:46 +0000332#ifndef XML_WITHOUT_CORBA
333 void *_private; /* for Corba, must be first ! */
Daniel Veillard27fb0751998-10-17 06:47:46 +0000334#endif
Daniel Veillardccb09631998-10-27 06:21:04 +0000335 xmlElementType type; /* XML_DOCUMENT_NODE, must be second ! */
Daniel Veillard260a68f1998-08-13 03:39:55 +0000336 char *name; /* name/filename/URI of the document */
Daniel Veillardcf461992000-03-14 18:30:20 +0000337 struct _xmlNode *children; /* the document tree */
338 struct _xmlNode *last; /* last child link */
339 struct _xmlNode *parent; /* child->parent link */
340 struct _xmlNode *next; /* next sibling link */
341 struct _xmlNode *prev; /* previous sibling link */
342 struct _xmlDoc *doc; /* autoreference to itself */
343
344 /* End of common part */
Daniel Veillard15a8df41998-09-24 19:15:06 +0000345 int compression;/* level of zlib compression */
Daniel Veillard260a68f1998-08-13 03:39:55 +0000346 int standalone; /* standalone document (no external refs) */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000347 struct _xmlDtd *intSubset; /* the document internal subset */
348 struct _xmlDtd *extSubset; /* the document external subset */
349 struct _xmlNs *oldNs; /* Global namespace, the old way */
Daniel Veillardcf461992000-03-14 18:30:20 +0000350 const xmlChar *version; /* the XML version string */
Daniel Veillardbe803962000-06-28 23:40:59 +0000351 const xmlChar *encoding; /* external initial encoding, if any */
Daniel Veillard991e63d1999-08-15 23:32:28 +0000352 void *ids; /* Hash table for ID attributes if any */
Daniel Veillardc08a2c61999-09-08 21:35:25 +0000353 void *refs; /* Hash table for IDREFs attributes if any */
Daniel Veillardcf461992000-03-14 18:30:20 +0000354 const xmlChar *URL; /* The URI for that document */
Daniel Veillardbe803962000-06-28 23:40:59 +0000355 int charset; /* encoding of the in-memory content
356 actually an xmlCharEncoding */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000357};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000358
359/*
Daniel Veillardbe803962000-06-28 23:40:59 +0000360 * Compatibility naming layer with libxml1
361 */
362#ifndef xmlChildrenNode
363#define xmlChildrenNode children
364#define xmlRootNode children
365#endif
366
367/*
Daniel Veillard260a68f1998-08-13 03:39:55 +0000368 * Variables.
369 */
370extern xmlNsPtr baseDTD;
371extern int oldXMLWDcompatibility;/* maintain compatibility with old WD */
372extern int xmlIndentTreeOutput; /* try to indent the tree dumps */
Daniel Veillardf5c2c871999-12-01 09:51:45 +0000373extern xmlBufferAllocationScheme xmlBufferAllocScheme; /* alloc scheme to use */
Daniel Veillarde41f2b72000-01-30 20:00:07 +0000374extern int xmlSaveNoEmptyTags; /* save empty tags as <empty></empty> */
Daniel Veillard260a68f1998-08-13 03:39:55 +0000375
376/*
Daniel Veillard5099ae81999-04-21 20:12:07 +0000377 * Handling Buffers.
378 */
379
Daniel Veillardb96e6431999-08-29 21:02:19 +0000380xmlBufferPtr xmlBufferCreate (void);
Daniel Veillardf5c2c871999-12-01 09:51:45 +0000381xmlBufferPtr xmlBufferCreateSize (size_t size);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000382void xmlBufferFree (xmlBufferPtr buf);
383int xmlBufferDump (FILE *file,
384 xmlBufferPtr buf);
385void xmlBufferAdd (xmlBufferPtr buf,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000386 const xmlChar *str,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000387 int len);
Daniel Veillardbe803962000-06-28 23:40:59 +0000388void xmlBufferAddHead (xmlBufferPtr buf,
389 const xmlChar *str,
390 int len);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000391void xmlBufferCat (xmlBufferPtr buf,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000392 const xmlChar *str);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000393void xmlBufferCCat (xmlBufferPtr buf,
394 const char *str);
395int xmlBufferShrink (xmlBufferPtr buf,
396 int len);
Daniel Veillard496a1cf2000-05-03 14:20:55 +0000397int xmlBufferGrow (xmlBufferPtr buf,
398 int len);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000399void xmlBufferEmpty (xmlBufferPtr buf);
Daniel Veillardf5c2c871999-12-01 09:51:45 +0000400const xmlChar* xmlBufferContent (const xmlBufferPtr buf);
401int xmlBufferUse (const xmlBufferPtr buf);
402void xmlBufferSetAllocationScheme(xmlBufferPtr buf,
403 xmlBufferAllocationScheme scheme);
404int xmlBufferLength (const xmlBufferPtr buf);
Daniel Veillard5099ae81999-04-21 20:12:07 +0000405
406/*
Daniel Veillard16253641998-10-28 22:58:05 +0000407 * Creating/freeing new structures
Daniel Veillard260a68f1998-08-13 03:39:55 +0000408 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000409xmlDtdPtr xmlCreateIntSubset (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000410 const xmlChar *name,
411 const xmlChar *ExternalID,
412 const xmlChar *SystemID);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000413xmlDtdPtr xmlNewDtd (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000414 const xmlChar *name,
415 const xmlChar *ExternalID,
416 const xmlChar *SystemID);
Daniel Veillardd83eb822000-06-30 18:39:56 +0000417xmlDtdPtr xmlGetIntSubset (xmlDocPtr doc);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000418void xmlFreeDtd (xmlDtdPtr cur);
419xmlNsPtr xmlNewGlobalNs (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000420 const xmlChar *href,
421 const xmlChar *prefix);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000422xmlNsPtr xmlNewNs (xmlNodePtr node,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000423 const xmlChar *href,
424 const xmlChar *prefix);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000425void xmlFreeNs (xmlNsPtr cur);
Daniel Veillard6077d031999-10-09 09:11:45 +0000426xmlDocPtr xmlNewDoc (const xmlChar *version);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000427void xmlFreeDoc (xmlDocPtr cur);
428xmlAttrPtr xmlNewDocProp (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000429 const xmlChar *name,
430 const xmlChar *value);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000431xmlAttrPtr xmlNewProp (xmlNodePtr node,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000432 const xmlChar *name,
433 const xmlChar *value);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000434xmlAttrPtr xmlNewNsProp (xmlNodePtr node,
435 xmlNsPtr ns,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000436 const xmlChar *name,
437 const xmlChar *value);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000438void xmlFreePropList (xmlAttrPtr cur);
439void xmlFreeProp (xmlAttrPtr cur);
440xmlAttrPtr xmlCopyProp (xmlNodePtr target,
441 xmlAttrPtr cur);
442xmlAttrPtr xmlCopyPropList (xmlNodePtr target,
443 xmlAttrPtr cur);
444xmlDtdPtr xmlCopyDtd (xmlDtdPtr dtd);
445xmlDocPtr xmlCopyDoc (xmlDocPtr doc,
446 int recursive);
Daniel Veillard16253641998-10-28 22:58:05 +0000447
448/*
449 * Creating new nodes
450 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000451xmlNodePtr xmlNewDocNode (xmlDocPtr doc,
452 xmlNsPtr ns,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000453 const xmlChar *name,
454 const xmlChar *content);
Daniel Veillard11a48ec1999-11-23 10:40:46 +0000455xmlNodePtr xmlNewDocRawNode (xmlDocPtr doc,
456 xmlNsPtr ns,
457 const xmlChar *name,
458 const xmlChar *content);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000459xmlNodePtr xmlNewNode (xmlNsPtr ns,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000460 const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000461xmlNodePtr xmlNewChild (xmlNodePtr parent,
462 xmlNsPtr ns,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000463 const xmlChar *name,
464 const xmlChar *content);
Daniel Veillard11a48ec1999-11-23 10:40:46 +0000465xmlNodePtr xmlNewTextChild (xmlNodePtr parent,
466 xmlNsPtr ns,
467 const xmlChar *name,
468 const xmlChar *content);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000469xmlNodePtr xmlNewDocText (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000470 const xmlChar *content);
471xmlNodePtr xmlNewText (const xmlChar *content);
472xmlNodePtr xmlNewPI (const xmlChar *name,
473 const xmlChar *content);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000474xmlNodePtr xmlNewDocTextLen (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000475 const xmlChar *content,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000476 int len);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000477xmlNodePtr xmlNewTextLen (const xmlChar *content,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000478 int len);
479xmlNodePtr xmlNewDocComment (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000480 const xmlChar *content);
481xmlNodePtr xmlNewComment (const xmlChar *content);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000482xmlNodePtr xmlNewCDataBlock (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000483 const xmlChar *content,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000484 int len);
Daniel Veillardcf461992000-03-14 18:30:20 +0000485xmlNodePtr xmlNewCharRef (xmlDocPtr doc,
486 const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000487xmlNodePtr xmlNewReference (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000488 const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000489xmlNodePtr xmlCopyNode (xmlNodePtr node,
490 int recursive);
491xmlNodePtr xmlCopyNodeList (xmlNodePtr node);
Daniel Veillard2eac5032000-01-09 21:08:56 +0000492xmlNodePtr xmlNewDocFragment (xmlDocPtr doc);
Daniel Veillard16253641998-10-28 22:58:05 +0000493
494/*
495 * Navigating
496 */
Daniel Veillard3dbfdca1999-12-15 19:08:23 +0000497xmlNodePtr xmlDocGetRootElement (xmlDocPtr doc);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000498xmlNodePtr xmlGetLastChild (xmlNodePtr parent);
499int xmlNodeIsText (xmlNodePtr node);
Daniel Veillard3e6d2372000-03-04 11:39:43 +0000500int xmlIsBlankNode (xmlNodePtr node);
Daniel Veillard16253641998-10-28 22:58:05 +0000501
502/*
503 * Changing the structure
504 */
Daniel Veillard5cb5ab81999-12-21 15:35:29 +0000505xmlNodePtr xmlDocSetRootElement (xmlDocPtr doc,
506 xmlNodePtr root);
507void xmlNodeSetName (xmlNodePtr cur,
508 const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000509xmlNodePtr xmlAddChild (xmlNodePtr parent,
510 xmlNodePtr cur);
Daniel Veillard87b95392000-08-12 21:12:04 +0000511xmlNodePtr xmlAddChildList (xmlNodePtr parent,
512 xmlNodePtr cur);
Daniel Veillard5cb5ab81999-12-21 15:35:29 +0000513xmlNodePtr xmlReplaceNode (xmlNodePtr old,
514 xmlNodePtr cur);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000515xmlNodePtr xmlAddSibling (xmlNodePtr cur,
516 xmlNodePtr elem);
Daniel Veillard5cb5ab81999-12-21 15:35:29 +0000517xmlNodePtr xmlAddPrevSibling (xmlNodePtr cur,
518 xmlNodePtr elem);
519xmlNodePtr xmlAddNextSibling (xmlNodePtr cur,
520 xmlNodePtr elem);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000521void xmlUnlinkNode (xmlNodePtr cur);
522xmlNodePtr xmlTextMerge (xmlNodePtr first,
523 xmlNodePtr second);
524void xmlTextConcat (xmlNodePtr node,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000525 const xmlChar *content,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000526 int len);
527void xmlFreeNodeList (xmlNodePtr cur);
528void xmlFreeNode (xmlNodePtr cur);
Daniel Veillard16253641998-10-28 22:58:05 +0000529
530/*
531 * Namespaces
532 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000533xmlNsPtr xmlSearchNs (xmlDocPtr doc,
534 xmlNodePtr node,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000535 const xmlChar *nameSpace);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000536xmlNsPtr xmlSearchNsByHref (xmlDocPtr doc,
537 xmlNodePtr node,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000538 const xmlChar *href);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000539xmlNsPtr * xmlGetNsList (xmlDocPtr doc,
540 xmlNodePtr node);
541void xmlSetNs (xmlNodePtr node,
542 xmlNsPtr ns);
543xmlNsPtr xmlCopyNamespace (xmlNsPtr cur);
544xmlNsPtr xmlCopyNamespaceList (xmlNsPtr cur);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000545
Daniel Veillard16253641998-10-28 22:58:05 +0000546/*
547 * Changing the content.
548 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000549xmlAttrPtr xmlSetProp (xmlNodePtr node,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000550 const xmlChar *name,
551 const xmlChar *value);
Daniel Veillard6077d031999-10-09 09:11:45 +0000552xmlChar * xmlGetProp (xmlNodePtr node,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000553 const xmlChar *name);
Daniel Veillard32bc74e2000-07-14 14:49:25 +0000554xmlAttrPtr xmlHasProp (xmlNodePtr node,
555 const xmlChar *name);
Daniel Veillard10a2c651999-12-12 13:03:50 +0000556xmlChar * xmlGetNsProp (xmlNodePtr node,
557 const xmlChar *name,
Ramiro Estrugobfce3771999-12-15 04:32:07 +0000558 const xmlChar *nameSpace);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000559xmlNodePtr xmlStringGetNodeList (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000560 const xmlChar *value);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000561xmlNodePtr xmlStringLenGetNodeList (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000562 const xmlChar *value,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000563 int len);
Daniel Veillard6077d031999-10-09 09:11:45 +0000564xmlChar * xmlNodeListGetString (xmlDocPtr doc,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000565 xmlNodePtr list,
566 int inLine);
Daniel Veillardbe803962000-06-28 23:40:59 +0000567xmlChar * xmlNodeListGetRawString (xmlDocPtr doc,
568 xmlNodePtr list,
569 int inLine);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000570void xmlNodeSetContent (xmlNodePtr cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000571 const xmlChar *content);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000572void xmlNodeSetContentLen (xmlNodePtr cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000573 const xmlChar *content,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000574 int len);
575void xmlNodeAddContent (xmlNodePtr cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000576 const xmlChar *content);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000577void xmlNodeAddContentLen (xmlNodePtr cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000578 const xmlChar *content,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000579 int len);
Daniel Veillard6077d031999-10-09 09:11:45 +0000580xmlChar * xmlNodeGetContent (xmlNodePtr cur);
Daniel Veillarda819dac1999-11-24 18:04:22 +0000581xmlChar * xmlNodeGetLang (xmlNodePtr cur);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000582void xmlNodeSetLang (xmlNodePtr cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000583 const xmlChar *lang);
Daniel Veillardcf461992000-03-14 18:30:20 +0000584int xmlNodeGetSpacePreserve (xmlNodePtr cur);
Daniel Veillard10a2c651999-12-12 13:03:50 +0000585xmlChar * xmlNodeGetBase (xmlDocPtr doc,
586 xmlNodePtr cur);
Daniel Veillard16253641998-10-28 22:58:05 +0000587
588/*
Daniel Veillardc08a2c61999-09-08 21:35:25 +0000589 * Removing content.
590 */
Daniel Veillardcf461992000-03-14 18:30:20 +0000591int xmlRemoveProp (xmlAttrPtr attr);
Daniel Veillardc08a2c61999-09-08 21:35:25 +0000592int xmlRemoveNode (xmlNodePtr node); /* TODO */
593
594/*
Daniel Veillard16253641998-10-28 22:58:05 +0000595 * Internal, don't use
596 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000597void xmlBufferWriteCHAR (xmlBufferPtr buf,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000598 const xmlChar *string);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000599void xmlBufferWriteChar (xmlBufferPtr buf,
600 const char *string);
601void xmlBufferWriteQuotedString(xmlBufferPtr buf,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000602 const xmlChar *string);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000603
Daniel Veillard16253641998-10-28 22:58:05 +0000604/*
Daniel Veillardcf461992000-03-14 18:30:20 +0000605 * Namespace handling
606 */
607int xmlReconciliateNs (xmlDocPtr doc,
608 xmlNodePtr tree);
609
610/*
Daniel Veillard16253641998-10-28 22:58:05 +0000611 * Saving
612 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000613void xmlDocDumpMemory (xmlDocPtr cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000614 xmlChar**mem,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000615 int *size);
Daniel Veillardbe803962000-06-28 23:40:59 +0000616int xmlDocDump (FILE *f,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000617 xmlDocPtr cur);
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000618void xmlElemDump (FILE *f,
Daniel Veillard06047432000-04-24 11:33:38 +0000619 xmlDocPtr doc,
620 xmlNodePtr cur);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000621int xmlSaveFile (const char *filename,
622 xmlDocPtr cur);
Daniel Veillard151b1b01998-09-23 00:49:46 +0000623
Daniel Veillardbe803962000-06-28 23:40:59 +0000624/* This one is exported from xmlIO.h
625
626int xmlSaveFileTo (xmlOutputBuffer *buf,
627 xmlDocPtr cur,
628 const char *encoding);
629 */
630
631int xmlSaveFileEnc (const char *filename,
632 xmlDocPtr cur,
633 const char *encoding);
634
Daniel Veillard16253641998-10-28 22:58:05 +0000635/*
636 * Compression
637 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000638int xmlGetDocCompressMode (xmlDocPtr doc);
639void xmlSetDocCompressMode (xmlDocPtr doc,
640 int mode);
641int xmlGetCompressMode (void);
642void xmlSetCompressMode (int mode);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000643
644#ifdef __cplusplus
645}
646#endif
647
648#endif /* __XML_TREE_H__ */
649