blob: e19408687ad6562dc55826fca315fcc46c20d621 [file] [log] [blame]
Owen Taylor3473f882001-02-23 17:55:21 +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 Veillardc5d64342001-06-24 12:13:24 +00007 * daniel@veillard.com
Owen Taylor3473f882001-02-23 17:55:21 +00008 *
9 * 14 Nov 2000 ht - added redefinition of xmlBufferWriteChar for VMS
10 *
11 */
12
13#ifndef __XML_TREE_H__
14#define __XML_TREE_H__
15
16#include <stdio.h>
Daniel Veillardc5d64342001-06-24 12:13:24 +000017#if defined(WIN32) && defined(_MSC_VER)
18#include <libxml/xmlwin32version.h>
19#else
Owen Taylor3473f882001-02-23 17:55:21 +000020#include <libxml/xmlversion.h>
Daniel Veillardc5d64342001-06-24 12:13:24 +000021#endif
Daniel Veillard67a21302001-04-11 14:39:16 +000022#include <libxml/xmlmemory.h>
Owen Taylor3473f882001-02-23 17:55:21 +000023
24#ifdef __cplusplus
25extern "C" {
26#endif
27
Daniel Veillard8bdb91d2001-10-31 17:52:43 +000028/*
29 * Some of the basic types pointer to structures:
30 */
31/* xmlIO.h */
32typedef struct _xmlParserInputBuffer xmlParserInputBuffer;
33typedef xmlParserInputBuffer *xmlParserInputBufferPtr;
34
CET 2001 Daniel Veillard5a37bde2001-11-01 14:31:22 +000035typedef struct _xmlOutputBuffer xmlOutputBuffer;
36typedef xmlOutputBuffer *xmlOutputBufferPtr;
37
Daniel Veillard8bdb91d2001-10-31 17:52:43 +000038/* parser.h */
39typedef struct _xmlParserInput xmlParserInput;
40typedef xmlParserInput *xmlParserInputPtr;
41
42typedef struct _xmlParserCtxt xmlParserCtxt;
43typedef xmlParserCtxt *xmlParserCtxtPtr;
44
Daniel Veillardd0463562001-10-13 09:15:48 +000045#define BASE_BUFFER_SIZE 4000
46
Daniel Veillard5e2dace2001-07-18 19:30:27 +000047/**
48 * XML_XML_NAMESPACE:
49 *
50 * This is the namespace for the special xml: prefix predefined in the
51 * XML Namespace specification
52 */
Owen Taylor3473f882001-02-23 17:55:21 +000053#define XML_XML_NAMESPACE \
54 (const xmlChar *) "http://www.w3.org/XML/1998/namespace"
55
56/*
57 * The different element types carried by an XML tree
58 *
59 * NOTE: This is synchronized with DOM Level1 values
60 * See http://www.w3.org/TR/REC-DOM-Level-1/
61 *
62 * Actually this had diverged a bit, and now XML_DOCUMENT_TYPE_NODE should
63 * be deprecated to use an XML_DTD_NODE.
64 */
65typedef enum {
66 XML_ELEMENT_NODE= 1,
67 XML_ATTRIBUTE_NODE= 2,
68 XML_TEXT_NODE= 3,
69 XML_CDATA_SECTION_NODE= 4,
70 XML_ENTITY_REF_NODE= 5,
71 XML_ENTITY_NODE= 6,
72 XML_PI_NODE= 7,
73 XML_COMMENT_NODE= 8,
74 XML_DOCUMENT_NODE= 9,
75 XML_DOCUMENT_TYPE_NODE= 10,
76 XML_DOCUMENT_FRAG_NODE= 11,
77 XML_NOTATION_NODE= 12,
78 XML_HTML_DOCUMENT_NODE= 13,
79 XML_DTD_NODE= 14,
80 XML_ELEMENT_DECL= 15,
81 XML_ATTRIBUTE_DECL= 16,
82 XML_ENTITY_DECL= 17,
83 XML_NAMESPACE_DECL= 18,
84 XML_XINCLUDE_START= 19,
85 XML_XINCLUDE_END= 20
Daniel Veillardeae522a2001-04-23 13:41:34 +000086#ifdef LIBXML_DOCB_ENABLED
87 ,XML_DOCB_DOCUMENT_NODE= 21
Owen Taylor3473f882001-02-23 17:55:21 +000088#endif
89} xmlElementType;
90
Daniel Veillardbed7b052001-05-19 14:59:49 +000091/**
92 * xmlChar:
Owen Taylor3473f882001-02-23 17:55:21 +000093 *
Daniel Veillardbed7b052001-05-19 14:59:49 +000094 * This is a basic byte in an UTF-8 encoded string.
95 * It's unsigned allowing to pinpoint case where char * are assigned
96 * to xmlChar * (possibly making serialization back impossible).
Owen Taylor3473f882001-02-23 17:55:21 +000097 */
98
99typedef unsigned char xmlChar;
100
Daniel Veillardbed7b052001-05-19 14:59:49 +0000101/**
102 * BAD_CAST:
103 *
104 * Macro to cast a string to an xmlChar * when one know its safe.
105 */
Owen Taylor3473f882001-02-23 17:55:21 +0000106#define BAD_CAST (xmlChar *)
107
Daniel Veillardbed7b052001-05-19 14:59:49 +0000108/**
109 * xmlNotation:
110 *
Owen Taylor3473f882001-02-23 17:55:21 +0000111 * a DTD Notation definition
112 */
113
114typedef struct _xmlNotation xmlNotation;
115typedef xmlNotation *xmlNotationPtr;
116struct _xmlNotation {
Daniel Veillard9e7160d2001-03-18 23:17:47 +0000117 const xmlChar *name; /* Notation name */
Owen Taylor3473f882001-02-23 17:55:21 +0000118 const xmlChar *PublicID; /* Public identifier, if any */
119 const xmlChar *SystemID; /* System identifier, if any */
120};
121
Daniel Veillardbed7b052001-05-19 14:59:49 +0000122/**
123 * xmlAttributeType:
124 *
125 * a DTD Attribute type definition
Owen Taylor3473f882001-02-23 17:55:21 +0000126 */
127
128typedef enum {
129 XML_ATTRIBUTE_CDATA = 1,
130 XML_ATTRIBUTE_ID,
131 XML_ATTRIBUTE_IDREF ,
132 XML_ATTRIBUTE_IDREFS,
133 XML_ATTRIBUTE_ENTITY,
134 XML_ATTRIBUTE_ENTITIES,
135 XML_ATTRIBUTE_NMTOKEN,
136 XML_ATTRIBUTE_NMTOKENS,
137 XML_ATTRIBUTE_ENUMERATION,
138 XML_ATTRIBUTE_NOTATION
139} xmlAttributeType;
140
Daniel Veillardbed7b052001-05-19 14:59:49 +0000141/**
142 * xmlAttributeDefault:
143 *
144 * a DTD Attribute default definition
145 */
146
Owen Taylor3473f882001-02-23 17:55:21 +0000147typedef enum {
148 XML_ATTRIBUTE_NONE = 1,
149 XML_ATTRIBUTE_REQUIRED,
150 XML_ATTRIBUTE_IMPLIED,
151 XML_ATTRIBUTE_FIXED
152} xmlAttributeDefault;
153
Daniel Veillardbed7b052001-05-19 14:59:49 +0000154/**
155 * xmlEnumeration:
156 *
157 * list structure used when there is an enumeration in DTDs
158 */
159
Owen Taylor3473f882001-02-23 17:55:21 +0000160typedef struct _xmlEnumeration xmlEnumeration;
161typedef xmlEnumeration *xmlEnumerationPtr;
162struct _xmlEnumeration {
163 struct _xmlEnumeration *next; /* next one */
164 const xmlChar *name; /* Enumeration name */
165};
166
Daniel Veillardbed7b052001-05-19 14:59:49 +0000167/**
168 * xmlAttribute:
169 *
170 * an Attribute declaration in a DTD
171 */
172
Owen Taylor3473f882001-02-23 17:55:21 +0000173typedef struct _xmlAttribute xmlAttribute;
174typedef xmlAttribute *xmlAttributePtr;
175struct _xmlAttribute {
Daniel Veillard0ec98632001-11-14 15:04:32 +0000176 void *_private; /* application data */
Owen Taylor3473f882001-02-23 17:55:21 +0000177 xmlElementType type; /* XML_ATTRIBUTE_DECL, must be second ! */
178 const xmlChar *name; /* Attribute name */
179 struct _xmlNode *children; /* NULL */
180 struct _xmlNode *last; /* NULL */
181 struct _xmlDtd *parent; /* -> DTD */
182 struct _xmlNode *next; /* next sibling link */
183 struct _xmlNode *prev; /* previous sibling link */
184 struct _xmlDoc *doc; /* the containing document */
185
186 struct _xmlAttribute *nexth; /* next in hash table */
187 xmlAttributeType atype; /* The attribute type */
188 xmlAttributeDefault def; /* the default */
189 const xmlChar *defaultValue; /* or the default value */
190 xmlEnumerationPtr tree; /* or the enumeration tree if any */
191 const xmlChar *prefix; /* the namespace prefix if any */
192 const xmlChar *elem; /* Element holding the attribute */
193};
194
Daniel Veillardbed7b052001-05-19 14:59:49 +0000195/**
196 * xmlElementContentType:
197 *
198 * Possible definitions of element content types
Owen Taylor3473f882001-02-23 17:55:21 +0000199 */
200typedef enum {
201 XML_ELEMENT_CONTENT_PCDATA = 1,
202 XML_ELEMENT_CONTENT_ELEMENT,
203 XML_ELEMENT_CONTENT_SEQ,
204 XML_ELEMENT_CONTENT_OR
205} xmlElementContentType;
206
Daniel Veillardbed7b052001-05-19 14:59:49 +0000207/**
208 * xmlElementContentOccur:
209 *
Daniel Veillardd1640922001-12-17 15:30:10 +0000210 * Possible definitions of element content occurrences
Daniel Veillardbed7b052001-05-19 14:59:49 +0000211 */
Owen Taylor3473f882001-02-23 17:55:21 +0000212typedef enum {
213 XML_ELEMENT_CONTENT_ONCE = 1,
214 XML_ELEMENT_CONTENT_OPT,
215 XML_ELEMENT_CONTENT_MULT,
216 XML_ELEMENT_CONTENT_PLUS
217} xmlElementContentOccur;
218
Daniel Veillardbed7b052001-05-19 14:59:49 +0000219/**
220 * xmlElementContent:
221 *
222 * an XML Element content as stored after parsing an element definition
223 * in a DTD.
224 */
225
Owen Taylor3473f882001-02-23 17:55:21 +0000226typedef struct _xmlElementContent xmlElementContent;
227typedef xmlElementContent *xmlElementContentPtr;
228struct _xmlElementContent {
229 xmlElementContentType type; /* PCDATA, ELEMENT, SEQ or OR */
230 xmlElementContentOccur ocur; /* ONCE, OPT, MULT or PLUS */
Daniel Veillardbe480fb2001-11-08 23:36:42 +0000231 const xmlChar *name; /* Element name */
Owen Taylor3473f882001-02-23 17:55:21 +0000232 struct _xmlElementContent *c1; /* first child */
233 struct _xmlElementContent *c2; /* second child */
Daniel Veillarddab4cb32001-04-20 13:03:48 +0000234 struct _xmlElementContent *parent; /* parent */
Daniel Veillardbe480fb2001-11-08 23:36:42 +0000235 const xmlChar *prefix; /* Element name */
Owen Taylor3473f882001-02-23 17:55:21 +0000236};
237
Daniel Veillardbed7b052001-05-19 14:59:49 +0000238/**
239 * xmlElementTypeVal:
240 *
Daniel Veillardd1640922001-12-17 15:30:10 +0000241 * the different possibilities for an element content type
Daniel Veillardbed7b052001-05-19 14:59:49 +0000242 */
243
Owen Taylor3473f882001-02-23 17:55:21 +0000244typedef enum {
Daniel Veillarda10efa82001-04-18 13:09:01 +0000245 XML_ELEMENT_TYPE_UNDEFINED = 0,
Owen Taylor3473f882001-02-23 17:55:21 +0000246 XML_ELEMENT_TYPE_EMPTY = 1,
247 XML_ELEMENT_TYPE_ANY,
248 XML_ELEMENT_TYPE_MIXED,
249 XML_ELEMENT_TYPE_ELEMENT
250} xmlElementTypeVal;
251
Daniel Veillardbed7b052001-05-19 14:59:49 +0000252/**
253 * xmlElement:
254 *
255 * an XML Element declaration from a DTD
256 */
257
Owen Taylor3473f882001-02-23 17:55:21 +0000258typedef struct _xmlElement xmlElement;
259typedef xmlElement *xmlElementPtr;
260struct _xmlElement {
Daniel Veillard0ec98632001-11-14 15:04:32 +0000261 void *_private; /* application data */
Owen Taylor3473f882001-02-23 17:55:21 +0000262 xmlElementType type; /* XML_ELEMENT_DECL, must be second ! */
263 const xmlChar *name; /* Element name */
264 struct _xmlNode *children; /* NULL */
265 struct _xmlNode *last; /* NULL */
266 struct _xmlDtd *parent; /* -> DTD */
267 struct _xmlNode *next; /* next sibling link */
268 struct _xmlNode *prev; /* previous sibling link */
269 struct _xmlDoc *doc; /* the containing document */
270
271 xmlElementTypeVal etype; /* The type */
272 xmlElementContentPtr content; /* the allowed element content */
273 xmlAttributePtr attributes; /* List of the declared attributes */
274 const xmlChar *prefix; /* the namespace prefix if any */
275};
276
Daniel Veillardbed7b052001-05-19 14:59:49 +0000277
Daniel Veillard5e2dace2001-07-18 19:30:27 +0000278/**
279 * XML_LOCAL_NAMESPACE:
280 *
281 * A namespace declaration node
282 */
Daniel Veillardbed7b052001-05-19 14:59:49 +0000283#define XML_LOCAL_NAMESPACE XML_NAMESPACE_DECL
284typedef xmlElementType xmlNsType;
285
286/**
287 * xmlNs:
288 *
Owen Taylor3473f882001-02-23 17:55:21 +0000289 * An XML namespace.
290 * Note that prefix == NULL is valid, it defines the default namespace
Daniel Veillardd1640922001-12-17 15:30:10 +0000291 * within the subtree (until overridden).
Owen Taylor3473f882001-02-23 17:55:21 +0000292 *
Owen Taylor3473f882001-02-23 17:55:21 +0000293 * xmlNsType is unified with xmlElementType
294 */
295
Owen Taylor3473f882001-02-23 17:55:21 +0000296typedef struct _xmlNs xmlNs;
297typedef xmlNs *xmlNsPtr;
298struct _xmlNs {
299 struct _xmlNs *next; /* next Ns link for this node */
300 xmlNsType type; /* global or local */
301 const xmlChar *href; /* URL for the namespace */
302 const xmlChar *prefix; /* prefix for the namespace */
303};
304
Daniel Veillardbed7b052001-05-19 14:59:49 +0000305/**
306 * xmlDtd:
307 *
Daniel Veillardd1640922001-12-17 15:30:10 +0000308 * An XML DTD, as defined by <!DOCTYPE ... There is actually one for
Daniel Veillardbed7b052001-05-19 14:59:49 +0000309 * the internal subset and for the external subset
Owen Taylor3473f882001-02-23 17:55:21 +0000310 */
311typedef struct _xmlDtd xmlDtd;
312typedef xmlDtd *xmlDtdPtr;
313struct _xmlDtd {
Daniel Veillard0ec98632001-11-14 15:04:32 +0000314 void *_private; /* application data */
Owen Taylor3473f882001-02-23 17:55:21 +0000315 xmlElementType type; /* XML_DTD_NODE, must be second ! */
316 const xmlChar *name; /* Name of the DTD */
317 struct _xmlNode *children; /* the value of the property link */
318 struct _xmlNode *last; /* last child link */
319 struct _xmlDoc *parent; /* child->parent link */
320 struct _xmlNode *next; /* next sibling link */
321 struct _xmlNode *prev; /* previous sibling link */
322 struct _xmlDoc *doc; /* the containing document */
323
324 /* End of common part */
325 void *notations; /* Hash table for notations if any */
326 void *elements; /* Hash table for elements if any */
327 void *attributes; /* Hash table for attributes if any */
328 void *entities; /* Hash table for entities if any */
329 const xmlChar *ExternalID; /* External identifier for PUBLIC DTD */
330 const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC DTD */
331 void *pentities; /* Hash table for param entities if any */
332};
333
Daniel Veillardbed7b052001-05-19 14:59:49 +0000334/**
335 * xmlAttr:
336 *
337 * A attribute on an XML node.
Owen Taylor3473f882001-02-23 17:55:21 +0000338 */
339typedef struct _xmlAttr xmlAttr;
340typedef xmlAttr *xmlAttrPtr;
341struct _xmlAttr {
Daniel Veillard0ec98632001-11-14 15:04:32 +0000342 void *_private; /* application data */
Owen Taylor3473f882001-02-23 17:55:21 +0000343 xmlElementType type; /* XML_ATTRIBUTE_NODE, must be second ! */
344 const xmlChar *name; /* the name of the property */
345 struct _xmlNode *children; /* the value of the property */
346 struct _xmlNode *last; /* NULL */
347 struct _xmlNode *parent; /* child->parent link */
348 struct _xmlAttr *next; /* next sibling link */
349 struct _xmlAttr *prev; /* previous sibling link */
350 struct _xmlDoc *doc; /* the containing document */
351 xmlNs *ns; /* pointer to the associated namespace */
352 xmlAttributeType atype; /* the attribute type if validating */
353};
354
Daniel Veillardbed7b052001-05-19 14:59:49 +0000355/**
356 * xmlID:
357 *
Owen Taylor3473f882001-02-23 17:55:21 +0000358 * An XML ID instance.
359 */
360
361typedef struct _xmlID xmlID;
362typedef xmlID *xmlIDPtr;
363struct _xmlID {
364 struct _xmlID *next; /* next ID */
365 const xmlChar *value; /* The ID name */
Daniel Veillardd1640922001-12-17 15:30:10 +0000366 xmlAttrPtr attr; /* The attribute holding it */
Owen Taylor3473f882001-02-23 17:55:21 +0000367};
368
Daniel Veillardbed7b052001-05-19 14:59:49 +0000369/**
370 * xmlRef:
371 *
Owen Taylor3473f882001-02-23 17:55:21 +0000372 * An XML IDREF instance.
373 */
374
375typedef struct _xmlRef xmlRef;
376typedef xmlRef *xmlRefPtr;
377struct _xmlRef {
378 struct _xmlRef *next; /* next Ref */
379 const xmlChar *value; /* The Ref name */
Daniel Veillardd1640922001-12-17 15:30:10 +0000380 xmlAttrPtr attr; /* The attribute holding it */
Owen Taylor3473f882001-02-23 17:55:21 +0000381};
382
Daniel Veillardbed7b052001-05-19 14:59:49 +0000383/**
384 * xmlBufferAllocationScheme:
385 *
386 * A buffer allocation scheme can be defined to either match exactly the
387 * need or double it's allocated size each time it is found too small
Owen Taylor3473f882001-02-23 17:55:21 +0000388 */
389
390typedef enum {
391 XML_BUFFER_ALLOC_DOUBLEIT,
392 XML_BUFFER_ALLOC_EXACT
393} xmlBufferAllocationScheme;
394
Daniel Veillardbed7b052001-05-19 14:59:49 +0000395/**
396 * xmlBuffer:
397 *
398 * A buffer structure
399 */
Owen Taylor3473f882001-02-23 17:55:21 +0000400typedef struct _xmlBuffer xmlBuffer;
401typedef xmlBuffer *xmlBufferPtr;
402struct _xmlBuffer {
403 xmlChar *content; /* The buffer content UTF8 */
404 unsigned int use; /* The buffer size used */
405 unsigned int size; /* The buffer size */
406 xmlBufferAllocationScheme alloc; /* The realloc method */
407};
408
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000409/**
410 * xmlNode:
411 *
Owen Taylor3473f882001-02-23 17:55:21 +0000412 * A node in an XML tree.
413 */
414typedef struct _xmlNode xmlNode;
415typedef xmlNode *xmlNodePtr;
416struct _xmlNode {
Daniel Veillard0ec98632001-11-14 15:04:32 +0000417 void *_private; /* application data */
Owen Taylor3473f882001-02-23 17:55:21 +0000418 xmlElementType type; /* type number, must be second ! */
419 const xmlChar *name; /* the name of the node, or the entity */
420 struct _xmlNode *children; /* parent->childs link */
421 struct _xmlNode *last; /* last child link */
422 struct _xmlNode *parent; /* child->parent link */
423 struct _xmlNode *next; /* next sibling link */
424 struct _xmlNode *prev; /* previous sibling link */
425 struct _xmlDoc *doc; /* the containing document */
426 xmlNs *ns; /* pointer to the associated namespace */
427#ifndef XML_USE_BUFFER_CONTENT
428 xmlChar *content; /* the content */
429#else
430 xmlBufferPtr content; /* the content in a buffer */
431#endif
432
433 /* End of common part */
434 struct _xmlAttr *properties;/* properties list */
435 xmlNs *nsDef; /* namespace definitions on this node */
436};
437
Daniel Veillard5e2dace2001-07-18 19:30:27 +0000438/**
439 * XML_GET_CONTENT:
440 *
441 * macro to extract the content pointer of a node
442 */
443#define XML_GET_CONTENT(n) \
Daniel Veillard566d4df2001-11-22 13:00:53 +0000444 ((n)->type == XML_ELEMENT_NODE ? NULL : (n)->content)
Daniel Veillard5e2dace2001-07-18 19:30:27 +0000445
446/**
447 * XML_GET_LINE:
448 *
Daniel Veillard566d4df2001-11-22 13:00:53 +0000449 * macro to extract the line number of an element node.
450 * This will work only if line numbering is activated by
451 * calling xmlLineNumbersDefault(1) before parsing
Daniel Veillard5e2dace2001-07-18 19:30:27 +0000452 */
453#define XML_GET_LINE(n) \
Daniel Veillard566d4df2001-11-22 13:00:53 +0000454 ((n)->type == XML_ELEMENT_NODE ? (int) (n)->content : 0)
Daniel Veillard7db37732001-07-12 01:20:08 +0000455
Daniel Veillardbed7b052001-05-19 14:59:49 +0000456/**
457 * xmlDoc:
458 *
Owen Taylor3473f882001-02-23 17:55:21 +0000459 * An XML document.
460 */
461typedef struct _xmlDoc xmlDoc;
462typedef xmlDoc *xmlDocPtr;
463struct _xmlDoc {
Daniel Veillard0ec98632001-11-14 15:04:32 +0000464 void *_private; /* application data */
Owen Taylor3473f882001-02-23 17:55:21 +0000465 xmlElementType type; /* XML_DOCUMENT_NODE, must be second ! */
466 char *name; /* name/filename/URI of the document */
467 struct _xmlNode *children; /* the document tree */
468 struct _xmlNode *last; /* last child link */
469 struct _xmlNode *parent; /* child->parent link */
470 struct _xmlNode *next; /* next sibling link */
471 struct _xmlNode *prev; /* previous sibling link */
472 struct _xmlDoc *doc; /* autoreference to itself */
473
474 /* End of common part */
475 int compression;/* level of zlib compression */
476 int standalone; /* standalone document (no external refs) */
477 struct _xmlDtd *intSubset; /* the document internal subset */
478 struct _xmlDtd *extSubset; /* the document external subset */
479 struct _xmlNs *oldNs; /* Global namespace, the old way */
480 const xmlChar *version; /* the XML version string */
481 const xmlChar *encoding; /* external initial encoding, if any */
482 void *ids; /* Hash table for ID attributes if any */
483 void *refs; /* Hash table for IDREFs attributes if any */
484 const xmlChar *URL; /* The URI for that document */
485 int charset; /* encoding of the in-memory content
486 actually an xmlCharEncoding */
487};
488
Daniel Veillardbed7b052001-05-19 14:59:49 +0000489/**
490 * xmlChildrenNode:
491 *
492 * Macro for compatibility naming layer with libxml1
Owen Taylor3473f882001-02-23 17:55:21 +0000493 */
494#ifndef xmlChildrenNode
495#define xmlChildrenNode children
Daniel Veillardbed7b052001-05-19 14:59:49 +0000496#endif
497
498/**
499 * xmlRootNode:
500 *
501 * Macro for compatibility naming layer with libxml1
502 */
503#ifndef xmlRootNode
Owen Taylor3473f882001-02-23 17:55:21 +0000504#define xmlRootNode children
505#endif
506
507/*
508 * Variables.
509 */
510LIBXML_DLL_IMPORT extern xmlNsPtr baseDTD;
511LIBXML_DLL_IMPORT extern int oldXMLWDcompatibility;/* maintain compatibility with old WD */
512LIBXML_DLL_IMPORT extern int xmlIndentTreeOutput; /* try to indent the tree dumps */
513LIBXML_DLL_IMPORT extern xmlBufferAllocationScheme xmlBufferAllocScheme; /* alloc scheme to use */
Daniel Veillarde356c282001-03-10 12:32:04 +0000514LIBXML_DLL_IMPORT extern int xmlSaveNoEmptyTags; /* save empty tags as <empty></empty> */
515LIBXML_DLL_IMPORT extern int xmlDefaultBufferSize; /* default buffer size */
Owen Taylor3473f882001-02-23 17:55:21 +0000516
517/*
518 * Handling Buffers.
519 */
520
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000521void xmlSetBufferAllocationScheme(xmlBufferAllocationScheme scheme);
522xmlBufferAllocationScheme xmlGetBufferAllocationScheme(void);
523
Owen Taylor3473f882001-02-23 17:55:21 +0000524xmlBufferPtr xmlBufferCreate (void);
525xmlBufferPtr xmlBufferCreateSize (size_t size);
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000526int xmlBufferResize (xmlBufferPtr buf,
527 unsigned int size);
Owen Taylor3473f882001-02-23 17:55:21 +0000528void xmlBufferFree (xmlBufferPtr buf);
529int xmlBufferDump (FILE *file,
530 xmlBufferPtr buf);
531void xmlBufferAdd (xmlBufferPtr buf,
532 const xmlChar *str,
533 int len);
534void xmlBufferAddHead (xmlBufferPtr buf,
535 const xmlChar *str,
536 int len);
537void xmlBufferCat (xmlBufferPtr buf,
538 const xmlChar *str);
539void xmlBufferCCat (xmlBufferPtr buf,
540 const char *str);
541int xmlBufferShrink (xmlBufferPtr buf,
542 unsigned int len);
543int xmlBufferGrow (xmlBufferPtr buf,
544 unsigned int len);
545void xmlBufferEmpty (xmlBufferPtr buf);
546const xmlChar* xmlBufferContent (const xmlBufferPtr buf);
Owen Taylor3473f882001-02-23 17:55:21 +0000547void xmlBufferSetAllocationScheme(xmlBufferPtr buf,
548 xmlBufferAllocationScheme scheme);
549int xmlBufferLength (const xmlBufferPtr buf);
550
551/*
552 * Creating/freeing new structures
553 */
554xmlDtdPtr xmlCreateIntSubset (xmlDocPtr doc,
555 const xmlChar *name,
556 const xmlChar *ExternalID,
557 const xmlChar *SystemID);
558xmlDtdPtr xmlNewDtd (xmlDocPtr doc,
559 const xmlChar *name,
560 const xmlChar *ExternalID,
561 const xmlChar *SystemID);
562xmlDtdPtr xmlGetIntSubset (xmlDocPtr doc);
563void xmlFreeDtd (xmlDtdPtr cur);
564xmlNsPtr xmlNewGlobalNs (xmlDocPtr doc,
565 const xmlChar *href,
566 const xmlChar *prefix);
567xmlNsPtr xmlNewNs (xmlNodePtr node,
568 const xmlChar *href,
569 const xmlChar *prefix);
570void xmlFreeNs (xmlNsPtr cur);
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000571void xmlFreeNsList (xmlNsPtr cur);
Owen Taylor3473f882001-02-23 17:55:21 +0000572xmlDocPtr xmlNewDoc (const xmlChar *version);
573void xmlFreeDoc (xmlDocPtr cur);
574xmlAttrPtr xmlNewDocProp (xmlDocPtr doc,
575 const xmlChar *name,
576 const xmlChar *value);
577xmlAttrPtr xmlNewProp (xmlNodePtr node,
578 const xmlChar *name,
579 const xmlChar *value);
580xmlAttrPtr xmlNewNsProp (xmlNodePtr node,
581 xmlNsPtr ns,
582 const xmlChar *name,
583 const xmlChar *value);
584void xmlFreePropList (xmlAttrPtr cur);
585void xmlFreeProp (xmlAttrPtr cur);
586xmlAttrPtr xmlCopyProp (xmlNodePtr target,
587 xmlAttrPtr cur);
588xmlAttrPtr xmlCopyPropList (xmlNodePtr target,
589 xmlAttrPtr cur);
590xmlDtdPtr xmlCopyDtd (xmlDtdPtr dtd);
591xmlDocPtr xmlCopyDoc (xmlDocPtr doc,
592 int recursive);
593
594/*
595 * Creating new nodes
596 */
597xmlNodePtr xmlNewDocNode (xmlDocPtr doc,
598 xmlNsPtr ns,
599 const xmlChar *name,
600 const xmlChar *content);
601xmlNodePtr xmlNewDocRawNode (xmlDocPtr doc,
602 xmlNsPtr ns,
603 const xmlChar *name,
604 const xmlChar *content);
605xmlNodePtr xmlNewNode (xmlNsPtr ns,
606 const xmlChar *name);
607xmlNodePtr xmlNewChild (xmlNodePtr parent,
608 xmlNsPtr ns,
609 const xmlChar *name,
610 const xmlChar *content);
611xmlNodePtr xmlNewTextChild (xmlNodePtr parent,
612 xmlNsPtr ns,
613 const xmlChar *name,
614 const xmlChar *content);
615xmlNodePtr xmlNewDocText (xmlDocPtr doc,
616 const xmlChar *content);
617xmlNodePtr xmlNewText (const xmlChar *content);
618xmlNodePtr xmlNewPI (const xmlChar *name,
619 const xmlChar *content);
620xmlNodePtr xmlNewDocTextLen (xmlDocPtr doc,
621 const xmlChar *content,
622 int len);
623xmlNodePtr xmlNewTextLen (const xmlChar *content,
624 int len);
625xmlNodePtr xmlNewDocComment (xmlDocPtr doc,
626 const xmlChar *content);
627xmlNodePtr xmlNewComment (const xmlChar *content);
628xmlNodePtr xmlNewCDataBlock (xmlDocPtr doc,
629 const xmlChar *content,
630 int len);
631xmlNodePtr xmlNewCharRef (xmlDocPtr doc,
632 const xmlChar *name);
633xmlNodePtr xmlNewReference (xmlDocPtr doc,
634 const xmlChar *name);
Daniel Veillard2ebd7a72001-08-28 21:07:03 +0000635xmlNodePtr xmlCopyNode (const xmlNodePtr node,
Owen Taylor3473f882001-02-23 17:55:21 +0000636 int recursive);
Daniel Veillard82daa812001-04-12 08:55:36 +0000637xmlNodePtr xmlDocCopyNode (xmlNodePtr node,
638 xmlDocPtr doc,
639 int recursive);
Owen Taylor3473f882001-02-23 17:55:21 +0000640xmlNodePtr xmlCopyNodeList (xmlNodePtr node);
641xmlNodePtr xmlNewDocFragment (xmlDocPtr doc);
642
643/*
644 * Navigating
645 */
Daniel Veillard8faa7832001-11-26 15:58:08 +0000646long xmlGetLineNo (xmlNodePtr node);
647xmlChar * xmlGetNodePath (xmlNodePtr node);
Owen Taylor3473f882001-02-23 17:55:21 +0000648xmlNodePtr xmlDocGetRootElement (xmlDocPtr doc);
649xmlNodePtr xmlGetLastChild (xmlNodePtr parent);
650int xmlNodeIsText (xmlNodePtr node);
651int xmlIsBlankNode (xmlNodePtr node);
652
653/*
654 * Changing the structure
655 */
656xmlNodePtr xmlDocSetRootElement (xmlDocPtr doc,
657 xmlNodePtr root);
658void xmlNodeSetName (xmlNodePtr cur,
659 const xmlChar *name);
660xmlNodePtr xmlAddChild (xmlNodePtr parent,
661 xmlNodePtr cur);
662xmlNodePtr xmlAddChildList (xmlNodePtr parent,
663 xmlNodePtr cur);
664xmlNodePtr xmlReplaceNode (xmlNodePtr old,
665 xmlNodePtr cur);
666xmlNodePtr xmlAddSibling (xmlNodePtr cur,
667 xmlNodePtr elem);
668xmlNodePtr xmlAddPrevSibling (xmlNodePtr cur,
669 xmlNodePtr elem);
670xmlNodePtr xmlAddNextSibling (xmlNodePtr cur,
671 xmlNodePtr elem);
672void xmlUnlinkNode (xmlNodePtr cur);
673xmlNodePtr xmlTextMerge (xmlNodePtr first,
674 xmlNodePtr second);
675void xmlTextConcat (xmlNodePtr node,
676 const xmlChar *content,
677 int len);
678void xmlFreeNodeList (xmlNodePtr cur);
679void xmlFreeNode (xmlNodePtr cur);
680void xmlSetTreeDoc (xmlNodePtr tree,
681 xmlDocPtr doc);
682void xmlSetListDoc (xmlNodePtr list,
683 xmlDocPtr doc);
684
685/*
686 * Namespaces
687 */
688xmlNsPtr xmlSearchNs (xmlDocPtr doc,
689 xmlNodePtr node,
690 const xmlChar *nameSpace);
691xmlNsPtr xmlSearchNsByHref (xmlDocPtr doc,
692 xmlNodePtr node,
693 const xmlChar *href);
694xmlNsPtr * xmlGetNsList (xmlDocPtr doc,
695 xmlNodePtr node);
696void xmlSetNs (xmlNodePtr node,
697 xmlNsPtr ns);
698xmlNsPtr xmlCopyNamespace (xmlNsPtr cur);
699xmlNsPtr xmlCopyNamespaceList (xmlNsPtr cur);
700
701/*
702 * Changing the content.
703 */
704xmlAttrPtr xmlSetProp (xmlNodePtr node,
705 const xmlChar *name,
706 const xmlChar *value);
707xmlChar * xmlGetProp (xmlNodePtr node,
708 const xmlChar *name);
709xmlAttrPtr xmlHasProp (xmlNodePtr node,
710 const xmlChar *name);
Daniel Veillarde95e2392001-06-06 10:46:28 +0000711xmlAttrPtr xmlHasNsProp (xmlNodePtr node,
712 const xmlChar *name,
Daniel Veillardca2366a2001-06-11 12:09:01 +0000713 const xmlChar *nameSpace);
Owen Taylor3473f882001-02-23 17:55:21 +0000714xmlAttrPtr xmlSetNsProp (xmlNodePtr node,
715 xmlNsPtr ns,
716 const xmlChar *name,
717 const xmlChar *value);
718xmlChar * xmlGetNsProp (xmlNodePtr node,
719 const xmlChar *name,
720 const xmlChar *nameSpace);
721xmlNodePtr xmlStringGetNodeList (xmlDocPtr doc,
722 const xmlChar *value);
723xmlNodePtr xmlStringLenGetNodeList (xmlDocPtr doc,
724 const xmlChar *value,
725 int len);
726xmlChar * xmlNodeListGetString (xmlDocPtr doc,
727 xmlNodePtr list,
728 int inLine);
729xmlChar * xmlNodeListGetRawString (xmlDocPtr doc,
730 xmlNodePtr list,
731 int inLine);
732void xmlNodeSetContent (xmlNodePtr cur,
733 const xmlChar *content);
734void xmlNodeSetContentLen (xmlNodePtr cur,
735 const xmlChar *content,
736 int len);
737void xmlNodeAddContent (xmlNodePtr cur,
738 const xmlChar *content);
739void xmlNodeAddContentLen (xmlNodePtr cur,
740 const xmlChar *content,
741 int len);
742xmlChar * xmlNodeGetContent (xmlNodePtr cur);
743xmlChar * xmlNodeGetLang (xmlNodePtr cur);
744void xmlNodeSetLang (xmlNodePtr cur,
745 const xmlChar *lang);
746int xmlNodeGetSpacePreserve (xmlNodePtr cur);
Daniel Veillardd1640922001-12-17 15:30:10 +0000747void xmlNodeSetSpacePreserve (xmlNodePtr cur,
748 int val);
Owen Taylor3473f882001-02-23 17:55:21 +0000749xmlChar * xmlNodeGetBase (xmlDocPtr doc,
750 xmlNodePtr cur);
751void xmlNodeSetBase (xmlNodePtr cur,
752 xmlChar *uri);
753
754/*
755 * Removing content.
756 */
Daniel Veillardd1640922001-12-17 15:30:10 +0000757int xmlRemoveProp (xmlAttrPtr cur);
Daniel Veillard9403a042001-05-28 11:00:53 +0000758int xmlUnsetProp (xmlNodePtr node,
759 const xmlChar *name);
760int xmlUnsetNsProp (xmlNodePtr node,
761 xmlNsPtr ns,
762 const xmlChar *name);
Owen Taylor3473f882001-02-23 17:55:21 +0000763
764/*
765 * Internal, don't use
766 */
767#ifdef VMS
768void xmlBufferWriteXmlCHAR (xmlBufferPtr buf,
769 const xmlChar *string);
770#define xmlBufferWriteCHAR xmlBufferWriteXmlCHAR
771#else
772void xmlBufferWriteCHAR (xmlBufferPtr buf,
773 const xmlChar *string);
774#endif
775void xmlBufferWriteChar (xmlBufferPtr buf,
776 const char *string);
777void xmlBufferWriteQuotedString(xmlBufferPtr buf,
778 const xmlChar *string);
779
780/*
781 * Namespace handling
782 */
783int xmlReconciliateNs (xmlDocPtr doc,
784 xmlNodePtr tree);
785
786/*
787 * Saving
788 */
789void xmlDocDumpFormatMemory (xmlDocPtr cur,
790 xmlChar**mem,
791 int *size,
792 int format);
793void xmlDocDumpMemory (xmlDocPtr cur,
794 xmlChar**mem,
795 int *size);
796void xmlDocDumpMemoryEnc (xmlDocPtr out_doc,
797 xmlChar **doc_txt_ptr,
798 int * doc_txt_len,
799 const char *txt_encoding);
800void xmlDocDumpFormatMemoryEnc(xmlDocPtr out_doc,
801 xmlChar **doc_txt_ptr,
802 int * doc_txt_len,
803 const char *txt_encoding,
804 int format);
805int xmlDocDump (FILE *f,
806 xmlDocPtr cur);
807void xmlElemDump (FILE *f,
808 xmlDocPtr doc,
809 xmlNodePtr cur);
810int xmlSaveFile (const char *filename,
811 xmlDocPtr cur);
Daniel Veillard67fee942001-04-26 18:59:03 +0000812int xmlSaveFormatFile (const char *filename,
813 xmlDocPtr cur,
814 int format);
Owen Taylor3473f882001-02-23 17:55:21 +0000815void xmlNodeDump (xmlBufferPtr buf,
816 xmlDocPtr doc,
817 xmlNodePtr cur,
818 int level,
819 int format);
820
CET 2001 Daniel Veillard5a37bde2001-11-01 14:31:22 +0000821int xmlSaveFileTo (xmlOutputBufferPtr buf,
Owen Taylor3473f882001-02-23 17:55:21 +0000822 xmlDocPtr cur,
823 const char *encoding);
CET 2001 Daniel Veillard5a37bde2001-11-01 14:31:22 +0000824int xmlSaveFormatFileTo (xmlOutputBufferPtr buf,
825 xmlDocPtr cur,
826 const char *encoding,
827 int format);
828void xmlNodeDumpOutput (xmlOutputBufferPtr buf,
829 xmlDocPtr doc,
830 xmlNodePtr cur,
831 int level,
832 int format,
833 const char *encoding);
Owen Taylor3473f882001-02-23 17:55:21 +0000834
Daniel Veillardd1640922001-12-17 15:30:10 +0000835int xmlSaveFormatFileEnc (const char *filename,
836 xmlDocPtr cur,
837 const char *encoding,
838 int format);
Daniel Veillardf012a642001-07-23 19:10:52 +0000839
Owen Taylor3473f882001-02-23 17:55:21 +0000840int xmlSaveFileEnc (const char *filename,
841 xmlDocPtr cur,
842 const char *encoding);
843
844/*
845 * Compression
846 */
847int xmlGetDocCompressMode (xmlDocPtr doc);
848void xmlSetDocCompressMode (xmlDocPtr doc,
849 int mode);
850int xmlGetCompressMode (void);
851void xmlSetCompressMode (int mode);
852
853#ifdef __cplusplus
854}
855#endif
856
857#endif /* __XML_TREE_H__ */
858