#include <DDXParser.h>
Collaboration diagram for DDXParser:
Public Member Functions | |
DDXParser (BaseTypeFactory *factory) | |
void | intern (const string &document, DDS *dest_dds, string *blob) |
void | intern_stream (FILE *in, DDS *dds, string *blob) |
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 76 of file DDXParser.h.
DDXParser::DDXParser | ( | BaseTypeFactory * | factory | ) | [inline] |
Definition at line 170 of file DDXParser.h.
void 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 823 of file DDXParser.cc.
References char_data, DBG2, and get_state().
Here is the call graph for this function:
void DDXParser::ddx_end_document | ( | DDXParser * | parser | ) | [static] |
Clean up after finishing a parse.
parser | The SAX parser |
Definition at line 482 of file DDXParser.cc.
References DBG2, ddx_fatal_error(), get_state(), Constructor::var_begin(), and Constructor::var_end().
Here is the call graph for this function:
void 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 686 of file DDXParser.cc.
References BaseType::add_var(), AttrTable::append_attr(), DBG2, ddx_fatal_error(), dods_array_c, dods_grid_c, dods_null_c, dods_sequence_c, dods_structure_c, get_state(), BaseType::is_constructor_type(), and BaseType::is_vector_type().
Here is the call graph for this function:
void 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 852 of file DDXParser.cc.
References ctxt, error_msg, 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 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 840 of file DDXParser.cc.
void 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 462 of file DDXParser.cc.
References at_stack, bt_stack, char_data, DBG2, dds, error_msg, DDS::get_attr_table(), get_state(), and set_state().
Here is the call graph for this function:
void 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 514 of file DDXParser.cc.
References attributes, check_required_attribute(), DBG2, DBGN, dds, ddx_fatal_error(), dods_array_c, get_state(), is_attribute_or_alias(), is_variable(), process_blob(), DDS::set_dataset_name(), set_state(), and transfer_attrs().
Here is the call graph for this function:
void DDXParser::intern | ( | const string & | document, | |
DDS * | dest_dds, | |||
string * | blob | |||
) |
Parse a DDX document stored in a file. The XML in the doucument 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 inforamtion to this DDS instance. | |
blob | Value/result parameter; puts the href which references the dataBLOB document here. |
DDXParseFailed | Thrown if the XML document could not be read or parsed. |
Definition at line 995 of file DDXParser.cc.
void DDXParser::intern_stream | ( | FILE * | in, | |
DDS * | dest_dds, | |||
string * | blob | |||
) |