blob: c9bd0035904ecf79409f0e65798ad17b15d71e78 [file] [log] [blame]
Daniel Veillard260a68f1998-08-13 03:39:55 +00001/*
2 * entities.h : interface for the XML entities handking
3 *
4 * See Copyright for the status of this software.
5 *
Daniel Veillard39a1f9a1999-01-17 19:11:59 +00006 * Daniel.Veillard@w3.org
Daniel Veillard260a68f1998-08-13 03:39:55 +00007 */
8
9#ifndef __XML_ENTITIES_H__
10#define __XML_ENTITIES_H__
Daniel Veillard260a68f1998-08-13 03:39:55 +000011
Daniel Veillard361d8452000-04-03 19:48:13 +000012#include <libxml/tree.h>
Daniel Veillard260a68f1998-08-13 03:39:55 +000013
14#ifdef __cplusplus
15extern "C" {
16#endif
17
Daniel Veillardcf461992000-03-14 18:30:20 +000018/*
19 * The different valid entity types
20 */
21typedef enum {
22 XML_INTERNAL_GENERAL_ENTITY = 1,
23 XML_EXTERNAL_GENERAL_PARSED_ENTITY = 2,
24 XML_EXTERNAL_GENERAL_UNPARSED_ENTITY = 3,
25 XML_INTERNAL_PARAMETER_ENTITY = 4,
26 XML_EXTERNAL_PARAMETER_ENTITY = 5,
27 XML_INTERNAL_PREDEFINED_ENTITY = 6
28} xmlEntityType;
Daniel Veillard260a68f1998-08-13 03:39:55 +000029
30/*
31 * An unit of storage for an entity, contains the string, the value
32 * and the linkind data needed for the linking in the hash table.
33 */
34
Daniel Veillard71b656e2000-01-05 14:46:17 +000035typedef struct _xmlEntity xmlEntity;
36typedef xmlEntity *xmlEntityPtr;
37struct _xmlEntity {
Daniel Veillardcf461992000-03-14 18:30:20 +000038#ifndef XML_WITHOUT_CORBA
39 void *_private; /* for Corba, must be first ! */
40#endif
41 xmlElementType type; /* XML_ENTITY_DECL, must be second ! */
42 const xmlChar *name; /* Attribute name */
43 struct _xmlNode *children; /* NULL */
44 struct _xmlNode *last; /* NULL */
45 struct _xmlDtd *parent; /* -> DTD */
46 struct _xmlNode *next; /* next sibling link */
47 struct _xmlNode *prev; /* previous sibling link */
48 struct _xmlDoc *doc; /* the containing document */
49
50 xmlChar *orig; /* content without ref substitution */
51 xmlChar *content; /* content or ndata if unparsed */
52 int length; /* the content length */
53 xmlEntityType etype; /* The entity type */
54 const xmlChar *ExternalID; /* External identifier for PUBLIC */
55 const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC Entity */
56
57#ifdef WITH_EXTRA_ENT_DETECT
58 /* Referenced entities name stack */
59 xmlChar *ent; /* Current parsed Node */
60 int entNr; /* Depth of the parsing stack */
61 int entMax; /* Max depth of the parsing stack */
62 xmlChar * *entTab; /* array of nodes */
63#endif
Daniel Veillard71b656e2000-01-05 14:46:17 +000064};
Daniel Veillard260a68f1998-08-13 03:39:55 +000065
66/*
67 * ALl entities are stored in a table there is one table per DTD
68 * and one extra per document.
69 */
70
71#define XML_MIN_ENTITIES_TABLE 32
72
Daniel Veillard71b656e2000-01-05 14:46:17 +000073typedef struct _xmlEntitiesTable xmlEntitiesTable;
74typedef xmlEntitiesTable *xmlEntitiesTablePtr;
75struct _xmlEntitiesTable {
Daniel Veillard260a68f1998-08-13 03:39:55 +000076 int nb_entities; /* number of elements stored */
77 int max_entities; /* maximum number of elements */
Daniel Veillardcf461992000-03-14 18:30:20 +000078 xmlEntityPtr *table; /* the table of entities */
Daniel Veillard71b656e2000-01-05 14:46:17 +000079};
Daniel Veillard260a68f1998-08-13 03:39:55 +000080
Daniel Veillardccb09631998-10-27 06:21:04 +000081
Daniel Veillard260a68f1998-08-13 03:39:55 +000082/*
83 * External functions :
84 */
85
Daniel Veillardcf461992000-03-14 18:30:20 +000086xmlEntityPtr xmlAddDocEntity (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +000087 const xmlChar *name,
Daniel Veillardb96e6431999-08-29 21:02:19 +000088 int type,
Daniel Veillarddd6b3671999-09-23 22:19:22 +000089 const xmlChar *ExternalID,
90 const xmlChar *SystemID,
91 const xmlChar *content);
Daniel Veillardcf461992000-03-14 18:30:20 +000092xmlEntityPtr xmlAddDtdEntity (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +000093 const xmlChar *name,
Daniel Veillardb96e6431999-08-29 21:02:19 +000094 int type,
Daniel Veillarddd6b3671999-09-23 22:19:22 +000095 const xmlChar *ExternalID,
96 const xmlChar *SystemID,
97 const xmlChar *content);
98xmlEntityPtr xmlGetPredefinedEntity (const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +000099xmlEntityPtr xmlGetDocEntity (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000100 const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000101xmlEntityPtr xmlGetDtdEntity (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000102 const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000103xmlEntityPtr xmlGetParameterEntity (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000104 const xmlChar *name);
105const xmlChar * xmlEncodeEntities (xmlDocPtr doc,
106 const xmlChar *input);
Daniel Veillard00fdf371999-10-08 09:40:39 +0000107xmlChar * xmlEncodeEntitiesReentrant(xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000108 const xmlChar *input);
Daniel Veillardbe803962000-06-28 23:40:59 +0000109xmlChar * xmlEncodeSpecialChars (xmlDocPtr doc,
110 const xmlChar *input);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000111xmlEntitiesTablePtr xmlCreateEntitiesTable (void);
112xmlEntitiesTablePtr xmlCopyEntitiesTable (xmlEntitiesTablePtr table);
113void xmlFreeEntitiesTable (xmlEntitiesTablePtr table);
114void xmlDumpEntitiesTable (xmlBufferPtr buf,
115 xmlEntitiesTablePtr table);
Daniel Veillardcf461992000-03-14 18:30:20 +0000116void xmlDumpEntityDecl (xmlBufferPtr buf,
117 xmlEntityPtr ent);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000118xmlEntitiesTablePtr xmlCopyEntitiesTable (xmlEntitiesTablePtr table);
Daniel Veillarda594bf41999-12-01 09:51:45 +0000119void xmlCleanupPredefinedEntities(void);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000120
Daniel Veillardcf461992000-03-14 18:30:20 +0000121#ifdef WITH_EXTRA_ENT_DETECT
122int xmlEntityAddReference (xmlEntityPtr ent,
123 const xmlChar *to);
124#endif
125
Daniel Veillard260a68f1998-08-13 03:39:55 +0000126#ifdef __cplusplus
127}
128#endif
129
130# endif /* __XML_ENTITIES_H__ */