libdap
Updated for version 3.20.6
libdap4 is an implementation of OPeNDAP's DAP protocol.
|
#include <D4ParserSax2.h>
Public Member Functions | |
bool | get_strict () const |
Get the setting of the 'strict' mode. More... | |
void | intern (istream &f, DMR *dest_dmr, bool debug=false) |
void | intern (const string &document, DMR *dest_dmr, bool debug=false) |
void | intern (const char *buffer, int size, DMR *dest_dmr, bool debug=false) |
void | set_strict (bool s) |
Set the 'strict' mode to true or false. 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 | dmr_start_document (void *parser) |
static void | dmr_end_document (void *parser) |
static void | dmr_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 | dmr_end_element (void *parser, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI) |
static void | dmr_get_characters (void *parser, const xmlChar *ch, int len) |
static void | dmr_ignoreable_whitespace (void *parser, const xmlChar *ch, int len) |
static void | dmr_get_cdata (void *parser, const xmlChar *value, int len) |
static xmlEntityPtr | dmr_get_entity (void *parser, const xmlChar *name) |
static void | dmr_fatal_error (void *parser, const char *msg,...) |
static void | dmr_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 Error of InternalErr 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 77 of file D4ParserSax2.h.
|
static |
Clean up after finishing a parse.
p | The SAX parser |
Definition at line 608 of file D4ParserSax2.cc.
|
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 1196 of file D4ParserSax2.cc.
|
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 1158 of file D4ParserSax2.cc.
|
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 1115 of file D4ParserSax2.cc.
|
static |
Handle the standard XML entities.
parser | The SAX parser |
name | The XML entity. |
Definition at line 1181 of file D4ParserSax2.cc.
|
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 1139 of file D4ParserSax2.cc.
|
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 590 of file D4ParserSax2.cc.
|
static |
Callback run when libxml2 reads the start of an element
p | Pointer to the parser object |
l | Localname of the element |
prefix | Namespace prefix of the element |
URI | the Element namespace name if available |
nb_namespaces | Number of namespace definitions on that node |
namespaces | Pointer to the array of prefix/URI pairs namespace definitions |
nb_attributes | The number of attributes on that node |
nb_defaulted | The number of defaulted attributes. The defaulted ones are at the end of the array |
attributes | Pointer to the array of (localname/prefix/URI/value/end) attribute values. |
Definition at line 642 of file D4ParserSax2.cc.
void libdap::D4ParserSax2::intern | ( | const char * | buffer, |
int | size, | ||
DMR * | dest_dmr, | ||
bool | debug = false |
||
) |
Parse a DMR document stored in a char *buffer.
document | Read the DMR from this string. |
dest_dmr | Value/result parameter; dumps the information to this DMR instance. |
debug | If true, ouput helpful debugging messages, False by default |
Error | Thrown if the XML document could not be read or parsed. |
InternalErr | Thrown if an internal error is found. |
Definition at line 1397 of file D4ParserSax2.cc.