34#include <libxml/parserInternals.h>
36#ifndef ddx_exceptions_h
48#ifndef base_type_factory_h
88 inside_attribute_container,
90 inside_attribute_value,
91 inside_other_xml_attribute,
113 xmlSAXHandler ddx_sax_parser;
119 stack<BaseType *> bt_stack;
120 stack<AttrTable *> at_stack;
127 unsigned int other_xml_depth;
128 unsigned int unknown_depth;
132 xmlParserCtxtPtr ctxt;
139 string dods_attr_name;
140 string dods_attr_type;
150 void clone(
const XMLAttribute &src) {
156 XMLAttribute() : prefix(
""), nsURI(
""), value(
"") {}
157 XMLAttribute(
const string &p,
const string &ns,
const string &v) : prefix(p), nsURI(ns), value(v) {}
160 XMLAttribute(
const xmlChar **attributes ) {
161 prefix = attributes[0] != 0 ? (
const char *)attributes[0] :
"";
162 nsURI = attributes[1] != 0 ? (
const char *)attributes[1] :
"";
163 value = string((
const char *)attributes[2], (
const char *)attributes[3]);
165 XMLAttribute(
const XMLAttribute &rhs) { clone(rhs); }
167 XMLAttribute &operator=(
const XMLAttribute &rhs) {
175 typedef map<string, XMLAttribute> XMLAttrMap;
176 XMLAttrMap attribute_table;
178 XMLAttrMap::iterator attr_table_begin() {
return attribute_table.begin(); }
180 XMLAttrMap::iterator attr_table_end() {
return attribute_table.end(); }
182 map<string, string> namespace_table;
185 void set_state(DDXParser::ParseState state);
186 DDXParser::ParseState get_state()
const;
196 void cleanup_parse();
204 void transfer_xml_attrs(
const xmlChar **attrs,
int nb_attributes);
205 void transfer_xml_ns(
const xmlChar **namespaces,
int nb_namespaces);
206 bool check_required_attribute(
const string &attr);
207 bool check_attribute(
const string &attr);
209 void process_attribute_element(
const xmlChar **attrs,
int nb_attrs);
210 void process_attribute_alias(
const xmlChar **attrs,
int nb_attrs);
212 void process_variable(
Type t, ParseState s,
const xmlChar **attrs,
int nb_attributes);
214 void process_dimension(
const xmlChar **attrs,
int nb_attrs);
215 void process_blob(
const xmlChar **attrs,
int nb_attrs);
217 bool is_attribute_or_alias(
const char *name,
const xmlChar **attrs,
int nb_attributes);
218 bool is_variable(
const char *name,
const xmlChar **attrs,
int nb_attributes);
220 void finish_variable(
const char *tag,
Type t,
const char *expected);
230 : d_factory(factory), other_xml(
""), other_xml_depth(0), unknown_depth(0), error_msg(
""), ctxt(0), dds(0),
231 blob_href(0), dods_attr_name(
""), dods_attr_type(
""), char_data(
""), root_ns(
"") {
232 memset(&ddx_sax_parser, 0,
sizeof(xmlSAXHandler));
243 ddx_sax_parser.initialized = XML_SAX2_MAGIC;
247 void intern(
const string &document,
DDS *dest_dds,
string &cid);
248 void intern_stream(FILE *in,
DDS *dds,
string &cid,
const string &boundary =
"");
249 void intern_stream(istream &in,
DDS *dds,
string &cid,
const string &boundary =
"");
255 const xmlChar *URI,
int nb_namespaces,
const xmlChar **namespaces,
256 int nb_attributes,
int nb_defaulted,
const xmlChar **attributes);
257 static void ddx_sax2_end_element(
void *parser,
const xmlChar *localname,
const xmlChar *prefix,
const xmlChar *URI);
261 static void ddx_get_cdata(
void *parser,
const xmlChar *value,
int len);
263 static xmlEntityPtr
ddx_get_entity(
void *parser,
const xmlChar *name);
The basic data type for the DODS DAP types.
static void ddx_fatal_error(void *parser, const char *msg,...)
static void ddx_ignoreable_whitespace(void *parser, const xmlChar *ch, int len)
static void ddx_get_characters(void *parser, const xmlChar *ch, int len)
static void ddx_sax2_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)
static void ddx_start_document(void *parser)
void intern_stream(FILE *in, DDS *dds, string &cid, const string &boundary="")
Read the DDX from a stream instead of a file.
friend class DDXParserTest
static void ddx_sax2_end_element(void *parser, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI)
void intern(const string &document, DDS *dest_dds, string &cid)
DDXParser(BaseTypeFactory *factory)
static void ddx_end_document(void *parser)
static void ddx_get_cdata(void *parser, const xmlChar *value, int len)
static xmlEntityPtr ddx_get_entity(void *parser, const xmlChar *name)
top level DAP object to house generic methods
Type
Identifies the data type.