91 inside_attribute_container,
93 inside_attribute_value,
94 inside_other_xml_attribute,
120 char d_parse_buffer[D4_PARSE_BUFF_SIZE+1];
122 xmlSAXHandler d_dmr_sax_parser;
127 DMR *dmr()
const {
return d_dmr; }
131 void push_state(D4ParserSax2::ParseState state) { s.push(state); }
132 D4ParserSax2::ParseState get_state()
const {
return s.top(); }
133 void pop_state() { s.pop(); }
134 bool empty_state()
const {
return s.empty(); }
136 stack<BaseType*> btp_stack;
137 void push_basetype(
BaseType *btp) { btp_stack.push(btp); }
138 BaseType *top_basetype()
const {
return btp_stack.top(); }
139 void pop_basetype() { btp_stack.pop(); }
140 bool empty_basetype()
const {
return btp_stack.empty(); }
142 stack<D4Group*> grp_stack;
143 void push_group(
D4Group *grp) { grp_stack.push(grp); }
144 D4Group *top_group()
const {
return grp_stack.top(); }
145 void pop_group() { grp_stack.pop(); }
146 bool empty_group()
const {
return grp_stack.empty(); }
148 stack<D4Attributes*> d_attrs_stack;
149 void push_attributes(
D4Attributes *attr) { d_attrs_stack.push(attr); }
150 D4Attributes *top_attributes()
const {
return d_attrs_stack.top(); }
151 void pop_attributes() { d_attrs_stack.pop(); }
152 bool empty_attributes()
const {
return d_attrs_stack.empty(); }
156 void clear_enum_def() { d_enum_def = 0; }
160 void clear_dim_def() { d_dim_def = 0; }
167 unsigned int other_xml_depth;
168 unsigned int unknown_depth;
172 xmlParserCtxtPtr d_context;
175 string dods_attr_name;
176 string dods_attr_type;
181 bool debug()
const {
return d_debug; }
191 void clone(
const XMLAttribute &src) {
197 XMLAttribute() : prefix(
""), nsURI(
""), value(
"") {}
198 XMLAttribute(
const string &p,
const string &ns,
const string &v)
199 : prefix(p), nsURI(ns), value(v) {}
202 XMLAttribute(
const xmlChar **attributes) {
203 prefix = attributes[0] != 0 ? (
const char *)attributes[0]:
"";
204 nsURI = attributes[1] != 0 ? (
const char *)attributes[1]:
"";
205 value = string((
const char *)attributes[2], (
const char *)attributes[3]);
207 XMLAttribute(
const XMLAttribute &rhs) {
210 XMLAttribute &operator=(
const XMLAttribute &rhs) {
218 typedef map<string, XMLAttribute> XMLAttrMap;
219 XMLAttrMap xml_attrs;
221 XMLAttrMap::iterator xml_attr_begin() {
return xml_attrs.begin(); }
223 XMLAttrMap::iterator xml_attr_end() {
return xml_attrs.end(); }
225 map<string, string> namespace_table;
227 void cleanup_parse();
235 void transfer_xml_attrs(
const xmlChar **attrs,
int nb_attributes);
236 void transfer_xml_ns(
const xmlChar **namespaces,
int nb_namespaces);
237 bool check_required_attribute(
const string &attr);
238 bool check_attribute(
const string & attr);
239 void process_variable_helper(
Type t, ParseState s,
const xmlChar **attrs,
int nb_attributes);
241 void process_enum_const_helper(
const xmlChar **attrs,
int nb_attributes);
242 void process_enum_def_helper(
const xmlChar **attrs,
int nb_attributes);
244 bool process_dimension(
const char *name,
const xmlChar **attrs,
int nb_attrs);
245 bool process_dimension_def(
const char *name,
const xmlChar **attrs,
int nb_attrs);
246 bool process_map(
const char *name,
const xmlChar **attrs,
int nb_attributes);
247 bool process_attribute(
const char *name,
const xmlChar **attrs,
int nb_attributes);
248 bool process_variable(
const char *name,
const xmlChar **attrs,
int nb_attributes);
249 bool process_group(
const char *name,
const xmlChar **attrs,
int nb_attributes);
250 bool process_enum_def(
const char *name,
const xmlChar **attrs,
int nb_attributes);
251 bool process_enum_const(
const char *name,
const xmlChar **attrs,
int nb_attributes);
253 void finish_variable(
const char *tag,
Type t,
const char *expected);
256 friend class D4ParserSax2Test;
260 d_dmr(0), d_enum_def(0), d_dim_def(0),
261 other_xml(
""), other_xml_depth(0), unknown_depth(0),
262 d_error_msg(
""), d_context(0),
263 dods_attr_name(
""), dods_attr_type(
""),
264 char_data(
""), root_ns(
""), d_debug(
false), d_strict(
true)
267 memset(&d_dmr_sax_parser, 0,
sizeof(xmlSAXHandler));
275 d_dmr_sax_parser.warning = &D4ParserSax2::dmr_error;
276 d_dmr_sax_parser.error = &D4ParserSax2::dmr_error;
278 d_dmr_sax_parser.initialized = XML_SAX2_MAGIC;
280 d_dmr_sax_parser.endElementNs = &D4ParserSax2::dmr_end_element;
283 void intern(istream &f,
DMR *dest_dmr,
bool debug =
false);
285 void intern(
const string &document,
DMR *dest_dmr,
bool debug =
false);
286 void intern(
const char *buffer,
int size,
DMR *dest_dmr,
bool debug =
false);
311 const xmlChar *localname,
const xmlChar *prefix,
const xmlChar *URI,
312 int nb_namespaces,
const xmlChar **namespaces,
int nb_attributes,
313 int nb_defaulted,
const xmlChar **attributes);
314 static void dmr_end_element(
void *parser,
const xmlChar *localname,
315 const xmlChar *prefix,
const xmlChar *URI);
319 const xmlChar * ch,
int len);
320 static void dmr_get_cdata(
void *parser,
const xmlChar *value,
int len);
322 static xmlEntityPtr
dmr_get_entity(
void *parser,
const xmlChar *name);
324 static void dmr_error(
void *parser,
const char *msg, ...);
static void dmr_start_element(void *parser, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI, int nb_namespaces, const xmlChar **namespaces, int nb_attributes, int nb_defaulted, const xmlChar **attributes)