Edinburgh Speech Tools 2.4-release
 
Loading...
Searching...
No Matches
dtd.h
1/*************************************************************************/
2/* */
3/* Copyright (c) 1997-98 Richard Tobin, Language Technology Group, HCRC, */
4/* University of Edinburgh. */
5/* */
6/* THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, */
7/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
8/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
9/* IN NO EVENT SHALL THE AUTHOR OR THE UNIVERSITY OF EDINBURGH BE LIABLE */
10/* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF */
11/* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION */
12/* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
13/* */
14/*************************************************************************/
15#ifndef DTD_H
16#define DTD_H
17
18#ifndef FOR_LT
19#define XML_API
20#endif
21
22#include "charset.h"
23
24/* Typedefs */
25
26typedef struct dtd *Dtd;
27
28typedef struct entity *Entity;
29
30typedef struct element_definition *ElementDefinition;
31
32typedef struct attribute_definition *AttributeDefinition;
33AttributeDefinition NextAttributeDefinition(ElementDefinition element,
34 AttributeDefinition previous);
35
36typedef struct notation_definition *NotationDefinition;
37
38/* DTDs */
39
40struct dtd {
41 const Char *name; /* The doctype name */
42 Entity internal_part, external_part;
43 Entity entities;
44 Entity parameter_entities;
45 Entity predefined_entities;
46#ifdef FOR_LT
47 NSL_Doctype_I *doctype;
48#else
49 ElementDefinition elements;
50#endif
51 NotationDefinition notations;
52};
53
54/* Entities */
55
56enum entity_type {ET_external, ET_internal};
57typedef enum entity_type EntityType;
58
59enum markup_language {ML_xml, ML_nsl, ML_unspecified};
60typedef enum markup_language MarkupLanguage;
61
62enum standalone_declaration {
63 /* NB must match NSL's rmdCode */
64 SDD_unspecified, SDD_no, SDD_yes, SDD_enum_count
65};
66typedef enum standalone_declaration StandaloneDeclaration;
67
68extern const char8 *StandaloneDeclarationName[SDD_enum_count];
69
70
71struct entity {
72 /* All entities */
73
74 const Char *name; /* The name in the entity declaration */
75 EntityType type; /* ET_external or ET_internal */
76 const char8 *base_url; /* If different from expected */
77 struct entity *next; /* For chaining a document's entity defns */
78 CharacterEncoding encoding; /* The character encoding of the entity */
79 Entity parent; /* The entity in which it is defined */
80 const char8 *url; /* URL of entity */
81
82 /* Internal entities */
83
84 const Char *text; /* Text of the entity */
85 int line_offset; /* Line offset of definition */
86 int line1_char_offset; /* Char offset on first line */
87 int matches_parent_text; /* False if might contain expanded PEs */
88
89 /* External entities */
90
91 const char8 *systemid; /* Declared public ID */
92 const char8 *publicid; /* Declared public ID */
93 NotationDefinition notation; /* Binary entity's declared notation */
94 MarkupLanguage ml_decl; /* XML, NSL or not specified */
95 const char8 *version_decl; /* XML declarations found in entity, if any */
96 CharacterEncoding encoding_decl;
97 StandaloneDeclaration standalone_decl;
98 const char8 *ddb_filename; /* filename in NSL declaration */
99};
100
101/* Elements */
102
103enum content_type {
104 /* NB this must match NSL's ctVals */
105 CT_mixed, CT_any, CT_bogus1, CT_bogus2, CT_empty, CT_element, CT_enum_count
106};
107typedef enum content_type ContentType;
108
109extern XML_API const char8 *ContentTypeName[CT_enum_count];
110
112 const Char *name; /* The element name */
113 int namelen;
114 int tentative;
115#ifdef FOR_LT
116 NSL_Doctype_I *doctype;
117 NSL_ElementSummary_I *elsum;
118#else
119 ContentType type; /* The declared content */
120 Char *content; /* Element content */
121 AttributeDefinition attributes;
122 struct element_definition *next;
123#endif
124};
125
126/* Attributes */
127
128enum default_type {
129 /* NB this must match NSL's NSL_ADefType */
130 DT_required, DT_bogus1, DT_implied,
131 DT_bogus2, DT_none, DT_fixed, DT_enum_count
132};
133typedef enum default_type DefaultType;
134
135extern XML_API const char8 *DefaultTypeName[DT_enum_count];
136
137enum attribute_type {
138 /* NB this must match NSL's NSL_Attr_Dec_Value */
139 AT_cdata, AT_bogus1, AT_bogus2, AT_nmtoken, AT_bogus3, AT_entity,
140 AT_idref, AT_bogus4, AT_bogus5, AT_nmtokens, AT_bogus6, AT_entities,
141 AT_idrefs, AT_id, AT_notation, AT_enumeration, AT_enum_count
142};
143typedef enum attribute_type AttributeType;
144
145extern XML_API const char8 *AttributeTypeName[AT_enum_count];
146
148#ifdef FOR_LT
149 /* NB this must match NSL's AttributeSummary */
150 /* We never really have one of these structures; only an AttributeSummary
151 cast to this type. We need to be able to access the type, so that
152 we can normalise if appropriate. We need to be able to refer to
153 the default_type and default_value, but these don't need to work
154 since we will never have ReturnDefaultedAttributes true in NSL. */
155 int a, b, c;
156 short d;
157 char type, default_type;
158 /* This had better never be accessed! */
159 Char *default_value;
160#else
161 const Char *name; /* The attribute name */
162 int namelen;
163 AttributeType type; /* The declared type */
164 Char **allowed_values; /* List of allowed values, argv style */
165 DefaultType default_type; /* The type of the declared default */
166 const Char *default_value; /* The declared default value */
167 struct attribute_definition *next;
168#endif
169};
170
171/* Notations */
172
174 const Char *name; /* The notation name */
175 int tentative;
176 const char8 *systemid; /* System identifier */
177 const char8 *publicid; /* Public identifier */
178 struct notation_definition *next;
179};
180
181/* Public functions */
182
183XML_API Dtd NewDtd(void);
184XML_API void FreeDtd(Dtd dtd);
185
186XML_API Entity NewExternalEntityN(const Char *name, int namelen,
187 const char8 *publicid, const char8 *systemid,
188 NotationDefinition notation,
189 Entity parent);
190XML_API Entity NewInternalEntityN(const Char *name, int namelen,
191 const Char *text, Entity parent,
192 int line_offset, int line1_char_offset,
193 int matches_parent_text);
194XML_API void FreeEntity(Entity e);
195
196XML_API const char8 *EntityURL(Entity e);
197XML_API const char8 *EntityDescription(Entity e);
198XML_API void EntitySetBaseURL(Entity e, const char8 *url);
199XML_API const char8 *EntityBaseURL(Entity e);
200
201XML_API Entity DefineEntity(Dtd dtd, Entity entity, int pe);
202XML_API Entity FindEntityN(Dtd dtd, const Char *name, int namelen, int pe);
203
204#define NewExternalEntity(name, pub, sys, nnot, parent) \
205 NewExternalEntityN(name, name ? Strlen(name) : 0, pub, sys, nnot, parent)
206#define NewInternalEntity(name, test, parent, l, l1, mat) \
207 NewInternalEntityN(name, name ? Strlen(name) : 0, test, parent, l, l1, mat)
208#define FindEntity(dtd, name, pe) FindEntityN(dtd, name, Strlen(name), pe)
209
210XML_API ElementDefinition DefineElementN(Dtd dtd, const Char *name, int namelen,
211 ContentType type, Char *content);
212XML_API ElementDefinition TentativelyDefineElementN(Dtd dtd,
213 const Char *name, int namelen);
214XML_API ElementDefinition RedefineElement(ElementDefinition e, ContentType type,
215 Char *content);
216XML_API ElementDefinition FindElementN(Dtd dtd, const Char *name, int namelen);
217XML_API void FreeElementDefinition(ElementDefinition e);
218
219#define DefineElement(dtd, name, type, content) \
220 DefineElementN(dtd, name, Strlen(name), type, content)
221#define TentativelyDefineElement(dtd, name) \
222 TentativelyDefineElementN(dtd, name, Strlen(name))
223#define FindElement(dtd, name) FindElementN(dtd, name, Strlen(name))
224
225XML_API AttributeDefinition DefineAttributeN(ElementDefinition element,
226 const Char *name, int namelen,
227 AttributeType type, Char **allowed_values,
228 DefaultType default_type,
229 const Char *default_value);
230XML_API AttributeDefinition FindAttributeN(ElementDefinition element,
231 const Char *name, int namelen);
232XML_API void FreeAttributeDefinition(AttributeDefinition a);
233
234#define DefineAttribute(element, name, type, all, dt, dv) \
235 DefineAttributeN(element, name, Strlen(name), type, all, dt, dv)
236#define FindAttribute(element, name) \
237 FindAttributeN(element, name, Strlen(name))
238
239XML_API NotationDefinition DefineNotationN(Dtd dtd, const Char *name, int namelen,
240 const char8 *publicid, const char8 *systemid);
241XML_API NotationDefinition TentativelyDefineNotationN(Dtd dtd,
242 const Char *name, int namelen);
243XML_API NotationDefinition RedefineNotation(NotationDefinition n,
244 const char8 *publicid, const char8 *systemid);
245XML_API NotationDefinition FindNotationN(Dtd dtd, const Char *name, int namelen);
246XML_API void FreeNotationDefinition(NotationDefinition n);
247
248#define DefineNotation(dtd, name, pub, sys) \
249 DefineNotationN(dtd, name, Strlen(name), pub, sys)
250#define TentativelyDefineNotation(dtd, name) \
251 TentativelyDefineNotationN(dtd, name, Strlen(name))
252#define FindNotation(dtd, name) FindNotationN(dtd, name, Strlen(name))
253
254#endif /* DTD_H */
Definition dtd.h:40
Definition dtd.h:71