blob: 00322c10a86d4628be88009b8c9e40301e83ea25 [file] [log] [blame]
Daniel Veillard01791d51998-07-24 19:24:09 +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 *
7 * $Id$
8 */
9
10#ifndef __XML_TREE_H__
11#define __XML_TREE_H__
12
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18/*
19 * Type definitions
20 */
21#ifdef UNICODE
22typedef unsigned short CHAR;
23#else
24typedef unsigned char CHAR;
25#endif
26
27/*
28 * Constants.
29 */
30#define XML_TYPE_TEXT 1
31
32/*
33 * An XML DTD defining a given name space.
34 */
35typedef struct xmlDtd {
36 struct xmlDtd *next; /* next Dtd link for this document */
37 const CHAR *href; /* URL for the DTD */
38 const CHAR *AS; /* URL for the DTD */
39 void *entities; /* Hash table for entities if any */
40} xmlDtd, *xmlDtdPtr;
41
42/*
43 * A property of an XML node.
44 */
45typedef struct xmlProp {
46 struct xmlNode *node; /* prop->node link */
47 struct xmlProp *next; /* parent->childs link */
48 const CHAR *name; /* the name of the property */
49 const CHAR *value; /* the value of the property */
50} xmlProp, *xmlPropPtr;
51
52/*
53 * A node in an XML tree.
54 */
55typedef struct xmlNode {
56 struct xmlNode *parent; /* child->parent link */
57 struct xmlNode *next; /* next sibling link */
58 struct xmlNode *childs; /* parent->childs link */
59 struct xmlProp *properties; /* properties list */
60 int type; /* type number in the DTD */
61 const CHAR *name; /* the name of the node */
62 xmlDtd *dtd; /* pointer to the DTD */
63 CHAR *content; /* the content */
64} xmlNode, *xmlNodePtr;
65
66/*
67 * An XML document.
68 */
69typedef struct xmlDoc {
70 const CHAR *version; /* the XML version string */
71 struct xmlDtd *dtds; /* referenced DTDs */
72 struct xmlNode *root; /* parent->childs link */
73 void *entities; /* Hash table for entities if any */
74} xmlDoc, *xmlDocPtr;
75
76/*
77 * Variables.
78 */
79extern xmlDtdPtr baseDTD;
80extern int oldXMLWDcompatibility;/* maintain compatibility with old WD */
81
82/*
83 * Functions.
84 */
85extern xmlDtdPtr xmlNewDtd(xmlDocPtr doc, const CHAR *href, const CHAR *AS);
86extern void xmlFreeDtd(xmlDtdPtr cur);
87extern xmlDocPtr xmlNewDoc(const CHAR *version);
88extern void xmlFreeDoc(xmlDocPtr cur);
89extern xmlPropPtr xmlNewProp(xmlNodePtr node, const CHAR *name,
90 const CHAR *value);
91extern const CHAR *xmlGetProp(xmlNodePtr node, const CHAR *name);
92extern void xmlFreePropList(xmlPropPtr cur);
93extern void xmlFreeProp(xmlPropPtr cur);
94extern xmlNodePtr xmlNewNode(xmlDtdPtr dtd, const CHAR *name, CHAR *content);
95extern xmlNodePtr xmlNewText(CHAR *content);
96extern xmlNodePtr xmlAddChild(xmlNodePtr parent, xmlNodePtr cur);
97extern void xmlFreeNodeList(xmlNodePtr cur);
98extern void xmlFreeNode(xmlNodePtr cur);
99extern void xmlNodeSetContent(xmlNodePtr cur, CHAR *content);
100extern xmlDtdPtr xmlSearchDtd(xmlDocPtr doc, CHAR *nameSpace);
101extern xmlNodePtr xmlNewChild(xmlNodePtr parent, xmlDtdPtr dtd,
102 const CHAR *name, CHAR *content);
103
104extern void xmlDocDumpMemory(xmlDocPtr cur, CHAR**mem, int *size);
105extern void xmlDocDump(FILE *f, xmlDocPtr doc);
106
107
108#ifdef __cplusplus
109}
110#endif
111
112#endif /* __XML_TREE_H__ */
113