44 #include "EST_error.h"
45 #include "EST_cutils.h"
46 #include "EST_cmd_line.h"
47 #include "EST_cmd_line_options.h"
48 #include "rxp/XML_Parser.h"
92 const char *instruction);
100 int main(
int argc,
char *argv[])
102 My_Parser_Class pclass;
111 "Summary: parse xml and output a tree.\n"
112 "use \"-\" to make input file stdin\n"
113 "-sysdir <string> Look for unqualified system entities in this directory"
117 switch (files.length())
119 case 0: filename=
"-";
121 case 1: filename=files.
first();
124 EST_error(
"Expected only one filename");
129 pclass.register_id(
"^\\([^/]*\\)",
130 al.
sval(
"-sysdir") +
"/\\1");
132 pclass.register_id(
"//CSTR//EST \\(.*\\)",
137 XML_Parser *parser = pclass.make_parser(filename,
149 for(them.
begin(attributes); them ; them++)
151 (
const char *)them->k,
152 (
const char *)them->v);
163 (void)print_attributes;
164 Parse_State *state = (Parse_State *)data;
168 printf(
"%*s document %d\n", state->depth*4,
">", state->depth);
176 Parse_State *state = (Parse_State *)data;
178 printf(
"%*s <document %d\n", state->depth*4,
">", state->depth);
188 (void)c; (void)p; (void)attributes;
189 Parse_State *state = (Parse_State *)data;
193 printf(
"%*s %s %d", state->depth*4,
">", name, state->depth);
194 print_attributes(attributes);
205 (void)c; (void)p; (void)attributes;
206 Parse_State *state = (Parse_State *)data;
208 printf(
"%*s %s %d", state->depth*4,
":", name, state->depth);
209 print_attributes(attributes);
220 Parse_State *state = (Parse_State *)data;
222 printf(
"%*s %s %d\n", state->depth*4,
"<", name, state->depth);
233 Parse_State *state = (Parse_State *)data;
235 printf(
"%*s [pcdata[%s]] %d\n", state->depth*4,
"", chars, state->depth);
245 Parse_State *state = (Parse_State *)data;
247 printf(
"%*s [cdata[%s]] %d\n", state->depth*4,
"", chars, state->depth);
254 const char *instruction)
257 Parse_State *state = (Parse_State *)data;
259 printf(
"%*s [proc[%s]] %d\n", state->depth*4,
"", instruction, state->depth);
268 Parse_State *state = (Parse_State *)data;
270 printf(
"%*s [error[%s]] %d\n", state->depth*4,
"", get_error(p), state->depth);
virtual void element_close(XML_Parser_Class &c, XML_Parser &p, void *data, const char *name)
virtual void pcdata(XML_Parser_Class &c, XML_Parser &p, void *data, const char *chars)
virtual void document_close(XML_Parser_Class &c, XML_Parser &p, void *data)
virtual void element_open(XML_Parser_Class &c, XML_Parser &p, void *data, const char *name, XML_Attribute_List &attributes)
A specialised hash table for when the key is an EST_String.
static EST_String cat(const EST_String s1, const EST_String s2=Empty, const EST_String s3=Empty, const EST_String s4=Empty, const EST_String s5=Empty, const EST_String s6=Empty, const EST_String s7=Empty, const EST_String s8=Empty, const EST_String s9=Empty)
const EST_String & sval(const EST_String &rkey, int m=1) const
virtual void element(XML_Parser_Class &c, XML_Parser &p, void *data, const char *name, XML_Attribute_List &attributes)
void error(XML_Parser_Class &c, XML_Parser &p, void *data, EST_String message)
const T & first() const
return const reference to first item in list
const int present(const K &rkey) const
Returns true if key is present.
virtual void cdata(XML_Parser_Class &c, XML_Parser &p, void *data, const char *chars)
void begin(const Container &over)
Set the iterator ready to run over this container.
virtual void error(XML_Parser_Class &c, XML_Parser &p, void *data)
virtual void processing(XML_Parser_Class &c, XML_Parser &p, void *data, const char *instruction)
virtual void document_open(XML_Parser_Class &c, XML_Parser &p, void *data)