34 #pragma implementation
39 using std::ostringstream ;
45 #define MY_ENCODING "ISO-8859-1"
46 #define BES_SCHEMA "http://xml.opendap.org/ns/bes/1.0#"
73 xmlFreeTextWriter( _writer ) ;
79 xmlBufferFree( _doc_buf ) ;
90 ((ostringstream *)
_strm)->str(
"" ) ;
116 _doc_buf = xmlBufferCreate() ;
117 if( _doc_buf == NULL )
120 string err = (string)
"Error creating the xml buffer for response "
127 _writer = xmlNewTextWriterMemory( _doc_buf, 0 ) ;
128 if( _writer == NULL )
131 string err = (string)
"Error creating the xml writer for response "
136 rc = xmlTextWriterSetIndent( _writer, 4 ) ;
140 string err = (string)
"Error starting indentation for response document "
145 rc = xmlTextWriterSetIndentString( _writer, BAD_CAST
" " ) ;
149 string err = (string)
"Error setting indentation for response document "
159 rc = xmlTextWriterStartDocument( _writer, NULL,
MY_ENCODING, NULL ) ;
163 string err = (string)
"Error starting xml response document for "
170 rc = xmlTextWriterStartElementNS( _writer, NULL,
176 string err = (string)
"Error starting the response element for response "
185 rc = xmlTextWriterWriteAttribute( _writer, BAD_CAST
REQUEST_ID,
186 BAD_CAST reqid.c_str() ) ;
190 string err = (string)
"Error adding attribute " + REQUEST_ID
197 rc = xmlTextWriterStartElement( _writer, BAD_CAST
_response_name.c_str() ) ;
201 string err = (string)
"Error creating root element for response "
222 rc = xmlTextWriterEndElement( _writer ) ;
226 string err = (string)
"Error ending response element for response "
232 rc = xmlTextWriterEndElement( _writer ) ;
236 string err = (string)
"Error ending specific response element "
241 rc = xmlTextWriterEndDocument( _writer ) ;
245 string err = (string)
"Error ending the response document for response "
251 xmlFreeTextWriter( _writer ) ;
255 if( !_doc_buf->content )
258 string err = (string)
"Error retrieving response document as string "
264 _doc = (
char *)_doc_buf->content ;
280 const string &tag_data,
281 map<string,string> *attrs )
284 int rc = xmlTextWriterStartElement( _writer, BAD_CAST tag_name.c_str() ) ;
288 string err = (string)
"Error starting element " + tag_name
295 map<string,string>::const_iterator i = attrs->begin() ;
296 map<string,string>::const_iterator e = attrs->end() ;
299 string name = (*i).first ;
300 string val = (*i).second ;
304 rc = xmlTextWriterWriteAttribute( _writer, BAD_CAST name.c_str(),
305 BAD_CAST val.c_str() ) ;
309 string err = (string)
"Error adding attribute " + name
317 if( !tag_data.empty() )
319 rc = xmlTextWriterWriteString( _writer, BAD_CAST tag_data.c_str() ) ;
323 string err = (string)
"Error writing the value for element "
330 rc = xmlTextWriterEndElement( _writer ) ;
334 string err = (string)
"Error ending element " + tag_name
347 map<string,string> *attrs )
363 map<string,string> *attrs )
369 if( ns.empty() && uri.empty() )
371 rc = xmlTextWriterStartElement( _writer, BAD_CAST tag_name.c_str());
375 string err = (string)
"Error starting element " + tag_name
382 const char *cns = NULL ;
383 if( !ns.empty() ) cns = ns.c_str() ;
384 rc = xmlTextWriterStartElementNS( _writer,
386 BAD_CAST tag_name.c_str(),
387 BAD_CAST uri.c_str() ) ;
391 string err = (string)
"Error starting element " + tag_name
399 map<string,string>::const_iterator i = attrs->begin() ;
400 map<string,string>::const_iterator e = attrs->end() ;
403 string name = (*i).first ;
404 string val = (*i).second ;
407 rc = xmlTextWriterWriteAttribute( _writer, BAD_CAST name.c_str(),
408 BAD_CAST val.c_str() ) ;
412 string err = (string)
"Error adding attribute " + name
433 string s = ((ostringstream *)
_strm)->str() ;
437 rc = xmlTextWriterWriteString( _writer, BAD_CAST s.c_str() ) ;
441 string err = (string)
"Error writing the value for element "
446 ((ostringstream *)
_strm)->str(
"" ) ;
450 rc = xmlTextWriterEndElement( _writer ) ;
454 string err = (string)
"Error ending element " + tag_name
468 for(
unsigned long i = 0; i < num_spaces; i++ )
483 for(
unsigned long i = 0; i < num_breaks; i++ )
509 begin_tag(
"html",
"",
"http://www.w3.org/1999/xhtml" ) ;
511 string newkey = key +
".HTML" ;
529 if( _started && !_ended )
544 if( _started && !_ended )
562 << (
void *)
this <<
")" << endl ;
virtual void end_response()
virtual void end_response()
end the response
exception thrown if inernal error encountered
virtual void add_data_from_file(const string &key, const string &name)
add data from a file to the informational object.
virtual void add_data_from_file(const string &key, const string &name)
add data from a file to the informational object
virtual void end_tag(const string &tag_name)
end a tagged part of the informational response
virtual void dump(ostream &strm) const
Displays debug information about this object.
virtual void print(ostream &strm)
print the information from this informational object to the specified stream
virtual void begin_response(const string &response_name, BESDataHandlerInterface &dhi)
begin the informational response
BESXMLInfo()
constructs an informational response object as an xml document
informational response object
virtual void add_space(unsigned long num_spaces)
add a space to the informational response
virtual void begin_tag(const string &tag_name, map< string, string > *attrs=0)
static ostream & LMarg(ostream &strm)
virtual void add_break(unsigned long num_breaks)
add a line break to the information
virtual void begin_tag(const string &tag_name, const string &ns, const string &uri, map< string, string > *attrs=0)
begin a tagged part of the information, information to follow
static BESInfo * BuildXMLInfo(const string &info_type)
virtual void send_text(BESInfo &info, BESDataHandlerInterface &dhi)=0
Structure storing information used by the BES to handle the request.
map< string, string > data
the map of string data that will be required for the current request.
virtual void add_tag(const string &tag_name, const string &tag_data, map< string, string > *attrs=0)
add tagged information to the inforamtional response
virtual void begin_response(const string &response_name, BESDataHandlerInterface &dhi)
begin the informational response
virtual void add_data(const string &s)
add data to this informational object.
virtual void transmit(BESTransmitter *transmitter, BESDataHandlerInterface &dhi)
transmit the text information as text
virtual void dump(ostream &strm) const
dumps information about this object
virtual void add_data(const string &s)
add data to this informational object.
virtual void end_tag(const string &tag_name)