libdap++
Updated for version 3.13.3
|
#include <D4ParserSax2.h>
Public Member Functions | |
D4ParserSax2 () | |
void | intern (const string &document, DDS *dest_dds) |
void | intern (istream &in, DDS *dest_dds) |
Read the DDX from a stream instead of a file. More... | |
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 | ddx_start_document (void *parser) |
static void | ddx_end_document (void *parser) |
static void | ddx_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_end_element (void *parser, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI) |
static void | ddx_get_characters (void *parser, const xmlChar *ch, int len) |
static void | ddx_ignoreable_whitespace (void *parser, const xmlChar *ch, int len) |
static void | ddx_get_cdata (void *parser, const xmlChar *value, int len) |
static xmlEntityPtr | ddx_get_entity (void *parser, const xmlChar *name) |
static void | ddx_fatal_error (void *parser, const char *msg,...) |
Friends | |
class | D4ParserSax2Test |
Parse the XML text which encodes the network/persistent representation of the DMR object. In the current implementation, the DMR is held by an instance of the class DDS which in turn holds variables which include attributes.
This parser for the DMR 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 D4ParserSax2 object. Once the error handler is called, construction of an DMR 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 D4ParseError 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 69 of file D4ParserSax2.h.
|
inline |
Definition at line 230 of file D4ParserSax2.h.
|
static |
Clean up after finishing a parse.
p | The SAX parser |
Definition at line 521 of file D4ParserSax2.cc.
References libdap::DDS::add_var_nocopy(), DBG2, and ddx_fatal_error().
Referenced by intern().
|
static |
Definition at line 771 of file D4ParserSax2.cc.
References libdap::D4Group::add_enumeration_nocopy(), libdap::BaseType::add_var(), libdap::AttrTable::append_attr(), DBG2, DBGN, ddx_fatal_error(), libdap::dods_array_c, libdap::dods_grid_c, libdap::dods_group_c, libdap::dods_sequence_c, libdap::dods_structure_c, libdap::get_type(), libdap::BaseType::is_constructor_type(), libdap::is_simple_type(), libdap::BaseType::is_vector_type(), and libdap::BaseType::type().
Referenced by intern().
|
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.
p | The SAX parser |
msg | A printf-style format string. |
Definition at line 1024 of file D4ParserSax2.cc.
References libdap::long_to_string().
Referenced by ddx_end_document(), ddx_end_element(), ddx_get_cdata(), ddx_start_element(), and intern().
|
static |
Get characters in a cdata block. DAP does not use CData, but XML in an OtherXML attribute (the value of that DAP attribute) might use it. This callback also allows CData when the parser is in the 'parser_unknown' state since some future DAP element might use it.
Definition at line 986 of file D4ParserSax2.cc.
References ddx_fatal_error().
Referenced by intern().
|
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 943 of file D4ParserSax2.cc.
References DBG2.
Referenced by intern().
|
static |
Handle the standard XML entities.
parser | The SAX parser |
name | The XML entity. |
Definition at line 1009 of file D4ParserSax2.cc.
Referenced by intern().
|
static |
Read whitespace that's not really important for content. This is used only for the OtherXML attribute type to preserve formating of the XML. Doing so makes the attribute value far easier to read.
Definition at line 967 of file D4ParserSax2.cc.
Referenced by intern().
|
static |
Initialize the SAX parser state object. This object is passed to each callback as a void pointer. The initial state is parser_start.
p | The SAX parser |
Definition at line 508 of file D4ParserSax2.cc.
References DBG2.
Referenced by intern().
|
static |
Definition at line 542 of file D4ParserSax2.cc.
References DBG2, DBGN, ddx_fatal_error(), libdap::dods_array_c, libdap::dods_group_c, libdap::BaseType::get_attr_table(), libdap::DDS::set_dap_version(), libdap::DDS::set_dataset_name(), libdap::DDS::set_namespace(), and libdap::DDS::set_request_xml_base().
Referenced by intern().
void libdap::D4ParserSax2::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. |
cid | Value/result parameter; puts the href which references the CID . |
D4ParseError | Thrown if the XML document could not be read or parsed. |
Definition at line 1152 of file D4ParserSax2.cc.
References ddx_end_document(), ddx_end_element(), ddx_fatal_error(), ddx_get_cdata(), ddx_get_characters(), ddx_get_entity(), ddx_ignoreable_whitespace(), ddx_start_document(), and ddx_start_element().
void libdap::D4ParserSax2::intern | ( | istream & | f, |
DDS * | dest_dds | ||
) |
This method reads and parses the DDX from a stream. When/if it encounters the <blob> element is records the value of the CID attribute and returns it using the cid value-result parameter. When the boundary marker is found, the parser will read that and return (if it is found before the DDX is completely parsed).
f | The input stream |
dest_dds | Value-result parameter. Pass a DDS in and the inforamtion in the DDX will be added to it. |
cid | Value-result parameter. When/if read, the value of the <blob> element's attribute will be returned here. |
boundary | Value of the M-MIME boundary separator; default is "" |
Definition at line 1084 of file D4ParserSax2.cc.
References DBG, ddx_end_document(), ddx_end_element(), ddx_fatal_error(), ddx_get_cdata(), ddx_get_characters(), ddx_get_entity(), ddx_ignoreable_whitespace(), ddx_start_document(), ddx_start_element(), and libdap::DDS::get_factory().
|
friend |
Definition at line 225 of file D4ParserSax2.h.