#include <DDXParser.h>
Collaboration diagram for libdap::DDXParser:
Public Member Functions | |
DDXParser (BaseTypeFactory *factory) | |
void | intern (const string &document, DDS *dest_dds) |
void | intern_stream (FILE *in, DDS *dds) |
Read the DDX from a stream instead of a file. | |
Static Public Member Functions | |
SAX Parser Callbacks | |
These methods are declared static in the class header. This gives them C linkage which allows them to be used as callbacks by the SAX parser engine. | |
static void | characters (DDXParser *parser, const xmlChar *ch, int len) |
static void | ddx_end_document (DDXParser *parser) |
static void | ddx_end_element (DDXParser *parser, const char *name) |
static void | ddx_fatal_error (DDXParser *parser, const char *msg,...) |
static xmlEntityPtr | ddx_get_entity (DDXParser *parser, const xmlChar *name) |
static void | ddx_start_document (DDXParser *parser) |
static void | ddx_start_element (DDXParser *parser, const char *name, const char **attrs) |
This parser for the DDX document uses the SAX interface of libxml2
. Static methods are used as callbacks for the SAX parser. These static methods are public because making them private complicates compilation. They should not be called by anything other than the intern method. They do not throw exceptions because exceptions from within callbacks are not reliable or portable. To signal errors, the methods record information in the DDXParser object. Once the error handler is called, construction of an DDX/DDS object ends even though the SAX parser still calls the various callback functions. The parser treats warnings, errors and fatal_errors the same way; when any are found parsing stops. The intern method throws an DDXParseFailed exception if an error was found.
Note that this class uses the C++-supplied default definitions for the default and copy constructors as well as the destructor and assignment operator.
Definition at line 79 of file DDXParser.h.
libdap::DDXParser::DDXParser | ( | BaseTypeFactory * | factory | ) | [inline] |
Definition at line 174 of file DDXParser.h.
void libdap::DDXParser::characters | ( | DDXParser * | parser, | |
const xmlChar * | ch, | |||
int | len | |||
) | [static] |
Process/accumulate character data. This may be called more than once for one logical clump of data. Only save character data when processing 'value' elements; throw away all other characters.
Definition at line 862 of file DDXParser.cc.
References char_data, DBG2, and get_state().
Here is the call graph for this function:
void libdap::DDXParser::ddx_end_document | ( | DDXParser * | parser | ) | [static] |
Clean up after finishing a parse.
parser | The SAX parser |
Definition at line 514 of file DDXParser.cc.
References DBG2, ddx_fatal_error(), get_state(), libdap::Constructor::var_begin(), and libdap::Constructor::var_end().
Here is the call graph for this function:
void libdap::DDXParser::ddx_end_element | ( | DDXParser * | parser, | |
const char * | name | |||
) | [static] |
Process an end element tag. This is where values are added to the DDS/DDX or their parent BaseType.
parser | The SAX parser state | |
name | The element name. |
Definition at line 725 of file DDXParser.cc.
References libdap::BaseType::add_var(), libdap::AttrTable::append_attr(), DBG2, ddx_fatal_error(), libdap::dods_array_c, libdap::dods_grid_c, libdap::dods_null_c, libdap::dods_sequence_c, libdap::dods_structure_c, get_state(), libdap::BaseType::is_constructor_type(), and libdap::BaseType::is_vector_type().
Here is the call graph for this function:
void libdap::DDXParser::ddx_fatal_error | ( | DDXParser * | parser, | |
const char * | msg, | |||
... | ||||
) | [static] |
Process an XML fatal error. Note that SAX provides for warnings, errors and fatal errors. This code treats them all as fatal errors since there's typically no way to tell a user about the error since there's often no user interface for this software.
parser | The SAX parser | |
msg | A printf-style format string. |
Definition at line 891 of file DDXParser.cc.
References ctxt, error_msg, libdap::long_to_string(), and set_state().
Referenced by ddx_end_document(), ddx_end_element(), and ddx_start_element().
Here is the call graph for this function:
xmlEntityPtr libdap::DDXParser::ddx_get_entity | ( | DDXParser * | parser, | |
const xmlChar * | name | |||
) | [static] |
Handle the standard XML entities.
parser | The SAX parser | |
name | The XML entity. |
Definition at line 879 of file DDXParser.cc.
void libdap::DDXParser::ddx_start_document | ( | DDXParser * | parser | ) | [static] |
Initialize the SAX parser state object. This object is passed to each callback as a void pointer. The initial state is parser_start.
parser | The SAX parser |
Definition at line 494 of file DDXParser.cc.
References at_stack, bt_stack, char_data, DBG2, dds, error_msg, libdap::DDS::get_attr_table(), get_state(), and set_state().
Here is the call graph for this function:
void libdap::DDXParser::ddx_start_element | ( | DDXParser * | parser, | |
const char * | name, | |||
const char ** | attrs | |||
) | [static] |
Process a start element tag. Because the DDX schema uses attributes and because libxml2 does not validate those, we do attribute validation here.
parser | The SAX parser | |
name | The element | |
attrs | character array of attribute names. |
Definition at line 549 of file DDXParser.cc.
References attributes, check_attribute(), check_required_attribute(), DBG2, DBGN, dds, ddx_fatal_error(), libdap::dods_array_c, get_state(), is_attribute_or_alias(), is_variable(), process_blob(), libdap::DDS::set_dap_version(), libdap::DDS::set_dataset_name(), set_state(), and transfer_attrs().
Here is the call graph for this function:
void libdap::DDXParser::intern | ( | const string & | document, | |
DDS * | dest_dds | |||
) |
Parse a DDX document stored in a file. The XML in the document is parsed and a binary DDX is built. This implementation stores the result in a DDS object where each instance of BaseType can hold an AttrTable object.
document | Read the DDX from this file. | |
dest_dds | Value/result parameter; dumps the information to this DDS instance. | |
blob | Value/result parameter; puts the href which references the dataBLOB document here. If this is a DAP 3.2+ document then this will be the null. |
DDXParseFailed | Thrown if the XML document could not be read or parsed. |
Definition at line 1036 of file DDXParser.cc.
void libdap::DDXParser::intern_stream | ( | FILE * | in, | |
DDS * | dest_dds | |||
) |