libdap++  Updated for version 3.13.3
libdap::D4ParserSax2 Class Reference

#include <D4ParserSax2.h>

Collaboration diagram for libdap::D4ParserSax2:
Collaboration graph

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
 

Detailed Description

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.

See also
DDS

Definition at line 69 of file D4ParserSax2.h.

Constructor & Destructor Documentation

libdap::D4ParserSax2::D4ParserSax2 ( )
inline

Definition at line 230 of file D4ParserSax2.h.

Member Function Documentation

void libdap::D4ParserSax2::ddx_end_document ( void *  p)
static

Clean up after finishing a parse.

Parameters
pThe SAX parser

Definition at line 521 of file D4ParserSax2.cc.

References libdap::DDS::add_var_nocopy(), DBG2, and ddx_fatal_error().

Referenced by intern().

Here is the call graph for this function:

void libdap::D4ParserSax2::ddx_end_element ( void *  parser,
const xmlChar *  localname,
const xmlChar *  prefix,
const xmlChar *  URI 
)
static
void libdap::D4ParserSax2::ddx_fatal_error ( void *  p,
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.

Note
This static function does not throw an exception or otherwise alter flow of control except for altering the parser state.
Parameters
pThe SAX parser
msgA 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().

Here is the call graph for this function:

void libdap::D4ParserSax2::ddx_get_cdata ( void *  p,
const xmlChar *  value,
int  len 
)
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().

Here is the call graph for this function:

void libdap::D4ParserSax2::ddx_get_characters ( void *  p,
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 943 of file D4ParserSax2.cc.

References DBG2.

Referenced by intern().

xmlEntityPtr libdap::D4ParserSax2::ddx_get_entity ( void *  parser,
const xmlChar *  name 
)
static

Handle the standard XML entities.

Parameters
parserThe SAX parser
nameThe XML entity.

Definition at line 1009 of file D4ParserSax2.cc.

Referenced by intern().

void libdap::D4ParserSax2::ddx_ignoreable_whitespace ( void *  p,
const xmlChar *  ch,
int  len 
)
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().

void libdap::D4ParserSax2::ddx_start_document ( void *  p)
static

Initialize the SAX parser state object. This object is passed to each callback as a void pointer. The initial state is parser_start.

Parameters
pThe SAX parser

Definition at line 508 of file D4ParserSax2.cc.

References DBG2.

Referenced by intern().

void libdap::D4ParserSax2::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 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.

Parameters
documentRead the DDX from this file.
dest_ddsValue/result parameter; dumps the information to this DDS instance.
cidValue/result parameter; puts the href which references the CID.
Exceptions
D4ParseErrorThrown 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().

Here is the call graph for this function:

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).

Parameters
fThe input stream
dest_ddsValue-result parameter. Pass a DDS in and the inforamtion in the DDX will be added to it.
cidValue-result parameter. When/if read, the value of the <blob> element's attribute will be returned here.
boundaryValue of the M-MIME boundary separator; default is ""
See also
DDXParserDAP4::intern().

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().

Here is the call graph for this function:

Friends And Related Function Documentation

friend class D4ParserSax2Test
friend

Definition at line 225 of file D4ParserSax2.h.


The documentation for this class was generated from the following files: