Daniel Veillard | 01791d5 | 1998-07-24 19:24:09 +0000 | [diff] [blame] | 1 | /* |
| 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 |
| 15 | extern "C" { |
| 16 | #endif |
| 17 | |
| 18 | /* |
| 19 | * Type definitions |
| 20 | */ |
| 21 | #ifdef UNICODE |
| 22 | typedef unsigned short CHAR; |
| 23 | #else |
| 24 | typedef 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 | */ |
| 35 | typedef 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 | */ |
| 45 | typedef 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 | */ |
| 55 | typedef 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 | */ |
| 69 | typedef 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 | */ |
| 79 | extern xmlDtdPtr baseDTD; |
| 80 | extern int oldXMLWDcompatibility;/* maintain compatibility with old WD */ |
| 81 | |
| 82 | /* |
| 83 | * Functions. |
| 84 | */ |
| 85 | extern xmlDtdPtr xmlNewDtd(xmlDocPtr doc, const CHAR *href, const CHAR *AS); |
| 86 | extern void xmlFreeDtd(xmlDtdPtr cur); |
| 87 | extern xmlDocPtr xmlNewDoc(const CHAR *version); |
| 88 | extern void xmlFreeDoc(xmlDocPtr cur); |
| 89 | extern xmlPropPtr xmlNewProp(xmlNodePtr node, const CHAR *name, |
| 90 | const CHAR *value); |
| 91 | extern const CHAR *xmlGetProp(xmlNodePtr node, const CHAR *name); |
| 92 | extern void xmlFreePropList(xmlPropPtr cur); |
| 93 | extern void xmlFreeProp(xmlPropPtr cur); |
| 94 | extern xmlNodePtr xmlNewNode(xmlDtdPtr dtd, const CHAR *name, CHAR *content); |
| 95 | extern xmlNodePtr xmlNewText(CHAR *content); |
| 96 | extern xmlNodePtr xmlAddChild(xmlNodePtr parent, xmlNodePtr cur); |
| 97 | extern void xmlFreeNodeList(xmlNodePtr cur); |
| 98 | extern void xmlFreeNode(xmlNodePtr cur); |
| 99 | extern void xmlNodeSetContent(xmlNodePtr cur, CHAR *content); |
| 100 | extern xmlDtdPtr xmlSearchDtd(xmlDocPtr doc, CHAR *nameSpace); |
| 101 | extern xmlNodePtr xmlNewChild(xmlNodePtr parent, xmlDtdPtr dtd, |
| 102 | const CHAR *name, CHAR *content); |
| 103 | |
| 104 | extern void xmlDocDumpMemory(xmlDocPtr cur, CHAR**mem, int *size); |
| 105 | extern void xmlDocDump(FILE *f, xmlDocPtr doc); |
| 106 | |
| 107 | |
| 108 | #ifdef __cplusplus |
| 109 | } |
| 110 | #endif |
| 111 | |
| 112 | #endif /* __XML_TREE_H__ */ |
| 113 | |