2 * Sherlock Library -- A simple XML parser
4 * (c) 2007 Pavel Charvat <pchar@ucw.cz>
6 * This software may be freely distributed and used according to the terms
7 * of the GNU Lesser General Public License.
10 #ifndef _SHERLOCK_XML_DTD_H
11 #define _SHERLOCK_XML_DTD_H
13 #include "sherlock/xml/xml.h"
16 struct mempool *pool; /* Memory pool where to allocate DTD */
17 slist gents; /* Link list of general entities */
18 slist pents; /* Link list of parapeter entities */
19 slist notns; /* Link list of notations */
20 slist elems; /* Link list of elements */
21 void *tab_gents; /* Hash table of general entities */
22 void *tab_pents; /* Hash table of parameter entities */
23 void *tab_notns; /* Hash table of notations */
24 void *tab_elems; /* Hash table of elements */
25 void *tab_enodes; /* Hash table of element sons */
26 void *tab_attrs; /* Hash table of element attributes */
27 void *tab_evals; /* Hash table of enumerated attribute values */
28 void *tab_enotns; /* hash table of enumerated attribute notations */
33 enum xml_dtd_notn_flags {
34 XML_DTD_NOTN_DECLARED = 0x1, /* The notation has been declared (interbal usage) */
38 snode n; /* Node in xml_dtd.notns */
39 uns flags; /* XML_DTD_NOTN_x */
40 char *name; /* Notation name */
41 struct xml_ext_id eid; /* External id */
46 enum xml_dtd_ent_flags {
47 XML_DTD_ENT_DECLARED = 0x1, /* The entity has been declared (internal usage) */
48 XML_DTD_ENT_VISITED = 0x2, /* Cycle detection (internal usage) */
49 XML_DTD_ENT_PARAMETER = 0x4, /* Parameter entity, general otherwise */
50 XML_DTD_ENT_EXTERNAL = 0x8, /* External entity, internal otherwise */
51 XML_DTD_ENT_UNPARSED = 0x10, /* Unparsed entity, parsed otherwise */
52 XML_DTD_ENT_TRIVIAL = 0x20, /* Replacement text is a sequence of characters and character references */
56 snode n; /* Node in xml_dtd.[gp]ents */
57 uns flags; /* XML_DTD_ENT_x */
58 char *name; /* Entity name */
59 char *text; /* Replacement text / expanded replacement text (XML_DTD_ENT_TRIVIAL) */
60 uns len; /* Text length */
61 struct xml_ext_id eid; /* External ID */
62 struct xml_dtd_notn *notn; /* Notation (XML_DTD_ENT_UNPARSED only) */
65 struct xml_dtd_ent *xml_dtd_find_gent(struct xml_context *ctx, char *name);
69 enum xml_dtd_elem_flags {
70 XML_DTD_ELEM_DECLARED = 0x1, /* The element has been declared (internal usage) */
73 enum xml_dtd_elem_type {
77 XML_DTD_ELEM_CHILDREN,
85 struct xml_dtd_elem_node *node;
88 struct xml_dtd_elem_node {
90 struct xml_dtd_elem_node *parent;
91 struct xml_dtd_elem *elem;
97 enum xml_dtd_elem_node_type {
103 enum xml_dtd_elem_node_occur {
104 XML_DTD_ELEM_OCCUR_ONCE,
105 XML_DTD_ELEM_OCCUR_OPT,
106 XML_DTD_ELEM_OCCUR_MULT,
107 XML_DTD_ELEM_OCCUR_PLUS,
112 enum xml_dtd_attribute_default {
119 enum xml_dtd_attribute_type {
132 struct xml_dtd_attr {
134 struct xml_dtd_elem *elem;
135 enum xml_dtd_attribute_type type;
136 enum xml_dtd_attribute_default default_mode;
140 struct xml_dtd_eval {
141 struct xml_dtd_attr *attr;
145 struct xml_dtd_enotn {
146 struct xml_dtd_attr *attr;
147 struct xml_dtd_notn *notn;
150 void xml_dtd_init(struct xml_context *ctx);
151 void xml_dtd_cleanup(struct xml_context *ctx);
152 void xml_dtd_finish(struct xml_context *ctx);