Edinburgh Speech Tools  2.1-release
dtd.h
Go to the documentation of this file.
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 
26 typedef struct dtd *Dtd;
27 
28 typedef struct entity *Entity;
29 
30 typedef struct element_definition *ElementDefinition;
31 
32 typedef struct attribute_definition *AttributeDefinition;
33 AttributeDefinition NextAttributeDefinition(ElementDefinition element,
34  AttributeDefinition previous);
35 
36 typedef struct notation_definition *NotationDefinition;
37 
38 /* DTDs */
39 
40 struct dtd {
41  const Char *name; /* The doctype name */
43  Entity 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 
57 typedef enum entity_type EntityType;
58 
61 
63  /* NB must match NSL's rmdCode */
65 };
67 
69 
70 
71 struct 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 */
98  const char8 *ddb_filename; /* filename in NSL declaration */
99 };
100 
101 /* Elements */
102 
104  /* NB this must match NSL's ctVals */
106 };
108 
110 
112  const Char *name; /* The element name */
113  int namelen;
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;
123 #endif
124 };
125 
126 /* Attributes */
127 
129  /* NB this must match NSL's NSL_ADefType */
132 };
134 
136 
138  /* NB this must match NSL's NSL_Attr_Dec_Value */
142 };
144 
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 */
168 #endif
169 };
170 
171 /* Notations */
172 
174  const Char *name; /* The notation name */
176  const char8 *systemid; /* System identifier */
177  const char8 *publicid; /* Public identifier */
179 };
180 
181 /* Public functions */
182 
183 XML_API Dtd NewDtd(void);
184 XML_API void FreeDtd(Dtd dtd);
185 
186 XML_API Entity NewExternalEntityN(const Char *name, int namelen,
187  const char8 *publicid, const char8 *systemid,
188  NotationDefinition notation,
189  Entity parent);
190 XML_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);
194 XML_API void FreeEntity(Entity e);
195 
196 XML_API const char8 *EntityURL(Entity e);
197 XML_API const char8 *EntityDescription(Entity e);
198 XML_API void EntitySetBaseURL(Entity e, const char8 *url);
199 XML_API const char8 *EntityBaseURL(Entity e);
200 
201 XML_API Entity DefineEntity(Dtd dtd, Entity entity, int pe);
202 XML_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 
210 XML_API ElementDefinition DefineElementN(Dtd dtd, const Char *name, int namelen,
211  ContentType type, Char *content);
212 XML_API ElementDefinition TentativelyDefineElementN(Dtd dtd,
213  const Char *name, int namelen);
214 XML_API ElementDefinition RedefineElement(ElementDefinition e, ContentType type,
215  Char *content);
216 XML_API ElementDefinition FindElementN(Dtd dtd, const Char *name, int namelen);
217 XML_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 
225 XML_API AttributeDefinition DefineAttributeN(ElementDefinition element,
226  const Char *name, int namelen,
227  AttributeType type, Char **allowed_values,
229  const Char *default_value);
230 XML_API AttributeDefinition FindAttributeN(ElementDefinition element,
231  const Char *name, int namelen);
232 XML_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 
239 XML_API NotationDefinition DefineNotationN(Dtd dtd, const Char *name, int namelen,
240  const char8 *publicid, const char8 *systemid);
241 XML_API NotationDefinition TentativelyDefineNotationN(Dtd dtd,
242  const Char *name, int namelen);
243 XML_API NotationDefinition RedefineNotation(NotationDefinition n,
244  const char8 *publicid, const char8 *systemid);
245 XML_API NotationDefinition FindNotationN(Dtd dtd, const Char *name, int namelen);
246 XML_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 */
attribute_type
Definition: dtd.h:137
Entity parent
Definition: dtd.h:79
struct attribute_definition * next
Definition: dtd.h:167
const char8 * ddb_filename
Definition: dtd.h:98
XML_API AttributeDefinition DefineAttributeN(ElementDefinition element, const Char *name, int namelen, AttributeType type, Char **allowed_values, DefaultType default_type, const Char *default_value)
Definition: dtd.c:582
XML_API void EntitySetBaseURL(Entity e, const char8 *url)
Definition: dtd.c:317
markup_language
Definition: dtd.h:59
const Char * name
Definition: dtd.h:112
entity_type
Definition: dtd.h:56
XML_API const char8 * DefaultTypeName[DT_enum_count]
Definition: dtd.c:37
struct entity * next
Definition: dtd.h:77
AttributeType type
Definition: dtd.h:163
const Char * default_value
Definition: dtd.h:166
XML_API void FreeDtd(Dtd dtd)
Definition: dtd.c:118
XML_API void FreeEntity(Entity e)
Definition: dtd.c:250
ContentType type
Definition: dtd.h:119
XML_API void FreeElementDefinition(ElementDefinition e)
Definition: dtd.c:542
Entity entities
Definition: dtd.h:43
Char ** allowed_values
Definition: dtd.h:164
XML_API const char8 * ContentTypeName[CT_enum_count]
Definition: dtd.c:46
Definition: dtd.h:140
Entity external_part
Definition: dtd.h:42
Definition: dtd.h:59
MarkupLanguage ml_decl
Definition: dtd.h:94
default_type
Definition: dtd.h:128
const Char * text
Definition: dtd.h:84
const Char * name
Definition: dtd.h:174
standalone_declaration
Definition: dtd.h:62
const char8 * base_url
Definition: dtd.h:76
CharacterEncoding encoding_decl
Definition: dtd.h:96
Definition: dtd.h:141
const Char * name
Definition: dtd.h:74
Definition: dtd.h:139
Definition: dtd.h:140
Definition: dtd.h:40
Entity internal_part
Definition: dtd.h:42
struct notation_definition * next
Definition: dtd.h:178
Definition: dtd.h:71
XML_API const char8 * EntityDescription(Entity e)
Definition: dtd.c:303
XML_API Entity NewExternalEntityN(const Char *name, int namelen, const char8 *publicid, const char8 *systemid, NotationDefinition notation, Entity parent)
Definition: dtd.c:182
enum attribute_type AttributeType
Definition: dtd.h:143
Definition: dtd.h:131
XML_API Entity DefineEntity(Dtd dtd, Entity entity, int pe)
Definition: dtd.c:338
enum entity_type EntityType
Definition: dtd.h:57
Definition: dtd.h:139
int line_offset
Definition: dtd.h:85
Definition: dtd.h:131
XML_API ElementDefinition DefineElementN(Dtd dtd, const Char *name, int namelen, ContentType type, Char *content)
Definition: dtd.c:378
Definition: dtd.h:105
const char8 * StandaloneDeclarationName[SDD_enum_count]
Definition: dtd.c:74
#define XML_API
Definition: dtd.h:19
NotationDefinition notations
Definition: dtd.h:51
Definition: dtd.h:141
EntityType type
Definition: dtd.h:75
Definition: dtd.h:105
XML_API Dtd NewDtd(void)
Definition: dtd.c:93
StandaloneDeclaration standalone_decl
Definition: dtd.h:97
enum content_type ContentType
Definition: dtd.h:107
XML_API ElementDefinition TentativelyDefineElementN(Dtd dtd, const Char *name, int namelen)
Definition: dtd.c:430
XML_API NotationDefinition DefineNotationN(Dtd dtd, const Char *name, int namelen, const char8 *publicid, const char8 *systemid)
Definition: dtd.c:712
Char * content
Definition: dtd.h:120
AttributeDefinition NextAttributeDefinition(ElementDefinition element, AttributeDefinition previous)
Definition: dtd.c:661
XML_API void FreeNotationDefinition(NotationDefinition n)
Definition: dtd.c:779
XML_API const char8 * AttributeTypeName[AT_enum_count]
Definition: dtd.c:55
struct element_definition * next
Definition: dtd.h:122
enum default_type DefaultType
Definition: dtd.h:133
const Char * name
Definition: dtd.h:41
enum standalone_declaration StandaloneDeclaration
Definition: dtd.h:66
XML_API NotationDefinition FindNotationN(Dtd dtd, const Char *name, int namelen)
Definition: dtd.c:768
const char8 * version_decl
Definition: dtd.h:95
NotationDefinition notation
Definition: dtd.h:93
Entity predefined_entities
Definition: dtd.h:45
const char8 * publicid
Definition: dtd.h:92
Definition: dtd.h:131
Definition: dtd.h:59
Definition: dtd.h:140
Definition: dtd.h:105
Definition: dtd.h:64
XML_API Entity FindEntityN(Dtd dtd, const Char *name, int namelen, int pe)
Definition: dtd.c:354
const char8 * publicid
Definition: dtd.h:177
const char8 * systemid
Definition: dtd.h:176
DefaultType default_type
Definition: dtd.h:165
int matches_parent_text
Definition: dtd.h:87
Definition: dtd.h:105
Definition: dtd.h:139
Definition: dtd.h:139
int line1_char_offset
Definition: dtd.h:86
enum character_encoding CharacterEncoding
Definition: charset.h:61
const char8 * systemid
Definition: dtd.h:91
XML_API ElementDefinition RedefineElement(ElementDefinition e, ContentType type, Char *content)
Definition: dtd.c:470
XML_API void FreeAttributeDefinition(AttributeDefinition a)
Definition: dtd.c:676
AttributeDefinition attributes
Definition: dtd.h:121
Definition: dtd.h:130
XML_API ElementDefinition FindElementN(Dtd dtd, const Char *name, int namelen)
Definition: dtd.c:495
content_type
Definition: dtd.h:103
XML_API const char8 * EntityBaseURL(Entity e)
Definition: dtd.c:322
CharacterEncoding encoding
Definition: dtd.h:78
Definition: dtd.h:64
char char8
Definition: charset.h:31
XML_API const char8 * EntityURL(Entity e)
Definition: dtd.c:275
Definition: dtd.h:140
enum markup_language MarkupLanguage
Definition: dtd.h:60
XML_API NotationDefinition RedefineNotation(NotationDefinition n, const char8 *publicid, const char8 *systemid)
Definition: dtd.c:758
Definition: dtd.h:139
const Char * name
Definition: dtd.h:161
const char8 * url
Definition: dtd.h:80
EST_Item * parent(const EST_Item *n)
return parent of n
XML_API AttributeDefinition FindAttributeN(ElementDefinition element, const Char *name, int namelen)
Definition: dtd.c:637
XML_API NotationDefinition TentativelyDefineNotationN(Dtd dtd, const Char *name, int namelen)
Definition: dtd.c:735
Definition: dtd.h:105
Entity parameter_entities
Definition: dtd.h:44
ElementDefinition elements
Definition: dtd.h:49
XML_API Entity NewInternalEntityN(const Char *name, int namelen, const Char *text, Entity parent, int line_offset, int line1_char_offset, int matches_parent_text)
Definition: dtd.c:216