Hash :
0ba4d537
Author :
Date :
1998-11-01T19:34:31
CharRef handling, comments, formatting, pre UTF-8 handling, Daniel.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
/*
* tree.h : describes the structures found in an tree resulting
* from an XML parsing.
*
* See Copyright for the status of this software.
*
* $Id$
*/
#ifndef __XML_TREE_H__
#define __XML_TREE_H__
#ifdef __cplusplus
extern "C" {
#endif
/*
* The different element types carried by an XML tree
*
* NOTE: This is synchronized with DOM Level1 values
* See http://www.w3.org/TR/REC-DOM-Level-1/
*/
typedef enum {
XML_ELEMENT_NODE= 1,
XML_ATTRIBUTE_NODE= 2,
XML_TEXT_NODE= 3,
XML_CDATA_SECTION_NODE= 4,
XML_ENTITY_REF_NODE= 5,
XML_ENTITY_NODE= 6,
XML_PI_NODE= 7,
XML_COMMENT_NODE= 8,
XML_DOCUMENT_NODE= 9,
XML_DOCUMENT_TYPE_NODE= 10,
XML_DOCUMENT_FRAG_NODE= 11,
XML_NOTATION_NODE= 12
} xmlElementType;
/*
* Size of an internal character representation.
*
* Currently we use 8bit chars internal representation for memory efficiency,
* but the parser is not tied to that, just define UNICODE to switch to
* a 16 bits internal representation. Note that with 8 bits wide
* CHARs one can still use UTF-8 to handle correctly non ISO-Latin
* input.
*/
#ifdef UNICODE
typedef unsigned short CHAR;
#else
typedef unsigned char CHAR;
#endif
/*
* a DTD Notation definition
* TODO !!!!
*/
/*
* a DTD Attribute definition
* TODO !!!!
*/
/*
* a DTD Element definition.
*/
#define XML_ELEMENT_TYPE_EMPTY 1
#define XML_ELEMENT_TYPE_ANY 2
#define XML_ELEMENT_TYPE_MIXED 3
#define XML_ELEMENT_TYPE_ELEMENT 4
typedef struct xmlElement {
const CHAR *name; /* Element name */
int type; /* type (too simple, to extend ...) */
/* TODO !!! more needed */
} xmlElement, *xmlElementPtr;
/*
* An XML namespace.
* Note that prefix == NULL is valid, it defines the default namespace
* within the subtree (until overriden).
*/
#define XML_GLOBAL_NAMESPACE 1 /* old style global namespace */
#define XML_LOCAL_NAMESPACE 2 /* new style local scoping */
typedef struct xmlNs {
struct xmlNs *next; /* next Ns link for this node */
int type; /* global or local */
const CHAR *href; /* URL for the namespace */
const CHAR *prefix; /* prefix for the namespace */
} xmlNs, *xmlNsPtr;
/*
* An XML DtD, as defined by <!DOCTYPE.
*/
typedef struct xmlDtd {
const CHAR *name; /* Name of the DTD */
const CHAR *ExternalID; /* External identifier for PUBLIC DTD */
const CHAR *SystemID; /* URI for a SYSTEM or PUBLIC DTD */
void *elements; /* Hash table for elements if any */
void *entities; /* Hash table for entities if any */
/* struct xmlDtd *next; * next link for this document */
} xmlDtd, *xmlDtdPtr;
/*
* A attribute of an XML node.
*/
typedef struct xmlAttr {
#ifndef XML_WITHOUT_CORBA
void *_private; /* for Corba, must be first ! */
void *vepv; /* for Corba, must be next ! */
#endif
xmlElementType type; /* XML_ATTRIBUTE_NODE, must be third ! */
struct xmlNode *node; /* attr->node link */
struct xmlAttr *next; /* parent->childs link */
const CHAR *name; /* the name of the property */
struct xmlNode *val; /* the value of the property */
} xmlAttr, *xmlAttrPtr;
/*
* A node in an XML tree.
*/
typedef struct xmlNode {
#ifndef XML_WITHOUT_CORBA
void *_private; /* for Corba, must be first ! */
void *vepv; /* for Corba, must be next ! */
#endif
xmlElementType type; /* type number in the DTD, must be third ! */
struct xmlDoc *doc; /* the containing document */
struct xmlNode *parent; /* child->parent link */
struct xmlNode *next; /* next sibling link */
struct xmlNode *prev; /* previous sibling link */
struct xmlNode *childs; /* parent->childs link */
struct xmlAttr *properties; /* properties list */
const CHAR *name; /* the name of the node, or the entity */
xmlNs *ns; /* pointer to the associated namespace */
xmlNs *nsDef; /* namespace definitions on this node */
CHAR *content; /* the content */
} xmlNode, *xmlNodePtr;
/*
* An XML document.
*/
typedef struct xmlDoc {
#ifndef XML_WITHOUT_CORBA
void *_private; /* for Corba, must be first ! */
void *vepv; /* for Corba, must be next ! */
#endif
xmlElementType type; /* XML_DOCUMENT_NODE, must be second ! */
char *name; /* name/filename/URI of the document */
const CHAR *version; /* the XML version string */
const CHAR *encoding; /* encoding, if any */
int compression;/* level of zlib compression */
int standalone; /* standalone document (no external refs) */
struct xmlDtd *dtd; /* the document DTD if available */
struct xmlNs *oldNs; /* Global namespace, the old way */
void *entities; /* Hash table for general entities if any */
struct xmlNode *root; /* the document tree */
} xmlDoc, *xmlDocPtr;
/*
* Variables.
*/
extern xmlNsPtr baseDTD;
extern int oldXMLWDcompatibility;/* maintain compatibility with old WD */
extern int xmlIndentTreeOutput; /* try to indent the tree dumps */
/*
* Creating/freeing new structures
*/
extern xmlDtdPtr xmlNewDtd(xmlDocPtr doc, const CHAR *name,
const CHAR *ExternalID, const CHAR *SystemID);
extern void xmlFreeDtd(xmlDtdPtr cur);
extern xmlNsPtr xmlNewGlobalNs(xmlDocPtr doc, const CHAR *href, const CHAR *AS);
extern xmlNsPtr xmlNewNs(xmlNodePtr node, const CHAR *href, const CHAR *AS);
extern void xmlFreeNs(xmlNsPtr cur);
extern xmlDocPtr xmlNewDoc(const CHAR *version);
extern void xmlFreeDoc(xmlDocPtr cur);
extern xmlAttrPtr xmlNewDocProp(xmlDocPtr doc, const CHAR *name,
const CHAR *value);
extern xmlAttrPtr xmlNewProp(xmlNodePtr node, const CHAR *name,
const CHAR *value);
extern void xmlFreePropList(xmlAttrPtr cur);
extern void xmlFreeProp(xmlAttrPtr cur);
/*
* Creating new nodes
*/
extern xmlNodePtr xmlNewDocNode(xmlDocPtr doc, xmlNsPtr ns,
const CHAR *name, CHAR *content);
extern xmlNodePtr xmlNewNode(xmlNsPtr ns, const CHAR *name);
extern xmlNodePtr xmlNewChild(xmlNodePtr parent, xmlNsPtr ns,
const CHAR *name, CHAR *content);
extern xmlNodePtr xmlNewDocText(xmlDocPtr doc, const CHAR *content);
extern xmlNodePtr xmlNewText(const CHAR *content);
extern xmlNodePtr xmlNewDocTextLen(xmlDocPtr doc, const CHAR *content, int len);
extern xmlNodePtr xmlNewTextLen(const CHAR *content, int len);
extern xmlNodePtr xmlNewDocComment(xmlDocPtr doc, CHAR *content);
extern xmlNodePtr xmlNewComment(CHAR *content);
extern xmlNodePtr xmlNewReference(xmlDocPtr doc, const CHAR *name);
/*
* Navigating
*/
extern xmlNodePtr xmlGetLastChild(xmlNodePtr node);
extern int xmlNodeIsText(xmlNodePtr node);
/*
* Changing the structure
*/
extern xmlNodePtr xmlAddChild(xmlNodePtr parent, xmlNodePtr cur);
extern void xmlUnlinkNode(xmlNodePtr cur);
extern xmlNodePtr xmlTextMerge(xmlNodePtr first, xmlNodePtr second);
extern void xmlTextConcat(xmlNodePtr node, const CHAR *content, int len);
extern void xmlFreeNodeList(xmlNodePtr cur);
extern void xmlFreeNode(xmlNodePtr cur);
/*
* Namespaces
*/
extern xmlNsPtr xmlSearchNs(xmlDocPtr doc, xmlNodePtr node,
const CHAR *nameSpace);
extern xmlNsPtr xmlSearchNsByHref(xmlDocPtr doc, xmlNodePtr node,
const CHAR *href);
extern void xmlSetNs(xmlNodePtr node, xmlNsPtr ns);
/*
* Changing the content.
*/
extern xmlAttrPtr xmlSetProp(xmlNodePtr node, const CHAR *name,
const CHAR *value);
extern const CHAR *xmlGetProp(xmlNodePtr node, const CHAR *name);
extern xmlNodePtr xmlStringGetNodeList(xmlDocPtr doc, const CHAR *value);
extern xmlNodePtr xmlStringLenGetNodeList(xmlDocPtr doc, const CHAR *value,
int len);
extern CHAR *xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, int inLine);
extern void xmlNodeSetContent(xmlNodePtr cur, const CHAR *content);
extern void xmlNodeSetContentLen(xmlNodePtr cur, const CHAR *content, int len);
extern void xmlNodeAddContent(xmlNodePtr cur, const CHAR *content);
extern void xmlNodeAddContentLen(xmlNodePtr cur, const CHAR *content, int len);
extern CHAR *xmlNodeGetContent(xmlNodePtr cur);
/*
* Internal, don't use
*/
extern void xmlBufferWriteCHAR(const CHAR *string);
extern void xmlBufferWriteChar(const char *string);
/*
* Saving
*/
extern void xmlDocDumpMemory(xmlDocPtr cur, CHAR**mem, int *size);
extern void xmlDocDump(FILE *f, xmlDocPtr doc);
int xmlSaveFile(const char *filename, xmlDocPtr cur);
/*
* Compression
*/
extern int xmlGetDocCompressMode (xmlDocPtr doc);
extern void xmlSetDocCompressMode (xmlDocPtr doc, int mode);
extern int xmlGetCompressMode(void);
extern void xmlSetCompressMode(int mode);
#ifdef __cplusplus
}
#endif
#endif /* __XML_TREE_H__ */