blob: 2a14d1d276e3b6dabe665f4ce0afb9f2ce14c354 [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#ifdef __cplusplus
17extern "C" {
18#endif
19
20/*
Daniel Veillardccb09631998-10-27 06:21:04 +000021 * The different element types carried by an XML tree
22 *
23 * NOTE: This is synchronized with DOM Level1 values
24 * See http://www.w3.org/TR/REC-DOM-Level-1/
25 */
26typedef enum {
27 XML_ELEMENT_NODE= 1,
28 XML_ATTRIBUTE_NODE= 2,
29 XML_TEXT_NODE= 3,
30 XML_CDATA_SECTION_NODE= 4,
31 XML_ENTITY_REF_NODE= 5,
32 XML_ENTITY_NODE= 6,
33 XML_PI_NODE= 7,
34 XML_COMMENT_NODE= 8,
35 XML_DOCUMENT_NODE= 9,
36 XML_DOCUMENT_TYPE_NODE= 10,
37 XML_DOCUMENT_FRAG_NODE= 11,
Daniel Veillard7c1206f1999-10-14 09:10:25 +000038 XML_NOTATION_NODE= 12,
Daniel Veillardcf461992000-03-14 18:30:20 +000039 XML_HTML_DOCUMENT_NODE= 13,
40 XML_DTD_NODE= 14,
41 XML_ELEMENT_DECL= 15,
42 XML_ATTRIBUTE_DECL= 16,
Daniel Veillard39c7d712000-09-10 16:14:55 +000043#ifdef LIBXML_SGML_ENABLED
44 XML_ENTITY_DECL= 17,
45 XML_SGML_DOCUMENT_NODE= 18
46#else
Daniel Veillardcf461992000-03-14 18:30:20 +000047 XML_ENTITY_DECL= 17
Daniel Veillard39c7d712000-09-10 16:14:55 +000048#endif
Daniel Veillardccb09631998-10-27 06:21:04 +000049} xmlElementType;
50
51/*
Daniel Veillard0ba4d531998-11-01 19:34:31 +000052 * Size of an internal character representation.
53 *
Daniel Veillardcf461992000-03-14 18:30:20 +000054 * We use 8bit chars internal representation for memory efficiency,
55 * Note that with 8 bits wide xmlChars one can still use UTF-8 to handle
56 * correctly non ISO-Latin input.
Daniel Veillard260a68f1998-08-13 03:39:55 +000057 */
Daniel Veillarddd6b3671999-09-23 22:19:22 +000058
Daniel Veillarddd6b3671999-09-23 22:19:22 +000059typedef unsigned char xmlChar;
Daniel Veillard260a68f1998-08-13 03:39:55 +000060
Daniel Veillarddd6b3671999-09-23 22:19:22 +000061#ifndef WIN32
62#ifndef CHAR
63#define CHAR xmlChar
64#endif
65#endif
66
67#define BAD_CAST (xmlChar *)
Daniel Veillardb96e6431999-08-29 21:02:19 +000068
Daniel Veillard260a68f1998-08-13 03:39:55 +000069/*
70 * a DTD Notation definition
Daniel Veillard260a68f1998-08-13 03:39:55 +000071 */
72
Daniel Veillard71b656e2000-01-05 14:46:17 +000073typedef struct _xmlNotation xmlNotation;
74typedef xmlNotation *xmlNotationPtr;
75struct _xmlNotation {
Daniel Veillarddd6b3671999-09-23 22:19:22 +000076 const xmlChar *name; /* Notation name */
77 const xmlChar *PublicID; /* Public identifier, if any */
78 const xmlChar *SystemID; /* System identifier, if any */
Daniel Veillard71b656e2000-01-05 14:46:17 +000079};
Daniel Veillard1e346af1999-02-22 10:33:01 +000080
Daniel Veillard260a68f1998-08-13 03:39:55 +000081/*
82 * a DTD Attribute definition
Daniel Veillard260a68f1998-08-13 03:39:55 +000083 */
84
Daniel Veillard1e346af1999-02-22 10:33:01 +000085typedef enum {
86 XML_ATTRIBUTE_CDATA = 1,
87 XML_ATTRIBUTE_ID,
88 XML_ATTRIBUTE_IDREF ,
89 XML_ATTRIBUTE_IDREFS,
90 XML_ATTRIBUTE_ENTITY,
91 XML_ATTRIBUTE_ENTITIES,
92 XML_ATTRIBUTE_NMTOKEN,
93 XML_ATTRIBUTE_NMTOKENS,
94 XML_ATTRIBUTE_ENUMERATION,
95 XML_ATTRIBUTE_NOTATION
96} xmlAttributeType;
Daniel Veillard39a1f9a1999-01-17 19:11:59 +000097
Daniel Veillard1e346af1999-02-22 10:33:01 +000098typedef enum {
99 XML_ATTRIBUTE_NONE = 1,
100 XML_ATTRIBUTE_REQUIRED,
101 XML_ATTRIBUTE_IMPLIED,
102 XML_ATTRIBUTE_FIXED
103} xmlAttributeDefault;
104
Daniel Veillard71b656e2000-01-05 14:46:17 +0000105typedef struct _xmlEnumeration xmlEnumeration;
Daniel Veillard1e346af1999-02-22 10:33:01 +0000106typedef xmlEnumeration *xmlEnumerationPtr;
Daniel Veillard71b656e2000-01-05 14:46:17 +0000107struct _xmlEnumeration {
108 struct _xmlEnumeration *next; /* next one */
109 const xmlChar *name; /* Enumeration name */
110};
Daniel Veillard1e346af1999-02-22 10:33:01 +0000111
Daniel Veillard71b656e2000-01-05 14:46:17 +0000112typedef struct _xmlAttribute xmlAttribute;
113typedef xmlAttribute *xmlAttributePtr;
114struct _xmlAttribute {
Daniel Veillardcf461992000-03-14 18:30:20 +0000115#ifndef XML_WITHOUT_CORBA
116 void *_private; /* for Corba, must be first ! */
117#endif
118 xmlElementType type; /* XML_ATTRIBUTE_DECL, must be second ! */
119 const xmlChar *name; /* Attribute name */
120 struct _xmlNode *children; /* NULL */
121 struct _xmlNode *last; /* NULL */
122 struct _xmlDtd *parent; /* -> DTD */
123 struct _xmlNode *next; /* next sibling link */
124 struct _xmlNode *prev; /* previous sibling link */
125 struct _xmlDoc *doc; /* the containing document */
126
127 struct _xmlAttribute *nexth; /* next in hash table */
128 xmlAttributeType atype; /* The attribute type */
129 xmlAttributeDefault def; /* the default */
130 const xmlChar *defaultValue; /* or the default value */
131 xmlEnumerationPtr tree; /* or the enumeration tree if any */
132 const xmlChar *prefix; /* the namespace prefix if any */
133 const xmlChar *elem; /* Element holding the attribute */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000134};
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000135
Daniel Veillard260a68f1998-08-13 03:39:55 +0000136/*
137 * a DTD Element definition.
138 */
Daniel Veillard1899e851999-02-01 12:18:54 +0000139typedef enum {
Daniel Veillard1e346af1999-02-22 10:33:01 +0000140 XML_ELEMENT_CONTENT_PCDATA = 1,
Daniel Veillard1899e851999-02-01 12:18:54 +0000141 XML_ELEMENT_CONTENT_ELEMENT,
142 XML_ELEMENT_CONTENT_SEQ,
143 XML_ELEMENT_CONTENT_OR
144} xmlElementContentType;
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000145
Daniel Veillard1899e851999-02-01 12:18:54 +0000146typedef enum {
Daniel Veillard1e346af1999-02-22 10:33:01 +0000147 XML_ELEMENT_CONTENT_ONCE = 1,
Daniel Veillard1899e851999-02-01 12:18:54 +0000148 XML_ELEMENT_CONTENT_OPT,
149 XML_ELEMENT_CONTENT_MULT,
150 XML_ELEMENT_CONTENT_PLUS
151} xmlElementContentOccur;
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000152
Daniel Veillard71b656e2000-01-05 14:46:17 +0000153typedef struct _xmlElementContent xmlElementContent;
154typedef xmlElementContent *xmlElementContentPtr;
155struct _xmlElementContent {
Daniel Veillard1899e851999-02-01 12:18:54 +0000156 xmlElementContentType type; /* PCDATA, ELEMENT, SEQ or OR */
157 xmlElementContentOccur ocur; /* ONCE, OPT, MULT or PLUS */
Daniel Veillard6077d031999-10-09 09:11:45 +0000158 const xmlChar *name; /* Element name */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000159 struct _xmlElementContent *c1; /* first child */
160 struct _xmlElementContent *c2; /* second child */
161};
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000162
Daniel Veillard1899e851999-02-01 12:18:54 +0000163typedef enum {
Daniel Veillard1e346af1999-02-22 10:33:01 +0000164 XML_ELEMENT_TYPE_EMPTY = 1,
Daniel Veillard1899e851999-02-01 12:18:54 +0000165 XML_ELEMENT_TYPE_ANY,
166 XML_ELEMENT_TYPE_MIXED,
167 XML_ELEMENT_TYPE_ELEMENT
168} xmlElementTypeVal;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000169
Daniel Veillard71b656e2000-01-05 14:46:17 +0000170typedef struct _xmlElement xmlElement;
171typedef xmlElement *xmlElementPtr;
172struct _xmlElement {
Daniel Veillardcf461992000-03-14 18:30:20 +0000173#ifndef XML_WITHOUT_CORBA
174 void *_private; /* for Corba, must be first ! */
175#endif
176 xmlElementType type; /* XML_ELEMENT_DECL, must be second ! */
Daniel Veillard6077d031999-10-09 09:11:45 +0000177 const xmlChar *name; /* Element name */
Daniel Veillardcf461992000-03-14 18:30:20 +0000178 struct _xmlNode *children; /* NULL */
179 struct _xmlNode *last; /* NULL */
180 struct _xmlDtd *parent; /* -> DTD */
181 struct _xmlNode *next; /* next sibling link */
182 struct _xmlNode *prev; /* previous sibling link */
183 struct _xmlDoc *doc; /* the containing document */
184
185 xmlElementTypeVal etype; /* The type */
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000186 xmlElementContentPtr content; /* the allowed element content */
Daniel Veillardb05deb71999-08-10 19:04:08 +0000187 xmlAttributePtr attributes; /* List of the declared attributes */
Daniel Veillardbe803962000-06-28 23:40:59 +0000188 const xmlChar *prefix; /* the namespace prefix if any */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000189};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000190
191/*
192 * An XML namespace.
193 * Note that prefix == NULL is valid, it defines the default namespace
194 * within the subtree (until overriden).
195 */
196
Daniel Veillard1899e851999-02-01 12:18:54 +0000197typedef enum {
Daniel Veillard1e346af1999-02-22 10:33:01 +0000198 XML_GLOBAL_NAMESPACE = 1, /* old style global namespace */
Daniel Veillard1899e851999-02-01 12:18:54 +0000199 XML_LOCAL_NAMESPACE /* new style local scoping */
200} xmlNsType;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000201
Daniel Veillard71b656e2000-01-05 14:46:17 +0000202typedef struct _xmlNs xmlNs;
203typedef xmlNs *xmlNsPtr;
204struct _xmlNs {
205 struct _xmlNs *next; /* next Ns link for this node */
Daniel Veillard1899e851999-02-01 12:18:54 +0000206 xmlNsType type; /* global or local */
Daniel Veillard6077d031999-10-09 09:11:45 +0000207 const xmlChar *href; /* URL for the namespace */
208 const xmlChar *prefix; /* prefix for the namespace */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000209};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000210
211/*
212 * An XML DtD, as defined by <!DOCTYPE.
213 */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000214typedef struct _xmlDtd xmlDtd;
215typedef xmlDtd *xmlDtdPtr;
216struct _xmlDtd {
Daniel Veillardcf461992000-03-14 18:30:20 +0000217#ifndef XML_WITHOUT_CORBA
218 void *_private; /* for Corba, must be first ! */
219#endif
220 xmlElementType type; /* XML_DTD_NODE, must be second ! */
Daniel Veillard6077d031999-10-09 09:11:45 +0000221 const xmlChar *name; /* Name of the DTD */
Daniel Veillardcf461992000-03-14 18:30:20 +0000222 struct _xmlNode *children; /* the value of the property link */
223 struct _xmlNode *last; /* last child link */
224 struct _xmlDoc *parent; /* child->parent link */
225 struct _xmlNode *next; /* next sibling link */
226 struct _xmlNode *prev; /* previous sibling link */
227 struct _xmlDoc *doc; /* the containing document */
228
229 /* End of common part */
Daniel Veillard1e346af1999-02-22 10:33:01 +0000230 void *notations; /* Hash table for notations if any */
Daniel Veillard260a68f1998-08-13 03:39:55 +0000231 void *elements; /* Hash table for elements if any */
Daniel Veillard1e346af1999-02-22 10:33:01 +0000232 void *attributes; /* Hash table for attributes if any */
Daniel Veillard260a68f1998-08-13 03:39:55 +0000233 void *entities; /* Hash table for entities if any */
Daniel Veillardcf461992000-03-14 18:30:20 +0000234 const xmlChar *ExternalID; /* External identifier for PUBLIC DTD */
235 const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC DTD */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000236};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000237
238/*
239 * A attribute of an XML node.
240 */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000241typedef struct _xmlAttr xmlAttr;
242typedef xmlAttr *xmlAttrPtr;
243struct _xmlAttr {
Daniel Veillard27fb0751998-10-17 06:47:46 +0000244#ifndef XML_WITHOUT_CORBA
245 void *_private; /* for Corba, must be first ! */
Daniel Veillard27fb0751998-10-17 06:47:46 +0000246#endif
Daniel Veillardcf461992000-03-14 18:30:20 +0000247 xmlElementType type; /* XML_ATTRIBUTE_NODE, must be second ! */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000248 const xmlChar *name; /* the name of the property */
Daniel Veillardcf461992000-03-14 18:30:20 +0000249 struct _xmlNode *children; /* the value of the property */
250 struct _xmlNode *last; /* NULL */
251 struct _xmlNode *parent; /* child->parent link */
252 struct _xmlAttr *next; /* next sibling link */
253 struct _xmlAttr *prev; /* previous sibling link */
254 struct _xmlDoc *doc; /* the containing document */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000255 xmlNs *ns; /* pointer to the associated namespace */
Daniel Veillardcf461992000-03-14 18:30:20 +0000256 xmlAttributeType atype; /* the attribute type if validating */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000257};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000258
259/*
Daniel Veillard991e63d1999-08-15 23:32:28 +0000260 * An XML ID instance.
261 */
262
Daniel Veillard71b656e2000-01-05 14:46:17 +0000263typedef struct _xmlID xmlID;
264typedef xmlID *xmlIDPtr;
265struct _xmlID {
266 struct _xmlID *next; /* next ID */
Daniel Veillard6077d031999-10-09 09:11:45 +0000267 const xmlChar *value; /* The ID name */
Daniel Veillard991e63d1999-08-15 23:32:28 +0000268 xmlAttrPtr attr; /* The attribut holding it */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000269};
Daniel Veillard991e63d1999-08-15 23:32:28 +0000270
271/*
Daniel Veillardc08a2c61999-09-08 21:35:25 +0000272 * An XML IDREF instance.
273 */
274
Daniel Veillard71b656e2000-01-05 14:46:17 +0000275typedef struct _xmlRef xmlRef;
276typedef xmlRef *xmlRefPtr;
277struct _xmlRef {
278 struct _xmlRef *next; /* next Ref */
Daniel Veillard6077d031999-10-09 09:11:45 +0000279 const xmlChar *value; /* The Ref name */
Daniel Veillardc08a2c61999-09-08 21:35:25 +0000280 xmlAttrPtr attr; /* The attribut holding it */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000281};
Daniel Veillardc08a2c61999-09-08 21:35:25 +0000282
283/*
Daniel Veillardf5c2c871999-12-01 09:51:45 +0000284 * A buffer structure
285 */
286
287typedef enum {
288 XML_BUFFER_ALLOC_DOUBLEIT,
289 XML_BUFFER_ALLOC_EXACT
290} xmlBufferAllocationScheme;
291
Daniel Veillard71b656e2000-01-05 14:46:17 +0000292typedef struct _xmlBuffer xmlBuffer;
293typedef xmlBuffer *xmlBufferPtr;
294struct _xmlBuffer {
Daniel Veillardf5c2c871999-12-01 09:51:45 +0000295 xmlChar *content; /* The buffer content UTF8 */
296 unsigned int use; /* The buffer size used */
297 unsigned int size; /* The buffer size */
298 xmlBufferAllocationScheme alloc; /* The realloc method */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000299};
Daniel Veillardf5c2c871999-12-01 09:51:45 +0000300
301/*
Daniel Veillard260a68f1998-08-13 03:39:55 +0000302 * A node in an XML tree.
303 */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000304typedef struct _xmlNode xmlNode;
305typedef xmlNode *xmlNodePtr;
306struct _xmlNode {
Daniel Veillard27fb0751998-10-17 06:47:46 +0000307#ifndef XML_WITHOUT_CORBA
308 void *_private; /* for Corba, must be first ! */
Daniel Veillard27fb0751998-10-17 06:47:46 +0000309#endif
Daniel Veillardcf461992000-03-14 18:30:20 +0000310 xmlElementType type; /* type number, must be second ! */
311 const xmlChar *name; /* the name of the node, or the entity */
312 struct _xmlNode *children; /* parent->childs link */
313 struct _xmlNode *last; /* last child link */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000314 struct _xmlNode *parent; /* child->parent link */
315 struct _xmlNode *next; /* next sibling link */
316 struct _xmlNode *prev; /* previous sibling link */
Daniel Veillardcf461992000-03-14 18:30:20 +0000317 struct _xmlDoc *doc; /* the containing document */
318 xmlNs *ns; /* pointer to the associated namespace */
Daniel Veillardf5c2c871999-12-01 09:51:45 +0000319#ifndef XML_USE_BUFFER_CONTENT
Daniel Veillardcf461992000-03-14 18:30:20 +0000320 xmlChar *content; /* the content */
Daniel Veillardf5c2c871999-12-01 09:51:45 +0000321#else
Daniel Veillardcf461992000-03-14 18:30:20 +0000322 xmlBufferPtr content; /* the content in a buffer */
Daniel Veillardf5c2c871999-12-01 09:51:45 +0000323#endif
Daniel Veillardcf461992000-03-14 18:30:20 +0000324
325 /* End of common part */
326 struct _xmlAttr *properties;/* properties list */
327 xmlNs *nsDef; /* namespace definitions on this node */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000328};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000329
330/*
331 * An XML document.
332 */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000333typedef struct _xmlDoc xmlDoc;
334typedef xmlDoc *xmlDocPtr;
335struct _xmlDoc {
Daniel Veillard27fb0751998-10-17 06:47:46 +0000336#ifndef XML_WITHOUT_CORBA
337 void *_private; /* for Corba, must be first ! */
Daniel Veillard27fb0751998-10-17 06:47:46 +0000338#endif
Daniel Veillardccb09631998-10-27 06:21:04 +0000339 xmlElementType type; /* XML_DOCUMENT_NODE, must be second ! */
Daniel Veillard260a68f1998-08-13 03:39:55 +0000340 char *name; /* name/filename/URI of the document */
Daniel Veillardcf461992000-03-14 18:30:20 +0000341 struct _xmlNode *children; /* the document tree */
342 struct _xmlNode *last; /* last child link */
343 struct _xmlNode *parent; /* child->parent link */
344 struct _xmlNode *next; /* next sibling link */
345 struct _xmlNode *prev; /* previous sibling link */
346 struct _xmlDoc *doc; /* autoreference to itself */
347
348 /* End of common part */
Daniel Veillard15a8df41998-09-24 19:15:06 +0000349 int compression;/* level of zlib compression */
Daniel Veillard260a68f1998-08-13 03:39:55 +0000350 int standalone; /* standalone document (no external refs) */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000351 struct _xmlDtd *intSubset; /* the document internal subset */
352 struct _xmlDtd *extSubset; /* the document external subset */
353 struct _xmlNs *oldNs; /* Global namespace, the old way */
Daniel Veillardcf461992000-03-14 18:30:20 +0000354 const xmlChar *version; /* the XML version string */
Daniel Veillardbe803962000-06-28 23:40:59 +0000355 const xmlChar *encoding; /* external initial encoding, if any */
Daniel Veillard991e63d1999-08-15 23:32:28 +0000356 void *ids; /* Hash table for ID attributes if any */
Daniel Veillardc08a2c61999-09-08 21:35:25 +0000357 void *refs; /* Hash table for IDREFs attributes if any */
Daniel Veillardcf461992000-03-14 18:30:20 +0000358 const xmlChar *URL; /* The URI for that document */
Daniel Veillardbe803962000-06-28 23:40:59 +0000359 int charset; /* encoding of the in-memory content
360 actually an xmlCharEncoding */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000361};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000362
363/*
Daniel Veillardbe803962000-06-28 23:40:59 +0000364 * Compatibility naming layer with libxml1
365 */
366#ifndef xmlChildrenNode
367#define xmlChildrenNode children
368#define xmlRootNode children
369#endif
370
371/*
Daniel Veillard260a68f1998-08-13 03:39:55 +0000372 * Variables.
373 */
374extern xmlNsPtr baseDTD;
375extern int oldXMLWDcompatibility;/* maintain compatibility with old WD */
376extern int xmlIndentTreeOutput; /* try to indent the tree dumps */
Daniel Veillardf5c2c871999-12-01 09:51:45 +0000377extern xmlBufferAllocationScheme xmlBufferAllocScheme; /* alloc scheme to use */
Daniel Veillarde41f2b72000-01-30 20:00:07 +0000378extern int xmlSaveNoEmptyTags; /* save empty tags as <empty></empty> */
Daniel Veillard260a68f1998-08-13 03:39:55 +0000379
380/*
Daniel Veillard5099ae81999-04-21 20:12:07 +0000381 * Handling Buffers.
382 */
383
Daniel Veillardb96e6431999-08-29 21:02:19 +0000384xmlBufferPtr xmlBufferCreate (void);
Daniel Veillardf5c2c871999-12-01 09:51:45 +0000385xmlBufferPtr xmlBufferCreateSize (size_t size);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000386void xmlBufferFree (xmlBufferPtr buf);
387int xmlBufferDump (FILE *file,
388 xmlBufferPtr buf);
389void xmlBufferAdd (xmlBufferPtr buf,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000390 const xmlChar *str,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000391 int len);
Daniel Veillardbe803962000-06-28 23:40:59 +0000392void xmlBufferAddHead (xmlBufferPtr buf,
393 const xmlChar *str,
394 int len);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000395void xmlBufferCat (xmlBufferPtr buf,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000396 const xmlChar *str);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000397void xmlBufferCCat (xmlBufferPtr buf,
398 const char *str);
399int xmlBufferShrink (xmlBufferPtr buf,
Daniel Veillard4b0755c2000-09-25 14:26:28 +0000400 unsigned int len);
Daniel Veillard496a1cf2000-05-03 14:20:55 +0000401int xmlBufferGrow (xmlBufferPtr buf,
Daniel Veillard4b0755c2000-09-25 14:26:28 +0000402 unsigned int len);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000403void xmlBufferEmpty (xmlBufferPtr buf);
Daniel Veillardf5c2c871999-12-01 09:51:45 +0000404const xmlChar* xmlBufferContent (const xmlBufferPtr buf);
405int xmlBufferUse (const xmlBufferPtr buf);
406void xmlBufferSetAllocationScheme(xmlBufferPtr buf,
407 xmlBufferAllocationScheme scheme);
408int xmlBufferLength (const xmlBufferPtr buf);
Daniel Veillard5099ae81999-04-21 20:12:07 +0000409
410/*
Daniel Veillard16253641998-10-28 22:58:05 +0000411 * Creating/freeing new structures
Daniel Veillard260a68f1998-08-13 03:39:55 +0000412 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000413xmlDtdPtr xmlCreateIntSubset (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000414 const xmlChar *name,
415 const xmlChar *ExternalID,
416 const xmlChar *SystemID);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000417xmlDtdPtr xmlNewDtd (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000418 const xmlChar *name,
419 const xmlChar *ExternalID,
420 const xmlChar *SystemID);
Daniel Veillardd83eb822000-06-30 18:39:56 +0000421xmlDtdPtr xmlGetIntSubset (xmlDocPtr doc);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000422void xmlFreeDtd (xmlDtdPtr cur);
423xmlNsPtr xmlNewGlobalNs (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000424 const xmlChar *href,
425 const xmlChar *prefix);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000426xmlNsPtr xmlNewNs (xmlNodePtr node,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000427 const xmlChar *href,
428 const xmlChar *prefix);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000429void xmlFreeNs (xmlNsPtr cur);
Daniel Veillard6077d031999-10-09 09:11:45 +0000430xmlDocPtr xmlNewDoc (const xmlChar *version);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000431void xmlFreeDoc (xmlDocPtr cur);
432xmlAttrPtr xmlNewDocProp (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000433 const xmlChar *name,
434 const xmlChar *value);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000435xmlAttrPtr xmlNewProp (xmlNodePtr node,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000436 const xmlChar *name,
437 const xmlChar *value);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000438xmlAttrPtr xmlNewNsProp (xmlNodePtr node,
439 xmlNsPtr ns,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000440 const xmlChar *name,
441 const xmlChar *value);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000442void xmlFreePropList (xmlAttrPtr cur);
443void xmlFreeProp (xmlAttrPtr cur);
444xmlAttrPtr xmlCopyProp (xmlNodePtr target,
445 xmlAttrPtr cur);
446xmlAttrPtr xmlCopyPropList (xmlNodePtr target,
447 xmlAttrPtr cur);
448xmlDtdPtr xmlCopyDtd (xmlDtdPtr dtd);
449xmlDocPtr xmlCopyDoc (xmlDocPtr doc,
450 int recursive);
Daniel Veillard16253641998-10-28 22:58:05 +0000451
452/*
453 * Creating new nodes
454 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000455xmlNodePtr xmlNewDocNode (xmlDocPtr doc,
456 xmlNsPtr ns,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000457 const xmlChar *name,
458 const xmlChar *content);
Daniel Veillard11a48ec1999-11-23 10:40:46 +0000459xmlNodePtr xmlNewDocRawNode (xmlDocPtr doc,
460 xmlNsPtr ns,
461 const xmlChar *name,
462 const xmlChar *content);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000463xmlNodePtr xmlNewNode (xmlNsPtr ns,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000464 const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000465xmlNodePtr xmlNewChild (xmlNodePtr parent,
466 xmlNsPtr ns,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000467 const xmlChar *name,
468 const xmlChar *content);
Daniel Veillard11a48ec1999-11-23 10:40:46 +0000469xmlNodePtr xmlNewTextChild (xmlNodePtr parent,
470 xmlNsPtr ns,
471 const xmlChar *name,
472 const xmlChar *content);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000473xmlNodePtr xmlNewDocText (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000474 const xmlChar *content);
475xmlNodePtr xmlNewText (const xmlChar *content);
476xmlNodePtr xmlNewPI (const xmlChar *name,
477 const xmlChar *content);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000478xmlNodePtr xmlNewDocTextLen (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000479 const xmlChar *content,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000480 int len);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000481xmlNodePtr xmlNewTextLen (const xmlChar *content,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000482 int len);
483xmlNodePtr xmlNewDocComment (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000484 const xmlChar *content);
485xmlNodePtr xmlNewComment (const xmlChar *content);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000486xmlNodePtr xmlNewCDataBlock (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000487 const xmlChar *content,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000488 int len);
Daniel Veillardcf461992000-03-14 18:30:20 +0000489xmlNodePtr xmlNewCharRef (xmlDocPtr doc,
490 const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000491xmlNodePtr xmlNewReference (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000492 const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000493xmlNodePtr xmlCopyNode (xmlNodePtr node,
494 int recursive);
495xmlNodePtr xmlCopyNodeList (xmlNodePtr node);
Daniel Veillard2eac5032000-01-09 21:08:56 +0000496xmlNodePtr xmlNewDocFragment (xmlDocPtr doc);
Daniel Veillard16253641998-10-28 22:58:05 +0000497
498/*
499 * Navigating
500 */
Daniel Veillard3dbfdca1999-12-15 19:08:23 +0000501xmlNodePtr xmlDocGetRootElement (xmlDocPtr doc);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000502xmlNodePtr xmlGetLastChild (xmlNodePtr parent);
503int xmlNodeIsText (xmlNodePtr node);
Daniel Veillard3e6d2372000-03-04 11:39:43 +0000504int xmlIsBlankNode (xmlNodePtr node);
Daniel Veillard16253641998-10-28 22:58:05 +0000505
506/*
507 * Changing the structure
508 */
Daniel Veillard5cb5ab81999-12-21 15:35:29 +0000509xmlNodePtr xmlDocSetRootElement (xmlDocPtr doc,
510 xmlNodePtr root);
511void xmlNodeSetName (xmlNodePtr cur,
512 const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000513xmlNodePtr xmlAddChild (xmlNodePtr parent,
514 xmlNodePtr cur);
Daniel Veillard87b95392000-08-12 21:12:04 +0000515xmlNodePtr xmlAddChildList (xmlNodePtr parent,
516 xmlNodePtr cur);
Daniel Veillard5cb5ab81999-12-21 15:35:29 +0000517xmlNodePtr xmlReplaceNode (xmlNodePtr old,
518 xmlNodePtr cur);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000519xmlNodePtr xmlAddSibling (xmlNodePtr cur,
520 xmlNodePtr elem);
Daniel Veillard5cb5ab81999-12-21 15:35:29 +0000521xmlNodePtr xmlAddPrevSibling (xmlNodePtr cur,
522 xmlNodePtr elem);
523xmlNodePtr xmlAddNextSibling (xmlNodePtr cur,
524 xmlNodePtr elem);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000525void xmlUnlinkNode (xmlNodePtr cur);
526xmlNodePtr xmlTextMerge (xmlNodePtr first,
527 xmlNodePtr second);
528void xmlTextConcat (xmlNodePtr node,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000529 const xmlChar *content,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000530 int len);
531void xmlFreeNodeList (xmlNodePtr cur);
532void xmlFreeNode (xmlNodePtr cur);
Daniel Veillard16253641998-10-28 22:58:05 +0000533
534/*
535 * Namespaces
536 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000537xmlNsPtr xmlSearchNs (xmlDocPtr doc,
538 xmlNodePtr node,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000539 const xmlChar *nameSpace);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000540xmlNsPtr xmlSearchNsByHref (xmlDocPtr doc,
541 xmlNodePtr node,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000542 const xmlChar *href);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000543xmlNsPtr * xmlGetNsList (xmlDocPtr doc,
544 xmlNodePtr node);
545void xmlSetNs (xmlNodePtr node,
546 xmlNsPtr ns);
547xmlNsPtr xmlCopyNamespace (xmlNsPtr cur);
548xmlNsPtr xmlCopyNamespaceList (xmlNsPtr cur);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000549
Daniel Veillard16253641998-10-28 22:58:05 +0000550/*
551 * Changing the content.
552 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000553xmlAttrPtr xmlSetProp (xmlNodePtr node,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000554 const xmlChar *name,
555 const xmlChar *value);
Daniel Veillard6077d031999-10-09 09:11:45 +0000556xmlChar * xmlGetProp (xmlNodePtr node,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000557 const xmlChar *name);
Daniel Veillard32bc74e2000-07-14 14:49:25 +0000558xmlAttrPtr xmlHasProp (xmlNodePtr node,
559 const xmlChar *name);
Daniel Veillard10a2c651999-12-12 13:03:50 +0000560xmlChar * xmlGetNsProp (xmlNodePtr node,
561 const xmlChar *name,
Ramiro Estrugobfce3771999-12-15 04:32:07 +0000562 const xmlChar *nameSpace);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000563xmlNodePtr xmlStringGetNodeList (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000564 const xmlChar *value);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000565xmlNodePtr xmlStringLenGetNodeList (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000566 const xmlChar *value,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000567 int len);
Daniel Veillard6077d031999-10-09 09:11:45 +0000568xmlChar * xmlNodeListGetString (xmlDocPtr doc,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000569 xmlNodePtr list,
570 int inLine);
Daniel Veillardbe803962000-06-28 23:40:59 +0000571xmlChar * xmlNodeListGetRawString (xmlDocPtr doc,
572 xmlNodePtr list,
573 int inLine);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000574void xmlNodeSetContent (xmlNodePtr cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000575 const xmlChar *content);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000576void xmlNodeSetContentLen (xmlNodePtr cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000577 const xmlChar *content,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000578 int len);
579void xmlNodeAddContent (xmlNodePtr cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000580 const xmlChar *content);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000581void xmlNodeAddContentLen (xmlNodePtr cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000582 const xmlChar *content,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000583 int len);
Daniel Veillard6077d031999-10-09 09:11:45 +0000584xmlChar * xmlNodeGetContent (xmlNodePtr cur);
Daniel Veillarda819dac1999-11-24 18:04:22 +0000585xmlChar * xmlNodeGetLang (xmlNodePtr cur);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000586void xmlNodeSetLang (xmlNodePtr cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000587 const xmlChar *lang);
Daniel Veillardcf461992000-03-14 18:30:20 +0000588int xmlNodeGetSpacePreserve (xmlNodePtr cur);
Daniel Veillard10a2c651999-12-12 13:03:50 +0000589xmlChar * xmlNodeGetBase (xmlDocPtr doc,
590 xmlNodePtr cur);
Daniel Veillard16253641998-10-28 22:58:05 +0000591
592/*
Daniel Veillardc08a2c61999-09-08 21:35:25 +0000593 * Removing content.
594 */
Daniel Veillardcf461992000-03-14 18:30:20 +0000595int xmlRemoveProp (xmlAttrPtr attr);
Daniel Veillardc08a2c61999-09-08 21:35:25 +0000596int xmlRemoveNode (xmlNodePtr node); /* TODO */
597
598/*
Daniel Veillard16253641998-10-28 22:58:05 +0000599 * Internal, don't use
600 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000601void xmlBufferWriteCHAR (xmlBufferPtr buf,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000602 const xmlChar *string);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000603void xmlBufferWriteChar (xmlBufferPtr buf,
604 const char *string);
605void xmlBufferWriteQuotedString(xmlBufferPtr buf,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000606 const xmlChar *string);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000607
Daniel Veillard16253641998-10-28 22:58:05 +0000608/*
Daniel Veillardcf461992000-03-14 18:30:20 +0000609 * Namespace handling
610 */
611int xmlReconciliateNs (xmlDocPtr doc,
612 xmlNodePtr tree);
613
614/*
Daniel Veillard16253641998-10-28 22:58:05 +0000615 * Saving
616 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000617void xmlDocDumpMemory (xmlDocPtr cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000618 xmlChar**mem,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000619 int *size);
Daniel Veillardbe803962000-06-28 23:40:59 +0000620int xmlDocDump (FILE *f,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000621 xmlDocPtr cur);
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000622void xmlElemDump (FILE *f,
Daniel Veillard06047432000-04-24 11:33:38 +0000623 xmlDocPtr doc,
624 xmlNodePtr cur);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000625int xmlSaveFile (const char *filename,
626 xmlDocPtr cur);
Daniel Veillardb656ebe2000-09-22 13:51:48 +0000627void xmlNodeDump (xmlBufferPtr buf,
628 xmlDocPtr doc,
629 xmlNodePtr cur,
630 int level,
631 int format);
Daniel Veillard151b1b01998-09-23 00:49:46 +0000632
Daniel Veillardbe803962000-06-28 23:40:59 +0000633/* This one is exported from xmlIO.h
634
635int xmlSaveFileTo (xmlOutputBuffer *buf,
636 xmlDocPtr cur,
637 const char *encoding);
638 */
639
640int xmlSaveFileEnc (const char *filename,
641 xmlDocPtr cur,
642 const char *encoding);
643
Daniel Veillard16253641998-10-28 22:58:05 +0000644/*
645 * Compression
646 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000647int xmlGetDocCompressMode (xmlDocPtr doc);
648void xmlSetDocCompressMode (xmlDocPtr doc,
649 int mode);
650int xmlGetCompressMode (void);
651void xmlSetCompressMode (int mode);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000652
653#ifdef __cplusplus
654}
655#endif
656
657#endif /* __XML_TREE_H__ */
658