34#include <libxml/parserInternals.h>
36#ifndef ddx_exceptions_h
37#include "DDXExceptions.h"
48#ifndef base_type_factory_h
49#include "BaseTypeFactory.h"
90 inside_attribute_container,
92 inside_attribute_value,
93 inside_other_xml_attribute,
115 xmlSAXHandler ddx_sax_parser;
121 stack<BaseType*> bt_stack;
122 stack<AttrTable*> at_stack;
129 unsigned int other_xml_depth;
130 unsigned int unknown_depth;
134 xmlParserCtxtPtr ctxt;
141 string dods_attr_name;
142 string dods_attr_type;
152 void clone(
const XMLAttribute &src) {
158 XMLAttribute() : prefix(
""), nsURI(
""), value(
"") {}
159 XMLAttribute(
const string &p,
const string &ns,
const string &v)
160 : prefix(p), nsURI(ns), value(v) {}
163 XMLAttribute(
const xmlChar **attributes) {
164 prefix = attributes[0] != 0 ? (
const char *)attributes[0]:
"";
165 nsURI = attributes[1] != 0 ? (
const char *)attributes[1]:
"";
166 value = string((
const char *)attributes[2], (
const char *)attributes[3]);
168 XMLAttribute(
const XMLAttribute &rhs) {
173 XMLAttribute &operator=(
const XMLAttribute &rhs) {
181 typedef map<string, XMLAttribute> XMLAttrMap;
182 XMLAttrMap attribute_table;
184 XMLAttrMap::iterator attr_table_begin() {
185 return attribute_table.begin();
188 XMLAttrMap::iterator attr_table_end() {
189 return attribute_table.end();
192 map<string, string> namespace_table;
195 void set_state(DDXParser::ParseState state);
196 DDXParser::ParseState get_state()
const;
206 void cleanup_parse();
214 void transfer_xml_attrs(
const xmlChar **attrs,
int nb_attributes);
215 void transfer_xml_ns(
const xmlChar **namespaces,
int nb_namespaces);
216 bool check_required_attribute(
const string &attr);
217 bool check_attribute(
const string & attr);
219 void process_attribute_element(
const xmlChar **attrs,
int nb_attrs);
220 void process_attribute_alias(
const xmlChar **attrs,
int nb_attrs);
222 void process_variable(
Type t, ParseState s,
const xmlChar **attrs,
225 void process_dimension(
const xmlChar **attrs,
int nb_attrs);
226 void process_blob(
const xmlChar **attrs,
int nb_attrs);
228 bool is_attribute_or_alias(
const char *name,
const xmlChar **attrs,
230 bool is_variable(
const char *name,
const xmlChar **attrs,
int nb_attributes);
232 void finish_variable(
const char *tag,
Type t,
const char *expected);
238 friend class DDXParserTest;
242 : d_factory(factory),
243 other_xml(
""), other_xml_depth(0), unknown_depth(0),
244 error_msg(
""), ctxt(0), dds(0), blob_href(0),
245 dods_attr_name(
""), dods_attr_type(
""),
246 char_data(
""), root_ns(
"")
248 memset( &ddx_sax_parser, 0,
sizeof(xmlSAXHandler) );
259 ddx_sax_parser.initialized = XML_SAX2_MAGIC;
260 ddx_sax_parser.startElementNs = &DDXParser::ddx_sax2_start_element;
261 ddx_sax_parser.endElementNs = &DDXParser::ddx_sax2_end_element;
264 void intern(
const string &document,
DDS *dest_dds,
string &cid);
265 void intern_stream(FILE *in,
DDS *dds,
string &cid,
const string &boundary =
"");
266 void intern_stream(istream &in,
DDS *dds,
string &cid,
const string &boundary =
"");
271 static void ddx_sax2_start_element(
void *parser,
272 const xmlChar *localname,
const xmlChar *prefix,
const xmlChar *URI,
273 int nb_namespaces,
const xmlChar **namespaces,
int nb_attributes,
274 int nb_defaulted,
const xmlChar **attributes);
275 static void ddx_sax2_end_element(
void *parser,
const xmlChar *localname,
276 const xmlChar *prefix,
const xmlChar *URI);
280 const xmlChar * ch,
int len);
281 static void ddx_get_cdata(
void *parser,
const xmlChar *value,
int len);
283 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_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.
void intern(const string &document, DDS *dest_dds, string &cid)
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.