Edinburgh Speech Tools  2.1-release
xmlparser.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 /* $Id: xmlparser.h,v 1.2 2001/04/04 13:11:27 awb Exp $ */
16 
17 #ifndef XMLPARSER_H
18 #define XMLPARSER_H
19 
20 #include "dtd.h"
21 #include "input.h"
22 
23 /* Typedefs */
24 
25 typedef struct parser_state *Parser;
26 typedef struct attribute *Attribute;
27 typedef struct content_particle *ContentParticle;
28 typedef struct xbit *XBit;
29 typedef void CallbackProc(XBit bit, void *arg);
30 typedef InputSource EntityOpenerProc(Entity e, void *arg);
31 
32 /* Bits */
33 
34 enum xbit_type {
40 };
41 typedef enum xbit_type XBitType;
42 
44 
45 struct attribute {
46  AttributeDefinition definition; /* The definition of this attribute */
47  Char *value; /* The (possibly normalised) value */
48  int quoted; /* Was it quoted? */
49  struct attribute *next; /* The next attribute or null */
50 };
51 
52 enum cp_type {
54 };
55 typedef enum cp_type CPType;
56 
58  enum cp_type type;
60  Char *name;
61  int nchildren;
63 };
64 
65 struct xbit {
66  Entity entity;
68  enum xbit_type type;
69  char8 *s1, *s2;
70  Char *S1, *S2;
71  int i1, i2;
72  Attribute attributes;
73  ElementDefinition element_definition;
74 #ifndef FOR_LT
75  int nchildren;
76  struct xbit *parent;
77  struct xbit **children;
78 #endif
79 };
80 
81 #define pcdata_chars S1
82 
83 #define pi_name S1
84 #define pi_chars S2
85 
86 #define comment_chars S1
87 
88 #define cdsect_chars S1
89 
90 #define xml_version s1
91 #define xml_encoding_name s2
92 #define xml_standalone i1
93 #define xml_encoding i2
94 
95 #define error_message s1
96 
97 /* Parser flags */
98 
127 };
128 typedef enum parser_flag ParserFlag;
129 
130 /* Parser */
131 
134 
135 struct element_info {
136  ElementDefinition definition;
137  Entity entity;
138 };
139 
140 struct parser_state {
141  enum parse_state state;
143  int have_dtd; /* True if dtd has been processed */
146  Char *name, *pbuf;
147  int namelen, pbufsize, pbufnext;
148  struct xbit xbit;
149  int peeked;
150  Dtd dtd; /* The document's DTD */
154  unsigned int flags;
159  int external_pe_depth; /* To keep track of whether we're in the */
160  /* internal subset: 0 <=> yes */
161 };
162 
163 XML_API int ParserInit(void);
164 XML_API Parser NewParser(void);
165 XML_API void FreeParser(Parser p);
166 
167 XML_API Entity ParserRootEntity(Parser p);
168 XML_API InputSource ParserRootSource(Parser p);
169 
170 XML_API XBit ReadXBit(Parser p);
171 XML_API XBit PeekXBit(Parser p);
172 XML_API void FreeXBit(XBit xbit);
173 
174 #ifndef FOR_LT
175 XBit ReadXTree(Parser p);
176 void FreeXTree(XBit tree);
177 #endif
178 
179 XML_API XBit ParseDtd(Parser p, Entity e);
180 
182 XML_API void ParserSetDtdCallback(Parser p, CallbackProc cb);
183 XML_API void ParserSetEntityOpener(Parser p, EntityOpenerProc opener);
184 XML_API void ParserSetCallbackArg(Parser p, void *arg);
185 
186 XML_API int ParserPush(Parser p, InputSource source);
187 XML_API void ParserPop(Parser p);
188 
189 XML_API void ParserSetFlag(Parser p, ParserFlag flag, int value);
190 #define ParserGetFlag(p, flag) ((p)->flags & (1 << (flag)))
191 
192 XML_API void ParserPerror(Parser p, XBit bit);
193 
194 #endif /* XMLPARSER_H */
XML_API XBit ParseDtd(Parser p, Entity e)
Definition: xmlparser.c:1986
int byte_offset
Definition: xmlparser.h:67
Char * value
Definition: xmlparser.h:47
struct input_source * source
Definition: xmlparser.h:145
CallbackProc * warning_callback
Definition: xmlparser.h:152
int i2
Definition: xmlparser.h:71
InputSource source
Definition: rxp.c:24
ElementDefinition definition
Definition: xmlparser.h:136
struct xbit * parent
Definition: xmlparser.h:76
struct attribute * next
Definition: xmlparser.h:49
InputSource EntityOpenerProc(Entity e, void *arg)
Definition: xmlparser.h:30
Definition: xmlparser.h:65
CallbackProc * dtd_callback
Definition: xmlparser.h:151
XBit ReadXTree(Parser p)
Definition: xmlparser.c:535
XML_API void ParserSetDtdCallback(Parser p, CallbackProc cb)
Definition: xmlparser.c:518
EntityOpenerProc * entity_opener
Definition: xmlparser.h:153
Attribute attributes
Definition: xmlparser.h:72
XML_API void ParserSetWarningCallback(Parser p, CallbackProc cb)
Definition: xmlparser.c:523
XML_API void ParserPerror(Parser p, XBit bit)
Definition: xmlparser.c:772
int nchildren
Definition: xmlparser.h:75
void CallbackProc(XBit bit, void *arg)
Definition: xmlparser.h:29
Entity entity
Definition: xmlparser.h:66
XML_API int ParserInit(void)
Definition: xmlparser.c:137
int external_pe_depth
Definition: xmlparser.h:159
Entity entity
Definition: xmlparser.h:137
Char * S2
Definition: xmlparser.h:70
void FreeXTree(XBit tree)
Definition: xmlparser.c:613
Entity document_entity
Definition: xmlparser.h:142
XML_API void ParserPop(Parser p)
Definition: xmlparser.c:711
#define XML_API
Definition: dtd.h:19
XML_API int ParserPush(Parser p, InputSource source)
Definition: xmlparser.c:656
cp_type
Definition: xmlparser.h:52
StandaloneDeclaration standalone
Definition: xmlparser.h:144
parser_flag
Definition: xmlparser.h:99
parse_state
Definition: xmlparser.h:132
XML_API Parser NewParser(void)
Definition: xmlparser.c:432
AttributeDefinition definition
Definition: xmlparser.h:46
XML_API void ParserSetFlag(Parser p, ParserFlag flag, int value)
Definition: xmlparser.c:756
void * callback_arg
Definition: xmlparser.h:158
enum standalone_declaration StandaloneDeclaration
Definition: dtd.h:66
XML_API XBit PeekXBit(Parser p)
Definition: xmlparser.c:643
char8 * s2
Definition: xmlparser.h:69
XML_API InputSource ParserRootSource(Parser p)
Definition: xmlparser.c:498
XML_API void FreeParser(Parser p)
Definition: xmlparser.c:488
unsigned int flags
Definition: xmlparser.h:154
enum xbit_type XBitType
Definition: xmlparser.h:41
struct content_particle ** children
Definition: xmlparser.h:62
int element_depth
Definition: xmlparser.h:157
ElementDefinition element_definition
Definition: xmlparser.h:73
XML_API Entity ParserRootEntity(Parser p)
Definition: xmlparser.c:508
Char * pbuf
Definition: xmlparser.h:146
xbit_type
Definition: xmlparser.h:34
enum parser_flag ParserFlag
Definition: xmlparser.h:128
XML_API void ParserSetCallbackArg(Parser p, void *arg)
Definition: xmlparser.c:513
char char8
Definition: charset.h:31
int tree
Definition: rxp.c:21
struct element_info * element_stack
Definition: xmlparser.h:155
enum cp_type CPType
Definition: xmlparser.h:55
XML_API const char8 * XBitTypeName[XBIT_enum_count]
Definition: xmlparser.c:118
int quoted
Definition: xmlparser.h:48
XML_API XBit ReadXBit(Parser p)
Definition: xmlparser.c:633
int element_stack_alloc
Definition: xmlparser.h:156
struct xbit ** children
Definition: xmlparser.h:77
XML_API void ParserSetEntityOpener(Parser p, EntityOpenerProc opener)
Definition: xmlparser.c:528
XML_API void FreeXBit(XBit xbit)
Definition: xmlparser.c:300