40 #include "EST_error.h"
41 #include "XML_Parser.h"
50 known_ids.
add_item(id_pattern, directory);
57 for(p=known_ids.
head(); p != 0; p= p->next())
69 return new XML_Parser(*
this, source, ent, data);
74 return new XML_Parser(*
this, source, NULL, data);
82 Entity ent = NewExternalEntity(0,0,strdup8(desc),0,0);
84 FILE16 *input16=MakeFILE16FromFILE(input,
"r");
87 EST_sys_error(
"Can't open 16 bit '%s'", (
const char *)desc);
89 SetCloseUnderlying(input16, 0);
91 return make_parser(NewInputSource(ent, input16), ent, data);
105 if ( filename ==
"-" )
108 FILE *input = fopen(filename,
"r");
111 EST_sys_error(
"Can't open '%s'", (
const char *)filename);
113 Entity ent = NewExternalEntity(0,0,strdup8(filename),0,0);
115 FILE16 *input16=MakeFILE16FromFILE(input,
"r");
118 EST_sys_error(
"Can't open 16 bit '%s'", (
const char *)filename);
120 SetCloseUnderlying(input16, 1);
122 return make_parser(NewInputSource(ent, input16), data);
128 EST_String id = ent->publicid?ent->publicid:ent->systemid;
131 int starts[EST_Regex_max_subexpressions];
132 int ends[EST_Regex_max_subexpressions];
133 for (p = known_ids.
head(); p != 0; p = p->next())
138 if (
id.matches(re, 0, starts, ends))
141 res.
subst(
id, starts, ends);
145 if((f = fopen(res,
"r")))
147 if(!(f16 = MakeFILE16FromFILE(f,
"r")))
149 SetCloseUnderlying(f16, 1);
151 return NewInputSource(ent, f16);
156 return EntityOpen(ent);
164 return parser->
open(ent);
172 { (void)c; (void)p; (void)data; }
177 { (void)c; (void)p; (void)data; }
184 { (void)c; (void)p; (void)data; (void)name; (void)attributes; }
191 { (void)c; (void)p; (void)data; (void)name; (void)attributes;
200 { (void)c; (void)p; (void)data; (void)name; }
206 { (void)c; (void)p; (void)data; (void)chars; }
212 { (void)c; (void)p; (void)data; (void)chars; }
217 const char *instruction)
218 { (void)c; (void)p; (void)data; (void)instruction; }
223 { (void)c; (void)p; (void)data; }
257 ParserSetFlag(
p, ReturnDefaultedAttributes, 1);
258 ParserSetCallbackArg(
p, (
void *)
this);
280 if (ParserPush(
p,
source) == -1)
281 EST_error(
"XML Parser error in push");
289 if (bit->type == XBIT_eof)
291 else if (bit->type == XBIT_start || bit->type == XBIT_empty)
296 for (b=bit->attributes; b; b=b->next)
301 if (bit->type == XBIT_start)
306 bit->element_definition->name,
320 bit->element_definition->name,
324 else if (bit->type == XBIT_end)
332 bit->element_definition->name
335 else if (bit->type == XBIT_pcdata)
343 else if (bit->type == XBIT_cdsect)
351 else if (bit->type == XBIT_pi)
359 else if (bit->type == XBIT_error)
385 p_track_context=flag;
390 p_track_contents=flag;
397 int linenum, charnum;
402 return "No Parse In Progress";
406 bit->type == XBIT_error ?
"Error" :
"Warning",
408 bit->error_message?bit->error_message:
"non XML error"
411 for(s=
p->source; s; s=s->parent)
415 p_error_message +=
" in entity \"";
416 p_error_message += s->entity->name;
417 p_error_message +=
"\"";
420 p_error_message +=
" in unnamed entity";
422 switch(SourceLineAndChar(s, &linenum, &charnum))
439 p_error_message +=
" defined in ";
443 p_error_message += EntityDescription(s->entity);
444 p_error_message +=
"\n";
447 return (
const char *)p_error_message;